Skip to content
Effect Days 2026 Get your ticket

OpenApiJsonSchema

22 exports Added in v0.69.0 Source

Encoding

make

Added in v1.0.0 Source

Signature

declare function make<A, I, R>(schema: any): Root

makeWithDefs

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;
}): JsonSchema

Model

Annotations interface

Added in v1.0.0 Source

Signature

interface Annotations {
default?: unknown;
description?: string;
examples?: Array<unknown>;
title?: string;
}

Any interface

Added in v1.0.0 Source

Signature

interface Any extends Annotations {
$id: "/schemas/any";
}

AnyObject interface

Added in v0.71.0 Source

Signature

interface AnyObject extends Annotations {
$id: "/schemas/object";
anyOf: [{
type: "object";
}, {
type: "array";
}];
nullable?: boolean;
}

AnyOf interface

Added in v1.0.0 Source

Signature

interface AnyOf extends Annotations {
anyOf: Array<JsonSchema>;
nullable?: boolean;
}

Array interface

Added in v1.0.0 Source

Signature

interface Array extends Annotations {
additionalItems?: boolean | JsonSchema;
items?: JsonSchema | Array<JsonSchema>;
maxItems?: number;
minItems?: number;
nullable?: boolean;
type: "array";
}

Boolean interface

Added in v1.0.0 Source

Signature

interface Boolean extends Annotations {
nullable?: boolean;
type: "boolean";
}

Empty interface

Added in v0.71.0 Source

Signature

interface Empty extends Annotations {
$id: "/schemas/%7B%7D";
anyOf: [{
type: "object";
}, {
type: "array";
}];
nullable?: boolean;
}

Enum interface

Added in v1.0.0 Source

Signature

interface Enum extends Annotations {
enum: Array<string | number | boolean | null>;
nullable?: boolean;
type?: "string" | "number" | "boolean";
}

Enums interface

Added in v0.71.0 Source

Signature

interface Enums extends Annotations {
$comment: "/schemas/enums";
anyOf: Array<{
enum: [string | number];
title: string;
type: "string" | "number";
}>;
nullable?: boolean;
}

Integer interface

Added in v1.0.0 Source

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 | Object

Never interface

Added in v1.0.0 Source

Signature

interface Never extends Annotations {
$id: "/schemas/never";
not: {};
nullable?: boolean;
}

Number interface

Added in v1.0.0 Source

Signature

interface Number extends Numeric {
type: "number";
}

Numeric interface

Added in v1.0.0 Source

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;
}

Object interface

Added in v1.0.0 Source

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";
}

Ref interface

Added in v1.0.0 Source

Signature

interface Ref extends Annotations {
$ref: string;
nullable?: boolean;
}

Root type

Added in v1.0.0 Source

Signature

type Root = JsonSchema & {
$defs?: Record<string, JsonSchema>;
}

String interface

Added in v1.0.0 Source

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";
}

Unknown interface

Added in v1.0.0 Source

Signature

interface Unknown extends Annotations {
$id: "/schemas/unknown";
}

Void interface

Added in v0.69.0 Source

Signature

interface Void extends Annotations {
$id: "/schemas/void";
}