Created
June 18, 2019 03:11
-
-
Save yawaramin/cb2a1f203114f825c610bd6025261154 to your computer and use it in GitHub Desktop.
Flow type description of JSON Schema (WIP)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* @flow */ | |
type NonNegativeInt = number | |
type PositiveNumber = number | |
type Regex = string | |
type SchemaType = { | |
description?: string, | |
} | |
type SchemaObject = { | |
...SchemaType, | |
type: "object", | |
maxProperties?: NonNegativeInt, | |
minProperties?: NonNegativeInt, | |
required?: string[], | |
properties: {[string]: Schema}, | |
patternProperties?: {[Regex]: Schema}, | |
additionalProperties?: Schema, | |
} | |
type SchemaArray = { | |
...SchemaType, | |
type: "array", | |
items?: Schema | Schema[], | |
additionalItems?: Schema, | |
maxItems?: NonNegativeInt, | |
minItems?: NonNegativeInt, | |
uniqueItems?: boolean, | |
contains?: Schema, | |
} | |
type SchemaString = { | |
...SchemaType, | |
type: "string", | |
maxLength?: NonNegativeInt, | |
minLength?: NonNegativeInt, | |
pattern?: Regex, | |
} | |
type SchemaNumber = { | |
...SchemaType, | |
type: "number", | |
multipleOf?: PositiveNumber, | |
maximum?: number, | |
exclusiveMaximum?: number, | |
minimum?: number, | |
exclusiveMinimum?: number, | |
} | |
type SchemaBoolean = { | |
...SchemaType, | |
type: "boolean" | |
} | |
type SchemaNull = { | |
...SchemaType, | |
type: "null" | |
} | |
type Schema = | |
| SchemaObject | |
| SchemaArray | |
| SchemaString | |
| SchemaNumber | |
| SchemaBoolean | |
| SchemaNull | |
type SchemaRoot = { | |
...Schema, | |
"$schema": string, | |
"$id": string, | |
title: string, | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment