import { JSONSchema4, JSONSchema4TypeName } from 'json-schema' export type SchemaType = 'ALL_OF' | 'UNNAMED_SCHEMA' | 'ANY' | 'ANY_OF' | 'BOOLEAN' | 'NAMED_ENUM' | 'NAMED_SCHEMA' | 'NULL' | 'NUMBER' | 'STRING' | 'OBJECT' | 'ONE_OF' | 'TYPED_ARRAY' | 'REFERENCE' | 'UNION' | 'UNNAMED_ENUM' | 'UNTYPED_ARRAY' | 'CUSTOM_TYPE' | 'BSON_DATE' export type JSONSchemaTypeName = JSONSchema4TypeName export interface JSONSchema extends JSONSchema4 { /** * schema extension to support numeric enums */ tsEnumNames?: string[] /** * schema extension to support custom types */ tsType?: string /** * schema extension to support BSON types used by MongoDB */ bsonType?: string } // const SCHEMA_PROPERTIES = [ // 'additionalItems', 'additionalProperties', 'items', 'definitions', // 'properties', 'patternProperties', 'dependencies', 'allOf', 'anyOf', // 'oneOf', 'not', 'required', '$schema', 'title', 'description', // ] // export function isSchema(a: any): a is SchemaSchema { // return [] // } export interface NormalizedJSONSchema extends JSONSchema { additionalItems?: boolean | NormalizedJSONSchema additionalProperties: boolean | NormalizedJSONSchema items?: NormalizedJSONSchema | NormalizedJSONSchema[] definitions?: { [k: string]: NormalizedJSONSchema } properties?: { [k: string]: NormalizedJSONSchema } patternProperties?: { [k: string]: NormalizedJSONSchema } dependencies?: { [k: string]: NormalizedJSONSchema | string[] } allOf?: NormalizedJSONSchema[] anyOf?: NormalizedJSONSchema[] oneOf?: NormalizedJSONSchema[] not?: NormalizedJSONSchema required: string[] } export interface EnumJSONSchema extends NormalizedJSONSchema { enum: any[] } export interface NamedEnumJSONSchema extends NormalizedJSONSchema { tsEnumNames: string[] } export interface SchemaSchema extends NormalizedJSONSchema { properties: { [k: string]: NormalizedJSONSchema } required: string[] } export interface JSONSchemaWithDefinitions extends NormalizedJSONSchema { definitions: { [k: string]: NormalizedJSONSchema } } export interface CustomTypeJSONSchema extends NormalizedJSONSchema { tsType: string }