using doc-forge

This commit is contained in:
2026-01-22 16:55:15 +05:30
parent 29c1579f40
commit f91c0b8792
36 changed files with 3739 additions and 238 deletions

View File

@@ -0,0 +1,53 @@
{
"module": "openapi_first.app",
"content": {
"path": "openapi_first.app",
"docstring": "openapi_first.app\n=========================\n\nOpenAPI-first application bootstrap for FastAPI.\n\nThis module provides `OpenAPIFirstApp`, a thin but strict abstraction\nthat enforces OpenAPI as the single source of truth for a FastAPI service.\n\nCore principles\n---------------\n- The OpenAPI specification (JSON or YAML) defines the entire API surface.\n- Every operationId in the OpenAPI spec must have a corresponding\n Python handler function.\n- Handlers are plain Python callables (no FastAPI decorators).\n- FastAPI route registration is derived exclusively from the spec.\n- FastAPI's autogenerated OpenAPI schema is fully overridden.\n\nWhat this module does\n---------------------\n- Loads and validates an OpenAPI 3.x specification.\n- Dynamically binds HTTP routes to handler functions using operationId.\n- Registers routes with FastAPI at application startup.\n- Ensures runtime behavior matches the OpenAPI contract exactly.\n\nWhat this module does NOT do\n----------------------------\n- It does not generate OpenAPI specs.\n- It does not generate client code.\n- It does not introduce a new framework or lifecycle.\n- It does not alter FastAPI dependency injection semantics.\n\nIntended usage\n--------------\nThis module is intended for teams that want:\n\n- OpenAPI-first API development\n- Strong contract enforcement\n- Minimal FastAPI boilerplate\n- Predictable, CI-friendly failures for spec/implementation drift",
"objects": {
"FastAPI": {
"name": "FastAPI",
"kind": "alias",
"path": "openapi_first.app.FastAPI",
"signature": "<bound method Alias.signature of Alias('FastAPI', 'fastapi.FastAPI')>",
"docstring": null
},
"load_openapi": {
"name": "load_openapi",
"kind": "function",
"path": "openapi_first.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."
},
"bind_routes": {
"name": "bind_routes",
"kind": "function",
"path": "openapi_first.app.bind_routes",
"signature": "<bound method Alias.signature of Alias('bind_routes', 'openapi_first.binder.bind_routes')>",
"docstring": "Bind OpenAPI operations to FastAPI routes.\n\nIterates through the OpenAPI specification paths and methods,\nresolves each operationId to a handler function, and registers\na corresponding APIRoute on the FastAPI application.\n\nParameters\n----------\napp : fastapi.FastAPI\n The FastAPI application instance to which routes will be added.\n\nspec : dict\n Parsed OpenAPI 3.x specification dictionary.\n\nroutes_module : module\n Python module containing handler functions. Each handler's\n name MUST exactly match an OpenAPI operationId.\n\nRaises\n------\nMissingOperationHandler\n If an operationId is missing from the spec or if no corresponding\n handler function exists in the routes module.\n\nBehavior guarantees\n-------------------\n- Route registration is deterministic and spec-driven.\n- No route decorators are required or supported.\n- Handler resolution errors surface at application startup."
},
"OpenAPIFirstApp": {
"name": "OpenAPIFirstApp",
"kind": "class",
"path": "openapi_first.app.OpenAPIFirstApp",
"signature": "<bound method Class.signature of Class('OpenAPIFirstApp', 49, 118)>",
"docstring": "FastAPI application enforcing OpenAPI-first design.\n\n`OpenAPIFirstApp` subclasses FastAPI and replaces manual route\nregistration with OpenAPI-driven binding. All routes are derived\nfrom the provided OpenAPI specification, and each operationId is\nmapped to a Python function in the supplied routes module.\n\nParameters\n----------\nopenapi_path : str\n Filesystem path to the OpenAPI 3.x specification file.\n This specification is treated as the authoritative API contract.\n\nroutes_module : module\n Python module containing handler functions whose names correspond\n exactly to OpenAPI operationId values.\n\n**fastapi_kwargs\n Additional keyword arguments passed directly to `fastapi.FastAPI`\n (e.g., title, version, middleware, lifespan handlers).\n\nRaises\n------\nOpenAPIFirstError\n If the OpenAPI specification is invalid, or if any declared\n operationId does not have a corresponding handler function.\n\nBehavior guarantees\n-------------------\n- No route can exist without an OpenAPI declaration.\n- No OpenAPI operation can exist without a handler.\n- Swagger UI and `/openapi.json` always reflect the provided spec.\n- Handler functions remain framework-agnostic and testable.\n\nExample\n-------\n>>> from openapi_first import OpenAPIFirstApp\n>>> import app.routes as routes\n>>>\n>>> app = OpenAPIFirstApp(\n... openapi_path=\"app/openapi.json\",\n... routes_module=routes,\n... title=\"Example Service\"\n... )",
"members": {
"openapi": {
"name": "openapi",
"kind": "attribute",
"path": "openapi_first.app.OpenAPIFirstApp.openapi",
"signature": null,
"docstring": null
}
}
},
"Any": {
"name": "Any",
"kind": "alias",
"path": "openapi_first.app.Any",
"signature": "<bound method Alias.signature of Alias('Any', 'typing.Any')>",
"docstring": null
}
}
}
}