(structure: SpecStructure)
| 275 | /** Parse the small component subkeys (parameters / requestBodies / responses) |
| 276 | * into a `components`-shaped object for `$ref` resolution. */ |
| 277 | export 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 |
no test coverage detected