* Recursively traverses the OpenAPI spec and merges any allOf schemas found * @param spec The OpenAPI specification to process * @returns The processed specification with merged allOf schemas
(spec: OpenAPIV3.Document)
| 34 | * @returns The processed specification with merged allOf schemas |
| 35 | */ |
| 36 | private mergeAllOfSchemas(spec: OpenAPIV3.Document): OpenAPIV3.Document { |
| 37 | // Deep clone the spec to avoid modifying the input |
| 38 | const processedSpec = structuredClone(spec); |
| 39 | |
| 40 | // Process components schemas if they exist |
| 41 | if (processedSpec.components?.schemas) { |
| 42 | for (const [key, schema] of Object.entries( |
| 43 | processedSpec.components.schemas |
| 44 | )) { |
| 45 | processedSpec.components.schemas[key] = this.processSchema( |
| 46 | schema as SchemaOrRef |
| 47 | ); |
| 48 | } |
| 49 | } |
| 50 | |
| 51 | // Process schemas in paths |
| 52 | for (const path of Object.values(processedSpec.paths || {})) { |
| 53 | this.processPathItem(path as OpenAPIV3.PathItemObject); |
| 54 | } |
| 55 | |
| 56 | return processedSpec; |
| 57 | } |
| 58 | |
| 59 | /** |
| 60 | * Processes a path item object, handling all nested schemas |
no test coverage detected