(ast: SchemaAST.AST): DocumentConverts a Schema AST into a Document.
When to use
Use when you have a single Schema AST and need a schema representation document.
Details
Shared/recursive sub-schemas are extracted into the references map.
Example (Converting a Schema to a Document)
import { Schema, SchemaRepresentation } from "effect"
const Person = Schema.Struct({
name: Schema.String,
age: Schema.Number
})
const doc = SchemaRepresentation.fromAST(Person.ast)
console.log(doc.representation._tag)
// "Objects"Source effect/SchemaRepresentation.ts:16371 lines
export const const fromAST: (
ast: SchemaAST.AST
) => Document
Converts a Schema AST into a
Document
.
When to use
Use when you have a single Schema AST and need a schema representation
document.
Details
Shared/recursive sub-schemas are extracted into the references map.
Example (Converting a Schema to a Document)
import { Schema, SchemaRepresentation } from "effect"
const Person = Schema.Struct({
name: Schema.String,
age: Schema.Number
})
const doc = SchemaRepresentation.fromAST(Person.ast)
console.log(doc.representation._tag)
// "Objects"
fromAST: (ast: SchemaAST.ASTast: import SchemaASTSchemaAST.type SchemaAST.AST = /*unresolved*/ anyAST) => 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 = import InternalRepresentationInternalRepresentation.function fromAST(
ast: SchemaAST.AST
): SchemaRepresentation.Document
fromAST