116 lines
7.7 KiB
JSON
116 lines
7.7 KiB
JSON
{
|
|
"module": "openapi_first.templates.crud_app.test_crud_app",
|
|
"content": {
|
|
"path": "openapi_first.templates.crud_app.test_crud_app",
|
|
"docstring": "End-to-end tests for the OpenAPI-first CRUD example app.\n\nThese tests validate that all CRUD operations behave correctly\nagainst the in-memory mock data store.\n- OpenAPI specification loading\n- OperationId-driven route binding on the server\n- OperationId-driven client invocation\n- Correct HTTP status codes and response payloads\n\nThe tests exercise all CRUD operations against an in-memory mock data\nstore and assume deterministic behavior within a single process.\n\nThe tests assume:\n- OpenAPI-first route binding\n- In-memory storage (no persistence guarantees)\n- Deterministic behavior in a single process\n- One-to-one correspondence between OpenAPI operationId values and\n server/client callables",
|
|
"objects": {
|
|
"TestClient": {
|
|
"name": "TestClient",
|
|
"kind": "alias",
|
|
"path": "openapi_first.templates.crud_app.test_crud_app.TestClient",
|
|
"signature": "<bound method Alias.signature of Alias('TestClient', 'fastapi.testclient.TestClient')>",
|
|
"docstring": null
|
|
},
|
|
"app": {
|
|
"name": "app",
|
|
"kind": "alias",
|
|
"path": "openapi_first.templates.crud_app.test_crud_app.app",
|
|
"signature": "<bound method Alias.signature of Alias('app', 'main.app')>",
|
|
"docstring": null
|
|
},
|
|
"load_openapi": {
|
|
"name": "load_openapi",
|
|
"kind": "function",
|
|
"path": "openapi_first.templates.crud_app.test_crud_app.load_openapi",
|
|
"signature": "<bound method Alias.signature of Alias('load_openapi', 'openapi_first.loader.load_openapi')>",
|
|
"docstring": "Load and validate an OpenAPI 3.x specification from disk.\n\nThe specification is parsed based on file extension and validated\nusing a strict OpenAPI schema validator. Any error results in an\nimmediate exception, preventing application startup.\n\nParameters\n----------\npath : str or pathlib.Path\n Filesystem path to an OpenAPI specification file.\n Supported extensions:\n - `.json`\n - `.yaml`\n - `.yml`\n\nReturns\n-------\ndict\n Parsed and validated OpenAPI specification.\n\nRaises\n------\nOpenAPISpecLoadError\n If the file does not exist, cannot be parsed, or fails\n OpenAPI schema validation."
|
|
},
|
|
"OpenAPIClient": {
|
|
"name": "OpenAPIClient",
|
|
"kind": "class",
|
|
"path": "openapi_first.templates.crud_app.test_crud_app.OpenAPIClient",
|
|
"signature": "<bound method Alias.signature of Alias('OpenAPIClient', 'openapi_first.client.OpenAPIClient')>",
|
|
"docstring": "OpenAPI-first HTTP client (httpx-based).\n\nThis client derives all callable methods directly from an OpenAPI 3.x\nspecification. Each operationId becomes a method on the client\ninstance.\n\nDesign principles\n-----------------\n- One callable per operationId\n- Explicit parameters (path, query, headers, body)\n- No implicit schema inference or mutation\n- Returns raw httpx.Response objects\n- No response validation or deserialization\n\nParameters\n----------\nspec : dict\n Parsed OpenAPI 3.x specification.\nbase_url : str | None\n Base URL of the target service. If omitted, the first entry\n in the OpenAPI `servers` list is used.\nclient : httpx.Client | None\n Optional preconfigured httpx client instance.\n\nRaises\n------\nOpenAPIClientError\n If:\n - No servers are defined and base_url is not provided\n - OpenAPI spec has no paths\n - An operation is missing operationId\n - Duplicate operationIds are detected\n - Required path parameters are missing\n - Required request body is missing\n\n Example\n-------\n```python\nfrom openapi_first import loader, client\n\nspec = loader.load_openapi(\"openapi.yaml\")\n\napi = client.OpenAPIClient(\n spec=spec,\n base_url=\"http://localhost:8000\",\n)\n\n# Call operationId: getUser\nresponse = api.getUser(\n path_params={\"user_id\": 123}\n)\n\nprint(response.status_code)\nprint(response.json())\n\n# Call operationId: createUser\nresponse = api.createUser(\n body={\"name\": \"Bob\"}\n)\n\nprint(response.status_code)\n```",
|
|
"members": {
|
|
"spec": {
|
|
"name": "spec",
|
|
"kind": "attribute",
|
|
"path": "openapi_first.templates.crud_app.test_crud_app.OpenAPIClient.spec",
|
|
"signature": "<bound method Alias.signature of Alias('spec', 'openapi_first.client.OpenAPIClient.spec')>",
|
|
"docstring": null
|
|
},
|
|
"base_url": {
|
|
"name": "base_url",
|
|
"kind": "attribute",
|
|
"path": "openapi_first.templates.crud_app.test_crud_app.OpenAPIClient.base_url",
|
|
"signature": "<bound method Alias.signature of Alias('base_url', 'openapi_first.client.OpenAPIClient.base_url')>",
|
|
"docstring": null
|
|
},
|
|
"client": {
|
|
"name": "client",
|
|
"kind": "attribute",
|
|
"path": "openapi_first.templates.crud_app.test_crud_app.OpenAPIClient.client",
|
|
"signature": "<bound method Alias.signature of Alias('client', 'openapi_first.client.OpenAPIClient.client')>",
|
|
"docstring": null
|
|
},
|
|
"operations": {
|
|
"name": "operations",
|
|
"kind": "function",
|
|
"path": "openapi_first.templates.crud_app.test_crud_app.OpenAPIClient.operations",
|
|
"signature": "<bound method Alias.signature of Alias('operations', 'openapi_first.client.OpenAPIClient.operations')>",
|
|
"docstring": null
|
|
}
|
|
}
|
|
},
|
|
"client": {
|
|
"name": "client",
|
|
"kind": "attribute",
|
|
"path": "openapi_first.templates.crud_app.test_crud_app.client",
|
|
"signature": null,
|
|
"docstring": null
|
|
},
|
|
"spec": {
|
|
"name": "spec",
|
|
"kind": "attribute",
|
|
"path": "openapi_first.templates.crud_app.test_crud_app.spec",
|
|
"signature": null,
|
|
"docstring": null
|
|
},
|
|
"test_list_items_initial": {
|
|
"name": "test_list_items_initial",
|
|
"kind": "function",
|
|
"path": "openapi_first.templates.crud_app.test_crud_app.test_list_items_initial",
|
|
"signature": "<bound method Function.signature of Function('test_list_items_initial', 38, 49)>",
|
|
"docstring": "Initial items should be present."
|
|
},
|
|
"test_get_item": {
|
|
"name": "test_get_item",
|
|
"kind": "function",
|
|
"path": "openapi_first.templates.crud_app.test_crud_app.test_get_item",
|
|
"signature": "<bound method Function.signature of Function('test_get_item', 52, 62)>",
|
|
"docstring": "Existing item should be retrievable by ID."
|
|
},
|
|
"test_create_item": {
|
|
"name": "test_create_item",
|
|
"kind": "function",
|
|
"path": "openapi_first.templates.crud_app.test_crud_app.test_create_item",
|
|
"signature": "<bound method Function.signature of Function('test_create_item', 65, 85)>",
|
|
"docstring": "Creating a new item should return the created entity."
|
|
},
|
|
"test_update_item": {
|
|
"name": "test_update_item",
|
|
"kind": "function",
|
|
"path": "openapi_first.templates.crud_app.test_crud_app.test_update_item",
|
|
"signature": "<bound method Function.signature of Function('test_update_item', 88, 112)>",
|
|
"docstring": "Updating an item should replace its values."
|
|
},
|
|
"test_delete_item": {
|
|
"name": "test_delete_item",
|
|
"kind": "function",
|
|
"path": "openapi_first.templates.crud_app.test_crud_app.test_delete_item",
|
|
"signature": "<bound method Function.signature of Function('test_delete_item', 115, 125)>",
|
|
"docstring": "Deleting an item should remove it from the store."
|
|
}
|
|
}
|
|
}
|
|
} |