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

Function parseSmallComponents

packages/plugins/openapi/src/sdk/split.ts:277–288  ·  view source on GitHub ↗
(structure: SpecStructure)

Source from the content-addressed store, hash-verified

275/** Parse the small component subkeys (parameters / requestBodies / responses)
276 * into a `components`-shaped object for `$ref` resolution. */
277export const parseSmallComponents = (structure: SpecStructure): Record<string, unknown> => {
278 if (structure.smallComponentRanges.length === 0) return {};
279 const body = structure.smallComponentRanges
280 .map((r) => structure.text.slice(r.start, r.end))
281 .join("");
282 const parsed = parseYaml(`components:\n${body}`);
283 const components =
284 parsed && typeof parsed === "object" ? (parsed as Record<string, unknown>).components : null;
285 return components && typeof components === "object"
286 ? (components as Record<string, unknown>)
287 : {};
288};
289
290/**
291 * Accept only the block-YAML profile the splitter can safely slice: no tabs, no

Calls 1

parseYamlFunction · 0.85

Tested by

no test coverage detected