(
query: string,
specId?: string
)
| 326 | } |
| 327 | |
| 328 | async searchOperations( |
| 329 | query: string, |
| 330 | specId?: string |
| 331 | ): Promise<LoadOperationResult[]> { |
| 332 | const targetSpecs: SpecCatalogEntry[] = []; |
| 333 | if (specId) { |
| 334 | const spec = this.catalog.find((spec) => spec.uri.specId === specId); |
| 335 | if (spec) { |
| 336 | targetSpecs.push(spec); |
| 337 | } |
| 338 | } else { |
| 339 | targetSpecs.push(...this.catalog); |
| 340 | } |
| 341 | |
| 342 | const results: LoadOperationResult[] = []; |
| 343 | for (const spec of targetSpecs) { |
| 344 | const specDoc = this.specs[spec.uri.specId]; |
| 345 | if (!specDoc?.paths) continue; |
| 346 | |
| 347 | for (const path in specDoc.paths) { |
| 348 | const pathItem = specDoc.paths[path]; |
| 349 | if (!pathItem) continue; |
| 350 | |
| 351 | for (const method in pathItem) { |
| 352 | if (method === "parameters" || method === "$ref") continue; |
| 353 | const operation = pathItem[method] as OpenAPIV3.OperationObject; |
| 354 | if (!operation) continue; |
| 355 | |
| 356 | // Search in operationId, summary, description, and tags |
| 357 | const searchText = [ |
| 358 | operation.operationId, |
| 359 | operation.summary, |
| 360 | operation.description, |
| 361 | ...(operation.tags || []), |
| 362 | ] |
| 363 | .filter(Boolean) |
| 364 | .join(" ") |
| 365 | .toLowerCase(); |
| 366 | |
| 367 | if (searchText.includes(query.toLowerCase())) { |
| 368 | results.push({ |
| 369 | path, |
| 370 | method, |
| 371 | operation, |
| 372 | specId: spec.uri.specId, |
| 373 | uri: `apis://${spec.uri.specId}/operations/${operation.operationId}`, |
| 374 | }); |
| 375 | } |
| 376 | } |
| 377 | } |
| 378 | } |
| 379 | |
| 380 | return results; |
| 381 | } |
| 382 | |
| 383 | async searchSchemas( |
| 384 | query: string, |
nothing calls this directly
no outgoing calls
no test coverage detected