(node: unknown)
| 132 | } |
| 133 | |
| 134 | function normalizeBrandCasingNode(node: unknown): void { |
| 135 | if (Array.isArray(node)) { |
| 136 | for (const item of node) normalizeBrandCasingNode(item); |
| 137 | return; |
| 138 | } |
| 139 | if (node === null || typeof node !== "object") return; |
| 140 | const obj = node as Record<string, unknown>; |
| 141 | |
| 142 | for (const defsKey of ["definitions", "$defs"] as const) { |
| 143 | const defs = obj[defsKey]; |
| 144 | if (defs && typeof defs === "object" && !Array.isArray(defs)) { |
| 145 | renameBrandDefinitionKeys(defs as Record<string, unknown>); |
| 146 | } |
| 147 | } |
| 148 | |
| 149 | for (const [key, value] of Object.entries(obj)) { |
| 150 | if (typeof value === "string") { |
| 151 | if (key === "$ref") { |
| 152 | obj[key] = fixBrandRef(value); |
| 153 | } else if (BRAND_NORMALIZED_STRING_KEYS.has(key)) { |
| 154 | obj[key] = fixBrandCasing(value); |
| 155 | } |
| 156 | } else { |
| 157 | normalizeBrandCasingNode(value); |
| 158 | } |
| 159 | } |
| 160 | } |
| 161 | |
| 162 | /** Apply brand-casing only to the definition-name segment of a `$ref`. */ |
| 163 | function fixBrandRef(ref: string): string { |
no test coverage detected
searching dependent graphs…