Validating an XDocument instance against its own schema reference
By : user30443
Date : March 29 2020, 07:55 AM
it fixes the issue If you want to validate on load try to use: XDocument.Load Method (XmlReader, LoadOptions) code :
XmlReader reader;
XmlReaderSettings settings = new XmlReaderSettings();
settings.ValidationType = ValidationType.Schema;
settings.ValidationFlags = XmlSchemaValidationFlags.ReportValidationWarnings |
XmlSchemaValidationFlags.ProcessSchemaLocation;
ValidationEventHandler validator = delegate(object sender,
ValidationEventArgs e)
{
Console.WriteLine("{0}: {1}", e.Severity, e.Message);
};
settings.ValidationEventHandler += validator;
settings.CloseInput = true;
StringReader sr = new StringReader(inputXml);
reader = XmlReader.Create(sr, settings);
|
Why is JSON not validating against schema?
By : jjhduggan
Date : March 29 2020, 07:55 AM
I wish did fix the issue. Your schema seems suspect. Working from the samples on jsonschemalint.com I created a properties container in the root for your properties, added description and type at the root and moved additionalProperties to the root as well. This validates your item on jsonschemalint.com: code :
{
"description": "StackOverflow test schema",
"type": "object",
"additionalProperties": false,
"properties": {
"category": {
"admin": {"type": "boolean"}
},
"username": {"type": "string"},
"password": {"type": "string"},
"name": {"type": "string"},
"email": {"type": "string", "format": "email"},
"phone": {"type": "string"},
"hours": {
"type": "array",
"items": {
"start": {"type": "string", "format": "date-time"},
"end": {"type": "string", "format": "date-time"}
}
}
}
}
|
invalid JSON Schema exception in RestAssured, while validating against schema from swagger
By : Imran
Date : March 29 2020, 07:55 AM
Does that help The issue was that I copied the schema from Model Schema on the swagger-ui.html page. But, noticed that this is a representation of response. Actual schema is created on /v2/api-docs.json page. Had to work on a little as there were so many definitions reused and had to bring them all together into one schema file each end point. Below is my final schema document. code :
{
"type": "array",
"items": {
"type": "object",
"properties": {
"couponAmount": {
"type": "number",
"format": "double"
},
"couponAmt": {
"type": "number",
"format": "double"
},
"couponDescription": {
"type": "string"
},
"couponNumber": {
"type": "string"
},
"creationDate": {
"type": "string"
},
"displayStartDate": {
"type": "string"
},
"divNumber": {
"type": "string"
},
"divStoreCoupon": {
"type": "string"
},
"expirationDate": {
"type": "string"
},
"maxSavings": {
"type": "number",
"format": "double"
},
"minPurchaseAmount": {
"type": "integer",
"format": "int32"
},
"minPurchaseQty": {
"type": "integer",
"format": "int32"
},
"offerType": {
"type": "string"
},
"promoDescription": {
"type": "string"
},
"promoType": {
"type": "string"
},
"rewardYN": {
"type": "boolean"
},
"updateDate": {
"type": "string"
}
}
}
}
|
java.lang.NoSuchFieldError: USE_DEFAULTS thrown while validating json schema through json schema validator
By : Jaro Vanderheijden
Date : March 29 2020, 07:55 AM
I think the issue was by ths following , Did you add the latest version of jackson-annotations? The USE_DEFAULTS enum constant was added in 2.6:
|
Validating json payload against swagger file - json-schema-validator
By : Saravanan Kotti
Date : March 29 2020, 07:55 AM
Hope this helps json-schema-validator seems to work with pure JSON Schema only. OpenAPI Specification uses an extended subset of JSON Schema, so the schema format is different. You need a library that can validate specifically against OpenAPI/Swagger definitions, such as Atlassian's swagger-request-validator.
|