Comments (4)
till none of the object1 or object2 has required fields and additionnalProperties set to false
object2string can match object1 definition as additionnal properties
if you want need this difference , you may either set in object1 the fiels object1string as required , and / or set additionnalProperties to false
that s kind be tricket as additionnalProperties set to false may impact the extensibility ( depending your definition of breaking change)
so to me it is not a bug
from spectral.
@LasneF I'm not sure if I quite understand what you are proposing. Are you saying because both of the oneOf objects don't have required fields and additionalProperties is set to true that it's matching both objects? If so, that makes sense. I was always supposing that even if you have a schema with no required properties that its still restricted but as you mentioned extensibility may be why it cannot do that.
from spectral.
yes that s it
and object like
{
"status" : "happy"
}
in fact surprisingly will match both schema object1 and object2 , this is why when doing validation of your sample it throw this error
your objec1 & object2 schema does not have enough "restriction" . As oneOf is strict ; it MUST match ONE and only ONE schema , it fails
if you want to have oneOf you need more restriction in your schema (like introducing some fields required , or additionnalProperties to false)
in fact in a oneOf statement , the schema need to be "kind of" incompatible each others
from spectral.
Thanks for the info! Just played with it and see that it works when doing it that way and makes perfect sense to me now. I'll close this and thanks for the quick education.
from spectral.
Related Issues (20)
- Incorrect deduplication after 1.18.2 HOT 4
- oas3-schema rule did not show the correct path and line number for response having extra schema with $ref HOT 3
- oas3-valid-media-example rule cannot handle schemas with discriminator HOT 1
- Critical vulnerability (CVE-2023-37466) reported due to transitive dependency, vm2 which is discontinued. HOT 6
- Percent-encoding JSON Pointers in #2511 introduced a breaking change in spectral-core and spectral-cli HOT 3
- Pattern function does not work un-quoted numbers HOT 3
- Stop including vm2 as a dependency HOT 1
- Update proxy-agent to remove vulnerable vm2 dependency HOT 2
- Cannot execute arm64 release binaries HOT 3
- BigInt/int64 number format not working
- content Type XML and example not property handle HOT 1
- Support for OAS Server Variables HOT 2
- Make sure op-security-defined rules work correctly with AND auth HOT 2
- Define Json Schema in OAS triggers no-$ref-siblings error
- comparing given value with other value within jsonpath HOT 1
- hay guys have a check i keek getting this iisue
- Double external ref to external ref to recursive schema causes false "ref does not exist" (OAS)
- Version 6.11 results in oas3-server-variables error for relative server URL and variable substitution HOT 1
- path params isn't working for params with "." in the name
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 spectral.