Files
openapi-first/mcp_docs/modules/openapi_first.binder.json
2026-03-08 00:41:19 +05:30

51 lines
4.2 KiB
JSON

{
"module": "openapi_first.binder",
"content": {
"path": "openapi_first.binder",
"docstring": "OpenAPI-driven route binding for FastAPI.\n\n---\n\n## Summary\n\nThis module is responsible for translating an OpenAPI 3.x specification\ninto concrete FastAPI routes. It enforces a strict one-to-one mapping\nbetween OpenAPI operations and Python handler functions using operationId.\n\nNotes:\n **Core Responsibility:**\n\n - Read path + method definitions from an OpenAPI specification\n - Resolve each operationId to a Python callable\n - Register routes with FastAPI using APIRoute\n - Fail fast when contract violations are detected\n\n **Design Constraints:**\n\n - All routes MUST be declared in the OpenAPI specification\n - All OpenAPI operations MUST define an operationId\n - Every operationId MUST resolve to a handler function\n - Handlers are plain Python callables (no decorators required)\n - No implicit route creation or inference is allowed\n\n **Constraints:**\n\n - This module intentionally does NOT: Perform request or response validation, generate Pydantic models, modify FastAPI dependency injection, or interpret OpenAPI semantics beyond routing metadata.",
"objects": {
"APIRoute": {
"name": "APIRoute",
"kind": "alias",
"path": "openapi_first.binder.APIRoute",
"signature": "<bound method Alias.signature of Alias('APIRoute', 'fastapi.routing.APIRoute')>",
"docstring": null
},
"MissingOperationHandler": {
"name": "MissingOperationHandler",
"kind": "class",
"path": "openapi_first.binder.MissingOperationHandler",
"signature": "<bound method Alias.signature of Alias('MissingOperationHandler', 'openapi_first.errors.MissingOperationHandler')>",
"docstring": "Raised when an OpenAPI operation cannot be resolved to a handler.\n\nNotes:\n **Scenarios:**\n\n - An OpenAPI operation does not define an operationId\n - An operationId is defined but no matching function exists in the provided routes module\n\n **Guarantees:**\n\n - This represents a violation of the OpenAPI-first contract and indicates that the specification and implementation are out of sync"
},
"bind_routes": {
"name": "bind_routes",
"kind": "function",
"path": "openapi_first.binder.bind_routes",
"signature": "<bound method Function.signature of Function('bind_routes', 38, 93)>",
"docstring": "Bind OpenAPI operations to FastAPI routes.\n\nArgs:\n app (fastapi.FastAPI):\n The FastAPI application instance to which routes will be added.\n spec (dict):\n Parsed OpenAPI 3.x specification dictionary.\n routes_module (module):\n Python module containing handler functions. Each handler's name MUST exactly match an OpenAPI operationId.\n\nRaises:\n MissingOperationHandler:\n If an operationId is missing from the spec or if no corresponding handler function exists in the routes module.\n\nNotes:\n **Responsibilities:**\n\n - Iterates through the OpenAPI specification paths and methods\n - Resolves each operationId to a handler function, and registers a corresponding APIRoute on the FastAPI application\n\n **Guarantees:**\n\n - Route registration is deterministic and spec-driven. No route decorators are required or supported. Handler resolution errors surface at application startup."
},
"Any": {
"name": "Any",
"kind": "alias",
"path": "openapi_first.binder.Any",
"signature": "<bound method Alias.signature of Alias('Any', 'typing.Any')>",
"docstring": null
},
"Dict": {
"name": "Dict",
"kind": "alias",
"path": "openapi_first.binder.Dict",
"signature": "<bound method Alias.signature of Alias('Dict', 'typing.Dict')>",
"docstring": null
},
"FastAPI": {
"name": "FastAPI",
"kind": "alias",
"path": "openapi_first.binder.FastAPI",
"signature": "<bound method Alias.signature of Alias('FastAPI', 'fastapi.FastAPI')>",
"docstring": null
}
}
}
}