(self: Constraint, target: StandardJSONSchemaV1.Target)
| 1337 | } |
| 1338 | |
| 1339 | function toBaseStandardJSONSchemaV1(self: Constraint, target: StandardJSONSchemaV1.Target): JsonSchema.JsonSchema { |
| 1340 | const doc2020_12 = toJsonSchemaDocument(self) |
| 1341 | if (target === "draft-2020-12") { |
| 1342 | const schema = doc2020_12.schema |
| 1343 | if (Object.keys(doc2020_12.definitions).length > 0) { |
| 1344 | schema.$defs = doc2020_12.definitions |
| 1345 | } |
| 1346 | return schema |
| 1347 | } else if (target === "draft-07") { |
| 1348 | const doc07 = JsonSchema.toDocumentDraft07(doc2020_12) |
| 1349 | const schema = doc07.schema |
| 1350 | if (Object.keys(doc07.definitions).length > 0) { |
| 1351 | schema.definitions = doc07.definitions |
| 1352 | } |
| 1353 | return schema |
| 1354 | } |
| 1355 | throw new globalThis.Error(`Unsupported target: ${target}`) |
| 1356 | } |
| 1357 | |
| 1358 | /** |
| 1359 | * Converts a schema to an experimental Standard JSON Schema V1 representation. |
no test coverage detected