Skip to main content
Module

x/fun/json_schema.ts

A collection of algebraic data types, lenses, and schemables based on a light weight higher kinded type implementation. Written for deno.
Latest
import * as fun from "https://deno.land/x/fun@v2.0.0/json_schema.ts";

JsonSchema contains a set of combinators to build a subset of JSON Schema in typescript. It also includes an instance of Schemable that is useful for describing a Schema to an external system.

Functions

Creates a JsonBuilder of an Array with values that match the supplied JsonBuilder

Creates a JsonBuilder of an boolean type

Creates a JsonBuilder of an date type

Creates a JsonBuilder that intersects two JsonBuilders

Creates a lazy JsonBuilder, which is useful for creating recursive JSON Schemas, mutual or otherwise. A limitation of typescript means that the type must be defined outside of the JsonBuilder and manually annotated

Creates a JsonBuilder over a tuple of literals

Creates a JsonBuilder that makes the given builder nullable

Creates a JsonBuilder of an number type

Creates a JsonBuilder of a partial with values and keys that match the supplied JsonBuilders

Collapse a JsonBuilder into a JsonSchema that can be logged or used as output for a webserver or a file.

Creates a JsonBuilder of a Record with string keys and values that match the supplied JsonBuilder

Creates a JsonBuilder of an string type

Creates a JsonBuilder of a struct with values and keys that match the supplied JsonBuilders

Creates a JsonBuilder of a tuple with values that match the supplied JsonBuilders

Creates a JsonBuilder that makes the given builder undefinable

Creates a JsonBuilder that unions two JsonBuilders

Creates a JsonBuilder of an unknown type

Interfaces

The Kind substitution scheme for JsonBuilder.

Type Aliases

JsonBuilder is a wrapper over State, used to construct a JsonSchema combinator by combinator. In this way it can also be used as a Schemable to create a JsonSchema that matches a Decoder.

Represents a recursive JSON Schema

Represents an intersection of Schemas in JSON Schema

Represents a union of Schemas in JSON Schema

Represents an array or tuple in JSON Schema

Represents boolean in JSON Schema

Represents string Date in JSON Schema

Represents a collection of Schemas that can be referenced by a $ref in JSON Schema

Represents null in JSON Schema

Represents null in JSON Schema

Represents number(float or integer) in JSON Schema

Represents a struct in JSON Schema

Represents an exclusive union of Schemas in JSON Schema

Represents a reference to another Schema in JSON Schema, generally useful for recursion or brevity.

Represents string in JSON Schema

Represents an unknown JSON Schema

Given a JsonBuilder this type will unwrap T for use in type level programming.