OpenApiJsonSchema
Encoding
Signature
declare function make<A, I, R>(schema: any): RootmakeWithDefs
Added in v1.0.0
Source
Creates a schema with additional options and definitions.
Options
defs: A record of definitions that are included in the schema.defsPath: The path to the definitions within the schema (defaults to "#/$defs/").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.
additionalPropertiesStrategy: Controls the handling of additional properties. Possible values are:"strict": Disallow additional properties (default behavior)."allow": Allow additional properties.
Signature
declare function makeWithDefs<A, I, R>(schema: any, options: { readonly additionalPropertiesStrategy?: AdditionalPropertiesStrategy; readonly defs: Record<string, any>; readonly defsPath?: string; readonly topLevelReferenceStrategy?: TopLevelReferenceStrategy;}): JsonSchemaModel
Annotations interface
Added in v1.0.0
Source
Signature
interface Annotations { default?: unknown; description?: string; examples?: Array<unknown>; title?: string;}Signature
interface Any extends Annotations { $id: "/schemas/any";}Signature
interface AnyObject extends Annotations { $id: "/schemas/object"; anyOf: [{ type: "object"; }, { type: "array"; }]; nullable?: boolean;}Signature
interface AnyOf extends Annotations { anyOf: Array<JsonSchema>; nullable?: boolean;}Signature
interface Array extends Annotations { additionalItems?: boolean | JsonSchema; items?: JsonSchema | Array<JsonSchema>; maxItems?: number; minItems?: number; nullable?: boolean; type: "array";}Signature
interface Boolean extends Annotations { nullable?: boolean; type: "boolean";}Signature
interface Empty extends Annotations { $id: "/schemas/%7B%7D"; anyOf: [{ type: "object"; }, { type: "array"; }]; nullable?: boolean;}Signature
interface Enum extends Annotations { enum: Array<string | number | boolean | null>; nullable?: boolean; type?: "string" | "number" | "boolean";}Signature
interface Enums extends Annotations { $comment: "/schemas/enums"; anyOf: Array<{ enum: [string | number]; title: string; type: "string" | "number"; }>; nullable?: boolean;}Signature
interface Integer extends Numeric { type: "integer";}JsonSchema type
Added in v0.71.0
Source
Signature
type JsonSchema = Never | Any | Unknown | Void | AnyObject | Empty | Ref | String | Number | Integer | Boolean | Array | Enum | Enums | AnyOf | ObjectSignature
interface Never extends Annotations { $id: "/schemas/never"; not: {}; nullable?: boolean;}Signature
interface Number extends Numeric { type: "number";}Signature
interface Numeric extends Annotations { allOf?: Array<{ exclusiveMaximum?: number; exclusiveMinimum?: number; maximum?: number; minimum?: number; multipleOf?: number; }>; exclusiveMaximum?: number; exclusiveMinimum?: number; format?: string; maximum?: number; minimum?: number; multipleOf?: number; nullable?: boolean;}Signature
interface Object extends Annotations { additionalProperties?: boolean | JsonSchema; nullable?: boolean; patternProperties?: Record<string, JsonSchema>; properties: Record<string, JsonSchema>; propertyNames?: JsonSchema; required: Array<string>; type: "object";}Signature
interface Ref extends Annotations { $ref: string; nullable?: boolean;}Signature
type Root = JsonSchema & { $defs?: Record<string, JsonSchema>;}Signature
interface String extends Annotations { allOf?: Array<{ maxLength?: number; minLength?: number; pattern?: string; }>; contentMediaType?: string; contentSchema?: JsonSchema; format?: string; maxLength?: number; minLength?: number; nullable?: boolean; pattern?: string; type: "string";}Signature
interface Unknown extends Annotations { $id: "/schemas/unknown";}Signature
interface Void extends Annotations { $id: "/schemas/void";}