Giter Site home page Giter Site logo

Comments (4)

LasneF avatar LasneF commented on June 14, 2024

@miller79

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.

miller79 avatar miller79 commented on June 14, 2024

@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.

LasneF avatar LasneF commented on June 14, 2024

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.

miller79 avatar miller79 commented on June 14, 2024

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)

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.