Comments (4)
{
"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 offirst
must beA
But it isX
- second schema of
oneOf
because: value offirst
must beB
but it isX
- third schema of
oneOf
because: value offirst
must beC
but it isX
i.e none ofoneOf
schemas satisfied. so validation fails.
just to clarify: both const
and required
are independent validations and both must be satisfied.
from jsonschema.
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.
if you are ok in sharing your schema and instance, then you can raise issue. no need to struggle for minimal reproduction
from jsonschema.
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)
- Is Custom format checkers supported? HOT 4
- Support for HTTP references HOT 3
- Add `Draft` to type `Schema` HOT 8
- Add warnings on json schema deprecated fields HOT 1
- Draft 2020-12 and array's "items" HOT 2
- Can add `Loader` , give schema and `[]byte` , parse to `map` or `struct` ? HOT 1
- pre-commit hook HOT 3
- request: validate examples HOT 1
- Can not install v5.2.0 HOT 7
- False positive error for a valid regex pattern HOT 1
- invalid jsonType: time.Time HOT 3
- Compiler short circuits when validating schemas, not providing the full list of errors
- Extension.Validate provides data in inconsistent order HOT 1
- Getting property name when compiling and validating user-defined keyword via extensions HOT 5
- Feature request: Pass custom compiler into "convenience" functions like CompileString HOT 2
- Performance drop when schema has "uniqueItems" set to true HOT 7
- `format` field of json schemas is not being validated HOT 1
- CompileString - stat .: permission denied HOT 1
- How can I validate to Python re flavor regex? HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from jsonschema.