Git Product home page Git Product logo

Comments (6)

SPGoding avatar SPGoding commented on July 23, 2024

Use anyOf instead of oneOf in your schema can solve this if I understand correctly.

from vscode-json-languageservice.

apupier avatar apupier commented on July 23, 2024

Use anyOf instead of oneOf in your schema can solve this if I understand correctly.

good point.
based on http://json-schema.org/draft/2019-09/json-schema-core.html#rfc.section.9.2.1.2


9.2.1.2. anyOf
This keyword's value MUST be a non-empty array. Each item of the array MUST be a valid JSON Schema.

An instance validates successfully against this keyword if it validates successfully against at least one schema defined by this keyword's value. Note that when annotations are being collected, all subschemas MUST be examined so that annotations are collected from each subschema that validates successfully.

9.2.1.3. oneOf
This keyword's value MUST be a non-empty array. Each item of the array MUST be a valid JSON Schema.

An instance validates successfully against this keyword if it validates successfully against exactly one schema defined by this keyword's value.

so the fact that a validation error is provided respect the specification. What would be interesting would be to improve the error message to point to the specification maybe?

nota: this will surely break a lot of other softwares that rely on this message: https://github.com/search?q=%22Matches+multiple+schemas+when+only+one+must+validate.%22&type=Code

from vscode-json-languageservice.

aeschli avatar aeschli commented on July 23, 2024

Do you have a suggestion on how the message should be improved? IMO the current message is correct.

from vscode-json-languageservice.

apupier avatar apupier commented on July 23, 2024

the current message is correct.

yes, it is correct. Unfortunately, i wasn't able to understand what was wrong and how to fix that. Given the large amount of people asking the same questions on StackOverflow, i think it will be good to find a way to drive more newbies like me.

Do you have a suggestion on how the message should be improved?

  • Matches multiple schemas when only one must validate. See json schema specification for oneOf http://json-schema.org/draft/2019-09/json-schema-core.html#rfc.section.9.2.1.3
  • The json schema <xxx> is requiring a single schema match as it is using the oneOf constraint. It is matching several schemas. See also json schema specification for oneOf http://json-schema.org/draft/2019-09/json-schema-core.html#rfc.section.9.2.1.3
  • The json schema <xxx> is requiring a single schema match as it is using the oneOf constraint. It is matching several schemas: <schema-1>, <schema-2>, <schema-3>. See also json schema specification for oneOf http://json-schema.org/draft/2019-09/json-schema-core.html#rfc.section.9.2.1.3

from vscode-json-languageservice.

aeschli avatar aeschli commented on July 23, 2024

I think the problem is that an end user sees the message, but the user doesn't care about schemas. The user probably wants a message like Object can not have property 'x' as well as 'y'..

from vscode-json-languageservice.

NotWearingPants avatar NotWearingPants commented on July 23, 2024

Another problem is that there is no way to know which schemas are possible without debugging the service.

Both for an end user and for a schema developer, it should specify something like Matches multiple schemas (Type2, Type5) when only one must validate., and then both can fix the problem.

The problem is that schemas don't necessarily have names, unless they're a $ref, so maybe showing the position in the schema file of the matches will do.

Yes the user doesn't care about schemas, but the user also wants to know what the problem is to work around it and maybe report it.

from vscode-json-languageservice.

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.