(value: unknown, key?: string)
| 51 | } |
| 52 | |
| 53 | function restoreModelRefs(value: unknown, key?: string): unknown { |
| 54 | if (Array.isArray(value)) return value.map((item) => restoreModelRefs(item)) |
| 55 | if (!isRecord(value)) return value |
| 56 | |
| 57 | const schema = Object.fromEntries(Object.entries(value).map(([name, item]) => [name, restoreModelRefs(item, name)])) |
| 58 | if ((key === "model" || key === "small_model") && schema.type === "string") { |
| 59 | return { ...schema, $ref: MODEL_REF } |
| 60 | } |
| 61 | return schema |
| 62 | } |
| 63 | |
| 64 | function isRecord(value: unknown): value is JsonSchema { |
| 65 | return typeof value === "object" && value !== null && !Array.isArray(value) |
no test coverage detected