JSONSchema overview
Added in v3.10.0
Table of contents
- encoding
- model
- JsonSchema7 (type alias)
- JsonSchema7Any (interface)
- JsonSchema7AnyOf (interface)
- JsonSchema7Array (interface)
- JsonSchema7Boolean (interface)
- JsonSchema7Enum (interface)
- JsonSchema7Enums (interface)
- JsonSchema7Integer (interface)
- JsonSchema7Never (interface)
- JsonSchema7Number (interface)
- JsonSchema7Numeric (interface)
- JsonSchema7Object (interface)
- JsonSchema7Ref (interface)
- JsonSchema7Root (type alias)
- JsonSchema7String (interface)
- JsonSchema7Unknown (interface)
- JsonSchema7Void (interface)
- JsonSchema7empty (interface)
- JsonSchema7object (interface)
- JsonSchemaAnnotations (interface)
encoding
fromAST
Returns a JSON Schema with additional options and definitions.
Warning
This function is experimental and subject to change.
Details
definitions
: A record of definitions that are included in the schema.definitionPath
: The path to the definitions within the schema (defaults to “#/$defs/”).target
: Which spec to target. Possible values are:'jsonSchema7'
: JSON Schema draft-07 (default behavior).'jsonSchema2019-09'
: JSON Schema draft-2019-09.'openApi3.1'
: OpenAPI 3.1.
topLevelReferenceStrategy
: Controls the handling of the top-level reference. Possible values are:"keep"
: Keep the top-level reference (default behavior)."skip"
: Skip the top-level reference.
Signature
export declare const fromAST: (
ast: AST.AST,
options: {
readonly definitions: Record<string, JsonSchema7>
readonly definitionPath?: string
readonly target?: Target
readonly topLevelReferenceStrategy?: TopLevelReferenceStrategy
}
) => JsonSchema7
Added in v3.11.5
make
Signature
export declare const make: <A, I, R>(schema: Schema.Schema<A, I, R>) => JsonSchema7Root
Added in v3.10.0
model
JsonSchema7 (type alias)
Signature
export type JsonSchema7 =
| JsonSchema7Never
| JsonSchema7Any
| JsonSchema7Unknown
| JsonSchema7Void
| JsonSchema7object
| JsonSchema7empty
| JsonSchema7Ref
| JsonSchema7String
| JsonSchema7Number
| JsonSchema7Integer
| JsonSchema7Boolean
| JsonSchema7Array
| JsonSchema7Enum
| JsonSchema7Enums
| JsonSchema7AnyOf
| JsonSchema7Object
Added in v3.10.0
JsonSchema7Any (interface)
Signature
export interface JsonSchema7Any extends JsonSchemaAnnotations {
$id: "/schemas/any"
}
Added in v3.10.0
JsonSchema7AnyOf (interface)
Signature
export interface JsonSchema7AnyOf extends JsonSchemaAnnotations {
anyOf: Array<JsonSchema7>
}
Added in v3.10.0
JsonSchema7Array (interface)
Signature
export interface JsonSchema7Array extends JsonSchemaAnnotations {
type: "array"
items?: JsonSchema7 | Array<JsonSchema7>
minItems?: number
maxItems?: number
additionalItems?: JsonSchema7 | boolean
}
Added in v3.10.0
JsonSchema7Boolean (interface)
Signature
export interface JsonSchema7Boolean extends JsonSchemaAnnotations {
type: "boolean"
}
Added in v3.10.0
JsonSchema7Enum (interface)
Signature
export interface JsonSchema7Enum extends JsonSchemaAnnotations {
type?: "string" | "number" | "boolean"
enum: Array<AST.LiteralValue>
}
Added in v3.10.0
JsonSchema7Enums (interface)
Signature
export interface JsonSchema7Enums extends JsonSchemaAnnotations {
$comment: "/schemas/enums"
anyOf: Array<{
type: "string" | "number"
title: string
enum: [string | number]
}>
}
Added in v3.10.0
JsonSchema7Integer (interface)
Signature
export interface JsonSchema7Integer extends JsonSchema7Numeric {
type: "integer"
}
Added in v3.10.0
JsonSchema7Never (interface)
Signature
export interface JsonSchema7Never extends JsonSchemaAnnotations {
$id: "/schemas/never"
not: {}
}
Added in v3.11.5
JsonSchema7Number (interface)
Signature
export interface JsonSchema7Number extends JsonSchema7Numeric {
type: "number"
}
Added in v3.10.0
JsonSchema7Numeric (interface)
Signature
export interface JsonSchema7Numeric extends JsonSchemaAnnotations {
minimum?: number
exclusiveMinimum?: number
maximum?: number
exclusiveMaximum?: number
multipleOf?: number
allOf?: Array<{
minimum?: number
exclusiveMinimum?: number
maximum?: number
exclusiveMaximum?: number
multipleOf?: number
}>
}
Added in v3.10.0
JsonSchema7Object (interface)
Signature
export interface JsonSchema7Object extends JsonSchemaAnnotations {
type: "object"
required: Array<string>
properties: Record<string, JsonSchema7>
additionalProperties?: boolean | JsonSchema7
patternProperties?: Record<string, JsonSchema7>
propertyNames?: JsonSchema7
}
Added in v3.10.0
JsonSchema7Ref (interface)
Signature
export interface JsonSchema7Ref extends JsonSchemaAnnotations {
$ref: string
}
Added in v3.10.0
JsonSchema7Root (type alias)
Signature
export type JsonSchema7Root = JsonSchema7 & {
$schema?: string
$defs?: Record<string, JsonSchema7>
}
Added in v3.10.0
JsonSchema7String (interface)
Signature
export interface JsonSchema7String extends JsonSchemaAnnotations {
type: "string"
minLength?: number
maxLength?: number
pattern?: string
format?: string
contentMediaType?: string
allOf?: Array<{
minLength?: number
maxLength?: number
pattern?: string
}>
}
Added in v3.10.0
JsonSchema7Unknown (interface)
Signature
export interface JsonSchema7Unknown extends JsonSchemaAnnotations {
$id: "/schemas/unknown"
}
Added in v3.10.0
JsonSchema7Void (interface)
Signature
export interface JsonSchema7Void extends JsonSchemaAnnotations {
$id: "/schemas/void"
}
Added in v3.10.0
JsonSchema7empty (interface)
Signature
export interface JsonSchema7empty extends JsonSchemaAnnotations {
$id: "/schemas/{}"
anyOf: [{ type: "object" }, { type: "array" }]
}
Added in v3.10.0
JsonSchema7object (interface)
Signature
export interface JsonSchema7object extends JsonSchemaAnnotations {
$id: "/schemas/object"
anyOf: [{ type: "object" }, { type: "array" }]
}
Added in v3.10.0
JsonSchemaAnnotations (interface)
Signature
export interface JsonSchemaAnnotations {
title?: string
description?: string
default?: unknown
examples?: Array<unknown>
}
Added in v3.10.0