Skip to content

Instantly share code, notes, and snippets.

@inca
Created July 17, 2020 12:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save inca/6ca5935424fc8cf819abb3d7741b1b27 to your computer and use it in GitHub Desktop.
Save inca/6ca5935424fc8cf819abb3d7741b1b27 to your computer and use it in GitHub Desktop.
JSON Schema Loose Type Annotations
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