MCPcopy Create free account
hub / github.com/ReAPI-com/mcp-openapi / mergeAllOfSchemas

Method mergeAllOfSchemas

src/core/SpecProcessor.ts:36–57  ·  view source on GitHub ↗

* 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)

Source from the content-addressed store, hash-verified

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

Callers 1

processMethod · 0.95

Calls 2

processSchemaMethod · 0.95
processPathItemMethod · 0.95

Tested by

no test coverage detected