(node: unknown)
| 53 | } |
| 54 | |
| 55 | function normalizeBrandCasingNode(node: unknown): void { |
| 56 | if (Array.isArray(node)) { |
| 57 | for (const item of node) normalizeBrandCasingNode(item); |
| 58 | return; |
| 59 | } |
| 60 | if (node === null || typeof node !== "object") return; |
| 61 | const obj = node as Record<string, unknown>; |
| 62 | |
| 63 | for (const defsKey of ["definitions", "$defs"] as const) { |
| 64 | const defs = obj[defsKey]; |
| 65 | if (defs && typeof defs === "object" && !Array.isArray(defs)) { |
| 66 | renameBrandDefinitionKeys(defs as Record<string, unknown>); |
| 67 | } |
| 68 | } |
| 69 | |
| 70 | for (const [key, value] of Object.entries(obj)) { |
| 71 | if (typeof value === "string") { |
| 72 | if (key === "$ref") { |
| 73 | obj[key] = fixBrandRef(value); |
| 74 | } else if (BRAND_NORMALIZED_STRING_KEYS.has(key)) { |
| 75 | obj[key] = fixBrandCasing(value); |
| 76 | } |
| 77 | } else { |
| 78 | normalizeBrandCasingNode(value); |
| 79 | } |
| 80 | } |
| 81 | } |
| 82 | |
| 83 | function fixBrandRef(ref: string): string { |
| 84 | const lastSlash = ref.lastIndexOf("/"); |
no test coverage detected
searching dependent graphs…