|
| 1 | +interface CommonSchema< |
| 2 | + SchemaType, |
| 3 | + MappedTypeScriptType, |
| 4 | + LogicSubschema, |
| 5 | +> { |
| 6 | + allOf?: Array<LogicSubschema>, |
| 7 | + anyOf?: Array<LogicSubschema>, |
| 8 | + const?: MappedTypeScriptType, |
| 9 | + default?: MappedTypeScriptType, |
| 10 | + deprecated?: boolean, |
| 11 | + description?: string, |
| 12 | + enum?: Array<MappedTypeScriptType>, |
| 13 | + examples?: Array<MappedTypeScriptType>, |
| 14 | + not?: LogicSubschema, |
| 15 | + oneOf?: Array<LogicSubschema>, |
| 16 | + readOnly?: boolean, |
| 17 | + title?: string, |
| 18 | + type?: SchemaType, |
| 19 | + writeOnly?: boolean |
| 20 | +} |
| 21 | + |
| 22 | +export interface NullSchema extends CommonSchema<'null', null, NullSchema> { |
| 23 | +} |
| 24 | + |
| 25 | +export interface BooleanSchema extends CommonSchema<'boolean', boolean, BooleanSchema> { |
| 26 | +} |
| 27 | + |
| 28 | +export interface StringSchema extends CommonSchema<'string', string, StringSchema> { |
| 29 | + maxLength?: number, |
| 30 | + minLength?: number, |
| 31 | + pattern?: string, |
| 32 | +} |
| 33 | + |
| 34 | +export interface NumberSchema extends CommonSchema<'number', number, NumberSchema> { |
| 35 | + exclusiveMaximum?: number, |
| 36 | + exclusiveMinimum?: number, |
| 37 | + maximum?: number, |
| 38 | + minimum?: number, |
| 39 | + multipleOf?: number, |
| 40 | +} |
| 41 | + |
| 42 | +export interface IntegerSchema extends CommonSchema<'integer', number, IntegerSchema> { |
| 43 | + exclusiveMaximum?: number, |
| 44 | + exclusiveMinimum?: number, |
| 45 | + maximum?: number, |
| 46 | + minimum?: number, |
| 47 | + multipleOf?: number, |
| 48 | +} |
| 49 | + |
| 50 | +export interface ArraySchema extends CommonSchema<'array', Array<any>, ArraySchema> { |
| 51 | + contains?: JsonSchema, |
| 52 | + items?: JsonSchema, |
| 53 | + maxContains?: number, |
| 54 | + maxItems?: number, |
| 55 | + minContains?: number, |
| 56 | + minItems?: number, |
| 57 | + prefixItems?: Array<JsonSchema>, |
| 58 | + uniqueItems?: boolean |
| 59 | +} |
| 60 | + |
| 61 | +export interface ObjectSchema extends CommonSchema<'object', Record<string, any>, ObjectSchema> { |
| 62 | + additionalProperties?: JsonSchema, |
| 63 | + dependentRequired?: Record<string, Array<string>>, |
| 64 | + maxProperties?: number, |
| 65 | + minProperties?: number, |
| 66 | + patternProperties?: { [propertyNameRegex: string]: JsonSchema }, |
| 67 | + properties?: { [propertyName: string]: JsonSchema }, |
| 68 | + propertyNames?: JsonSchema, |
| 69 | + required?: Array<string>, |
| 70 | +} |
| 71 | + |
| 72 | +type CommonProperties = keyof CommonSchema<any, any, any>; |
| 73 | + |
| 74 | +export interface AnySchema extends Omit<NullSchema, CommonProperties>, |
| 75 | + Omit<BooleanSchema, CommonProperties>, |
| 76 | + Omit<StringSchema, CommonProperties>, |
| 77 | + Omit<NumberSchema, CommonProperties>, |
| 78 | + Omit<IntegerSchema, CommonProperties>, |
| 79 | + Omit<ArraySchema, CommonProperties>, |
| 80 | + Omit<ObjectSchema, CommonProperties>, |
| 81 | + CommonSchema<undefined | Array<'string' | 'integer' | 'number' | 'array' | 'object' | 'boolean' | 'null'>, any, JsonSchema> { |
| 82 | +} |
| 83 | + |
| 84 | +export type JsonSchema = NullSchema | BooleanSchema | StringSchema | NumberSchema | IntegerSchema | ArraySchema | ObjectSchema | AnySchema; |
0 commit comments