Skip to content

Instantly share code, notes, and snippets.

@ctgardner
Created February 27, 2018 03:55
Show Gist options
  • Save ctgardner/41a663df35c12160af314d02d856b4d7 to your computer and use it in GitHub Desktop.
Save ctgardner/41a663df35c12160af314d02d856b4d7 to your computer and use it in GitHub Desktop.
JSON Schema Flow type
/*
Shamelessly stolen from https://github.com/tdegrunt/jsonschema/issues/184#issue-173862957 and improved by @micheal-hill
DISCLAIMER: Use at own risk.
*/
type JsonSchema = {|
+id?: string;
+$schema?: string;
+title?: string;
+description?: string;
+multipleOf?: number;
+maximum?: number;
+exclusiveMaximum?: boolean;
+minimum?: number;
+exclusiveMinimum?: boolean;
+maxLength?: number;
+minLength?: number;
+pattern?: string;
+additionalItems?: boolean | JsonSchema;
+items?: JsonSchema | JsonSchema[];
+maxItems?: number;
+minItems?: number;
+uniqueItems?: boolean;
+maxProperties?: number;
+minProperties?: number;
+required?: string[];
+additionalProperties?: boolean | JsonSchema;
+definitions?: {
[name: string]: JsonSchema
};
+properties?: {
[name: string]: JsonSchema
};
+patternProperties?: {
[name: string]: JsonSchema
};
+dependencies?: {
[name: string]: JsonSchema | string[]
};
+enum?: any[];
+type?: string | string[];
+allOf?: JsonSchema[];
+anyOf?: JsonSchema[];
+oneOf?: JsonSchema[];
+not?: JsonSchema;
|};
export type { JsonSchema };
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment