(
document: Document,
options?: Schema.ToJsonSchemaOptions
): JsonSchema.Document<"draft-2020-12">Converts a Document to a Draft 2020-12 JSON Schema document.
When to use
Use when you need to produce a standard JSON Schema document from a schema
representation Document.
Gotchas
JSON Schema generation is best-effort. Some Effect schema representation semantics cannot be represented exactly in JSON Schema, and importing an emitted JSON Schema may produce an equivalent approximation rather than the original representation shape.
Example (Generating JSON Schema)
import { Schema, SchemaRepresentation } from "effect"
const doc = SchemaRepresentation.fromAST(Schema.String.ast)
const jsonSchema = SchemaRepresentation.toJsonSchemaDocument(doc)
console.log(jsonSchema.schema.type)
// "string"export const const toJsonSchemaDocument: (
document: Document,
options?: Schema.ToJsonSchemaOptions
) => JsonSchema.Document<"draft-2020-12">
Converts a
Document
to a Draft 2020-12 JSON Schema document.
When to use
Use when you need to produce a standard JSON Schema document from a schema
representation Document.
Gotchas
JSON Schema generation is best-effort. Some Effect schema representation
semantics cannot be represented exactly in JSON Schema, and importing an
emitted JSON Schema may produce an equivalent approximation rather than the
original representation shape.
Example (Generating JSON Schema)
import { Schema, SchemaRepresentation } from "effect"
const doc = SchemaRepresentation.fromAST(Schema.String.ast)
const jsonSchema = SchemaRepresentation.toJsonSchemaDocument(doc)
console.log(jsonSchema.schema.type)
// "string"
toJsonSchemaDocument: (
document: Document(parameter) document: {
representation: Representation;
references: References;
}
document: type Document = {
readonly representation: Representation
readonly references: References
}
A single
Representation
together with its named
References
.
When to use
Use when representing a single Schema AST together with its named references
before reconstructing a runtime Schema, converting to JSON Schema, or
wrapping it as a
MultiDocument
.
Document,
options: Schema.ToJsonSchemaOptionsoptions?: import SchemaSchema.type Schema.ToJsonSchemaOptions = /*unresolved*/ anyToJsonSchemaOptions
) => import JsonSchemaJsonSchema.type JsonSchema.Document = /*unresolved*/ anyDocument<"draft-2020-12"> = import InternalRepresentationInternalRepresentation.function toJsonSchemaDocument(
document: SchemaRepresentation.Document,
options?: Schema.ToJsonSchemaOptions
): JsonSchema.Document<"draft-2020-12">
toJsonSchemaDocument