MCPcopy Create free account
hub / github.com/Effect-TS/effect / toBaseStandardJSONSchemaV1

Function toBaseStandardJSONSchemaV1

packages/effect/src/Schema.ts:1339–1356  ·  view source on GitHub ↗
(self: Constraint, target: StandardJSONSchemaV1.Target)

Source from the content-addressed store, hash-verified

1337}
1338
1339function 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.

Callers 2

inputFunction · 0.85
outputFunction · 0.85

Calls 1

toJsonSchemaDocumentFunction · 0.70

Tested by

no test coverage detected