WIP converting all static strings over to draft 2020-12

This commit is contained in:
Glen Mabey 2025-01-27 11:38:07 -07:00
parent 40af3ec396
commit a244024759
97 changed files with 164 additions and 384 deletions

View File

@ -6,7 +6,7 @@
This is a C++ library for validating JSON documents based on a This is a C++ library for validating JSON documents based on a
[JSON Schema](http://json-schema.org/) which itself should validate with [JSON Schema](http://json-schema.org/) which itself should validate with
[draft-7 of JSON Schema Validation](http://json-schema.org/schema). [draft 2020-12 of JSON Schema Validation](http://json-schema.org/schema).
First a disclaimer: *It is work in progress and First a disclaimer: *It is work in progress and
contributions or hints or discussions are welcome.* contributions or hints or discussions are welcome.*
@ -24,7 +24,7 @@ Although significant changes have been done for the 2nd version
(a complete rewrite) the API is compatible with the 1.0.0 release. Except for (a complete rewrite) the API is compatible with the 1.0.0 release. Except for
the namespace which is now `nlohmann::json_schema`. the namespace which is now `nlohmann::json_schema`.
Version **2** supports JSON schema draft 7, whereas 1 was supporting draft 4 Version **2** supports JSON schema draft 2020-12, whereas 1 was supporting draft 4
only. Please update your schemas. only. Please update your schemas.
The primary change in 2 is the way a schema is used. While in version 1 the schema was The primary change in 2 is the way a schema is used. While in version 1 the schema was
@ -170,7 +170,7 @@ using nlohmann::json_schema::json_validator;
// The schema is defined based upon a string literal // The schema is defined based upon a string literal
static json person_schema = R"( static json person_schema = R"(
{ {
"$schema": "http://json-schema.org/draft-07/schema#", "$schema": "http://json-schema.org/draft/2020-12/schema",
"title": "A person", "title": "A person",
"properties": { "properties": {
"name": { "name": {
@ -314,7 +314,7 @@ using nlohmann::json_schema::json_validator;
static const json rectangle_schema = R"( static const json rectangle_schema = R"(
{ {
"$schema": "http://json-schema.org/draft-07/schema#", "$schema": "http://json-schema.org/draft/2020-12/schema",
"title": "A rectangle", "title": "A rectangle",
"properties": { "properties": {
"width": { "width": {
@ -353,7 +353,7 @@ int main()
The example above will output the specified default values `{"height":10,"width":20}` to stdout. The example above will output the specified default values `{"height":10,"width":20}` to stdout.
> Note that the default value specified in a `$ref` may be overridden by the current instance location. Also note that this behavior will break draft-7, but it is compliant to newer drafts (e.g. `2019-09` or `2020-12`). > Note that the default value specified in a `$ref` may be overridden by the current instance location. Also note that this behavior will break draft 2020-12, but it is compliant to newer drafts (e.g. `2019-09` or `2020-12`).
# Contributing # Contributing

View File

@ -8,7 +8,7 @@ using nlohmann::json_schema::json_validator;
// The schema is defined based upon a string literal // The schema is defined based upon a string literal
static json uri_schema = R"( static json uri_schema = R"(
{ {
"$schema": "http://json-schema.org/draft-07/schema#", "$schema": "http://json-schema.org/draft/2020-12/schema",
"type": "object", "type": "object",
"properties": { "properties": {
"myUri": { "myUri": {

View File

@ -9,7 +9,7 @@ using nlohmann::json_schema::json_validator;
// The schema is defined based upon a string literal // The schema is defined based upon a string literal
static json person_schema = R"( static json person_schema = R"(
{ {
"$schema": "http://json-schema.org/draft-07/schema#", "$schema": "http://json-schema.org/draft/2020-12/schema",
"title": "A person", "title": "A person",
"properties": { "properties": {
"name": { "name": {

194
schema
View File

@ -1,168 +1,58 @@
{ {
"$schema": "http://json-schema.org/draft-07/schema#", "$schema": "https://json-schema.org/draft/2020-12/schema",
"$id": "http://json-schema.org/draft-07/schema#", "$id": "https://json-schema.org/draft/2020-12/schema",
"title": "Core schema meta-schema", "$vocabulary": {
"definitions": { "https://json-schema.org/draft/2020-12/vocab/core": true,
"schemaArray": { "https://json-schema.org/draft/2020-12/vocab/applicator": true,
"type": "array", "https://json-schema.org/draft/2020-12/vocab/unevaluated": true,
"minItems": 1, "https://json-schema.org/draft/2020-12/vocab/validation": true,
"items": { "$ref": "#" } "https://json-schema.org/draft/2020-12/vocab/meta-data": true,
}, "https://json-schema.org/draft/2020-12/vocab/format-annotation": true,
"nonNegativeInteger": { "https://json-schema.org/draft/2020-12/vocab/content": true
"type": "integer",
"minimum": 0
},
"nonNegativeIntegerDefault0": {
"allOf": [
{ "$ref": "#/definitions/nonNegativeInteger" },
{ "default": 0 }
]
},
"simpleTypes": {
"enum": [
"array",
"boolean",
"integer",
"null",
"number",
"object",
"string"
]
},
"stringArray": {
"type": "array",
"items": { "type": "string" },
"uniqueItems": true,
"default": []
}
}, },
"$dynamicAnchor": "meta",
"title": "Core and Validation specifications meta-schema",
"allOf": [
{"$ref": "meta/core"},
{"$ref": "meta/applicator"},
{"$ref": "meta/unevaluated"},
{"$ref": "meta/validation"},
{"$ref": "meta/meta-data"},
{"$ref": "meta/format-annotation"},
{"$ref": "meta/content"}
],
"type": ["object", "boolean"], "type": ["object", "boolean"],
"$comment": "This meta-schema also defines keywords that have appeared in previous drafts in order to prevent incompatible extensions as they remain in common use.",
"properties": { "properties": {
"$id": {
"type": "string",
"format": "uri-reference"
},
"$schema": {
"type": "string",
"format": "uri"
},
"$ref": {
"type": "string",
"format": "uri-reference"
},
"$comment": {
"type": "string"
},
"title": {
"type": "string"
},
"description": {
"type": "string"
},
"default": true,
"readOnly": {
"type": "boolean",
"default": false
},
"examples": {
"type": "array",
"items": true
},
"multipleOf": {
"type": "number",
"exclusiveMinimum": 0
},
"maximum": {
"type": "number"
},
"exclusiveMaximum": {
"type": "number"
},
"minimum": {
"type": "number"
},
"exclusiveMinimum": {
"type": "number"
},
"maxLength": { "$ref": "#/definitions/nonNegativeInteger" },
"minLength": { "$ref": "#/definitions/nonNegativeIntegerDefault0" },
"pattern": {
"type": "string",
"format": "regex"
},
"additionalItems": { "$ref": "#" },
"items": {
"anyOf": [
{ "$ref": "#" },
{ "$ref": "#/definitions/schemaArray" }
],
"default": true
},
"maxItems": { "$ref": "#/definitions/nonNegativeInteger" },
"minItems": { "$ref": "#/definitions/nonNegativeIntegerDefault0" },
"uniqueItems": {
"type": "boolean",
"default": false
},
"contains": { "$ref": "#" },
"maxProperties": { "$ref": "#/definitions/nonNegativeInteger" },
"minProperties": { "$ref": "#/definitions/nonNegativeIntegerDefault0" },
"required": { "$ref": "#/definitions/stringArray" },
"additionalProperties": { "$ref": "#" },
"definitions": { "definitions": {
"$comment": "\"definitions\" has been replaced by \"$defs\".",
"type": "object", "type": "object",
"additionalProperties": { "$ref": "#" }, "additionalProperties": { "$dynamicRef": "#meta" },
"default": {} "deprecated": true,
},
"properties": {
"type": "object",
"additionalProperties": { "$ref": "#" },
"default": {}
},
"patternProperties": {
"type": "object",
"additionalProperties": { "$ref": "#" },
"propertyNames": { "format": "regex" },
"default": {} "default": {}
}, },
"dependencies": { "dependencies": {
"$comment": "\"dependencies\" has been split and replaced by \"dependentSchemas\" and \"dependentRequired\" in order to serve their differing semantics.",
"type": "object", "type": "object",
"additionalProperties": { "additionalProperties": {
"anyOf": [ "anyOf": [
{ "$ref": "#" }, { "$dynamicRef": "#meta" },
{ "$ref": "#/definitions/stringArray" } { "$ref": "meta/validation#/$defs/stringArray" }
] ]
} },
"deprecated": true,
"default": {}
}, },
"propertyNames": { "$ref": "#" }, "$recursiveAnchor": {
"const": true, "$comment": "\"$recursiveAnchor\" has been replaced by \"$dynamicAnchor\".",
"enum": { "$ref": "meta/core#/$defs/anchorString",
"type": "array", "deprecated": true
"items": true,
"minItems": 1,
"uniqueItems": true
}, },
"type": { "$recursiveRef": {
"anyOf": [ "$comment": "\"$recursiveRef\" has been replaced by \"$dynamicRef\".",
{ "$ref": "#/definitions/simpleTypes" }, "$ref": "meta/core#/$defs/uriReferenceString",
{ "deprecated": true
"type": "array", }
"items": { "$ref": "#/definitions/simpleTypes" }, }
"minItems": 1,
"uniqueItems": true
}
]
},
"format": { "type": "string" },
"contentMediaType": { "type": "string" },
"contentEncoding": { "type": "string" },
"if": {"$ref": "#"},
"then": {"$ref": "#"},
"else": {"$ref": "#"},
"allOf": { "$ref": "#/definitions/schemaArray" },
"anyOf": { "$ref": "#/definitions/schemaArray" },
"oneOf": { "$ref": "#/definitions/schemaArray" },
"not": { "$ref": "#" }
},
"default": true
} }

View File

@ -1,6 +1,6 @@
target_sources(nlohmann_json_schema_validator PRIVATE target_sources(nlohmann_json_schema_validator PRIVATE
smtp-address-validator.cpp smtp-address-validator.cpp
json-schema-draft7.json.cpp json-schema-draft_2020-12.json.cpp
json-uri.cpp json-uri.cpp
json-validator.cpp json-validator.cpp
json-patch.cpp json-patch.cpp

View File

@ -9,7 +9,7 @@ namespace
// with fixes // with fixes
const nlohmann::json patch_schema = R"patch({ const nlohmann::json patch_schema = R"patch({
"title": "JSON schema for JSONPatch files", "title": "JSON schema for JSONPatch files",
"$schema": "http://json-schema.org/draft-04/schema#", "$schema": "http://json-schema.org/draft/2020-12/schema",
"type": "array", "type": "array",
"items": { "items": {

View File

@ -1,185 +0,0 @@
/*
* JSON schema validator for JSON for modern C++
*
* Copyright (c) 2016-2019 Patrick Boettcher <p@yai.se>.
*
* SPDX-License-Identifier: MIT
*
*/
#include <nlohmann/json.hpp>
namespace nlohmann
{
namespace json_schema
{
json draft7_schema_builtin = R"( {
"$schema": "http://json-schema.org/draft-07/schema#",
"$id": "http://json-schema.org/draft-07/schema#",
"title": "Core schema meta-schema",
"definitions": {
"schemaArray": {
"type": "array",
"minItems": 1,
"items": { "$ref": "#" }
},
"nonNegativeInteger": {
"type": "integer",
"minimum": 0
},
"nonNegativeIntegerDefault0": {
"allOf": [
{ "$ref": "#/definitions/nonNegativeInteger" },
{ "default": 0 }
]
},
"simpleTypes": {
"enum": [
"array",
"boolean",
"integer",
"null",
"number",
"object",
"string"
]
},
"stringArray": {
"type": "array",
"items": { "type": "string" },
"uniqueItems": true,
"default": []
}
},
"type": ["object", "boolean"],
"properties": {
"$id": {
"type": "string",
"format": "uri-reference"
},
"$schema": {
"type": "string",
"format": "uri"
},
"$ref": {
"type": "string",
"format": "uri-reference"
},
"$comment": {
"type": "string"
},
"title": {
"type": "string"
},
"description": {
"type": "string"
},
"default": true,
"readOnly": {
"type": "boolean",
"default": false
},
"examples": {
"type": "array",
"items": true
},
"multipleOf": {
"type": "number",
"exclusiveMinimum": 0
},
"maximum": {
"type": "number"
},
"exclusiveMaximum": {
"type": "number"
},
"minimum": {
"type": "number"
},
"exclusiveMinimum": {
"type": "number"
},
"maxLength": { "$ref": "#/definitions/nonNegativeInteger" },
"minLength": { "$ref": "#/definitions/nonNegativeIntegerDefault0" },
"pattern": {
"type": "string",
"format": "regex"
},
"additionalItems": { "$ref": "#" },
"items": {
"anyOf": [
{ "$ref": "#" },
{ "$ref": "#/definitions/schemaArray" }
],
"default": true
},
"maxItems": { "$ref": "#/definitions/nonNegativeInteger" },
"minItems": { "$ref": "#/definitions/nonNegativeIntegerDefault0" },
"uniqueItems": {
"type": "boolean",
"default": false
},
"contains": { "$ref": "#" },
"maxProperties": { "$ref": "#/definitions/nonNegativeInteger" },
"minProperties": { "$ref": "#/definitions/nonNegativeIntegerDefault0" },
"required": { "$ref": "#/definitions/stringArray" },
"additionalProperties": { "$ref": "#" },
"definitions": {
"type": "object",
"additionalProperties": { "$ref": "#" },
"default": {}
},
"properties": {
"type": "object",
"additionalProperties": { "$ref": "#" },
"default": {}
},
"patternProperties": {
"type": "object",
"additionalProperties": { "$ref": "#" },
"propertyNames": { "format": "regex" },
"default": {}
},
"dependencies": {
"type": "object",
"additionalProperties": {
"anyOf": [
{ "$ref": "#" },
{ "$ref": "#/definitions/stringArray" }
]
}
},
"propertyNames": { "$ref": "#" },
"const": true,
"enum": {
"type": "array",
"items": true,
"minItems": 1,
"uniqueItems": true
},
"type": {
"anyOf": [
{ "$ref": "#/definitions/simpleTypes" },
{
"type": "array",
"items": { "$ref": "#/definitions/simpleTypes" },
"minItems": 1,
"uniqueItems": true
}
]
},
"format": { "type": "string" },
"contentMediaType": { "type": "string" },
"contentEncoding": { "type": "string" },
"if": { "$ref": "#" },
"then": { "$ref": "#" },
"else": { "$ref": "#" },
"allOf": { "$ref": "#/definitions/schemaArray" },
"anyOf": { "$ref": "#/definitions/schemaArray" },
"oneOf": { "$ref": "#/definitions/schemaArray" },
"not": { "$ref": "#" }
},
"default": true
} )"_json;
}
} // namespace nlohmann

View File

@ -0,0 +1,75 @@
/*
* JSON schema validator for JSON for modern C++
*
* Copyright (c) 2016-2019 Patrick Boettcher <p@yai.se>.
*
* SPDX-License-Identifier: MIT
*
*/
#include <nlohmann/json.hpp>
namespace nlohmann
{
namespace json_schema
{
json draft_2020_12_schema_builtin = R"( {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"$id": "https://json-schema.org/draft/2020-12/schema",
"$vocabulary": {
"https://json-schema.org/draft/2020-12/vocab/core": true,
"https://json-schema.org/draft/2020-12/vocab/applicator": true,
"https://json-schema.org/draft/2020-12/vocab/unevaluated": true,
"https://json-schema.org/draft/2020-12/vocab/validation": true,
"https://json-schema.org/draft/2020-12/vocab/meta-data": true,
"https://json-schema.org/draft/2020-12/vocab/format-annotation": true,
"https://json-schema.org/draft/2020-12/vocab/content": true
},
"$dynamicAnchor": "meta",
"title": "Core and Validation specifications meta-schema",
"allOf": [
{"$ref": "meta/core"},
{"$ref": "meta/applicator"},
{"$ref": "meta/unevaluated"},
{"$ref": "meta/validation"},
{"$ref": "meta/meta-data"},
{"$ref": "meta/format-annotation"},
{"$ref": "meta/content"}
],
"type": ["object", "boolean"],
"$comment": "This meta-schema also defines keywords that have appeared in previous drafts in order to prevent incompatible extensions as they remain in common use.",
"properties": {
"definitions": {
"$comment": "\"definitions\" has been replaced by \"$defs\".",
"type": "object",
"additionalProperties": { "$dynamicRef": "#meta" },
"deprecated": true,
"default": {}
},
"dependencies": {
"$comment": "\"dependencies\" has been split and replaced by \"dependentSchemas\" and \"dependentRequired\" in order to serve their differing semantics.",
"type": "object",
"additionalProperties": {
"anyOf": [
{ "$dynamicRef": "#meta" },
{ "$ref": "meta/validation#/$defs/stringArray" }
]
},
"deprecated": true,
"default": {}
},
"$recursiveAnchor": {
"$comment": "\"$recursiveAnchor\" has been replaced by \"$dynamicAnchor\".",
"$ref": "meta/core#/$defs/anchorString",
"deprecated": true
},
"$recursiveRef": {
"$comment": "\"$recursiveRef\" has been replaced by \"$dynamicRef\".",
"$ref": "meta/core#/$defs/uriReferenceString",
"deprecated": true
}
}
} )"_json;
}
} // namespace nlohmann

View File

@ -1409,7 +1409,7 @@ std::shared_ptr<schema> schema::make(json &schema,
schema.erase(attr); schema.erase(attr);
// special case where we break draft-7 and allow overriding of properties when a $ref is used // special case where we break draft-7 and allow overriding of properties when a $ref is used <<-- might be out-of-date now that 2020-12 is used
attr = schema.find("default"); attr = schema.find("default");
if (attr != schema.end()) { if (attr != schema.end()) {
// copy the referenced schema depending on the underlying type and modify the default value // copy the referenced schema depending on the underlying type and modify the default value

View File

@ -37,7 +37,7 @@ namespace nlohmann
// A class representing a JSON-URI for schemas derived from // A class representing a JSON-URI for schemas derived from
// section 8 of JSON Schema: A Media Type for Describing JSON Documents // section 8 of JSON Schema: A Media Type for Describing JSON Documents
// draft-wright-json-schema-00 // draft-wright-json-schema-00 <<-- might be incorrect now that 2020-12 is used
// //
// New URIs can be derived from it using the derive()-method. // New URIs can be derived from it using the derive()-method.
// This is useful for resolving refs or subschema-IDs in json-schemas. // This is useful for resolving refs or subschema-IDs in json-schemas.
@ -128,7 +128,7 @@ public:
namespace json_schema namespace json_schema
{ {
extern json draft7_schema_builtin; extern json draft_2020_12_schema_builtin;
typedef std::function<void(const json_uri & /*id*/, json & /*value*/)> schema_loader; typedef std::function<void(const json_uri & /*id*/, json & /*value*/)> schema_loader;
typedef std::function<void(const std::string & /*format*/, const std::string & /*value*/)> format_checker; typedef std::function<void(const std::string & /*format*/, const std::string & /*value*/)> format_checker;

View File

@ -398,7 +398,7 @@ void default_string_format_check(const std::string &format, const std::string &v
throw exception; throw exception;
} }
} else { } else {
/* yet unsupported JSON schema draft 7 built-ins */ /* as-of-yet unsupported JSON schema draft 2020-12 built-ins */
static const std::vector<std::string> jsonSchemaStringFormatBuiltIns{ static const std::vector<std::string> jsonSchemaStringFormatBuiltIns{
"date-time", "time", "date", "email", "idn-email", "hostname", "idn-hostname", "ipv4", "ipv6", "uri", "date-time", "time", "date", "email", "idn-email", "hostname", "idn-hostname", "ipv4", "ipv6", "uri",
"uri-reference", "iri", "iri-reference", "uri-template", "json-pointer", "relative-json-pointer", "regex"}; "uri-reference", "iri", "iri-reference", "uri-template", "json-pointer", "relative-json-pointer", "regex"};

View File

@ -1,6 +1,6 @@
set(JSON_SCHEMA_TEST_PREFIX "JSON-Suite" CACHE STRING "prefix for JSON-tests added to ctest") set(JSON_SCHEMA_TEST_PREFIX "JSON-Suite" CACHE STRING "prefix for JSON-tests added to ctest")
set(DRAFT "draft7") set(DRAFT "draft_2020-12")
# find schema-test-suite # find schema-test-suite
find_path(JSON_SCHEMA_TEST_SUITE_PATH find_path(JSON_SCHEMA_TEST_SUITE_PATH

View File

@ -18,8 +18,8 @@ using nlohmann::json_schema::json_validator;
static void loader(const json_uri &uri, json &schema) static void loader(const json_uri &uri, json &schema)
{ {
if (uri.location() == "http://json-schema.org/draft-07/schema") { if (uri.location() == "http://json-schema.org/draft/2020-12/schema") {
schema = nlohmann::json_schema::draft7_schema_builtin; schema = nlohmann::json_schema::draft_2020_12_schema_builtin;
return; return;
} }

View File

@ -1,12 +1,12 @@
[ [
{ {
"description": "validate definition against metaschema", "description": "validate definition against metaschema",
"schema": {"$ref": "http://json-schema.org/draft-07/schema#"}, "schema": {"$schema": "http://json-schema.org/draft/2020-12/schema"},
"tests": [ "tests": [
{ {
"description": "valid definition schema", "description": "valid definition schema",
"data": { "data": {
"definitions": { "$defs": {
"foo": {"type": "integer"} "foo": {"type": "integer"}
} }
}, },
@ -15,7 +15,7 @@
{ {
"description": "invalid definition schema", "description": "invalid definition schema",
"data": { "data": {
"definitions": { "$defs": {
"foo": {"type": 1} "foo": {"type": 1}
} }
}, },

View File

@ -213,7 +213,7 @@
}, },
{ {
"description": "remote ref, containing refs itself", "description": "remote ref, containing refs itself",
"schema": {"$ref": "http://json-schema.org/draft-07/schema#"}, "schema": {"$schema": "https://json-schema.org/draft/2020-12/schema"},
"tests": [ "tests": [
{ {
"description": "remote ref valid", "description": "remote ref valid",

View File

@ -21,7 +21,7 @@ namespace
// The schema is defined based upon a string literal // The schema is defined based upon a string literal
static json person_schema = R"( static json person_schema = R"(
{ {
"$schema": "http://json-schema.org/draft-07/schema#", "$schema": "http://json-schema.org/draft/2020-12/schema",
"title": "A person", "title": "A person",
"properties": { "properties": {
"name": { "name": {

View File

@ -1,6 +1,6 @@
{ {
"$id": "http://xxx.local/schemas/mySchema.json", "$id": "http://xxx.local/schemas/mySchema.json",
"$schema": "http://json-schema.org/draft-07/schema#", "$schema": "http://json-schema.org/draft/2020-12/schema",
"type": "object", "type": "object",
"properties": { "properties": {

View File

@ -1,6 +1,6 @@
{ {
"$id": "http://xxx.local/schemas/mySchema.json", "$id": "http://xxx.local/schemas/mySchema.json",
"$schema": "http://json-schema.org/draft-07/schema#", "$schema": "http://json-schema.org/draft/2020-12/schema",
"type": "object", "type": "object",
"properties": { "properties": {

View File

@ -1,5 +1,5 @@
{ {
"$schema": "http://json-schema.org/draft-04/schema#", "$schema": "http://json-schema.org/draft/2020-12/schema",
"properties": { "properties": {
"x": { "x": {
"type": "integer", "type": "integer",

View File

@ -21,7 +21,7 @@ static int error_count;
// The schema is defined based upon a string literal // The schema is defined based upon a string literal
static json person_schema = R"( static json person_schema = R"(
{ {
"$schema": "http://json-schema.org/draft-07/schema#", "$schema": "http://json-schema.org/draft/2020-12/schema",
"type": "integer", "type": "integer",
"definitions": { "definitions": {
"A": { "A": {

View File

@ -7,7 +7,7 @@ using nlohmann::json_schema::json_validator;
static const json rectangle_schema = R"( static const json rectangle_schema = R"(
{ {
"$schema": "http://json-schema.org/draft-07/schema#", "$schema": "http://json-schema.org/draft/2020-12/schema",
"properties": { "properties": {
"width": { "width": {
"$ref": "#/definitions/length", "$ref": "#/definitions/length",
@ -27,7 +27,7 @@ static const json rectangle_schema = R"(
static const json quad_schema = R"( static const json quad_schema = R"(
{ {
"$schema": "http://json-schema.org/draft-07/schema#", "$schema": "http://json-schema.org/draft/2020-12/schema",
"properties": { "properties": {
"width": { "width": {
"$ref": "#/properties/height", "$ref": "#/properties/height",
@ -57,7 +57,7 @@ static const json quad_schema = R"(
static const json default_schema = R"( static const json default_schema = R"(
{ {
"$schema": "http://json-schema.org/draft-07/schema#", "$schema": "http://json-schema.org/draft/2020-12/schema",
"definitions": { "definitions": {
"defaultLength": { "defaultLength": {
"default": 5 "default": 5

View File

@ -1,5 +1,5 @@
{ {
"$schema": "http://json-schema.org/draft-07/schema#", "$schema": "http://json-schema.org/draft/2020-12/schema",
"$id": "https://example.invalid/color.schema.json", "$id": "https://example.invalid/color.schema.json",
"title": "color", "title": "color",
"description": "X11/HTML/CSS color name as a JSON string", "description": "X11/HTML/CSS color name as a JSON string",

View File

@ -1,5 +1,5 @@
{ {
"$schema": "http://json-schema.org/draft-07/schema#", "$schema": "http://json-schema.org/draft/2020-12/schema",
"$id": "https://example.invalid/entities.schema.json", "$id": "https://example.invalid/entities.schema.json",
"title": "Entities", "title": "Entities",
"type": "array", "type": "array",

View File

@ -7,7 +7,7 @@ using nlohmann::json_schema::json_validator;
static const json default_schema = R"( static const json default_schema = R"(
{ {
"$schema": "http://json-schema.org/draft-07/schema#", "$schema": "http://json-schema.org/draft/2020-12/schema",
"type": "object", "type": "object",
"oneOf": [ "oneOf": [
{ {

View File

@ -7,7 +7,7 @@ using nlohmann::json_schema::json_validator;
static const json root_default = R"( static const json root_default = R"(
{ {
"$schema": "http://json-schema.org/draft-07/schema#", "$schema": "http://json-schema.org/draft/2020-12/schema",
"properties": { "properties": {
"width": { "width": {
"type": "integer" "type": "integer"

View File

@ -6,7 +6,7 @@ using nlohmann::json_schema::json_validator;
static const json person_schema = R"( static const json person_schema = R"(
{ {
"$schema": "http://json-schema.org/draft-07/schema#", "$schema": "http://json-schema.org/draft/2020-12/schema",
"title": "A person", "title": "A person",
"properties": { "properties": {
"name": { "name": {

View File

@ -6,7 +6,7 @@ using nlohmann::json_schema::json_validator;
static const json schema = R"( static const json schema = R"(
{ {
"$schema": "http://json-schema.org/draft-07/schema#", "$schema": "http://json-schema.org/draft/2020-12/schema",
"$id": "arc.schema.json", "$id": "arc.schema.json",
"properties": { "properties": {
"angle": { "angle": {

View File

@ -21,7 +21,7 @@ namespace
// The schema is defined based upon a string literal // The schema is defined based upon a string literal
static json person_schema = R"( static json person_schema = R"(
{ {
"$schema": "http://json-schema.org/draft-07/schema#", "$schema": "http://json-schema.org/draft/2020-12/schema",
"title": "A person", "title": "A person",
"properties": { "properties": {
"name": { "name": {

View File

@ -5,7 +5,7 @@ using nlohmann::json_schema::json_validator;
static const json person_schema = R"( static const json person_schema = R"(
{ {
"$schema": "http://json-schema.org/draft-07/schema#", "$schema": "http://json-schema.org/draft/2020-12/schema",
"title": "A person", "title": "A person",
"properties": { "properties": {
"name": { "name": {

View File

@ -1,5 +1,5 @@
{ {
"$schema": "http://json-schema.org/draft-04/schema#", "$schema": "http://json-schema.org/draft/2020-12/schema",
"description": "Describes bar", "description": "Describes bar",
"type": "object", "type": "object",
"required": [ "required": [

View File

@ -1,5 +1,5 @@
{ {
"$schema": "http://json-schema.org/draft-04/schema#", "$schema": "http://json-schema.org/draft/2020-12/schema",
"description": "Describes foo", "description": "Describes foo",
"type": "object", "type": "object",
"allOf": [ "allOf": [

View File

@ -1,5 +1,5 @@
{ {
"$schema": "http://json-schema.org/draft-04/schema#", "$schema": "http://json-schema.org/draft/2020-12/schema",
"description": "Describes baz", "description": "Describes baz",
"$ref": "qux/qux.json" "$ref": "qux/qux.json"
} }

View File

@ -1,5 +1,5 @@
{ {
"$schema": "http://json-schema.org/draft-04/schema#", "$schema": "http://json-schema.org/draft/2020-12/schema",
"description": "Describes qux", "description": "Describes qux",
"type": "object", "type": "object",
"required": [ "required": [

View File

@ -1,5 +1,5 @@
{ {
"$schema": "http://json-schema.org/draft-04/schema#", "$schema": "http://json-schema.org/draft/2020-12/schema",
"description": "Describes foo", "description": "Describes foo",
"$ref": "baz/baz.json" "$ref": "baz/baz.json"
} }

View File

@ -1,6 +1,6 @@
{ {
"$id": "http://xxx.local/schemas/mySchema.json", "$id": "http://xxx.local/schemas/mySchema.json",
"$schema": "http://json-schema.org/draft-07/schema#", "$schema": "http://json-schema.org/draft/2020-12/schema",
"definitions": { "definitions": {
"topDef": { "topDef": {
"$id": "#topDef_ref", "$id": "#topDef_ref",

View File

@ -91,15 +91,15 @@ int main(void)
"", "",
""); "");
json_uri http("http://json-schema.org/draft-07/schema#"); json_uri http("http://json-schema.org/draft/2020-12/schema");
paths(http, paths(http,
"http://json-schema.org/draft-07/schema", "http://json-schema.org/draft/2020-12/schema",
"http://json-schema.org/draft-07", "http://json-schema.org/draft/2020-12",
"http://json-schema.org"); "http://json-schema.org");
pointer_plain_name(http, pointer_plain_name(http,
"http://json-schema.org/draft-07/schema", "http://json-schema.org/draft/2020-12/schema",
"http://json-schema.org/draft-07", "http://json-schema.org/draft/2020-12",
"http://json-schema.org"); "http://json-schema.org");
return errors; return errors;