fixing examples and adding doc strings
This commit is contained in:
@@ -29,8 +29,8 @@
|
||||
"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... )",
|
||||
"signature": "<bound method Class.signature of Class('OpenAPIFirstApp', 49, 120)>",
|
||||
"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```python\nfrom openapi_first import OpenAPIFirstApp\nimport app.routes as routes\n\napp = OpenAPIFirstApp(\n openapi_path=\"app/openapi.json\",\n routes_module=routes,\n title=\"Example Service\",\n)\n```",
|
||||
"members": {
|
||||
"openapi": {
|
||||
"name": "openapi",
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
"module": "openapi_first.client",
|
||||
"content": {
|
||||
"path": "openapi_first.client",
|
||||
"docstring": null,
|
||||
"docstring": "openapi_first.client\n====================\n\nOpenAPI-first HTTP client for contract-driven services.\n\nThis module provides `OpenAPIClient`, a thin, strict HTTP client that\nderives all callable operations directly from an OpenAPI 3.x specification.\n\nIt is the client counterpart to `OpenAPIFirstApp`.\n\nCore principles\n---------------\n- The OpenAPI specification is the single source of truth.\n- Each operationId becomes a callable Python method.\n- No implicit schema mutation or inference.\n- No code generation step.\n- Minimal abstraction over httpx.\n\nWhat this module does\n---------------------\n- Parses an OpenAPI 3.x specification.\n- Dynamically creates one callable per operationId.\n- Enforces presence of:\n - servers\n - paths\n - operationId\n- Formats path parameters safely.\n- Handles JSON request bodies explicitly.\n- Returns raw `httpx.Response` objects.\n\nWhat this module does NOT do\n----------------------------\n- It does not generate client code.\n- It does not validate request/response schemas.\n- It does not deserialize responses.\n- It does not retry requests.\n- It does not implement authentication helpers.\n- It does not assume non-2xx responses are failures.\n\nIntended usage\n--------------\nThis client is designed for:\n\n- Service-to-service communication\n- Integration testing\n- Contract-driven internal SDK usage\n- Systems that want OpenAPI-first symmetry with `OpenAPIFirstApp`\n\nDesign constraints\n------------------\n- Only the first server in the OpenAPI `servers` list is used if\n `base_url` is not explicitly provided.\n- Only explicitly declared request bodies are allowed.\n- `application/json` is handled natively; other media types are sent as raw content.\n- All responses are returned as-is.",
|
||||
"objects": {
|
||||
"Any": {
|
||||
"name": "Any",
|
||||
@@ -57,15 +57,15 @@
|
||||
"name": "OpenAPIClientError",
|
||||
"kind": "class",
|
||||
"path": "openapi_first.client.OpenAPIClientError",
|
||||
"signature": "<bound method Class.signature of Class('OpenAPIClientError', 9, 10)>",
|
||||
"signature": "<bound method Class.signature of Class('OpenAPIClientError', 67, 68)>",
|
||||
"docstring": "Raised when an OpenAPI client operation fails."
|
||||
},
|
||||
"OpenAPIClient": {
|
||||
"name": "OpenAPIClient",
|
||||
"kind": "class",
|
||||
"path": "openapi_first.client.OpenAPIClient",
|
||||
"signature": "<bound method Class.signature of Class('OpenAPIClient', 13, 176)>",
|
||||
"docstring": "OpenAPI-first HTTP client (httpx-based).\n\n- One callable per operationId\n- Explicit parameters (path, query, headers, body)\n- No implicit schema inference or mutation",
|
||||
"signature": "<bound method Class.signature of Class('OpenAPIClient', 71, 291)>",
|
||||
"docstring": "OpenAPI-first HTTP client (httpx-based).\n\nThis client derives all callable methods directly from an OpenAPI 3.x\nspecification. Each operationId becomes a method on the client\ninstance.\n\nDesign principles\n-----------------\n- One callable per operationId\n- Explicit parameters (path, query, headers, body)\n- No implicit schema inference or mutation\n- Returns raw httpx.Response objects\n- No response validation or deserialization\n\nParameters\n----------\nspec : dict\n Parsed OpenAPI 3.x specification.\nbase_url : str | None\n Base URL of the target service. If omitted, the first entry\n in the OpenAPI `servers` list is used.\nclient : httpx.Client | None\n Optional preconfigured httpx client instance.\n\nRaises\n------\nOpenAPIClientError\n If:\n - No servers are defined and base_url is not provided\n - OpenAPI spec has no paths\n - An operation is missing operationId\n - Duplicate operationIds are detected\n - Required path parameters are missing\n - Required request body is missing\n\n Example\n-------\n```python\nfrom openapi_first import loader, client\n\nspec = loader.load_openapi(\"openapi.yaml\")\n\napi = client.OpenAPIClient(\n spec=spec,\n base_url=\"http://localhost:8000\",\n)\n\n# Call operationId: getUser\nresponse = api.getUser(\n path_params={\"user_id\": 123}\n)\n\nprint(response.status_code)\nprint(response.json())\n\n# Call operationId: createUser\nresponse = api.createUser(\n body={\"name\": \"Bob\"}\n)\n\nprint(response.status_code)\n```",
|
||||
"members": {
|
||||
"spec": {
|
||||
"name": "spec",
|
||||
@@ -92,7 +92,7 @@
|
||||
"name": "operations",
|
||||
"kind": "function",
|
||||
"path": "openapi_first.client.OpenAPIClient.operations",
|
||||
"signature": "<bound method Function.signature of Function('operations', 45, 46)>",
|
||||
"signature": "<bound method Function.signature of Function('operations', 160, 161)>",
|
||||
"docstring": null
|
||||
}
|
||||
}
|
||||
|
||||
@@ -36,8 +36,8 @@
|
||||
"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... )",
|
||||
"signature": "<bound method Class.signature of Class('OpenAPIFirstApp', 49, 120)>",
|
||||
"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```python\nfrom openapi_first import OpenAPIFirstApp\nimport app.routes as routes\n\napp = OpenAPIFirstApp(\n openapi_path=\"app/openapi.json\",\n routes_module=routes,\n title=\"Example Service\",\n)\n```",
|
||||
"members": {
|
||||
"openapi": {
|
||||
"name": "openapi",
|
||||
@@ -178,7 +178,7 @@
|
||||
"kind": "module",
|
||||
"path": "openapi_first.client",
|
||||
"signature": null,
|
||||
"docstring": null,
|
||||
"docstring": "openapi_first.client\n====================\n\nOpenAPI-first HTTP client for contract-driven services.\n\nThis module provides `OpenAPIClient`, a thin, strict HTTP client that\nderives all callable operations directly from an OpenAPI 3.x specification.\n\nIt is the client counterpart to `OpenAPIFirstApp`.\n\nCore principles\n---------------\n- The OpenAPI specification is the single source of truth.\n- Each operationId becomes a callable Python method.\n- No implicit schema mutation or inference.\n- No code generation step.\n- Minimal abstraction over httpx.\n\nWhat this module does\n---------------------\n- Parses an OpenAPI 3.x specification.\n- Dynamically creates one callable per operationId.\n- Enforces presence of:\n - servers\n - paths\n - operationId\n- Formats path parameters safely.\n- Handles JSON request bodies explicitly.\n- Returns raw `httpx.Response` objects.\n\nWhat this module does NOT do\n----------------------------\n- It does not generate client code.\n- It does not validate request/response schemas.\n- It does not deserialize responses.\n- It does not retry requests.\n- It does not implement authentication helpers.\n- It does not assume non-2xx responses are failures.\n\nIntended usage\n--------------\nThis client is designed for:\n\n- Service-to-service communication\n- Integration testing\n- Contract-driven internal SDK usage\n- Systems that want OpenAPI-first symmetry with `OpenAPIFirstApp`\n\nDesign constraints\n------------------\n- Only the first server in the OpenAPI `servers` list is used if\n `base_url` is not explicitly provided.\n- Only explicitly declared request bodies are allowed.\n- `application/json` is handled natively; other media types are sent as raw content.\n- All responses are returned as-is.",
|
||||
"members": {
|
||||
"Any": {
|
||||
"name": "Any",
|
||||
@@ -233,15 +233,15 @@
|
||||
"name": "OpenAPIClientError",
|
||||
"kind": "class",
|
||||
"path": "openapi_first.client.OpenAPIClientError",
|
||||
"signature": "<bound method Class.signature of Class('OpenAPIClientError', 9, 10)>",
|
||||
"signature": "<bound method Class.signature of Class('OpenAPIClientError', 67, 68)>",
|
||||
"docstring": "Raised when an OpenAPI client operation fails."
|
||||
},
|
||||
"OpenAPIClient": {
|
||||
"name": "OpenAPIClient",
|
||||
"kind": "class",
|
||||
"path": "openapi_first.client.OpenAPIClient",
|
||||
"signature": "<bound method Class.signature of Class('OpenAPIClient', 13, 176)>",
|
||||
"docstring": "OpenAPI-first HTTP client (httpx-based).\n\n- One callable per operationId\n- Explicit parameters (path, query, headers, body)\n- No implicit schema inference or mutation",
|
||||
"signature": "<bound method Class.signature of Class('OpenAPIClient', 71, 291)>",
|
||||
"docstring": "OpenAPI-first HTTP client (httpx-based).\n\nThis client derives all callable methods directly from an OpenAPI 3.x\nspecification. Each operationId becomes a method on the client\ninstance.\n\nDesign principles\n-----------------\n- One callable per operationId\n- Explicit parameters (path, query, headers, body)\n- No implicit schema inference or mutation\n- Returns raw httpx.Response objects\n- No response validation or deserialization\n\nParameters\n----------\nspec : dict\n Parsed OpenAPI 3.x specification.\nbase_url : str | None\n Base URL of the target service. If omitted, the first entry\n in the OpenAPI `servers` list is used.\nclient : httpx.Client | None\n Optional preconfigured httpx client instance.\n\nRaises\n------\nOpenAPIClientError\n If:\n - No servers are defined and base_url is not provided\n - OpenAPI spec has no paths\n - An operation is missing operationId\n - Duplicate operationIds are detected\n - Required path parameters are missing\n - Required request body is missing\n\n Example\n-------\n```python\nfrom openapi_first import loader, client\n\nspec = loader.load_openapi(\"openapi.yaml\")\n\napi = client.OpenAPIClient(\n spec=spec,\n base_url=\"http://localhost:8000\",\n)\n\n# Call operationId: getUser\nresponse = api.getUser(\n path_params={\"user_id\": 123}\n)\n\nprint(response.status_code)\nprint(response.json())\n\n# Call operationId: createUser\nresponse = api.createUser(\n body={\"name\": \"Bob\"}\n)\n\nprint(response.status_code)\n```",
|
||||
"members": {
|
||||
"spec": {
|
||||
"name": "spec",
|
||||
@@ -268,7 +268,7 @@
|
||||
"name": "operations",
|
||||
"kind": "function",
|
||||
"path": "openapi_first.client.OpenAPIClient.operations",
|
||||
"signature": "<bound method Function.signature of Function('operations', 45, 46)>",
|
||||
"signature": "<bound method Function.signature of Function('operations', 160, 161)>",
|
||||
"docstring": null
|
||||
}
|
||||
}
|
||||
@@ -461,7 +461,7 @@
|
||||
"kind": "class",
|
||||
"path": "openapi_first.templates.crud_app.main.OpenAPIFirstApp",
|
||||
"signature": "<bound method Alias.signature of Alias('OpenAPIFirstApp', 'openapi_first.app.OpenAPIFirstApp')>",
|
||||
"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... )",
|
||||
"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```python\nfrom openapi_first import OpenAPIFirstApp\nimport app.routes as routes\n\napp = OpenAPIFirstApp(\n openapi_path=\"app/openapi.json\",\n routes_module=routes,\n title=\"Example Service\",\n)\n```",
|
||||
"members": {
|
||||
"openapi": {
|
||||
"name": "openapi",
|
||||
@@ -579,7 +579,7 @@
|
||||
"kind": "class",
|
||||
"path": "openapi_first.templates.crud_app.test_crud_app.OpenAPIClient",
|
||||
"signature": "<bound method Alias.signature of Alias('OpenAPIClient', 'openapi_first.client.OpenAPIClient')>",
|
||||
"docstring": "OpenAPI-first HTTP client (httpx-based).\n\n- One callable per operationId\n- Explicit parameters (path, query, headers, body)\n- No implicit schema inference or mutation",
|
||||
"docstring": "OpenAPI-first HTTP client (httpx-based).\n\nThis client derives all callable methods directly from an OpenAPI 3.x\nspecification. Each operationId becomes a method on the client\ninstance.\n\nDesign principles\n-----------------\n- One callable per operationId\n- Explicit parameters (path, query, headers, body)\n- No implicit schema inference or mutation\n- Returns raw httpx.Response objects\n- No response validation or deserialization\n\nParameters\n----------\nspec : dict\n Parsed OpenAPI 3.x specification.\nbase_url : str | None\n Base URL of the target service. If omitted, the first entry\n in the OpenAPI `servers` list is used.\nclient : httpx.Client | None\n Optional preconfigured httpx client instance.\n\nRaises\n------\nOpenAPIClientError\n If:\n - No servers are defined and base_url is not provided\n - OpenAPI spec has no paths\n - An operation is missing operationId\n - Duplicate operationIds are detected\n - Required path parameters are missing\n - Required request body is missing\n\n Example\n-------\n```python\nfrom openapi_first import loader, client\n\nspec = loader.load_openapi(\"openapi.yaml\")\n\napi = client.OpenAPIClient(\n spec=spec,\n base_url=\"http://localhost:8000\",\n)\n\n# Call operationId: getUser\nresponse = api.getUser(\n path_params={\"user_id\": 123}\n)\n\nprint(response.status_code)\nprint(response.json())\n\n# Call operationId: createUser\nresponse = api.createUser(\n body={\"name\": \"Bob\"}\n)\n\nprint(response.status_code)\n```",
|
||||
"members": {
|
||||
"spec": {
|
||||
"name": "spec",
|
||||
@@ -683,7 +683,7 @@
|
||||
"kind": "class",
|
||||
"path": "openapi_first.templates.health_app.main.OpenAPIFirstApp",
|
||||
"signature": "<bound method Alias.signature of Alias('OpenAPIFirstApp', 'openapi_first.app.OpenAPIFirstApp')>",
|
||||
"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... )",
|
||||
"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```python\nfrom openapi_first import OpenAPIFirstApp\nimport app.routes as routes\n\napp = OpenAPIFirstApp(\n openapi_path=\"app/openapi.json\",\n routes_module=routes,\n title=\"Example Service\",\n)\n```",
|
||||
"members": {
|
||||
"openapi": {
|
||||
"name": "openapi",
|
||||
@@ -812,7 +812,7 @@
|
||||
"kind": "class",
|
||||
"path": "openapi_first.templates.model_app.main.OpenAPIFirstApp",
|
||||
"signature": "<bound method Alias.signature of Alias('OpenAPIFirstApp', 'openapi_first.app.OpenAPIFirstApp')>",
|
||||
"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... )",
|
||||
"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```python\nfrom openapi_first import OpenAPIFirstApp\nimport app.routes as routes\n\napp = OpenAPIFirstApp(\n openapi_path=\"app/openapi.json\",\n routes_module=routes,\n title=\"Example Service\",\n)\n```",
|
||||
"members": {
|
||||
"openapi": {
|
||||
"name": "openapi",
|
||||
@@ -999,7 +999,7 @@
|
||||
"kind": "class",
|
||||
"path": "openapi_first.templates.model_app.test_model_app.OpenAPIClient",
|
||||
"signature": "<bound method Alias.signature of Alias('OpenAPIClient', 'openapi_first.client.OpenAPIClient')>",
|
||||
"docstring": "OpenAPI-first HTTP client (httpx-based).\n\n- One callable per operationId\n- Explicit parameters (path, query, headers, body)\n- No implicit schema inference or mutation",
|
||||
"docstring": "OpenAPI-first HTTP client (httpx-based).\n\nThis client derives all callable methods directly from an OpenAPI 3.x\nspecification. Each operationId becomes a method on the client\ninstance.\n\nDesign principles\n-----------------\n- One callable per operationId\n- Explicit parameters (path, query, headers, body)\n- No implicit schema inference or mutation\n- Returns raw httpx.Response objects\n- No response validation or deserialization\n\nParameters\n----------\nspec : dict\n Parsed OpenAPI 3.x specification.\nbase_url : str | None\n Base URL of the target service. If omitted, the first entry\n in the OpenAPI `servers` list is used.\nclient : httpx.Client | None\n Optional preconfigured httpx client instance.\n\nRaises\n------\nOpenAPIClientError\n If:\n - No servers are defined and base_url is not provided\n - OpenAPI spec has no paths\n - An operation is missing operationId\n - Duplicate operationIds are detected\n - Required path parameters are missing\n - Required request body is missing\n\n Example\n-------\n```python\nfrom openapi_first import loader, client\n\nspec = loader.load_openapi(\"openapi.yaml\")\n\napi = client.OpenAPIClient(\n spec=spec,\n base_url=\"http://localhost:8000\",\n)\n\n# Call operationId: getUser\nresponse = api.getUser(\n path_params={\"user_id\": 123}\n)\n\nprint(response.status_code)\nprint(response.json())\n\n# Call operationId: createUser\nresponse = api.createUser(\n body={\"name\": \"Bob\"}\n)\n\nprint(response.status_code)\n```",
|
||||
"members": {
|
||||
"spec": {
|
||||
"name": "spec",
|
||||
|
||||
@@ -67,7 +67,7 @@
|
||||
"kind": "class",
|
||||
"path": "openapi_first.templates.crud_app.main.OpenAPIFirstApp",
|
||||
"signature": "<bound method Alias.signature of Alias('OpenAPIFirstApp', 'openapi_first.app.OpenAPIFirstApp')>",
|
||||
"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... )",
|
||||
"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```python\nfrom openapi_first import OpenAPIFirstApp\nimport app.routes as routes\n\napp = OpenAPIFirstApp(\n openapi_path=\"app/openapi.json\",\n routes_module=routes,\n title=\"Example Service\",\n)\n```",
|
||||
"members": {
|
||||
"openapi": {
|
||||
"name": "openapi",
|
||||
@@ -185,7 +185,7 @@
|
||||
"kind": "class",
|
||||
"path": "openapi_first.templates.crud_app.test_crud_app.OpenAPIClient",
|
||||
"signature": "<bound method Alias.signature of Alias('OpenAPIClient', 'openapi_first.client.OpenAPIClient')>",
|
||||
"docstring": "OpenAPI-first HTTP client (httpx-based).\n\n- One callable per operationId\n- Explicit parameters (path, query, headers, body)\n- No implicit schema inference or mutation",
|
||||
"docstring": "OpenAPI-first HTTP client (httpx-based).\n\nThis client derives all callable methods directly from an OpenAPI 3.x\nspecification. Each operationId becomes a method on the client\ninstance.\n\nDesign principles\n-----------------\n- One callable per operationId\n- Explicit parameters (path, query, headers, body)\n- No implicit schema inference or mutation\n- Returns raw httpx.Response objects\n- No response validation or deserialization\n\nParameters\n----------\nspec : dict\n Parsed OpenAPI 3.x specification.\nbase_url : str | None\n Base URL of the target service. If omitted, the first entry\n in the OpenAPI `servers` list is used.\nclient : httpx.Client | None\n Optional preconfigured httpx client instance.\n\nRaises\n------\nOpenAPIClientError\n If:\n - No servers are defined and base_url is not provided\n - OpenAPI spec has no paths\n - An operation is missing operationId\n - Duplicate operationIds are detected\n - Required path parameters are missing\n - Required request body is missing\n\n Example\n-------\n```python\nfrom openapi_first import loader, client\n\nspec = loader.load_openapi(\"openapi.yaml\")\n\napi = client.OpenAPIClient(\n spec=spec,\n base_url=\"http://localhost:8000\",\n)\n\n# Call operationId: getUser\nresponse = api.getUser(\n path_params={\"user_id\": 123}\n)\n\nprint(response.status_code)\nprint(response.json())\n\n# Call operationId: createUser\nresponse = api.createUser(\n body={\"name\": \"Bob\"}\n)\n\nprint(response.status_code)\n```",
|
||||
"members": {
|
||||
"spec": {
|
||||
"name": "spec",
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
"kind": "class",
|
||||
"path": "openapi_first.templates.crud_app.main.OpenAPIFirstApp",
|
||||
"signature": "<bound method Alias.signature of Alias('OpenAPIFirstApp', 'openapi_first.app.OpenAPIFirstApp')>",
|
||||
"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... )",
|
||||
"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```python\nfrom openapi_first import OpenAPIFirstApp\nimport app.routes as routes\n\napp = OpenAPIFirstApp(\n openapi_path=\"app/openapi.json\",\n routes_module=routes,\n title=\"Example Service\",\n)\n```",
|
||||
"members": {
|
||||
"openapi": {
|
||||
"name": "openapi",
|
||||
|
||||
@@ -30,7 +30,7 @@
|
||||
"kind": "class",
|
||||
"path": "openapi_first.templates.crud_app.test_crud_app.OpenAPIClient",
|
||||
"signature": "<bound method Alias.signature of Alias('OpenAPIClient', 'openapi_first.client.OpenAPIClient')>",
|
||||
"docstring": "OpenAPI-first HTTP client (httpx-based).\n\n- One callable per operationId\n- Explicit parameters (path, query, headers, body)\n- No implicit schema inference or mutation",
|
||||
"docstring": "OpenAPI-first HTTP client (httpx-based).\n\nThis client derives all callable methods directly from an OpenAPI 3.x\nspecification. Each operationId becomes a method on the client\ninstance.\n\nDesign principles\n-----------------\n- One callable per operationId\n- Explicit parameters (path, query, headers, body)\n- No implicit schema inference or mutation\n- Returns raw httpx.Response objects\n- No response validation or deserialization\n\nParameters\n----------\nspec : dict\n Parsed OpenAPI 3.x specification.\nbase_url : str | None\n Base URL of the target service. If omitted, the first entry\n in the OpenAPI `servers` list is used.\nclient : httpx.Client | None\n Optional preconfigured httpx client instance.\n\nRaises\n------\nOpenAPIClientError\n If:\n - No servers are defined and base_url is not provided\n - OpenAPI spec has no paths\n - An operation is missing operationId\n - Duplicate operationIds are detected\n - Required path parameters are missing\n - Required request body is missing\n\n Example\n-------\n```python\nfrom openapi_first import loader, client\n\nspec = loader.load_openapi(\"openapi.yaml\")\n\napi = client.OpenAPIClient(\n spec=spec,\n base_url=\"http://localhost:8000\",\n)\n\n# Call operationId: getUser\nresponse = api.getUser(\n path_params={\"user_id\": 123}\n)\n\nprint(response.status_code)\nprint(response.json())\n\n# Call operationId: createUser\nresponse = api.createUser(\n body={\"name\": \"Bob\"}\n)\n\nprint(response.status_code)\n```",
|
||||
"members": {
|
||||
"spec": {
|
||||
"name": "spec",
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
"kind": "class",
|
||||
"path": "openapi_first.templates.health_app.main.OpenAPIFirstApp",
|
||||
"signature": "<bound method Alias.signature of Alias('OpenAPIFirstApp', 'openapi_first.app.OpenAPIFirstApp')>",
|
||||
"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... )",
|
||||
"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```python\nfrom openapi_first import OpenAPIFirstApp\nimport app.routes as routes\n\napp = OpenAPIFirstApp(\n openapi_path=\"app/openapi.json\",\n routes_module=routes,\n title=\"Example Service\",\n)\n```",
|
||||
"members": {
|
||||
"openapi": {
|
||||
"name": "openapi",
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
"kind": "class",
|
||||
"path": "openapi_first.templates.health_app.main.OpenAPIFirstApp",
|
||||
"signature": "<bound method Alias.signature of Alias('OpenAPIFirstApp', 'openapi_first.app.OpenAPIFirstApp')>",
|
||||
"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... )",
|
||||
"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```python\nfrom openapi_first import OpenAPIFirstApp\nimport app.routes as routes\n\napp = OpenAPIFirstApp(\n openapi_path=\"app/openapi.json\",\n routes_module=routes,\n title=\"Example Service\",\n)\n```",
|
||||
"members": {
|
||||
"openapi": {
|
||||
"name": "openapi",
|
||||
|
||||
@@ -74,7 +74,7 @@
|
||||
"kind": "class",
|
||||
"path": "openapi_first.templates.crud_app.main.OpenAPIFirstApp",
|
||||
"signature": "<bound method Alias.signature of Alias('OpenAPIFirstApp', 'openapi_first.app.OpenAPIFirstApp')>",
|
||||
"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... )",
|
||||
"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```python\nfrom openapi_first import OpenAPIFirstApp\nimport app.routes as routes\n\napp = OpenAPIFirstApp(\n openapi_path=\"app/openapi.json\",\n routes_module=routes,\n title=\"Example Service\",\n)\n```",
|
||||
"members": {
|
||||
"openapi": {
|
||||
"name": "openapi",
|
||||
@@ -192,7 +192,7 @@
|
||||
"kind": "class",
|
||||
"path": "openapi_first.templates.crud_app.test_crud_app.OpenAPIClient",
|
||||
"signature": "<bound method Alias.signature of Alias('OpenAPIClient', 'openapi_first.client.OpenAPIClient')>",
|
||||
"docstring": "OpenAPI-first HTTP client (httpx-based).\n\n- One callable per operationId\n- Explicit parameters (path, query, headers, body)\n- No implicit schema inference or mutation",
|
||||
"docstring": "OpenAPI-first HTTP client (httpx-based).\n\nThis client derives all callable methods directly from an OpenAPI 3.x\nspecification. Each operationId becomes a method on the client\ninstance.\n\nDesign principles\n-----------------\n- One callable per operationId\n- Explicit parameters (path, query, headers, body)\n- No implicit schema inference or mutation\n- Returns raw httpx.Response objects\n- No response validation or deserialization\n\nParameters\n----------\nspec : dict\n Parsed OpenAPI 3.x specification.\nbase_url : str | None\n Base URL of the target service. If omitted, the first entry\n in the OpenAPI `servers` list is used.\nclient : httpx.Client | None\n Optional preconfigured httpx client instance.\n\nRaises\n------\nOpenAPIClientError\n If:\n - No servers are defined and base_url is not provided\n - OpenAPI spec has no paths\n - An operation is missing operationId\n - Duplicate operationIds are detected\n - Required path parameters are missing\n - Required request body is missing\n\n Example\n-------\n```python\nfrom openapi_first import loader, client\n\nspec = loader.load_openapi(\"openapi.yaml\")\n\napi = client.OpenAPIClient(\n spec=spec,\n base_url=\"http://localhost:8000\",\n)\n\n# Call operationId: getUser\nresponse = api.getUser(\n path_params={\"user_id\": 123}\n)\n\nprint(response.status_code)\nprint(response.json())\n\n# Call operationId: createUser\nresponse = api.createUser(\n body={\"name\": \"Bob\"}\n)\n\nprint(response.status_code)\n```",
|
||||
"members": {
|
||||
"spec": {
|
||||
"name": "spec",
|
||||
@@ -296,7 +296,7 @@
|
||||
"kind": "class",
|
||||
"path": "openapi_first.templates.health_app.main.OpenAPIFirstApp",
|
||||
"signature": "<bound method Alias.signature of Alias('OpenAPIFirstApp', 'openapi_first.app.OpenAPIFirstApp')>",
|
||||
"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... )",
|
||||
"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```python\nfrom openapi_first import OpenAPIFirstApp\nimport app.routes as routes\n\napp = OpenAPIFirstApp(\n openapi_path=\"app/openapi.json\",\n routes_module=routes,\n title=\"Example Service\",\n)\n```",
|
||||
"members": {
|
||||
"openapi": {
|
||||
"name": "openapi",
|
||||
@@ -425,7 +425,7 @@
|
||||
"kind": "class",
|
||||
"path": "openapi_first.templates.model_app.main.OpenAPIFirstApp",
|
||||
"signature": "<bound method Alias.signature of Alias('OpenAPIFirstApp', 'openapi_first.app.OpenAPIFirstApp')>",
|
||||
"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... )",
|
||||
"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```python\nfrom openapi_first import OpenAPIFirstApp\nimport app.routes as routes\n\napp = OpenAPIFirstApp(\n openapi_path=\"app/openapi.json\",\n routes_module=routes,\n title=\"Example Service\",\n)\n```",
|
||||
"members": {
|
||||
"openapi": {
|
||||
"name": "openapi",
|
||||
@@ -612,7 +612,7 @@
|
||||
"kind": "class",
|
||||
"path": "openapi_first.templates.model_app.test_model_app.OpenAPIClient",
|
||||
"signature": "<bound method Alias.signature of Alias('OpenAPIClient', 'openapi_first.client.OpenAPIClient')>",
|
||||
"docstring": "OpenAPI-first HTTP client (httpx-based).\n\n- One callable per operationId\n- Explicit parameters (path, query, headers, body)\n- No implicit schema inference or mutation",
|
||||
"docstring": "OpenAPI-first HTTP client (httpx-based).\n\nThis client derives all callable methods directly from an OpenAPI 3.x\nspecification. Each operationId becomes a method on the client\ninstance.\n\nDesign principles\n-----------------\n- One callable per operationId\n- Explicit parameters (path, query, headers, body)\n- No implicit schema inference or mutation\n- Returns raw httpx.Response objects\n- No response validation or deserialization\n\nParameters\n----------\nspec : dict\n Parsed OpenAPI 3.x specification.\nbase_url : str | None\n Base URL of the target service. If omitted, the first entry\n in the OpenAPI `servers` list is used.\nclient : httpx.Client | None\n Optional preconfigured httpx client instance.\n\nRaises\n------\nOpenAPIClientError\n If:\n - No servers are defined and base_url is not provided\n - OpenAPI spec has no paths\n - An operation is missing operationId\n - Duplicate operationIds are detected\n - Required path parameters are missing\n - Required request body is missing\n\n Example\n-------\n```python\nfrom openapi_first import loader, client\n\nspec = loader.load_openapi(\"openapi.yaml\")\n\napi = client.OpenAPIClient(\n spec=spec,\n base_url=\"http://localhost:8000\",\n)\n\n# Call operationId: getUser\nresponse = api.getUser(\n path_params={\"user_id\": 123}\n)\n\nprint(response.status_code)\nprint(response.json())\n\n# Call operationId: createUser\nresponse = api.createUser(\n body={\"name\": \"Bob\"}\n)\n\nprint(response.status_code)\n```",
|
||||
"members": {
|
||||
"spec": {
|
||||
"name": "spec",
|
||||
|
||||
@@ -81,7 +81,7 @@
|
||||
"kind": "class",
|
||||
"path": "openapi_first.templates.model_app.main.OpenAPIFirstApp",
|
||||
"signature": "<bound method Alias.signature of Alias('OpenAPIFirstApp', 'openapi_first.app.OpenAPIFirstApp')>",
|
||||
"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... )",
|
||||
"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```python\nfrom openapi_first import OpenAPIFirstApp\nimport app.routes as routes\n\napp = OpenAPIFirstApp(\n openapi_path=\"app/openapi.json\",\n routes_module=routes,\n title=\"Example Service\",\n)\n```",
|
||||
"members": {
|
||||
"openapi": {
|
||||
"name": "openapi",
|
||||
@@ -268,7 +268,7 @@
|
||||
"kind": "class",
|
||||
"path": "openapi_first.templates.model_app.test_model_app.OpenAPIClient",
|
||||
"signature": "<bound method Alias.signature of Alias('OpenAPIClient', 'openapi_first.client.OpenAPIClient')>",
|
||||
"docstring": "OpenAPI-first HTTP client (httpx-based).\n\n- One callable per operationId\n- Explicit parameters (path, query, headers, body)\n- No implicit schema inference or mutation",
|
||||
"docstring": "OpenAPI-first HTTP client (httpx-based).\n\nThis client derives all callable methods directly from an OpenAPI 3.x\nspecification. Each operationId becomes a method on the client\ninstance.\n\nDesign principles\n-----------------\n- One callable per operationId\n- Explicit parameters (path, query, headers, body)\n- No implicit schema inference or mutation\n- Returns raw httpx.Response objects\n- No response validation or deserialization\n\nParameters\n----------\nspec : dict\n Parsed OpenAPI 3.x specification.\nbase_url : str | None\n Base URL of the target service. If omitted, the first entry\n in the OpenAPI `servers` list is used.\nclient : httpx.Client | None\n Optional preconfigured httpx client instance.\n\nRaises\n------\nOpenAPIClientError\n If:\n - No servers are defined and base_url is not provided\n - OpenAPI spec has no paths\n - An operation is missing operationId\n - Duplicate operationIds are detected\n - Required path parameters are missing\n - Required request body is missing\n\n Example\n-------\n```python\nfrom openapi_first import loader, client\n\nspec = loader.load_openapi(\"openapi.yaml\")\n\napi = client.OpenAPIClient(\n spec=spec,\n base_url=\"http://localhost:8000\",\n)\n\n# Call operationId: getUser\nresponse = api.getUser(\n path_params={\"user_id\": 123}\n)\n\nprint(response.status_code)\nprint(response.json())\n\n# Call operationId: createUser\nresponse = api.createUser(\n body={\"name\": \"Bob\"}\n)\n\nprint(response.status_code)\n```",
|
||||
"members": {
|
||||
"spec": {
|
||||
"name": "spec",
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
"kind": "class",
|
||||
"path": "openapi_first.templates.model_app.main.OpenAPIFirstApp",
|
||||
"signature": "<bound method Alias.signature of Alias('OpenAPIFirstApp', 'openapi_first.app.OpenAPIFirstApp')>",
|
||||
"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... )",
|
||||
"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```python\nfrom openapi_first import OpenAPIFirstApp\nimport app.routes as routes\n\napp = OpenAPIFirstApp(\n openapi_path=\"app/openapi.json\",\n routes_module=routes,\n title=\"Example Service\",\n)\n```",
|
||||
"members": {
|
||||
"openapi": {
|
||||
"name": "openapi",
|
||||
|
||||
@@ -30,7 +30,7 @@
|
||||
"kind": "class",
|
||||
"path": "openapi_first.templates.model_app.test_model_app.OpenAPIClient",
|
||||
"signature": "<bound method Alias.signature of Alias('OpenAPIClient', 'openapi_first.client.OpenAPIClient')>",
|
||||
"docstring": "OpenAPI-first HTTP client (httpx-based).\n\n- One callable per operationId\n- Explicit parameters (path, query, headers, body)\n- No implicit schema inference or mutation",
|
||||
"docstring": "OpenAPI-first HTTP client (httpx-based).\n\nThis client derives all callable methods directly from an OpenAPI 3.x\nspecification. Each operationId becomes a method on the client\ninstance.\n\nDesign principles\n-----------------\n- One callable per operationId\n- Explicit parameters (path, query, headers, body)\n- No implicit schema inference or mutation\n- Returns raw httpx.Response objects\n- No response validation or deserialization\n\nParameters\n----------\nspec : dict\n Parsed OpenAPI 3.x specification.\nbase_url : str | None\n Base URL of the target service. If omitted, the first entry\n in the OpenAPI `servers` list is used.\nclient : httpx.Client | None\n Optional preconfigured httpx client instance.\n\nRaises\n------\nOpenAPIClientError\n If:\n - No servers are defined and base_url is not provided\n - OpenAPI spec has no paths\n - An operation is missing operationId\n - Duplicate operationIds are detected\n - Required path parameters are missing\n - Required request body is missing\n\n Example\n-------\n```python\nfrom openapi_first import loader, client\n\nspec = loader.load_openapi(\"openapi.yaml\")\n\napi = client.OpenAPIClient(\n spec=spec,\n base_url=\"http://localhost:8000\",\n)\n\n# Call operationId: getUser\nresponse = api.getUser(\n path_params={\"user_id\": 123}\n)\n\nprint(response.status_code)\nprint(response.json())\n\n# Call operationId: createUser\nresponse = api.createUser(\n body={\"name\": \"Bob\"}\n)\n\nprint(response.status_code)\n```",
|
||||
"members": {
|
||||
"spec": {
|
||||
"name": "spec",
|
||||
|
||||
@@ -84,14 +84,16 @@ class OpenAPIFirstApp(FastAPI):
|
||||
|
||||
Example
|
||||
-------
|
||||
>>> from openapi_first import OpenAPIFirstApp
|
||||
>>> import app.routes as routes
|
||||
>>>
|
||||
>>> app = OpenAPIFirstApp(
|
||||
... openapi_path="app/openapi.json",
|
||||
... routes_module=routes,
|
||||
... title="Example Service"
|
||||
... )
|
||||
```python
|
||||
from openapi_first import OpenAPIFirstApp
|
||||
import app.routes as routes
|
||||
|
||||
app = OpenAPIFirstApp(
|
||||
openapi_path="app/openapi.json",
|
||||
routes_module=routes,
|
||||
title="Example Service",
|
||||
)
|
||||
```
|
||||
"""
|
||||
|
||||
def __init__(
|
||||
|
||||
@@ -1,3 +1,61 @@
|
||||
"""
|
||||
openapi_first.client
|
||||
====================
|
||||
|
||||
OpenAPI-first HTTP client for contract-driven services.
|
||||
|
||||
This module provides `OpenAPIClient`, a thin, strict HTTP client that
|
||||
derives all callable operations directly from an OpenAPI 3.x specification.
|
||||
|
||||
It is the client counterpart to `OpenAPIFirstApp`.
|
||||
|
||||
Core principles
|
||||
---------------
|
||||
- The OpenAPI specification is the single source of truth.
|
||||
- Each operationId becomes a callable Python method.
|
||||
- No implicit schema mutation or inference.
|
||||
- No code generation step.
|
||||
- Minimal abstraction over httpx.
|
||||
|
||||
What this module does
|
||||
---------------------
|
||||
- Parses an OpenAPI 3.x specification.
|
||||
- Dynamically creates one callable per operationId.
|
||||
- Enforces presence of:
|
||||
- servers
|
||||
- paths
|
||||
- operationId
|
||||
- Formats path parameters safely.
|
||||
- Handles JSON request bodies explicitly.
|
||||
- Returns raw `httpx.Response` objects.
|
||||
|
||||
What this module does NOT do
|
||||
----------------------------
|
||||
- It does not generate client code.
|
||||
- It does not validate request/response schemas.
|
||||
- It does not deserialize responses.
|
||||
- It does not retry requests.
|
||||
- It does not implement authentication helpers.
|
||||
- It does not assume non-2xx responses are failures.
|
||||
|
||||
Intended usage
|
||||
--------------
|
||||
This client is designed for:
|
||||
|
||||
- Service-to-service communication
|
||||
- Integration testing
|
||||
- Contract-driven internal SDK usage
|
||||
- Systems that want OpenAPI-first symmetry with `OpenAPIFirstApp`
|
||||
|
||||
Design constraints
|
||||
------------------
|
||||
- Only the first server in the OpenAPI `servers` list is used if
|
||||
`base_url` is not explicitly provided.
|
||||
- Only explicitly declared request bodies are allowed.
|
||||
- `application/json` is handled natively; other media types are sent as raw content.
|
||||
- All responses are returned as-is.
|
||||
"""
|
||||
|
||||
from typing import Any, Callable, Dict, Optional
|
||||
from urllib.parse import urljoin
|
||||
|
||||
@@ -14,9 +72,66 @@ class OpenAPIClient:
|
||||
"""
|
||||
OpenAPI-first HTTP client (httpx-based).
|
||||
|
||||
This client derives all callable methods directly from an OpenAPI 3.x
|
||||
specification. Each operationId becomes a method on the client
|
||||
instance.
|
||||
|
||||
Design principles
|
||||
-----------------
|
||||
- One callable per operationId
|
||||
- Explicit parameters (path, query, headers, body)
|
||||
- No implicit schema inference or mutation
|
||||
- Returns raw httpx.Response objects
|
||||
- No response validation or deserialization
|
||||
|
||||
Parameters
|
||||
----------
|
||||
spec : dict
|
||||
Parsed OpenAPI 3.x specification.
|
||||
base_url : str | None
|
||||
Base URL of the target service. If omitted, the first entry
|
||||
in the OpenAPI `servers` list is used.
|
||||
client : httpx.Client | None
|
||||
Optional preconfigured httpx client instance.
|
||||
|
||||
Raises
|
||||
------
|
||||
OpenAPIClientError
|
||||
If:
|
||||
- No servers are defined and base_url is not provided
|
||||
- OpenAPI spec has no paths
|
||||
- An operation is missing operationId
|
||||
- Duplicate operationIds are detected
|
||||
- Required path parameters are missing
|
||||
- Required request body is missing
|
||||
|
||||
Example
|
||||
-------
|
||||
```python
|
||||
from openapi_first import loader, client
|
||||
|
||||
spec = loader.load_openapi("openapi.yaml")
|
||||
|
||||
api = client.OpenAPIClient(
|
||||
spec=spec,
|
||||
base_url="http://localhost:8000",
|
||||
)
|
||||
|
||||
# Call operationId: getUser
|
||||
response = api.getUser(
|
||||
path_params={"user_id": 123}
|
||||
)
|
||||
|
||||
print(response.status_code)
|
||||
print(response.json())
|
||||
|
||||
# Call operationId: createUser
|
||||
response = api.createUser(
|
||||
body={"name": "Bob"}
|
||||
)
|
||||
|
||||
print(response.status_code)
|
||||
```
|
||||
"""
|
||||
|
||||
def __init__(
|
||||
|
||||
Reference in New Issue
Block a user