(
document: JsonSchema.Document<"draft-2020-12">,
options?: {
readonly onEnter?:
| ((js: JsonSchema.JsonSchema) => JsonSchema.JsonSchema)
| undefined
}
): DocumentParses a Draft 2020-12 JSON Schema document into a Document.
When to use
Use when you need to import a Draft 2020-12 JSON Schema document into the Effect schema representation system.
Details
options.onEnter is an optional hook called on each JSON Schema node before
processing, allowing pre-transformation.
Gotchas
JSON Schema import is best-effort. Some JSON Schema constructs do not map
exactly to Effect schema representations, and importing a schema previously
emitted by toJsonSchemaDocument may produce an equivalent approximation
rather than the original representation shape.
This throws if a $ref cannot be resolved within the document's definitions.
Circular $refs are detected and cause an error.
export function function fromJsonSchemaDocument(
document: JsonSchema.Document<"draft-2020-12">,
options?: {
readonly onEnter?:
| ((
js: JsonSchema.JsonSchema
) => JsonSchema.JsonSchema)
| undefined
}
): Document
Parses a Draft 2020-12 JSON Schema document into a
Document
.
When to use
Use when you need to import a Draft 2020-12 JSON Schema document into the
Effect schema representation system.
Details
options.onEnter is an optional hook called on each JSON Schema node before
processing, allowing pre-transformation.
Gotchas
JSON Schema import is best-effort. Some JSON Schema constructs do not map
exactly to Effect schema representations, and importing a schema previously
emitted by toJsonSchemaDocument may produce an equivalent approximation
rather than the original representation shape.
This throws if a $ref cannot be resolved within the document's definitions.
Circular $refs are detected and cause an error.
fromJsonSchemaDocument(document: JsonSchema.Document<"draft-2020-12">(parameter) document: {
dialect: D;
schema: JsonSchema;
definitions: Definitions;
}
document: import JsonSchemaJsonSchema.type JsonSchema.Document = /*unresolved*/ anyDocument<"draft-2020-12">, options: {
readonly onEnter?:
| ((
js: JsonSchema.JsonSchema
) => JsonSchema.JsonSchema)
| undefined
}
options?: {
readonly onEnter?: | ((
js: JsonSchema.JsonSchema
) => JsonSchema.JsonSchema)
| undefined
onEnter?: ((js: JsonSchema.JsonSchemajs: import JsonSchemaJsonSchema.type JsonSchema.JsonSchema = /*unresolved*/ anyJsonSchema) => import JsonSchemaJsonSchema.type JsonSchema.JsonSchema = /*unresolved*/ anyJsonSchema) | undefined
}): 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 {
const { const references: Referencesreferences, representations: readonly [
Representation,
...Array<Representation>
]
representations: const schemas: readonly [
Representation,
...Representation[]
]
const schemas: {
0: Representation;
length: number;
toString: () => string;
toLocaleString: { (): string; (locales: string | string[], options?: Intl.NumberFormatOptions & Intl.DateTimeFormatOptions): string };
concat: { (...items: Array<ConcatArray<Representation>>): Array<Representation>; (...items: Array<Representation | ConcatArray<Representation>>): Array<Representation> };
join: (separator?: string) => string;
slice: (start?: number, end?: number) => Array<Representation>;
indexOf: (searchElement: Representation, fromIndex?: number) => number;
lastIndexOf: (searchElement: Representation, fromIndex?: number) => number;
every: { (predicate: (value: Representation, index: number, array: ReadonlyArray<Representation>) => value is S, thisArg?: any): this is readonly S[]; (predicate: (value: Representation, index: number, array: ReadonlyArray<Representation>) => unk…;
some: (predicate: (value: Representation, index: number, array: ReadonlyArray<Representation>) => unknown, thisArg?: any) => boolean;
forEach: (callbackfn: (value: Representation, index: number, array: ReadonlyArray<Representation>) => void, thisArg?: any) => void;
map: (callbackfn: (value: Representation, index: number, array: ReadonlyArray<Representation>) => U, thisArg?: any) => Array<U>;
filter: { (predicate: (value: Representation, index: number, array: ReadonlyArray<Representation>) => value is S, thisArg?: any): Array<S>; (predicate: (value: Representation, index: number, array: ReadonlyArray<Representation>) => unknown, thisAr…;
reduce: { (callbackfn: (previousValue: Representation, currentValue: Representation, currentIndex: number, array: ReadonlyArray<Representation>) => Representation): Representation; (callbackfn: (previousValue: Representation, currentValue: Represe…;
reduceRight: { (callbackfn: (previousValue: Representation, currentValue: Representation, currentIndex: number, array: ReadonlyArray<Representation>) => Representation): Representation; (callbackfn: (previousValue: Representation, currentValue: Represe…;
find: { (predicate: (value: Representation, index: number, obj: ReadonlyArray<Representation>) => value is S, thisArg?: any): S | undefined; (predicate: (value: Representation, index: number, obj: ReadonlyArray<Representation>) => unknown, thisA…;
findIndex: (predicate: (value: Representation, index: number, obj: ReadonlyArray<Representation>) => unknown, thisArg?: any) => number;
entries: () => ArrayIterator<[number, Representation]>;
keys: () => ArrayIterator<number>;
values: () => ArrayIterator<Representation>;
includes: (searchElement: Representation, fromIndex?: number) => boolean;
flatMap: (callback: (this: This, value: Representation, index: number, array: Array<Representation>) => U | ReadonlyArray<U>, thisArg?: This | undefined) => Array<U>;
flat: (this: A, depth?: D | undefined) => Array<FlatArray<A, D>>;
at: (index: number) => Representation | undefined;
findLast: { (predicate: (value: Representation, index: number, array: ReadonlyArray<Representation>) => value is S, thisArg?: any): S | undefined; (predicate: (value: Representation, index: number, array: ReadonlyArray<Representation>) => unknown, t…;
findLastIndex: (predicate: (value: Representation, index: number, array: ReadonlyArray<Representation>) => unknown, thisArg?: any) => number;
toReversed: () => Array<Representation>;
toSorted: (compareFn?: ((a: Representation, b: Representation) => number) | undefined) => Array<Representation>;
toSpliced: { (start: number, deleteCount: number, ...items: Array<Representation>): Array<Representation>; (start: number, deleteCount?: number): Array<Representation> };
with: (index: number, value: Representation) => Array<Representation>;
}
schemas } = function fromJsonSchemaMultiDocument(
document: JsonSchema.MultiDocument<"draft-2020-12">,
options?: {
readonly onEnter?:
| ((
js: JsonSchema.JsonSchema
) => JsonSchema.JsonSchema)
| undefined
}
): MultiDocument
Parses a Draft 2020-12 JSON Schema multi-document into a
When to use
Use when you need to import a Draft 2020-12 JSON Schema multi-document whose
schemas share definitions.
Details
options.onEnter is an optional hook called on each JSON Schema node before
processing.
Gotchas
JSON Schema import is best-effort. Some JSON Schema constructs do not map
exactly to Effect schema representations, and importing schemas previously
emitted by toJsonSchemaMultiDocument may produce equivalent approximations
rather than the original representation shapes.
This throws if a $ref cannot be resolved.
fromJsonSchemaMultiDocument({
dialect: anydialect: document: JsonSchema.Document<"draft-2020-12">(parameter) document: {
dialect: D;
schema: JsonSchema;
definitions: Definitions;
}
document.dialect,
schemas: any[](property) schemas: {
0: JsonSchema.JsonSchema;
length: 1;
toString: () => string;
toLocaleString: { (): string; (locales: string | string[], options?: Intl.NumberFormatOptions & Intl.DateTimeFormatOptions): string };
pop: () => JsonSchema.JsonSchema | undefined;
push: (...items: Array<JsonSchema.JsonSchema>) => number;
concat: { (...items: Array<ConcatArray<JsonSchema.JsonSchema>>): Array<JsonSchema.JsonSchema>; (...items: Array<JsonSchema.JsonSchema | ConcatArray<JsonSchema.JsonSchema>>): Array<JsonSchema.JsonSchema> };
join: (separator?: string) => string;
reverse: () => Array<JsonSchema.JsonSchema>;
shift: () => JsonSchema.JsonSchema | undefined;
slice: (start?: number, end?: number) => Array<JsonSchema.JsonSchema>;
sort: (compareFn?: ((a: JsonSchema.JsonSchema, b: JsonSchema.JsonSchema) => number) | undefined) => [JsonSchema.JsonSchema];
splice: { (start: number, deleteCount?: number): Array<JsonSchema.JsonSchema>; (start: number, deleteCount: number, ...items: Array<JsonSchema.JsonSchema>): Array<JsonSchema.JsonSchema> };
unshift: (...items: Array<JsonSchema.JsonSchema>) => number;
indexOf: (searchElement: JsonSchema.JsonSchema, fromIndex?: number) => number;
lastIndexOf: (searchElement: JsonSchema.JsonSchema, fromIndex?: number) => number;
every: { (predicate: (value: JsonSchema.JsonSchema, index: number, array: Array<JsonSchema.JsonSchema>) => value is S, thisArg?: any): this is S[]; (predicate: (value: JsonSchema.JsonSchema, index: number, array: Array<JsonSchema.JsonSchema>) => …;
some: (predicate: (value: JsonSchema.JsonSchema, index: number, array: Array<JsonSchema.JsonSchema>) => unknown, thisArg?: any) => boolean;
forEach: (callbackfn: (value: JsonSchema.JsonSchema, index: number, array: Array<JsonSchema.JsonSchema>) => void, thisArg?: any) => void;
map: (callbackfn: (value: JsonSchema.JsonSchema, index: number, array: Array<JsonSchema.JsonSchema>) => U, thisArg?: any) => Array<U>;
filter: { (predicate: (value: JsonSchema.JsonSchema, index: number, array: Array<JsonSchema.JsonSchema>) => value is S, thisArg?: any): Array<S>; (predicate: (value: JsonSchema.JsonSchema, index: number, array: Array<JsonSchema.JsonSchema>) => unk…;
reduce: { (callbackfn: (previousValue: JsonSchema.JsonSchema, currentValue: JsonSchema.JsonSchema, currentIndex: number, array: Array<JsonSchema.JsonSchema>) => JsonSchema.JsonSchema): JsonSchema.JsonSchema; (callbackfn: (previousValue: JsonSchema…;
reduceRight: { (callbackfn: (previousValue: JsonSchema.JsonSchema, currentValue: JsonSchema.JsonSchema, currentIndex: number, array: Array<JsonSchema.JsonSchema>) => JsonSchema.JsonSchema): JsonSchema.JsonSchema; (callbackfn: (previousValue: JsonSchema…;
find: { (predicate: (value: JsonSchema.JsonSchema, index: number, obj: Array<JsonSchema.JsonSchema>) => value is S, thisArg?: any): S | undefined; (predicate: (value: JsonSchema.JsonSchema, index: number, obj: Array<JsonSchema.JsonSchema>) => un…;
findIndex: (predicate: (value: JsonSchema.JsonSchema, index: number, obj: Array<JsonSchema.JsonSchema>) => unknown, thisArg?: any) => number;
fill: (value: JsonSchema.JsonSchema, start?: number, end?: number) => [JsonSchema.JsonSchema];
copyWithin: (target: number, start: number, end?: number) => [JsonSchema.JsonSchema];
entries: () => ArrayIterator<[number, JsonSchema.JsonSchema]>;
keys: () => ArrayIterator<number>;
values: () => ArrayIterator<JsonSchema.JsonSchema>;
includes: (searchElement: JsonSchema.JsonSchema, fromIndex?: number) => boolean;
flatMap: (callback: (this: This, value: JsonSchema.JsonSchema, index: number, array: Array<JsonSchema.JsonSchema>) => U | ReadonlyArray<U>, thisArg?: This | undefined) => Array<U>;
flat: (this: A, depth?: D | undefined) => Array<FlatArray<A, D>>;
at: (index: number) => JsonSchema.JsonSchema | undefined;
findLast: { (predicate: (value: JsonSchema.JsonSchema, index: number, array: Array<JsonSchema.JsonSchema>) => value is S, thisArg?: any): S | undefined; (predicate: (value: JsonSchema.JsonSchema, index: number, array: Array<JsonSchema.JsonSchema>) =…;
findLastIndex: (predicate: (value: JsonSchema.JsonSchema, index: number, array: Array<JsonSchema.JsonSchema>) => unknown, thisArg?: any) => number;
toReversed: () => Array<JsonSchema.JsonSchema>;
toSorted: (compareFn?: ((a: JsonSchema.JsonSchema, b: JsonSchema.JsonSchema) => number) | undefined) => Array<JsonSchema.JsonSchema>;
toSpliced: { (start: number, deleteCount: number, ...items: Array<JsonSchema.JsonSchema>): Array<JsonSchema.JsonSchema>; (start: number, deleteCount?: number): Array<JsonSchema.JsonSchema> };
with: (index: number, value: JsonSchema.JsonSchema) => Array<JsonSchema.JsonSchema>;
}
schemas: [document: JsonSchema.Document<"draft-2020-12">(parameter) document: {
dialect: D;
schema: JsonSchema;
definitions: Definitions;
}
document.schema],
definitions: JsonSchema.Definitionsdefinitions: document: JsonSchema.Document<"draft-2020-12">(parameter) document: {
dialect: D;
schema: JsonSchema;
definitions: Definitions;
}
document.definitions
}, options: {
readonly onEnter?:
| ((
js: JsonSchema.JsonSchema
) => JsonSchema.JsonSchema)
| undefined
}
options)
return {
representation: Representationrepresentation: const schemas: readonly [
Representation,
...Representation[]
]
const schemas: {
0: Representation;
length: number;
toString: () => string;
toLocaleString: { (): string; (locales: string | string[], options?: Intl.NumberFormatOptions & Intl.DateTimeFormatOptions): string };
concat: { (...items: Array<ConcatArray<Representation>>): Array<Representation>; (...items: Array<Representation | ConcatArray<Representation>>): Array<Representation> };
join: (separator?: string) => string;
slice: (start?: number, end?: number) => Array<Representation>;
indexOf: (searchElement: Representation, fromIndex?: number) => number;
lastIndexOf: (searchElement: Representation, fromIndex?: number) => number;
every: { (predicate: (value: Representation, index: number, array: ReadonlyArray<Representation>) => value is S, thisArg?: any): this is readonly S[]; (predicate: (value: Representation, index: number, array: ReadonlyArray<Representation>) => unk…;
some: (predicate: (value: Representation, index: number, array: ReadonlyArray<Representation>) => unknown, thisArg?: any) => boolean;
forEach: (callbackfn: (value: Representation, index: number, array: ReadonlyArray<Representation>) => void, thisArg?: any) => void;
map: (callbackfn: (value: Representation, index: number, array: ReadonlyArray<Representation>) => U, thisArg?: any) => Array<U>;
filter: { (predicate: (value: Representation, index: number, array: ReadonlyArray<Representation>) => value is S, thisArg?: any): Array<S>; (predicate: (value: Representation, index: number, array: ReadonlyArray<Representation>) => unknown, thisAr…;
reduce: { (callbackfn: (previousValue: Representation, currentValue: Representation, currentIndex: number, array: ReadonlyArray<Representation>) => Representation): Representation; (callbackfn: (previousValue: Representation, currentValue: Represe…;
reduceRight: { (callbackfn: (previousValue: Representation, currentValue: Representation, currentIndex: number, array: ReadonlyArray<Representation>) => Representation): Representation; (callbackfn: (previousValue: Representation, currentValue: Represe…;
find: { (predicate: (value: Representation, index: number, obj: ReadonlyArray<Representation>) => value is S, thisArg?: any): S | undefined; (predicate: (value: Representation, index: number, obj: ReadonlyArray<Representation>) => unknown, thisA…;
findIndex: (predicate: (value: Representation, index: number, obj: ReadonlyArray<Representation>) => unknown, thisArg?: any) => number;
entries: () => ArrayIterator<[number, Representation]>;
keys: () => ArrayIterator<number>;
values: () => ArrayIterator<Representation>;
includes: (searchElement: Representation, fromIndex?: number) => boolean;
flatMap: (callback: (this: This, value: Representation, index: number, array: Array<Representation>) => U | ReadonlyArray<U>, thisArg?: This | undefined) => Array<U>;
flat: (this: A, depth?: D | undefined) => Array<FlatArray<A, D>>;
at: (index: number) => Representation | undefined;
findLast: { (predicate: (value: Representation, index: number, array: ReadonlyArray<Representation>) => value is S, thisArg?: any): S | undefined; (predicate: (value: Representation, index: number, array: ReadonlyArray<Representation>) => unknown, t…;
findLastIndex: (predicate: (value: Representation, index: number, array: ReadonlyArray<Representation>) => unknown, thisArg?: any) => number;
toReversed: () => Array<Representation>;
toSorted: (compareFn?: ((a: Representation, b: Representation) => number) | undefined) => Array<Representation>;
toSpliced: { (start: number, deleteCount: number, ...items: Array<Representation>): Array<Representation>; (start: number, deleteCount?: number): Array<Representation> };
with: (index: number, value: Representation) => Array<Representation>;
}
schemas[0],
references: Referencesreferences
}
}