MCPcopy Index your code
hub / github.com/ReAPI-com/mcp-openapi / scanAndSave

Method scanAndSave

src/core/SpecService.ts:150–240  ·  view source on GitHub ↗
(folderPath: string)

Source from the content-addressed store, hash-verified

148 }
149
150 async scanAndSave(folderPath: string): Promise<void> {
151 this.logger.debug({ folderPath }, "Starting scan and persist operation");
152 const tempCatalog: SpecCatalogEntry[] = [];
153 const pendingOperations: Array<{
154 spec: OpenAPIV3.Document;
155 entry: SpecCatalogEntry;
156 }> = [];
157
158 try {
159 for await (const scanResult of this.scanner.scan(folderPath)) {
160 const { filename, spec, specId, error } = scanResult;
161
162 if (error) {
163 this.logger.warn({ filename, error }, "Error scanning file");
164 continue;
165 }
166
167 try {
168 const operations: SpecOperationEntry[] = [];
169 const schemas: SpecSchemaEntry[] = [];
170
171 // Extract operations
172 for (const path in spec.paths) {
173 const pathItem = spec.paths[path];
174 for (const method in pathItem) {
175 if (method === "parameters" || method === "$ref") continue;
176 const operation = pathItem[method] as OpenAPIV3.OperationObject;
177 operations.push({
178 path,
179 method,
180 description: operation.description,
181 operationId: operation.operationId,
182 });
183 }
184 }
185
186 // Extract schemas
187 if (spec.components?.schemas) {
188 for (const [name, schema] of Object.entries(
189 spec.components.schemas
190 )) {
191 schemas.push({
192 name,
193 description: (schema as OpenAPIV3.SchemaObject).description,
194 });
195 }
196 }
197
198 const entry: SpecCatalogEntry = {
199 uri: {
200 specId,
201 type: "specification",
202 identifier: specId,
203 },
204 description: spec.info.description,
205 operations,
206 schemas,
207 };

Callers 1

initializeMethod · 0.95

Calls 8

ensureDirectoriesMethod · 0.95
saveSpecMethod · 0.95
saveSpecCatalogMethod · 0.95
debugMethod · 0.65
scanMethod · 0.65
warnMethod · 0.65
infoMethod · 0.65
errorMethod · 0.65

Tested by

no test coverage detected