json-schema.d.ts 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. type JsonSchema = boolean | ArraySchema | ObjectSchema | NumberSchema | StringSchema;
  2. type JsonType = 'array' | 'object' | 'string' | 'number' | 'integer' | 'boolean' | 'null';
  3. interface CommonSchema {
  4. type?: JsonType | JsonType[];
  5. const?: unknown;
  6. enum?: unknown[];
  7. format?: string;
  8. allOf?: JsonSchema[];
  9. anyOf?: JsonSchema[];
  10. oneOf?: JsonSchema[];
  11. not?: JsonSchema;
  12. if?: JsonSchema;
  13. then?: JsonSchema;
  14. else?: JsonSchema;
  15. $id?: string;
  16. $defs?: Record<string, JsonSchema>;
  17. $anchor?: string;
  18. $dynamicAnchor?: string;
  19. $ref?: string;
  20. $dynamicRef?: string;
  21. $schema?: string;
  22. $vocabulary?: Record<string, boolean>;
  23. $comment?: string;
  24. default?: unknown;
  25. deprecated?: boolean;
  26. readOnly?: boolean;
  27. writeOnly?: boolean;
  28. title?: string;
  29. description?: string;
  30. examples?: unknown[];
  31. }
  32. interface ArraySchema extends CommonSchema {
  33. prefixItems?: JsonSchema[];
  34. items?: JsonSchema;
  35. contains?: JsonSchema;
  36. unevaluatedItems?: JsonSchema;
  37. maxItems?: number;
  38. minItems?: number;
  39. uniqueItems?: boolean;
  40. maxContains?: number;
  41. minContains?: number;
  42. }
  43. interface ObjectSchema extends CommonSchema {
  44. properties?: Record<string, JsonSchema>;
  45. patternProperties?: Record<string, JsonSchema>;
  46. additionalProperties?: JsonSchema;
  47. propertyNames?: JsonSchema;
  48. unevaluatedProperties?: JsonSchema;
  49. maxProperties?: number;
  50. minProperties?: number;
  51. required?: string[];
  52. dependentRequired?: Record<string, string[]>;
  53. dependentSchemas?: Record<string, JsonSchema>;
  54. }
  55. interface StringSchema extends CommonSchema {
  56. maxLength?: number;
  57. minLength?: number;
  58. patter?: string;
  59. contentEncoding?: string;
  60. contentMediaType?: string;
  61. contentSchema?: JsonSchema;
  62. }
  63. interface NumberSchema extends CommonSchema {
  64. multipleOf?: number;
  65. maximum?: number;
  66. exclusiveMaximum?: number;
  67. minimum?: number;
  68. exclusiveMinimum?: number;
  69. }