feat: codegen routes — sanitize resource names, --inject-request/--package, expand form bodies
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.
This commit is contained in:
@@ -4,61 +4,40 @@
|
||||
"path": "openapi_first.templates.model_app.routes",
|
||||
"docstring": "CRUD route handlers bound via OpenAPI operationId.\n\nThis module defines OpenAPI-bound operation handlers for a model-based\nCRUD service. Functions in this module are bound to HTTP routes\nexclusively via OpenAPI ``operationId`` values.\n\nHandlers explicitly control HTTP response status codes to ensure runtime\nbehavior matches the OpenAPI contract. Domain models defined using\nPydantic are used for request and response payloads.\n\nNo routing decorators, path definitions, or implicit framework behavior\nappear in this module. All routing, HTTP methods, and schemas are defined\nin the OpenAPI specification.",
|
||||
"objects": {
|
||||
"Response": {
|
||||
"name": "Response",
|
||||
"kind": "alias",
|
||||
"path": "openapi_first.templates.model_app.routes.Response",
|
||||
"signature": "<bound method Alias.signature of Alias('Response', 'fastapi.Response')>",
|
||||
"docstring": null
|
||||
},
|
||||
"HTTPException": {
|
||||
"name": "HTTPException",
|
||||
"kind": "alias",
|
||||
"path": "openapi_first.templates.model_app.routes.HTTPException",
|
||||
"signature": "<bound method Alias.signature of Alias('HTTPException', 'fastapi.HTTPException')>",
|
||||
"docstring": null
|
||||
},
|
||||
"ItemCreate": {
|
||||
"name": "ItemCreate",
|
||||
"kind": "alias",
|
||||
"path": "openapi_first.templates.model_app.routes.ItemCreate",
|
||||
"signature": "<bound method Alias.signature of Alias('ItemCreate', 'models.ItemCreate')>",
|
||||
"docstring": null
|
||||
},
|
||||
"list_items": {
|
||||
"name": "list_items",
|
||||
"kind": "function",
|
||||
"path": "openapi_first.templates.model_app.routes.list_items",
|
||||
"signature": "<bound method Function.signature of Function('list_items', 29, 41)>",
|
||||
"signature": "list_items() -> list[Item]",
|
||||
"docstring": "List all items.\n\nImplements the OpenAPI operation identified by\n``operationId: list_items``.\n\nReturns\n-------\nlist[Item]\n A list of item domain objects."
|
||||
},
|
||||
"get_item": {
|
||||
"name": "get_item",
|
||||
"kind": "function",
|
||||
"path": "openapi_first.templates.model_app.routes.get_item",
|
||||
"signature": "<bound method Function.signature of Function('get_item', 44, 69)>",
|
||||
"signature": "get_item(item_id: int) -> Item",
|
||||
"docstring": "Retrieve a single item by ID.\n\nImplements the OpenAPI operation identified by\n``operationId: get_item``.\n\nParameters\n----------\nitem_id : int\n Identifier of the item to retrieve.\n\nReturns\n-------\nItem\n The requested item.\n\nRaises\n------\nHTTPException\n 404 if the item does not exist."
|
||||
},
|
||||
"create_item": {
|
||||
"name": "create_item",
|
||||
"kind": "function",
|
||||
"path": "openapi_first.templates.model_app.routes.create_item",
|
||||
"signature": "<bound method Function.signature of Function('create_item', 72, 93)>",
|
||||
"docstring": "Create a new item.\n\nImplements the OpenAPI operation identified by\n``operationId: create_item``.\n\nParameters\n----------\npayload : ItemCreate\n Request body describing the item to create.\nresponse : fastapi.Response\n Response object used to set the HTTP status code.\n\nReturns\n-------\nItem\n The newly created item."
|
||||
"signature": "create_item(payload: ItemCreate, response: Response) -> Item",
|
||||
"docstring": "Create a new item.\n\nImplements the OpenAPI operation identified by\n``operationId: create_item``.\n\nParameters\n----------\npayload : ItemCreate\n Request body describing the item to create.\nresponse : Response\n Response object used to set the HTTP status code.\n\nReturns\n-------\nItem\n The newly created item."
|
||||
},
|
||||
"update_item": {
|
||||
"name": "update_item",
|
||||
"kind": "function",
|
||||
"path": "openapi_first.templates.model_app.routes.update_item",
|
||||
"signature": "<bound method Function.signature of Function('update_item', 96, 123)>",
|
||||
"signature": "update_item(item_id: int, payload: ItemCreate) -> Item",
|
||||
"docstring": "Update an existing item.\n\nImplements the OpenAPI operation identified by\n``operationId: update_item``.\n\nParameters\n----------\nitem_id : int\n Identifier of the item to update.\npayload : ItemCreate\n New item data.\n\nReturns\n-------\nItem\n The updated item.\n\nRaises\n------\nHTTPException\n 404 if the item does not exist."
|
||||
},
|
||||
"delete_item": {
|
||||
"name": "delete_item",
|
||||
"kind": "function",
|
||||
"path": "openapi_first.templates.model_app.routes.delete_item",
|
||||
"signature": "<bound method Function.signature of Function('delete_item', 126, 156)>",
|
||||
"docstring": "Delete an existing item.\n\nImplements the OpenAPI operation identified by\n``operationId: delete_item``.\n\nParameters\n----------\nitem_id : int\n Identifier of the item to delete.\nresponse : fastapi.Response\n Response object used to set the HTTP status code.\n\nReturns\n-------\nNone\n No content.\n\nRaises\n------\nHTTPException\n 404 if the item does not exist."
|
||||
"signature": "delete_item(item_id: int, response: Response) -> None",
|
||||
"docstring": "Delete an existing item.\n\nImplements the OpenAPI operation identified by\n``operationId: delete_item``.\n\nParameters\n----------\nitem_id : int\n Identifier of the item to delete.\nresponse : Response\n Response object used to set the HTTP status code.\n\nReturns\n-------\nNone\n No content.\n\nRaises\n------\nHTTPException\n 404 if the item does not exist."
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user