Skip to content

Instantly share code, notes, and snippets.

Created June 18, 2019 03:11
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
Flow type description of JSON Schema (WIP)
/* @flow */
type NonNegativeInt = number
type PositiveNumber = number
type Regex = string
type SchemaType = {
description?: string,
type SchemaObject = {
type: "object",
maxProperties?: NonNegativeInt,
minProperties?: NonNegativeInt,
required?: string[],
properties: {[string]: Schema},
patternProperties?: {[Regex]: Schema},
additionalProperties?: Schema,
type SchemaArray = {
type: "array",
items?: Schema | Schema[],
additionalItems?: Schema,
maxItems?: NonNegativeInt,
minItems?: NonNegativeInt,
uniqueItems?: boolean,
contains?: Schema,
type SchemaString = {
type: "string",
maxLength?: NonNegativeInt,
minLength?: NonNegativeInt,
pattern?: Regex,
type SchemaNumber = {
type: "number",
multipleOf?: PositiveNumber,
maximum?: number,
exclusiveMaximum?: number,
minimum?: number,
exclusiveMinimum?: number,
type SchemaBoolean = {
type: "boolean"
type SchemaNull = {
type: "null"
type Schema =
| SchemaObject
| SchemaArray
| SchemaString
| SchemaNumber
| SchemaBoolean
| SchemaNull
type SchemaRoot = {
"$schema": string,
"$id": string,
title: string,
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment