Git Product home page Git Product logo

Comments (2)

justin-tay avatar justin-tay commented on June 20, 2024

Thanks for raising the issue.

I think the simple fix is to have it fall back on

if (this.validationContext.getConfig().isOpenAPI3StyleDiscriminators()
&& (discriminator != null || executionContext.getCurrentDiscriminatorContext().isActive())
&& !executionContext.getCurrentDiscriminatorContext().isDiscriminatorMatchFound()) {
errors = Collections.singleton(message().instanceNode(node).instanceLocation(instanceLocation)
.locale(executionContext.getExecutionConfig().getLocale())
.arguments(
"based on the provided discriminator. No alternative could be chosen based on the discriminator property")
.build());
}

I don't really have an objection to a specific error message for the missing property, since the spec states If the discriminator value does not match an implicit or explicit mapping, no schema can be determined and validation SHOULD fail.

But if you want to do so then ideally the PR should have a proper fix, meaning that

  • Ensure that the missing property message raised is consistent for all the discriminator usages eg. allOf, anyOf, oneOf
  • The messages should all be localized (Currently even the current message isn't properly localized and would tack on an english message)

from json-schema-validator.

justin-tay avatar justin-tay commented on June 20, 2024

After looking at this closer it looks like due to the following

To make the behavior consistent with the rest of the usages the logic needs to treat the discriminator as matching if the property is not present in the data and rely on the required validator to catch the missing discriminator.

I shall probably create the PR to resolve this.

from json-schema-validator.

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.