Environment
Nuget Package: JsonSchema.Net
Nuget Version: 2.0.2
OS: Win10
.Net Target: .Net Framework 4.7.2
Describe the bug
Schema validation, when json data is incorrect ( has additional non unique item in Contacts Array ) reports additional validation messages " All values fail against the false schema ". Validation is passing when ununique contact item is removed.
To Reproduce
Json Schema:
{
"$schema": "http://json-schema.org/draft-07/schema#",
"$id": "http://messagebroker.fff.pl/rpn/dci/kkt.json",
"type": "object",
"title": "JSON Schema dokumentu bazowego zdarzenia RPN-DCI-KKT. Version 3b. 2020-01-21",
"definitions": {
"guid": {
"$id": "#guid",
"title": "Definicja obligatoryjnego GUID (regex)",
"type": "string",
"examples": [
"09C9A8DA-B40F-4E3A-9746-7B10AFEC2C4F",
"2d9bbb00-878f-49b0-9d48-767ce3e12dee"
],
"minLength": 36,
"maxLength": 36,
"pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$"
},
"string50Nullable": {
"$id": "#string50Nullable",
"title": "Definicja opcjonalnego tekstu o długości nie przekraczającej 50 znaków",
"default": null,
"anyOf": [
{
"type": "string",
"minLength": 1,
"maxLength": 50,
"pattern": "^(.*)$"
},
{
"type": "null"
}
]
},
"string250Nullable": {
"$id": "#string250Nullable",
"title": "Definicja opcjonalnego tekstu o długości nie przekraczającej 250 znaków",
"default": null,
"anyOf": [
{
"type": "string",
"minLength": 1,
"maxLength": 250,
"pattern": "^(.*)$"
},
{
"type": "null"
}
]
},
"dictionaryElement": {
"$id": "#dictionaryElement",
"type": "object",
"title": "Definicja elementu słownika",
"additionalProperties": false,
"required": [
"ElementCode",
"ElementName"
],
"properties": {
"ElementCode": {
"$ref": "#string50Nullable",
"title": "Kod elementu słownika",
"minLength": 1
},
"ElementName": {
"$ref": "#string250Nullable",
"title": "Nazwa elementu słownika"
}
}
},
"bitNullable": {
"$id": "#bitNullable",
"title": "Definicja opcjonalnej flagi bitowej",
"default": null,
"anyOf": [
{
"type": "integer",
"minimum": 0,
"maximum": 1
},
{
"type": "null"
}
]
},
"string100Nullable": {
"$id": "#string100Nullable",
"title": "Definicja opcjonalnego tekstu o długości nie przekraczającej 100 znaków",
"default": null,
"anyOf": [
{
"type": "string",
"minLength": 1,
"maxLength": 100,
"pattern": "^(.*)$"
},
{
"type": "null"
}
]
},
"positiveInteger3Nullable": {
"$id": "#positiveInteger3Nullable",
"title": "Definicja opcjonalnej dodatniej liczby całkowitej do 3 cyfr",
"default": null,
"anyOf": [
{
"type": "integer",
"minimum": 1,
"maximum": 999
},
{
"type": "null"
}
]
},
"contact": {
"$id": "#contact",
"type": "object",
"title": "Dana kontaktowa",
"additionalProperties": false,
"required": [
"ContactType",
"ContactValue",
"CountryCode",
"IsMainContact",
"IsDeleted"
],
"properties": {
"ContactType": {
"$ref": "#dictionaryElement",
"title": "Typ danej kontaktowej"
},
"ContactValue": {
"$ref": "#string100Nullable",
"title": "Wartość danej kontaktowej"
},
"CountryCode": {
"$ref": "#positiveInteger3Nullable",
"title": "Kod kraju danej kontaktowej"
},
"IsMainContact": {
"$ref": "#bitNullable",
"title": "Flaga bitowa oznaczająca główną daną kontaktową"
},
"IsDeleted": {
"$ref": "#bitNullable",
"title": "Flaga bitowa oznaczająca usuniętą daną kontaktową"
}
}
}
},
"required": [
"ContentDefinitionId",
"DataModelId",
"Contacts"
],
"properties": {
"ContentDefinitionId": {
"$ref": "#guid",
"title": "Identyfikator definicji treści zdarzenia"
},
"DataModelId": {
"$ref": "#guid",
"title": "Identyfikator definicji wykorzystanego modelu danych (źródłowego, pośredniego lub docelowego)"
},
"Contacts": {
"type": "array",
"title": "Lista danych kontaktowych osoby",
"minItems": 0,
"uniqueItems": true,
"additionalItems": false,
"items": {
"$ref": "#contact",
"title": "Dana kontaktowa osoby"
}
}
},
"additionalProperties": false
}
JSON Data incorrect ( non unique contact item in Contacts array ):
{
"ContentDefinitionId": "fa81bc1d-3efe-4192-9e03-31e9898fef90",
"DataModelId": "fb81bc1d-3efe-4192-9e03-31e9898fef90",
"Contacts": [
{
"ContactType": {
"ElementCode": "Email",
"ElementName": "Adres email"
},
"ContactValue": "w@M.N2.org",
"CountryCode": null,
"IsMainContact": 0,
"IsDeleted": 0
},
{
"ContactType": {
"ElementCode": "MobilePhone",
"ElementName": "Telefon komórkowy"
},
"ContactValue": "753841174",
"CountryCode": 48,
"IsMainContact": 1,
"IsDeleted": 0
},
{
"ContactType": {
"ElementCode": "MobilePhone",
"ElementName": "Telefon komórkowy"
},
"ContactValue": "753841174",
"CountryCode": 48,
"IsMainContact": 1,
"IsDeleted": 0
}
]
}
Expected behavior
No additional messages added as validation result. It makes log more complex and much more heavy
Environment
Nuget Package: JsonSchema.Net
Nuget Version: 2.0.2
OS: Win10
.Net Target: .Net Framework 4.7.2
Describe the bug
Schema validation, when json data is incorrect ( has additional non unique item in Contacts Array ) reports additional validation messages " All values fail against the false schema ". Validation is passing when ununique contact item is removed.
To Reproduce
Json Schema:
{ "$schema": "http://json-schema.org/draft-07/schema#", "$id": "http://messagebroker.fff.pl/rpn/dci/kkt.json", "type": "object", "title": "JSON Schema dokumentu bazowego zdarzenia RPN-DCI-KKT. Version 3b. 2020-01-21", "definitions": { "guid": { "$id": "#guid", "title": "Definicja obligatoryjnego GUID (regex)", "type": "string", "examples": [ "09C9A8DA-B40F-4E3A-9746-7B10AFEC2C4F", "2d9bbb00-878f-49b0-9d48-767ce3e12dee" ], "minLength": 36, "maxLength": 36, "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$" }, "string50Nullable": { "$id": "#string50Nullable", "title": "Definicja opcjonalnego tekstu o długości nie przekraczającej 50 znaków", "default": null, "anyOf": [ { "type": "string", "minLength": 1, "maxLength": 50, "pattern": "^(.*)$" }, { "type": "null" } ] }, "string250Nullable": { "$id": "#string250Nullable", "title": "Definicja opcjonalnego tekstu o długości nie przekraczającej 250 znaków", "default": null, "anyOf": [ { "type": "string", "minLength": 1, "maxLength": 250, "pattern": "^(.*)$" }, { "type": "null" } ] }, "dictionaryElement": { "$id": "#dictionaryElement", "type": "object", "title": "Definicja elementu słownika", "additionalProperties": false, "required": [ "ElementCode", "ElementName" ], "properties": { "ElementCode": { "$ref": "#string50Nullable", "title": "Kod elementu słownika", "minLength": 1 }, "ElementName": { "$ref": "#string250Nullable", "title": "Nazwa elementu słownika" } } }, "bitNullable": { "$id": "#bitNullable", "title": "Definicja opcjonalnej flagi bitowej", "default": null, "anyOf": [ { "type": "integer", "minimum": 0, "maximum": 1 }, { "type": "null" } ] }, "string100Nullable": { "$id": "#string100Nullable", "title": "Definicja opcjonalnego tekstu o długości nie przekraczającej 100 znaków", "default": null, "anyOf": [ { "type": "string", "minLength": 1, "maxLength": 100, "pattern": "^(.*)$" }, { "type": "null" } ] }, "positiveInteger3Nullable": { "$id": "#positiveInteger3Nullable", "title": "Definicja opcjonalnej dodatniej liczby całkowitej do 3 cyfr", "default": null, "anyOf": [ { "type": "integer", "minimum": 1, "maximum": 999 }, { "type": "null" } ] }, "contact": { "$id": "#contact", "type": "object", "title": "Dana kontaktowa", "additionalProperties": false, "required": [ "ContactType", "ContactValue", "CountryCode", "IsMainContact", "IsDeleted" ], "properties": { "ContactType": { "$ref": "#dictionaryElement", "title": "Typ danej kontaktowej" }, "ContactValue": { "$ref": "#string100Nullable", "title": "Wartość danej kontaktowej" }, "CountryCode": { "$ref": "#positiveInteger3Nullable", "title": "Kod kraju danej kontaktowej" }, "IsMainContact": { "$ref": "#bitNullable", "title": "Flaga bitowa oznaczająca główną daną kontaktową" }, "IsDeleted": { "$ref": "#bitNullable", "title": "Flaga bitowa oznaczająca usuniętą daną kontaktową" } } } }, "required": [ "ContentDefinitionId", "DataModelId", "Contacts" ], "properties": { "ContentDefinitionId": { "$ref": "#guid", "title": "Identyfikator definicji treści zdarzenia" }, "DataModelId": { "$ref": "#guid", "title": "Identyfikator definicji wykorzystanego modelu danych (źródłowego, pośredniego lub docelowego)" }, "Contacts": { "type": "array", "title": "Lista danych kontaktowych osoby", "minItems": 0, "uniqueItems": true, "additionalItems": false, "items": { "$ref": "#contact", "title": "Dana kontaktowa osoby" } } }, "additionalProperties": false }JSON Data incorrect ( non unique contact item in Contacts array ):
{ "ContentDefinitionId": "fa81bc1d-3efe-4192-9e03-31e9898fef90", "DataModelId": "fb81bc1d-3efe-4192-9e03-31e9898fef90", "Contacts": [ { "ContactType": { "ElementCode": "Email", "ElementName": "Adres email" }, "ContactValue": "w@M.N2.org", "CountryCode": null, "IsMainContact": 0, "IsDeleted": 0 }, { "ContactType": { "ElementCode": "MobilePhone", "ElementName": "Telefon komórkowy" }, "ContactValue": "753841174", "CountryCode": 48, "IsMainContact": 1, "IsDeleted": 0 }, { "ContactType": { "ElementCode": "MobilePhone", "ElementName": "Telefon komórkowy" }, "ContactValue": "753841174", "CountryCode": 48, "IsMainContact": 1, "IsDeleted": 0 } ] }Expected behavior
No additional messages added as validation result. It makes log more complex and much more heavy