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,270 +4,193 @@
|
||||
"path": "openapi_first.templates.vet_app.routes",
|
||||
"docstring": "Veterinary Clinic route handlers bound via OpenAPI operationId.\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.vet_app.routes.Response",
|
||||
"signature": "<bound method Alias.signature of Alias('Response', 'fastapi.Response')>",
|
||||
"docstring": null
|
||||
},
|
||||
"HTTPException": {
|
||||
"name": "HTTPException",
|
||||
"kind": "alias",
|
||||
"path": "openapi_first.templates.vet_app.routes.HTTPException",
|
||||
"signature": "<bound method Alias.signature of Alias('HTTPException', 'fastapi.HTTPException')>",
|
||||
"docstring": null
|
||||
},
|
||||
"UploadFile": {
|
||||
"name": "UploadFile",
|
||||
"kind": "alias",
|
||||
"path": "openapi_first.templates.vet_app.routes.UploadFile",
|
||||
"signature": "<bound method Alias.signature of Alias('UploadFile', 'fastapi.UploadFile')>",
|
||||
"docstring": null
|
||||
},
|
||||
"StreamingResponse": {
|
||||
"name": "StreamingResponse",
|
||||
"kind": "alias",
|
||||
"path": "openapi_first.templates.vet_app.routes.StreamingResponse",
|
||||
"signature": "<bound method Alias.signature of Alias('StreamingResponse', 'fastapi.responses.StreamingResponse')>",
|
||||
"docstring": null
|
||||
},
|
||||
"subscribe": {
|
||||
"name": "subscribe",
|
||||
"kind": "alias",
|
||||
"path": "openapi_first.templates.vet_app.routes.subscribe",
|
||||
"signature": "<bound method Alias.signature of Alias('subscribe', 'sse.subscribe')>",
|
||||
"docstring": null
|
||||
},
|
||||
"unsubscribe": {
|
||||
"name": "unsubscribe",
|
||||
"kind": "alias",
|
||||
"path": "openapi_first.templates.vet_app.routes.unsubscribe",
|
||||
"signature": "<bound method Alias.signature of Alias('unsubscribe', 'sse.unsubscribe')>",
|
||||
"docstring": null
|
||||
},
|
||||
"ParentCreate": {
|
||||
"name": "ParentCreate",
|
||||
"kind": "alias",
|
||||
"path": "openapi_first.templates.vet_app.routes.ParentCreate",
|
||||
"signature": "<bound method Alias.signature of Alias('ParentCreate', 'models.ParentCreate')>",
|
||||
"docstring": null
|
||||
},
|
||||
"VetCreate": {
|
||||
"name": "VetCreate",
|
||||
"kind": "alias",
|
||||
"path": "openapi_first.templates.vet_app.routes.VetCreate",
|
||||
"signature": "<bound method Alias.signature of Alias('VetCreate', 'models.VetCreate')>",
|
||||
"docstring": null
|
||||
},
|
||||
"TreatmentCreate": {
|
||||
"name": "TreatmentCreate",
|
||||
"kind": "alias",
|
||||
"path": "openapi_first.templates.vet_app.routes.TreatmentCreate",
|
||||
"signature": "<bound method Alias.signature of Alias('TreatmentCreate', 'models.TreatmentCreate')>",
|
||||
"docstring": null
|
||||
},
|
||||
"PetCreate": {
|
||||
"name": "PetCreate",
|
||||
"kind": "alias",
|
||||
"path": "openapi_first.templates.vet_app.routes.PetCreate",
|
||||
"signature": "<bound method Alias.signature of Alias('PetCreate', 'models.PetCreate')>",
|
||||
"docstring": null
|
||||
},
|
||||
"AppointmentCreate": {
|
||||
"name": "AppointmentCreate",
|
||||
"kind": "alias",
|
||||
"path": "openapi_first.templates.vet_app.routes.AppointmentCreate",
|
||||
"signature": "<bound method Alias.signature of Alias('AppointmentCreate', 'models.AppointmentCreate')>",
|
||||
"docstring": null
|
||||
},
|
||||
"list_parents": {
|
||||
"name": "list_parents",
|
||||
"kind": "function",
|
||||
"path": "openapi_first.templates.vet_app.routes.list_parents",
|
||||
"signature": "<bound method Function.signature of Function('list_parents', 60, 76)>",
|
||||
"signature": "list_parents(limit: int = 20, offset: int = 0) -> dict",
|
||||
"docstring": "List parents (paginated).\n\nParameters\n----------\nlimit : int\n Maximum number of records to return.\noffset : int\n Number of records to skip.\n\nReturns\n-------\ndict\n Paginated response with ``total`` and ``items``."
|
||||
},
|
||||
"create_parent": {
|
||||
"name": "create_parent",
|
||||
"kind": "function",
|
||||
"path": "openapi_first.templates.vet_app.routes.create_parent",
|
||||
"signature": "<bound method Function.signature of Function('create_parent', 79, 94)>",
|
||||
"docstring": "Create a parent.\n\nParameters\n----------\npayload : ParentCreate\n Parent data excluding the ``id`` field.\n\nReturns\n-------\nParent\n The newly created parent."
|
||||
"signature": "create_parent(payload: ParentCreate, response: Response) -> Parent",
|
||||
"docstring": "Create a parent.\n\nParameters\n----------\npayload : ParentCreate\n Parent data excluding the ``id`` field.\nresponse : Response\n Response object used to set the HTTP status code.\n\nReturns\n-------\nParent\n The newly created parent."
|
||||
},
|
||||
"get_parent": {
|
||||
"name": "get_parent",
|
||||
"kind": "function",
|
||||
"path": "openapi_first.templates.vet_app.routes.get_parent",
|
||||
"signature": "<bound method Function.signature of Function('get_parent', 97, 118)>",
|
||||
"signature": "get_parent(id: int) -> Parent",
|
||||
"docstring": "Retrieve a single parent by ID.\n\nParameters\n----------\nid : int\n Identifier of the parent.\n\nReturns\n-------\nParent\n The requested parent.\n\nRaises\n------\nHTTPException\n 404 if the parent does not exist."
|
||||
},
|
||||
"update_parent": {
|
||||
"name": "update_parent",
|
||||
"kind": "function",
|
||||
"path": "openapi_first.templates.vet_app.routes.update_parent",
|
||||
"signature": "<bound method Function.signature of Function('update_parent', 121, 144)>",
|
||||
"signature": "update_parent(id: int, payload: ParentCreate) -> Parent",
|
||||
"docstring": "Update an existing parent.\n\nParameters\n----------\nid : int\n Identifier of the parent.\npayload : ParentCreate\n Updated parent data.\n\nReturns\n-------\nParent\n The updated parent.\n\nRaises\n------\nHTTPException\n 404 if the parent does not exist."
|
||||
},
|
||||
"delete_parent": {
|
||||
"name": "delete_parent",
|
||||
"kind": "function",
|
||||
"path": "openapi_first.templates.vet_app.routes.delete_parent",
|
||||
"signature": "<bound method Function.signature of Function('delete_parent', 147, 164)>",
|
||||
"docstring": "Delete an existing parent.\n\nParameters\n----------\nid : int\n Identifier of the parent.\n\nRaises\n------\nHTTPException\n 404 if the parent does not exist."
|
||||
"signature": "delete_parent(id: int, response: Response) -> None",
|
||||
"docstring": "Delete an existing parent.\n\nParameters\n----------\nid : int\n Identifier of the parent.\nresponse : Response\n Response object used to set the HTTP status code.\n\nRaises\n------\nHTTPException\n 404 if the parent does not exist."
|
||||
},
|
||||
"list_vets": {
|
||||
"name": "list_vets",
|
||||
"kind": "function",
|
||||
"path": "openapi_first.templates.vet_app.routes.list_vets",
|
||||
"signature": "<bound method Function.signature of Function('list_vets', 172, 175)>",
|
||||
"signature": "list_vets(limit: int = 20, offset: int = 0)",
|
||||
"docstring": "List vets (paginated)."
|
||||
},
|
||||
"create_vet": {
|
||||
"name": "create_vet",
|
||||
"kind": "function",
|
||||
"path": "openapi_first.templates.vet_app.routes.create_vet",
|
||||
"signature": "<bound method Function.signature of Function('create_vet', 178, 182)>",
|
||||
"signature": "create_vet(payload: VetCreate, response: Response)",
|
||||
"docstring": "Create a vet."
|
||||
},
|
||||
"get_vet": {
|
||||
"name": "get_vet",
|
||||
"kind": "function",
|
||||
"path": "openapi_first.templates.vet_app.routes.get_vet",
|
||||
"signature": "<bound method Function.signature of Function('get_vet', 185, 190)>",
|
||||
"signature": "get_vet(id: int)",
|
||||
"docstring": "Retrieve a single vet by ID."
|
||||
},
|
||||
"update_vet": {
|
||||
"name": "update_vet",
|
||||
"kind": "function",
|
||||
"path": "openapi_first.templates.vet_app.routes.update_vet",
|
||||
"signature": "<bound method Function.signature of Function('update_vet', 193, 198)>",
|
||||
"signature": "update_vet(id: int, payload: VetCreate)",
|
||||
"docstring": "Update an existing vet."
|
||||
},
|
||||
"delete_vet": {
|
||||
"name": "delete_vet",
|
||||
"kind": "function",
|
||||
"path": "openapi_first.templates.vet_app.routes.delete_vet",
|
||||
"signature": "<bound method Function.signature of Function('delete_vet', 201, 207)>",
|
||||
"signature": "delete_vet(id: int, response: Response)",
|
||||
"docstring": "Delete an existing vet."
|
||||
},
|
||||
"list_treatments": {
|
||||
"name": "list_treatments",
|
||||
"kind": "function",
|
||||
"path": "openapi_first.templates.vet_app.routes.list_treatments",
|
||||
"signature": "<bound method Function.signature of Function('list_treatments', 215, 223)>",
|
||||
"signature": "list_treatments() -> list[Treatment]",
|
||||
"docstring": "List treatments (catalogue).\n\nReturns\n-------\nlist[Treatment]\n A list of treatment domain objects."
|
||||
},
|
||||
"create_treatment": {
|
||||
"name": "create_treatment",
|
||||
"kind": "function",
|
||||
"path": "openapi_first.templates.vet_app.routes.create_treatment",
|
||||
"signature": "<bound method Function.signature of Function('create_treatment', 226, 230)>",
|
||||
"signature": "create_treatment(payload: TreatmentCreate, response: Response)",
|
||||
"docstring": "Add a treatment (admin only)."
|
||||
},
|
||||
"get_treatment": {
|
||||
"name": "get_treatment",
|
||||
"kind": "function",
|
||||
"path": "openapi_first.templates.vet_app.routes.get_treatment",
|
||||
"signature": "<bound method Function.signature of Function('get_treatment', 233, 238)>",
|
||||
"signature": "get_treatment(id: int)",
|
||||
"docstring": "Retrieve a single treatment by ID."
|
||||
},
|
||||
"update_treatment": {
|
||||
"name": "update_treatment",
|
||||
"kind": "function",
|
||||
"path": "openapi_first.templates.vet_app.routes.update_treatment",
|
||||
"signature": "<bound method Function.signature of Function('update_treatment', 241, 246)>",
|
||||
"signature": "update_treatment(id: int, payload: TreatmentCreate)",
|
||||
"docstring": "Update an existing treatment."
|
||||
},
|
||||
"delete_treatment": {
|
||||
"name": "delete_treatment",
|
||||
"kind": "function",
|
||||
"path": "openapi_first.templates.vet_app.routes.delete_treatment",
|
||||
"signature": "<bound method Function.signature of Function('delete_treatment', 249, 255)>",
|
||||
"signature": "delete_treatment(id: int, response: Response)",
|
||||
"docstring": "Delete an existing treatment."
|
||||
},
|
||||
"list_pets": {
|
||||
"name": "list_pets",
|
||||
"kind": "function",
|
||||
"path": "openapi_first.templates.vet_app.routes.list_pets",
|
||||
"signature": "<bound method Function.signature of Function('list_pets', 263, 266)>",
|
||||
"signature": "list_pets(limit: int = 20, offset: int = 0)",
|
||||
"docstring": "List pets (paginated)."
|
||||
},
|
||||
"create_pet": {
|
||||
"name": "create_pet",
|
||||
"kind": "function",
|
||||
"path": "openapi_first.templates.vet_app.routes.create_pet",
|
||||
"signature": "<bound method Function.signature of Function('create_pet', 269, 273)>",
|
||||
"signature": "create_pet(payload: PetCreate, response: Response)",
|
||||
"docstring": "Create a pet."
|
||||
},
|
||||
"get_pet": {
|
||||
"name": "get_pet",
|
||||
"kind": "function",
|
||||
"path": "openapi_first.templates.vet_app.routes.get_pet",
|
||||
"signature": "<bound method Function.signature of Function('get_pet', 276, 281)>",
|
||||
"signature": "get_pet(id: int)",
|
||||
"docstring": "Retrieve a single pet by ID."
|
||||
},
|
||||
"update_pet": {
|
||||
"name": "update_pet",
|
||||
"kind": "function",
|
||||
"path": "openapi_first.templates.vet_app.routes.update_pet",
|
||||
"signature": "<bound method Function.signature of Function('update_pet', 284, 289)>",
|
||||
"signature": "update_pet(id: int, payload: PetCreate)",
|
||||
"docstring": "Update an existing pet."
|
||||
},
|
||||
"delete_pet": {
|
||||
"name": "delete_pet",
|
||||
"kind": "function",
|
||||
"path": "openapi_first.templates.vet_app.routes.delete_pet",
|
||||
"signature": "<bound method Function.signature of Function('delete_pet', 292, 298)>",
|
||||
"signature": "delete_pet(id: int, response: Response)",
|
||||
"docstring": "Delete an existing pet."
|
||||
},
|
||||
"upload_pet_photo": {
|
||||
"name": "upload_pet_photo",
|
||||
"kind": "function",
|
||||
"path": "openapi_first.templates.vet_app.routes.upload_pet_photo",
|
||||
"signature": "<bound method Function.signature of Function('upload_pet_photo', 301, 317)>",
|
||||
"signature": "upload_pet_photo(id: int, file: UploadFile) -> dict",
|
||||
"docstring": "Upload a pet photo.\n\nParameters\n----------\nid : int\n Identifier of the pet.\nfile : UploadFile\n Image file to upload.\n\nReturns\n-------\ndict\n A confirmation with the pet ID."
|
||||
},
|
||||
"list_appointments": {
|
||||
"name": "list_appointments",
|
||||
"kind": "function",
|
||||
"path": "openapi_first.templates.vet_app.routes.list_appointments",
|
||||
"signature": "<bound method Function.signature of Function('list_appointments', 325, 337)>",
|
||||
"signature": "list_appointments(limit: int = 20, offset: int = 0, date: str = None, vet: int = None, pet: int = None)",
|
||||
"docstring": "List appointments (paginated, filterable)."
|
||||
},
|
||||
"create_appointment": {
|
||||
"name": "create_appointment",
|
||||
"kind": "function",
|
||||
"path": "openapi_first.templates.vet_app.routes.create_appointment",
|
||||
"signature": "<bound method Function.signature of Function('create_appointment', 340, 344)>",
|
||||
"signature": "create_appointment(payload: AppointmentCreate, response: Response)",
|
||||
"docstring": "Create an appointment."
|
||||
},
|
||||
"get_appointment": {
|
||||
"name": "get_appointment",
|
||||
"kind": "function",
|
||||
"path": "openapi_first.templates.vet_app.routes.get_appointment",
|
||||
"signature": "<bound method Function.signature of Function('get_appointment', 347, 352)>",
|
||||
"signature": "get_appointment(id: int)",
|
||||
"docstring": "Retrieve a single appointment by ID."
|
||||
},
|
||||
"update_appointment": {
|
||||
"name": "update_appointment",
|
||||
"kind": "function",
|
||||
"path": "openapi_first.templates.vet_app.routes.update_appointment",
|
||||
"signature": "<bound method Function.signature of Function('update_appointment', 355, 360)>",
|
||||
"signature": "update_appointment(id: int, payload: AppointmentCreate)",
|
||||
"docstring": "Update an existing appointment."
|
||||
},
|
||||
"delete_appointment": {
|
||||
"name": "delete_appointment",
|
||||
"kind": "function",
|
||||
"path": "openapi_first.templates.vet_app.routes.delete_appointment",
|
||||
"signature": "<bound method Function.signature of Function('delete_appointment', 363, 369)>",
|
||||
"signature": "delete_appointment(id: int, response: Response)",
|
||||
"docstring": "Delete an existing appointment."
|
||||
},
|
||||
"stream_actions": {
|
||||
"name": "stream_actions",
|
||||
"kind": "function",
|
||||
"path": "openapi_first.templates.vet_app.routes.stream_actions",
|
||||
"signature": "<bound method Function.signature of Function('stream_actions', 372, 389)>",
|
||||
"signature": "stream_actions(id: int)",
|
||||
"docstring": "Stream animal actions via SSE, scoped to a pet's species."
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user