From 8cc6016bab0d31aedba54e390e73d0f4a82ea543 Mon Sep 17 00:00:00 2001 From: Chris Harvey Date: Fri, 1 Feb 2019 11:49:46 -0500 Subject: [PATCH] export meta-schema version types; allow `$schema` property to be string close #32249 --- types/json-schema/index.d.ts | 32 ++++++++++++++++++++++---------- 1 file changed, 22 insertions(+), 10 deletions(-) diff --git a/types/json-schema/index.d.ts b/types/json-schema/index.d.ts index 156a86c9a5..89f8d6ae9b 100644 --- a/types/json-schema/index.d.ts +++ b/types/json-schema/index.d.ts @@ -20,6 +20,15 @@ export type JSONSchema4TypeName = 'string' | 'number' | 'integer' | 'boolean' */ export type JSONSchema4Type = any[] | boolean | number | null | object | string +/** + * Meta schema + * @see https://tools.ietf.org/html/draft-handrews-json-schema-validation-01#section-5 + */ +export type JSONSchema4Version = 'http://json-schema.org/schema#' | 'http://json-schema.org/hyper-schema#' + | 'http://json-schema.org/draft-04/schema#' | 'http://json-schema.org/draft-04/hyper-schema#' + | 'http://json-schema.org/draft-03/schema#' | 'http://json-schema.org/draft-03/hyper-schema#' + | string; + /** * JSON Schema V4 * @see https://tools.ietf.org/html/draft-zyp-json-schema-04 @@ -27,10 +36,7 @@ export type JSONSchema4Type = any[] | boolean | number | null | object | string export interface JSONSchema4 { id?: string $ref?: string - $schema?: 'http://json-schema.org/schema#' | 'http://json-schema.org/hyper-schema#' - | 'http://json-schema.org/draft-04/schema#' | 'http://json-schema.org/draft-04/hyper-schema#' - | 'http://json-schema.org/draft-03/schema#' | 'http://json-schema.org/draft-03/hyper-schema#' - | string + $schema?: JSONSchema4Version /** * This attribute is a string that provides a short description of the @@ -210,6 +216,14 @@ export type JSONSchema6TypeName = 'string' | 'number' | 'integer' | 'boolean' | export type JSONSchema6Type = any[] | boolean | number | null | object | string +/** + * Meta schema + * @see https://tools.ietf.org/html/draft-handrews-json-schema-validation-01#section-5 + */ +export type JSONSchema6Version = 'http://json-schema.org/schema#' | 'http://json-schema.org/hyper-schema#' + | 'http://json-schema.org/draft-06/schema#' | 'http://json-schema.org/draft-06/hyper-schema#' + | string; + /** * JSON Schema V6 * @see https://tools.ietf.org/html/draft-wright-json-schema-validation-01 @@ -218,8 +232,7 @@ export type JSONSchema6Definition = JSONSchema6 | boolean; export interface JSONSchema6 { $id?: string $ref?: string - $schema?: 'http://json-schema.org/schema#' | 'http://json-schema.org/hyper-schema#' | - 'http://json-schema.org/draft-06/schema#' | 'http://json-schema.org/draft-06/hyper-schema#' + $schema?: JSONSchema6Version /** * Must be strictly greater than 0. @@ -504,10 +517,9 @@ export interface JSONSchema7Array extends Array {} * Meta schema * @see https://tools.ietf.org/html/draft-handrews-json-schema-validation-01#section-5 */ -export type JSONSchema7Version = 'http://json-schema.org/schema#' - | 'http://json-schema.org/hyper-schema#' - | 'http://json-schema.org/draft-07/schema#' - | 'http://json-schema.org/draft-07/hyper-schema#'; +export type JSONSchema7Version = 'http://json-schema.org/schema#' | 'http://json-schema.org/hyper-schema#' + | 'http://json-schema.org/draft-07/schema#' | 'http://json-schema.org/draft-07/hyper-schema#' + | string; /** * JSON Schema v7