(doc: ParsedDocument)
| 349 | * to rebuild the shared `definitions` instead of re-parsing the spec. |
| 350 | */ |
| 351 | export 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 |
no test coverage detected