Interface: JSONSchema
A JSON Schema (drafts 04 to 2020-12), or an OpenAPI 3.0/3.1 schema object (the schemas of the property maps are objects: a boolean schema can be written as {} or {not: {}}). Returned by toJsonSchema() and DTO.toJsonSchema(), accepted by fromJsonSchema() and DTO.fromJsonSchema(). The keywords not listed (the extensions, x-...) are allowed as well.
Indexable
[
keyword:string]:unknown
Properties
$anchor?
optional$anchor?:string
A plain name identifying the schema in its document, which a reference reaches as #name (draft 2019-09 and later).
$comment?
optional$comment?:string
A comment for the schema maintainers, ignored by the validation.
$defs?
optional$defs?:Record<string,JSONSchema>
The reusable schemas, by name, which the references reach as #/$defs/<name> (draft 2019-09 and later).
$dynamicAnchor?
optional$dynamicAnchor?:string
A name which the $dynamicRef references resolve to dynamically (draft 2020-12).
$dynamicRef?
optional$dynamicRef?:string
A reference resolved in the dynamic scope of the validation, to the $dynamicAnchor of the same name (draft 2020-12).
$id?
optional$id?:string
The URI identifying the schema, which the references ($ref) of other schemas can point to (drafts 06 and later).
$recursiveAnchor?
optional$recursiveAnchor?:boolean
Whether the schema is a target of the $recursiveRef references (draft 2019-09).
$recursiveRef?
optional$recursiveRef?:string
A reference resolved in the dynamic scope of the validation, to the schemas marked with $recursiveAnchor (draft 2019-09).
$ref?
optional$ref?:string
A reference to another schema, by URI or JSON pointer (#/$defs/User), which the value must match too.
$schema?
optional$schema?:string
The URI of the JSON Schema version (dialect) the schema is written in, like https://json-schema.org/draft/2020-12/schema.
additionalItems?
optionaladditionalItems?:JSONSchemaDefinition
The schema of the items following the ones items lists as an array (drafts 04 to 2019-09).
additionalProperties?
optionaladditionalProperties?:JSONSchemaDefinition
The schema of the properties neither properties nor patternProperties list; false forbids them.
allOf?
optionalallOf?:JSONSchemaDefinition[]
The schemas the value must all match.
anyOf?
optionalanyOf?:JSONSchemaDefinition[]
The schemas the value must match at least one of.
const?
optionalconst?:unknown
The only value allowed.
contains?
optionalcontains?:JSONSchemaDefinition
A schema at least one item of an array value must match (minContains and maxContains change the count).
contentEncoding?
optionalcontentEncoding?:string
The encoding of the content of a string value, like base64.
contentMediaType?
optionalcontentMediaType?:string
The media type of the content of a string value, like application/json.
default?
optionaldefault?:unknown
The value used when it is missing (a schema imported by fromJsonSchema() applies it).
definitions?
optionaldefinitions?:Record<string,JSONSchema>
The reusable schemas, by name, which the references reach as #/definitions/<name> (drafts 04 to 07).
dependencies?
optionaldependencies?:Record<string,JSONSchema|string[]>
By property name: when the property is present, the properties listed must be too, or the object must match the schema (drafts 04 to 07, split into dependentRequired and dependentSchemas in draft 2019-09).
dependentRequired?
optionaldependentRequired?:Record<string,string[]>
By property name: the properties an object value must have when it has that property (draft 2019-09 and later).
dependentSchemas?
optionaldependentSchemas?:Record<string,JSONSchema>
By property name: the schema an object value must match when it has that property (draft 2019-09 and later).
deprecated?
optionaldeprecated?:boolean
Whether the value should not be used any more (draft 2019-09 and later, OpenAPI).
Default
falsedescription?
optionaldescription?:string
A description of the value, for documentation.
else?
optionalelse?:JSONSchemaDefinition
The schema a value not matching if must match.
enum?
optionalenum?:unknown[]
The only values allowed.
example?
optionalexample?:unknown
An example value, for documentation (OpenAPI).
examples?
optionalexamples?:unknown[]
Example values, for documentation.
exclusiveMaximum?
optionalexclusiveMaximum?:number|boolean
The limit a numeric value must be lower than (a number from draft 06), or in draft 04 and OpenAPI 3.0 whether maximum is exclusive (a boolean).
exclusiveMinimum?
optionalexclusiveMinimum?:number|boolean
The limit a numeric value must be greater than (a number from draft 06), or in draft 04 and OpenAPI 3.0 whether minimum is exclusive (a boolean).
format?
optionalformat?:string
The format of a string value: date-time, email, uri, uuid, ipv4…
id?
optionalid?:string
The URI identifying the schema in draft 04 (replaced by $id in the later drafts).
if?
optionalif?:JSONSchemaDefinition
A condition: a value matching it must match then, the others else (draft 07 and later).
items?
optionalitems?:JSONSchemaDefinition|JSONSchemaDefinition[]
The schema of every item of an array value; an array of schemas lists the schemas of the first items (drafts 04 to 2019-09, replaced by prefixItems in draft 2020-12).
maxContains?
optionalmaxContains?:number
The maximum number of items matching contains (draft 2019-09 and later).
maximum?
optionalmaximum?:number
The largest numeric value allowed (inclusive).
maxItems?
optionalmaxItems?:number
The maximum number of items of an array value.
maxLength?
optionalmaxLength?:number
The maximum length of a string value, in characters (Unicode code points).
maxProperties?
optionalmaxProperties?:number
The maximum number of properties of an object value.
minContains?
optionalminContains?:number
The minimum number of items matching contains (draft 2019-09 and later).
Default
1minimum?
optionalminimum?:number
The smallest numeric value allowed (inclusive).
minItems?
optionalminItems?:number
The minimum number of items of an array value.
minLength?
optionalminLength?:number
The minimum length of a string value, in characters (Unicode code points).
minProperties?
optionalminProperties?:number
The minimum number of properties of an object value.
multipleOf?
optionalmultipleOf?:number
The number a numeric value must be a multiple of (greater than 0).
not?
optionalnot?:JSONSchemaDefinition
A schema the value must not match.
nullable?
optionalnullable?:boolean
Whether the value may be null as well as of its type (OpenAPI 3.0; the later versions add null to type).
Default
falseoneOf?
optionaloneOf?:JSONSchemaDefinition[]
The schemas the value must match exactly one of.
pattern?
optionalpattern?:string
The regular expression (ECMA 262) a string value must match, anywhere in the string unless anchored.
patternProperties?
optionalpatternProperties?:Record<string,JSONSchema>
The schemas of the properties whose name matches a regular expression, by regular expression.
prefixItems?
optionalprefixItems?:JSONSchemaDefinition[]
The schemas of the first items of an array value, in order (draft 2020-12).
properties?
optionalproperties?:Record<string,JSONSchema>
The schemas of the properties of an object value, by property name.
propertyNames?
optionalpropertyNames?:JSONSchemaDefinition
The schema every property name of an object value must match.
readOnly?
optionalreadOnly?:boolean
Whether the value is managed by its owner and is ignored when sent to it.
Default
falserequired?
optionalrequired?:string[]
The names of the properties an object value must have.
then?
optionalthen?:JSONSchemaDefinition
The schema a value matching if must match.
title?
optionaltitle?:string
A short title of the value, for documentation.
type?
optionaltype?:JSONSchemaTypeName|JSONSchemaTypeName[]
The type of the value, or the types it may have.
unevaluatedItems?
optionalunevaluatedItems?:JSONSchemaDefinition
The schema of the array items no other keyword evaluated (draft 2019-09 and later).
unevaluatedProperties?
optionalunevaluatedProperties?:JSONSchemaDefinition
The schema of the properties no other keyword evaluated (draft 2019-09 and later).
uniqueItems?
optionaluniqueItems?:boolean
Whether the items of an array value must all be different.
Default
falsewriteOnly?
optionalwriteOnly?:boolean
Whether the value is only sent to its owner and never returned by it (a password).
Default
false