(value: unknown)
| 1597 | } |
| 1598 | |
| 1599 | function collectLocalDefinitionRefNames(value: unknown): Set<string> { |
| 1600 | const refs = new Set<string>(); |
| 1601 | |
| 1602 | const visit = (node: unknown): void => { |
| 1603 | if (!node || typeof node !== "object") return; |
| 1604 | if (Array.isArray(node)) { |
| 1605 | for (const item of node) visit(item); |
| 1606 | return; |
| 1607 | } |
| 1608 | |
| 1609 | const record = node as Record<string, unknown>; |
| 1610 | if (typeof record.$ref === "string") { |
| 1611 | const localRef = parseLocalDefinitionRef(record.$ref); |
| 1612 | if (localRef) refs.add(localRef); |
| 1613 | } |
| 1614 | for (const child of Object.values(record)) visit(child); |
| 1615 | }; |
| 1616 | |
| 1617 | visit(value); |
| 1618 | return refs; |
| 1619 | } |
| 1620 | |
| 1621 | function parseLocalDefinitionRef(ref: string): string | undefined { |
| 1622 | const match = ref.match(/^#\/(?:definitions|\$defs)\/(.+)$/); |
no test coverage detected
searching dependent graphs…