logo
down
shadow

Json schema validating wrong instance as true


Json schema validating wrong instance as true

By : user3042027
Date : November 27 2020, 12:01 PM
this one helps. I have the following schema and I'm having a hard time trying to understand why it is not working. , Your problem is with the definition of the oneOf
code :
"oneOf": [
    {
        "type":"string"
    }, 
    {
        "type": "object",
        "patternProperties": {
            "^[\\<\\>\\=\\!\\=\\>\\<]\\_[0-9]+$" : {
                "type":"string"
            }
        }
    },
    {
        "type": "object",
        "patternProperties": {        
            "^\\w+( +\\w+)*$" : {
                "type":"string"
            }
        }
    }
]
"oneOf": [
    {
        "type":"string"
    }, 
    {
        "type": "object",
        "patternProperties": {
            "^[\\<\\>\\=\\!\\=\\>\\<]\\_[0-9]+$" : {
                "type":"string"
            },
            "^\\w+( +\\w+)*$" : {
                "type":"string"
            }
        }
    }
]
"oneOf": [
    {
        "type":"string"
    }, 
    {
        "type": "object",
        "additionalProperties": false,
        "patternProperties": {
            "^[\\<\\>\\=\\!\\=\\>\\<]\\_[0-9]+$" : {
                "type":"string"
            }
        }
    },
    {
        "type": "object",
        "additionalProperties": false,
        "patternProperties": {        
            "^\\w+( +\\w+)*$" : {
                "type":"string"
            }
        }
    }
]


Share : facebook icon twitter icon
Validating an XDocument instance against its own schema reference

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?

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

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

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

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.
Related Posts Related Posts :
  • how to write r.headers from different urls into one json?
  • Parsing JSON concurrently - panic of runtime error (decoding related)
  • How to fix "Subscript out of range" error in XML HTTP Request
  • Splitting nested arrays as separate entities
  • Trying to parse the JSON and create an extracted JSON
  • NiFi JoltTransformJson outputs only first record
  • Dynamic (But known as another key value) JSON Decoding with Swift Decodable
  • How to use map on json response returned by a REST API with ReactJs
  • How to read a file line by line and then output all lines compounded with sth in jq?
  • java.lang.RuntimeException: Failed : HTTP error code : 400 : Bad Request
  • How to check jq result is null or not?
  • CloudFormation - How to use Sub intrinsic function?
  • VBA: Nested JSON Object Structure for UK Bank Holidays - Run Time Errors 13, 438 and 449
  • JasperReports. Using value from parent json in child table
  • Output key value pairs as JSON from T-SQL query
  • Getting key value pairs with linux server
  • Modifying settings.json in vscode to add shell escape flag to pdflatex in latex workshop
  • Unable to render data into grid column using JSON results
  • JSON decode failed
  • How to remove brakets on Json respone
  • How to parse JSON-input
  • JSON syntax for getting personal query ID
  • detecting 400 response without JSON response
  • Newtonsoft deserializing Json incorrectly
  • Getting _jsonparsefailure with valid json in logstash
  • How to send Map as String in POST request in flutter?
  • Difficulty fetching json data from API using Angular
  • Reading JSON data for my select query in SQL Server
  • AWS CloudFormation Template (JSON) to Create EC2 - Unexpected Error
  • How to concat multiple fields to same line with jq
  • Issue sending POST request from Swift
  • Storing JSON in BigQuery
  • How to get the value of a key in a JSON?
  • How to validate JSON input in Go
  • Extracting specific and latest data from http webserver using golang
  • Incorrect type. Expected "object"
  • json_to_record with embedded encoded json in PostgreSQL >= 10
  • Nested json extract from powershell
  • Parsing Json using Golang
  • Type 'number' is not assignable to type 'string'. How to cast number to string
  • kubectl - format the resource quota values in json format
  • Initializing and inserting nested JSON data in Golang?
  • Open JSON files in PhpStorm built-in web server
  • Extract Badge ID from JSON in .gitlab-ci.yml
  • Sharing Json Schema files among projects with versioning
  • Export Json data to an excel file using Angular 4
  • Return an empty array instead of null with golang for json return with gin
  • can Kafka connect value conveter (JSONConverter) can be used to convert GPB?
  • read json and access multiple keys
  • Spark How to get number of Keys changed in two JSONS in Scala?
  • Break JSON in pager "less"
  • How to filter Map in Flutter?
  • Convert hashmap to simple object in Groovy
  • Not extracting json properly using json4s
  • How do I display JSON data in my tableView when objects have the same value?
  • Where I can parse IoT data in Azure so I can afterwards save it to SQL DB
  • How to unmarshal this json string
  • What's wrong with my JSON?
  • JSON parsing problem in BlackBerry
  • GWT: How can I use JsonpRequestBuilder to handle a Json response of a list
  • shadow
    Privacy Policy - Terms - Contact Us © festivalmusicasacra.org