Giter Club home page Giter Club logo

Comments (4)

santhosh-tekuri avatar santhosh-tekuri commented on May 29, 2024
{
    "foobar": [
        {
            "first": "A",
            "second": true
        },
        {
            "first": "X"
        }
    ]
}

the complete error I get when %#v is used:

[I#] [S#] doesn't validate with https://foo.com/test/definitions.json#
  [I#/foobar/1] [S#/properties/foobar/items/oneOf] oneOf failed
    [I#/foobar/1] [S#/properties/foobar/items/oneOf/0]
      [I#/foobar/1] [S#/properties/foobar/items/oneOf/0/required] missing properties: 'second'
      [I#/foobar/1/first] [S#/properties/foobar/items/oneOf/0/properties/first/const] value must be "A"
    [I#/foobar/1/first] [S#/properties/foobar/items/oneOf/1/properties/first/const] value must be "B"
    [I#/foobar/1/first] [S#/properties/foobar/items/oneOf/2/properties/first/const] value must be "C"```

this is the expected result. the instance json you passed does not validate with the provided schema:

let me clarify why it is invalid:

second item {"first": "X" } does not satisfy:

  • first schema of oneOf because: "second" property is missing && value of first must be A But it is X
  • second schema of oneOf because: value of first must be B but it is X
  • third schema of oneOf because: value of first must be C but it is X
    i.e none of oneOf schemas satisfied. so validation fails.

just to clarify: both const and required are independent validations and both must be satisfied.

from jsonschema.

byrnedo avatar byrnedo commented on May 29, 2024

Ah I'm sorry @santhosh-tekuri , that was an incorrect reproduction I gave you to begin with. Should have checked that twice.
I'll open a new ticket with a correct reproduction. Thanks for the quick and thorough reply.

from jsonschema.

santhosh-tekuri avatar santhosh-tekuri commented on May 29, 2024

if you are ok in sharing your schema and instance, then you can raise issue. no need to struggle for minimal reproduction

from jsonschema.

byrnedo avatar byrnedo commented on May 29, 2024

After actually looking through this the problem is on our side. 🤦
It was the same scenario but on of the oneOf had an extra field that could be type [ "string", "null"] and which was also required, and that was not being sent in the payload, so of course that won't pass validation.

from jsonschema.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.