* Resolve a $ref in a JSON Schema against the current definitions. * Returns the resolved schema, or the original if no $ref is present.
(schema: JSONSchema7 | undefined)
| 237 | * Returns the resolved schema, or the original if no $ref is present. |
| 238 | */ |
| 239 | function resolveRef(schema: JSONSchema7 | undefined): JSONSchema7 | undefined { |
| 240 | if (!schema) return schema; |
| 241 | if (schema.$ref) { |
| 242 | const name = schema.$ref.replace(/^#\/definitions\//, ""); |
| 243 | const resolved = currentDefinitions[name]; |
| 244 | if (!resolved) { |
| 245 | console.warn(`[codegen] Unresolved $ref: ${schema.$ref}`); |
| 246 | return schema; |
| 247 | } |
| 248 | return resolved; |
| 249 | } |
| 250 | return schema; |
| 251 | } |
| 252 | |
| 253 | /** Extract the definition name from a $ref string (e.g., "#/definitions/Foo" → "Foo") */ |
| 254 | function extractRefName(schema: JSONSchema7 | null | undefined): string | null { |
no outgoing calls
no test coverage detected
searching dependent graphs…