Created
July 17, 2020 12:40
-
-
Save inca/6ca5935424fc8cf819abb3d7741b1b27 to your computer and use it in GitHub Desktop.
JSON Schema Loose Type Annotations
This file contains hidden or 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
export type JsonSchemaTypePrimitive = 'null' | 'string' | 'number' | 'integer' | 'boolean' | 'array' | 'object'; | |
export type JsonSchemaType = JsonSchemaTypePrimitive | JsonSchemaTypePrimitive[]; | |
export interface JsonSchema { | |
type?: JsonSchemaType; | |
// number | |
minimum?: number; | |
maximum?: number; | |
exclusiveMinimum?: number; | |
exclusiveMaximum?: number; | |
multipleOf?: number; | |
// string | |
minLength?: number; | |
maxLength?: number; | |
pattern?: string; | |
format?: string; | |
// array | |
minItems?: number; | |
maxItems?: number; | |
uniqueItems?: number; | |
items?: JsonSchema | JsonSchema[]; | |
additionalItems?: boolean | JsonSchema; | |
contains?: JsonSchema; | |
// object | |
minProperties?: number; | |
maxProperties?: number; | |
required?: string[]; | |
properties?: { [key: string]: JsonSchema }; | |
patternProperties?: { [key: string]: JsonSchema }; | |
additionalProperties?: boolean | JsonSchema; | |
propertyNames?: JsonSchema; | |
// any | |
enum?: any[]; | |
const?: any; | |
// compound | |
not?: JsonSchema; | |
oneOf?: JsonSchema[]; | |
anyOf?: JsonSchema[]; | |
allOf?: JsonSchema[]; | |
if?: JsonSchema[]; | |
then?: JsonSchema[]; | |
else?: JsonSchema[]; | |
// misc | |
[key: string]: any; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment