MCPcopy Create free account
hub / github.com/UsefulSoftwareCo/executor / buildDefsJson

Function buildDefsJson

packages/plugins/openapi/src/sdk/backing.ts:351–363  ·  view source on GitHub ↗
(doc: ParsedDocument)

Source from the content-addressed store, hash-verified

349 * to rebuild the shared `definitions` instead of re-parsing the spec.
350 */
351export const buildDefsJson = (doc: ParsedDocument): string => {
352 const schemas = doc.components?.schemas;
353 if (!schemas) return "{}";
354 let json = "{";
355 let first = true;
356 for (const [name, schema] of Object.entries(schemas)) {
357 const serialized = JSON.stringify(normalizeOpenApiRefs(schema));
358 if (serialized === undefined) continue;
359 json += `${first ? "" : ","}${JSON.stringify(name)}:${serialized}`;
360 first = false;
361 }
362 return `${json}}`;
363};
364
365/**
366 * Streaming twin of `buildDefsJson`: serialize the content-addressed defs blob

Callers 1

Calls 1

normalizeOpenApiRefsFunction · 0.85

Tested by

no test coverage detected