Sanitize descriptions and summaries to be public-API friendly.
(spec: dict)
| 91 | |
| 92 | |
| 93 | def _sanitize_spec(spec: dict) -> dict: |
| 94 | """Sanitize descriptions and summaries to be public-API friendly.""" |
| 95 | path_summary_overrides = { |
| 96 | '/api/options/models': 'List Supported Models', |
| 97 | '/api/options/agents': 'List Agents', |
| 98 | '/api/options/security-analyzers': 'List Security Analyzers', |
| 99 | '/api/conversations/{conversation_id}/list-files': 'List Workspace Files', |
| 100 | '/api/conversations/{conversation_id}/select-file': 'Get File Content', |
| 101 | '/api/conversations/{conversation_id}/zip-directory': 'Download Workspace Archive', |
| 102 | } |
| 103 | path_description_overrides = { |
| 104 | '/api/options/models': 'List model identifiers available on this server based on configured providers.', |
| 105 | '/api/options/agents': 'List available agent types supported by this server.', |
| 106 | '/api/options/security-analyzers': 'List supported security analyzers.', |
| 107 | '/api/conversations/{conversation_id}/list-files': 'List workspace files visible to the conversation runtime. Applies .gitignore and internal ignore rules.', |
| 108 | '/api/conversations/{conversation_id}/select-file': 'Return the content of the given file from the conversation workspace.', |
| 109 | '/api/conversations/{conversation_id}/zip-directory': 'Return a ZIP archive of the current conversation workspace.', |
| 110 | } |
| 111 | |
| 112 | for path, methods in list(spec.get('paths', {}).items()): |
| 113 | for method, meta in list(methods.items()): |
| 114 | if not isinstance(meta, dict): |
| 115 | continue |
| 116 | # Override overly specific summaries where helpful |
| 117 | if path in path_summary_overrides: |
| 118 | meta['summary'] = path_summary_overrides[path] |
| 119 | # Override description if provided; otherwise sanitize |
| 120 | if path in path_description_overrides: |
| 121 | meta['description'] = path_description_overrides[path] |
| 122 | elif 'description' in meta and isinstance(meta['description'], str): |
| 123 | meta['description'] = _sanitize_description(meta['description']) |
| 124 | |
| 125 | return spec |
| 126 | |
| 127 | |
| 128 | def generate_openapi_spec(): |
no test coverage detected