codegen_routes.generate_routes now sanitizes resource identifiers (fetch-requests -> fetch_requests), optionally prepends 'request: Request' (inject_request) and emits <resource>/routes.py packages with __init__.py (package). multipart/form-data and x-www-form-urlencoded bodies expand to per-property UploadFile/File/Form params instead of an opaque dict; spec paths are normalized to forward slashes to avoid Windows escape issues. Adds CLI flags --inject-request/--package, 7 focused tests, and refreshes lib/wiki/MCP docs to the real CLI.
102 lines
6.4 KiB
JSON
102 lines
6.4 KiB
JSON
{
|
|
"module": "openapi_first.templates.model_app.test_model_app",
|
|
"content": {
|
|
"path": "openapi_first.templates.model_app.test_model_app",
|
|
"docstring": "End-to-end tests for the OpenAPI-first model CRUD example app.\n\nThese tests validate that all CRUD operations behave correctly\nagainst the in-memory mock data store using Pydantic models.\n- OpenAPI specification loading\n- OperationId-driven route binding on the server\n- OperationId-driven client invocation\n- Pydantic model-based request and response handling\n\nAll CRUD operations are exercised against an in-memory mock data store\nbacked by Pydantic domain models.\n\nThe tests assume:\n- OpenAPI-first route binding\n- Pydantic model validation\n- In-memory storage (no persistence guarantees)\n- Deterministic behavior in a single process",
|
|
"objects": {
|
|
"load_openapi": {
|
|
"name": "load_openapi",
|
|
"kind": "function",
|
|
"path": "openapi_first.templates.model_app.test_model_app.load_openapi",
|
|
"signature": "load_openapi(path: str | Path)",
|
|
"docstring": "Load and validate an OpenAPI 3.x specification from disk.\n\nArgs:\n path (str | Path):\n Filesystem path to an OpenAPI specification file. Supported\n extensions: `.json`, `.yaml`, `.yml`.\n\nReturns:\n dict[str, Any]:\n Parsed and validated OpenAPI specification.\n\nRaises:\n OpenAPISpecLoadError:\n If the file does not exist, cannot be parsed, or fails OpenAPI\n schema validation.\n\nNotes:\n **Guarantees:**\n\n - The specification is parsed based on file extension and validated\n using a strict OpenAPI schema validator.\n - Any error results in an immediate exception, preventing\n application startup."
|
|
},
|
|
"OpenAPIClient": {
|
|
"name": "OpenAPIClient",
|
|
"kind": "class",
|
|
"path": "openapi_first.templates.model_app.test_model_app.OpenAPIClient",
|
|
"signature": "OpenAPIClient(spec: dict[str, Any], base_url: str | None = None, client: httpx.Client | None = None)",
|
|
"docstring": "OpenAPI-first HTTP client (`httpx`-based).\n\nArgs:\n spec (dict[str, Any]):\n Parsed OpenAPI 3.x specification.\n base_url (str | None):\n Base URL of the target service. If omitted, the first entry in the\n OpenAPI `servers` list is used.\n client (httpx.Client | None):\n Optional preconfigured httpx client instance.\n\nRaises:\n OpenAPIClientError:\n If no servers are defined, spec has no paths, operationIds are\n missing/duplicate, or required parameters are missing.\n\nNotes:\n **Responsibilities:**\n\n - This client derives all callable methods directly from an\n OpenAPI 3.x specification. Each `operationId` becomes a method\n on the client instance.\n\n **Guarantees:**\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\nExample:\n ```python\n from openapi_first import loader, client\n\n spec = loader.load_openapi(\"openapi.yaml\")\n\n api = client.OpenAPIClient(\n spec=spec,\n base_url=\"http://localhost:8000\",\n )\n\n # Call operationId: getUser\n response = api.getUser(\n path_params={\"user_id\": 123}\n )\n\n print(response.status_code)\n print(response.json())\n ```",
|
|
"members": {
|
|
"spec": {
|
|
"name": "spec",
|
|
"kind": "attribute",
|
|
"path": "openapi_first.templates.model_app.test_model_app.OpenAPIClient.spec",
|
|
"signature": null,
|
|
"docstring": null
|
|
},
|
|
"base_url": {
|
|
"name": "base_url",
|
|
"kind": "attribute",
|
|
"path": "openapi_first.templates.model_app.test_model_app.OpenAPIClient.base_url",
|
|
"signature": null,
|
|
"docstring": null
|
|
},
|
|
"client": {
|
|
"name": "client",
|
|
"kind": "attribute",
|
|
"path": "openapi_first.templates.model_app.test_model_app.OpenAPIClient.client",
|
|
"signature": null,
|
|
"docstring": null
|
|
},
|
|
"operations": {
|
|
"name": "operations",
|
|
"kind": "function",
|
|
"path": "openapi_first.templates.model_app.test_model_app.OpenAPIClient.operations",
|
|
"signature": "operations()",
|
|
"docstring": null
|
|
}
|
|
}
|
|
},
|
|
"client": {
|
|
"name": "client",
|
|
"kind": "attribute",
|
|
"path": "openapi_first.templates.model_app.test_model_app.client",
|
|
"signature": null,
|
|
"docstring": null
|
|
},
|
|
"spec": {
|
|
"name": "spec",
|
|
"kind": "attribute",
|
|
"path": "openapi_first.templates.model_app.test_model_app.spec",
|
|
"signature": null,
|
|
"docstring": null
|
|
},
|
|
"test_list_items_initial": {
|
|
"name": "test_list_items_initial",
|
|
"kind": "function",
|
|
"path": "openapi_first.templates.model_app.test_model_app.test_list_items_initial",
|
|
"signature": "test_list_items_initial()",
|
|
"docstring": "Initial items should be present."
|
|
},
|
|
"test_get_item": {
|
|
"name": "test_get_item",
|
|
"kind": "function",
|
|
"path": "openapi_first.templates.model_app.test_model_app.test_get_item",
|
|
"signature": "test_get_item()",
|
|
"docstring": "Existing item should be retrievable by ID."
|
|
},
|
|
"test_create_item": {
|
|
"name": "test_create_item",
|
|
"kind": "function",
|
|
"path": "openapi_first.templates.model_app.test_model_app.test_create_item",
|
|
"signature": "test_create_item()",
|
|
"docstring": "Creating a new item should return the created entity."
|
|
},
|
|
"test_update_item": {
|
|
"name": "test_update_item",
|
|
"kind": "function",
|
|
"path": "openapi_first.templates.model_app.test_model_app.test_update_item",
|
|
"signature": "test_update_item()",
|
|
"docstring": "Updating an item should replace its values."
|
|
},
|
|
"test_delete_item": {
|
|
"name": "test_delete_item",
|
|
"kind": "function",
|
|
"path": "openapi_first.templates.model_app.test_model_app.test_delete_item",
|
|
"signature": "test_delete_item()",
|
|
"docstring": "Deleting an item should remove it from the store."
|
|
}
|
|
}
|
|
}
|
|
} |