| 102 | ]); |
| 103 | |
| 104 | function detectVersion(schema: JSONSchema.JSONSchema, defaultTarget?: JSONSchemaVersion): JSONSchemaVersion { |
| 105 | const $schema = schema.$schema; |
| 106 | |
| 107 | if ($schema === "https://json-schema.org/draft/2020-12/schema") { |
| 108 | return "draft-2020-12"; |
| 109 | } |
| 110 | if ($schema === "http://json-schema.org/draft-07/schema#") { |
| 111 | return "draft-7"; |
| 112 | } |
| 113 | if ($schema === "http://json-schema.org/draft-04/schema#") { |
| 114 | return "draft-4"; |
| 115 | } |
| 116 | |
| 117 | // Use defaultTarget if provided, otherwise default to draft-2020-12 |
| 118 | return defaultTarget ?? "draft-2020-12"; |
| 119 | } |
| 120 | |
| 121 | function resolveRef(ref: string, ctx: ConversionContext): JSONSchema.JSONSchema { |
| 122 | if (!ref.startsWith("#")) { |