jsonschema.d.ts 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. /**
  2. * Primitive type
  3. * @see https://tools.ietf.org/html/draft-handrews-json-schema-validation-01#section-6.1.1
  4. */
  5. export type JSONSchemaTypeName = ({} & string) | 'string' | 'number' | 'integer' | 'boolean' | 'object' | 'array' | 'null';
  6. /**
  7. * Primitive type
  8. * @see https://tools.ietf.org/html/draft-handrews-json-schema-validation-01#section-6.1.1
  9. */
  10. export type JSONSchemaType = string | number | boolean | JSONSchemaObject | JSONSchemaArray | null;
  11. export interface JSONSchemaObject {
  12. [key: string]: JSONSchemaType;
  13. }
  14. export interface JSONSchemaArray extends Array<JSONSchemaType> {
  15. }
  16. /**
  17. * Meta schema
  18. *
  19. * Recommended values:
  20. * - 'http://json-schema.org/schema#'
  21. * - 'http://json-schema.org/hyper-schema#'
  22. * - 'http://json-schema.org/draft-07/schema#'
  23. * - 'http://json-schema.org/draft-07/hyper-schema#'
  24. *
  25. * @see https://tools.ietf.org/html/draft-handrews-json-schema-validation-01#section-5
  26. */
  27. export type JSONSchemaVersion = string;
  28. /**
  29. * JSON Schema v7
  30. * @see https://tools.ietf.org/html/draft-handrews-json-schema-validation-01
  31. */
  32. export type JSONSchemaDefinition = JSONSchema | boolean;
  33. export interface JSONSchema {
  34. $id?: string | undefined;
  35. $comment?: string | undefined;
  36. /**
  37. * @see https://tools.ietf.org/html/draft-handrews-json-schema-validation-01#section-6.1
  38. */
  39. type?: JSONSchemaTypeName | JSONSchemaTypeName[] | undefined;
  40. enum?: JSONSchemaType[] | undefined;
  41. const?: JSONSchemaType | undefined;
  42. /**
  43. * @see https://tools.ietf.org/html/draft-handrews-json-schema-validation-01#section-6.2
  44. */
  45. multipleOf?: number | undefined;
  46. maximum?: number | undefined;
  47. exclusiveMaximum?: number | undefined;
  48. minimum?: number | undefined;
  49. exclusiveMinimum?: number | undefined;
  50. /**
  51. * @see https://tools.ietf.org/html/draft-handrews-json-schema-validation-01#section-6.3
  52. */
  53. maxLength?: number | undefined;
  54. minLength?: number | undefined;
  55. pattern?: string | undefined;
  56. /**
  57. * @see https://tools.ietf.org/html/draft-handrews-json-schema-validation-01#section-6.4
  58. */
  59. items?: JSONSchemaDefinition | JSONSchemaDefinition[] | undefined;
  60. additionalItems?: JSONSchemaDefinition | undefined;
  61. maxItems?: number | undefined;
  62. minItems?: number | undefined;
  63. uniqueItems?: boolean | undefined;
  64. contains?: JSONSchemaDefinition | undefined;
  65. /**
  66. * @see https://tools.ietf.org/html/draft-handrews-json-schema-validation-01#section-6.5
  67. */
  68. maxProperties?: number | undefined;
  69. minProperties?: number | undefined;
  70. required?: string[] | undefined;
  71. properties?: {
  72. [key: string]: JSONSchemaDefinition;
  73. } | undefined;
  74. patternProperties?: {
  75. [key: string]: JSONSchemaDefinition;
  76. } | undefined;
  77. additionalProperties?: JSONSchemaDefinition | undefined;
  78. propertyNames?: JSONSchemaDefinition | undefined;
  79. /**
  80. * @see https://tools.ietf.org/html/draft-handrews-json-schema-validation-01#section-6.6
  81. */
  82. if?: JSONSchemaDefinition | undefined;
  83. then?: JSONSchemaDefinition | undefined;
  84. else?: JSONSchemaDefinition | undefined;
  85. /**
  86. * @see https://tools.ietf.org/html/draft-handrews-json-schema-validation-01#section-6.7
  87. */
  88. allOf?: JSONSchemaDefinition[] | undefined;
  89. anyOf?: JSONSchemaDefinition[] | undefined;
  90. oneOf?: JSONSchemaDefinition[] | undefined;
  91. not?: JSONSchemaDefinition | undefined;
  92. /**
  93. * @see https://tools.ietf.org/html/draft-handrews-json-schema-validation-01#section-7
  94. */
  95. format?: string | undefined;
  96. /**
  97. * @see https://tools.ietf.org/html/draft-handrews-json-schema-validation-01#section-10
  98. */
  99. title?: string | undefined;
  100. description?: string | undefined;
  101. default?: JSONSchemaType | undefined;
  102. readOnly?: boolean | undefined;
  103. writeOnly?: boolean | undefined;
  104. examples?: JSONSchemaType | undefined;
  105. }
  106. //# sourceMappingURL=jsonschema.d.ts.map