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:
2026-10-13 03:26:31 +05:30
parent b559323dfe
commit 51ffb4aae9
38 changed files with 1156 additions and 3027 deletions

View File

@@ -4,53 +4,11 @@
"path": "openapi_first.templates.vet_app.models",
"docstring": null,
"objects": {
"date": {
"name": "date",
"kind": "alias",
"path": "openapi_first.templates.vet_app.models.date",
"signature": "<bound method Alias.signature of Alias('date', 'datetime.date')>",
"docstring": null
},
"datetime": {
"name": "datetime",
"kind": "alias",
"path": "openapi_first.templates.vet_app.models.datetime",
"signature": "<bound method Alias.signature of Alias('datetime', 'datetime.datetime')>",
"docstring": null
},
"Annotated": {
"name": "Annotated",
"kind": "alias",
"path": "openapi_first.templates.vet_app.models.Annotated",
"signature": "<bound method Alias.signature of Alias('Annotated', 'typing.Annotated')>",
"docstring": null
},
"Literal": {
"name": "Literal",
"kind": "alias",
"path": "openapi_first.templates.vet_app.models.Literal",
"signature": "<bound method Alias.signature of Alias('Literal', 'typing.Literal')>",
"docstring": null
},
"BaseModel": {
"name": "BaseModel",
"kind": "alias",
"path": "openapi_first.templates.vet_app.models.BaseModel",
"signature": "<bound method Alias.signature of Alias('BaseModel', 'pydantic.BaseModel')>",
"docstring": null
},
"Field": {
"name": "Field",
"kind": "alias",
"path": "openapi_first.templates.vet_app.models.Field",
"signature": "<bound method Alias.signature of Alias('Field', 'pydantic.Field')>",
"docstring": null
},
"Metadata": {
"name": "Metadata",
"kind": "class",
"path": "openapi_first.templates.vet_app.models.Metadata",
"signature": "<bound method Class.signature of Class('Metadata', 6, 8)>",
"signature": null,
"docstring": null,
"members": {
"createdOn": {
@@ -73,7 +31,7 @@
"name": "ParentBase",
"kind": "class",
"path": "openapi_first.templates.vet_app.models.ParentBase",
"signature": "<bound method Class.signature of Class('ParentBase', 11, 15)>",
"signature": null,
"docstring": null,
"members": {
"name": {
@@ -110,14 +68,14 @@
"name": "ParentCreate",
"kind": "class",
"path": "openapi_first.templates.vet_app.models.ParentCreate",
"signature": "<bound method Class.signature of Class('ParentCreate', 18, 19)>",
"signature": null,
"docstring": null
},
"Parent": {
"name": "Parent",
"kind": "class",
"path": "openapi_first.templates.vet_app.models.Parent",
"signature": "<bound method Class.signature of Class('Parent', 22, 23)>",
"signature": null,
"docstring": null,
"members": {
"id": {
@@ -133,7 +91,7 @@
"name": "VetBase",
"kind": "class",
"path": "openapi_first.templates.vet_app.models.VetBase",
"signature": "<bound method Class.signature of Class('VetBase', 26, 31)>",
"signature": null,
"docstring": null,
"members": {
"name": {
@@ -177,14 +135,14 @@
"name": "VetCreate",
"kind": "class",
"path": "openapi_first.templates.vet_app.models.VetCreate",
"signature": "<bound method Class.signature of Class('VetCreate', 34, 35)>",
"signature": null,
"docstring": null
},
"Vet": {
"name": "Vet",
"kind": "class",
"path": "openapi_first.templates.vet_app.models.Vet",
"signature": "<bound method Class.signature of Class('Vet', 38, 39)>",
"signature": null,
"docstring": null,
"members": {
"id": {
@@ -200,7 +158,7 @@
"name": "ProcedureNoteBase",
"kind": "class",
"path": "openapi_first.templates.vet_app.models.ProcedureNoteBase",
"signature": "<bound method Class.signature of Class('ProcedureNoteBase', 42, 44)>",
"signature": null,
"docstring": null,
"members": {
"summary": {
@@ -223,7 +181,7 @@
"name": "BasicNote",
"kind": "class",
"path": "openapi_first.templates.vet_app.models.BasicNote",
"signature": "<bound method Class.signature of Class('BasicNote', 47, 48)>",
"signature": null,
"docstring": null,
"members": {
"noteType": {
@@ -239,7 +197,7 @@
"name": "HeartRateNote",
"kind": "class",
"path": "openapi_first.templates.vet_app.models.HeartRateNote",
"signature": "<bound method Class.signature of Class('HeartRateNote', 51, 53)>",
"signature": null,
"docstring": null,
"members": {
"noteType": {
@@ -262,7 +220,7 @@
"name": "DentalNote",
"kind": "class",
"path": "openapi_first.templates.vet_app.models.DentalNote",
"signature": "<bound method Class.signature of Class('DentalNote', 56, 59)>",
"signature": null,
"docstring": null,
"members": {
"noteType": {
@@ -292,7 +250,7 @@
"name": "VaccineNote",
"kind": "class",
"path": "openapi_first.templates.vet_app.models.VaccineNote",
"signature": "<bound method Class.signature of Class('VaccineNote', 62, 65)>",
"signature": null,
"docstring": null,
"members": {
"noteType": {
@@ -322,7 +280,7 @@
"name": "PreOpNote",
"kind": "class",
"path": "openapi_first.templates.vet_app.models.PreOpNote",
"signature": "<bound method Class.signature of Class('PreOpNote', 68, 71)>",
"signature": null,
"docstring": null,
"members": {
"noteType": {
@@ -352,7 +310,7 @@
"name": "SurgeryNote",
"kind": "class",
"path": "openapi_first.templates.vet_app.models.SurgeryNote",
"signature": "<bound method Class.signature of Class('SurgeryNote', 74, 77)>",
"signature": null,
"docstring": null,
"members": {
"noteType": {
@@ -389,7 +347,7 @@
"name": "Procedure",
"kind": "class",
"path": "openapi_first.templates.vet_app.models.Procedure",
"signature": "<bound method Class.signature of Class('Procedure', 86, 90)>",
"signature": null,
"docstring": null,
"members": {
"name": {
@@ -426,7 +384,7 @@
"name": "TreatmentBase",
"kind": "class",
"path": "openapi_first.templates.vet_app.models.TreatmentBase",
"signature": "<bound method Class.signature of Class('TreatmentBase', 93, 96)>",
"signature": null,
"docstring": null,
"members": {
"label": {
@@ -456,14 +414,14 @@
"name": "TreatmentCreate",
"kind": "class",
"path": "openapi_first.templates.vet_app.models.TreatmentCreate",
"signature": "<bound method Class.signature of Class('TreatmentCreate', 99, 100)>",
"signature": null,
"docstring": null
},
"Treatment": {
"name": "Treatment",
"kind": "class",
"path": "openapi_first.templates.vet_app.models.Treatment",
"signature": "<bound method Class.signature of Class('Treatment', 103, 104)>",
"signature": null,
"docstring": null,
"members": {
"id": {
@@ -479,7 +437,7 @@
"name": "PetBase",
"kind": "class",
"path": "openapi_first.templates.vet_app.models.PetBase",
"signature": "<bound method Class.signature of Class('PetBase', 107, 114)>",
"signature": null,
"docstring": null,
"members": {
"name": {
@@ -537,7 +495,7 @@
"name": "PetCreate",
"kind": "class",
"path": "openapi_first.templates.vet_app.models.PetCreate",
"signature": "<bound method Class.signature of Class('PetCreate', 117, 118)>",
"signature": null,
"docstring": null,
"members": {
"parent_ids": {
@@ -553,7 +511,7 @@
"name": "Pet",
"kind": "class",
"path": "openapi_first.templates.vet_app.models.Pet",
"signature": "<bound method Class.signature of Class('Pet', 121, 123)>",
"signature": null,
"docstring": null,
"members": {
"id": {
@@ -576,7 +534,7 @@
"name": "AppointmentBase",
"kind": "class",
"path": "openapi_first.templates.vet_app.models.AppointmentBase",
"signature": "<bound method Class.signature of Class('AppointmentBase', 126, 130)>",
"signature": null,
"docstring": null,
"members": {
"date": {
@@ -613,7 +571,7 @@
"name": "AppointmentCreate",
"kind": "class",
"path": "openapi_first.templates.vet_app.models.AppointmentCreate",
"signature": "<bound method Class.signature of Class('AppointmentCreate', 133, 136)>",
"signature": null,
"docstring": null,
"members": {
"pet_id": {
@@ -643,7 +601,7 @@
"name": "Appointment",
"kind": "class",
"path": "openapi_first.templates.vet_app.models.Appointment",
"signature": "<bound method Class.signature of Class('Appointment', 139, 143)>",
"signature": null,
"docstring": null,
"members": {
"id": {