Generate the OpenAPI specification from the FastAPI app.
()
| 126 | |
| 127 | |
| 128 | def generate_openapi_spec(): |
| 129 | """Generate the OpenAPI specification from the FastAPI app.""" |
| 130 | spec = app.openapi() |
| 131 | |
| 132 | # Explicitly exclude certain endpoints that are operational or UI-only convenience |
| 133 | excluded_endpoints = [ |
| 134 | '/server_info', # Operational/system diagnostics |
| 135 | '/api/conversations/{conversation_id}/vscode-url', # UI/runtime convenience |
| 136 | '/api/conversations/{conversation_id}/web-hosts', # UI/runtime convenience |
| 137 | ] |
| 138 | |
| 139 | if 'paths' in spec: |
| 140 | for endpoint in excluded_endpoints: |
| 141 | if endpoint in spec['paths']: |
| 142 | del spec['paths'][endpoint] |
| 143 | print(f'Excluded endpoint: {endpoint}') |
| 144 | |
| 145 | # Sanitize descriptions and summaries |
| 146 | spec = _sanitize_spec(spec) |
| 147 | |
| 148 | return spec |
| 149 | |
| 150 | |
| 151 | def load_current_spec(spec_path): |
no test coverage detected