Code Monkey home page Code Monkey logo

Comments (4)

seriousme avatar seriousme commented on May 24, 2024 1

Hi,

thanks for reporting!

It should check for invalid refs (see

test("non-existing path throws error", async (t) => {
)

But apparently your case falls between the cracks.

I will check!

Kind regards,
Hans

from openapi-schema-validator.

seriousme avatar seriousme commented on May 24, 2024

ok, I checked and its a bit tricky :-)

Up until now validation only checked if the specification matched the JSONschema for that specification.
Your example matches the schema as the JSONschema of OpenAPI 3.0.0 allows for the $ref at the place where you put them, and the value of the $ref is a string as required by the JSONschema of OpenAPI 3.0.0. Hence the validator said that your schema is valid.

Since we can't validate the $ref via the JSONschema, there needs to be an extra logic check. This check was already present in resolveRefs but if you were doing a pure validation then resolveRefs would not be called as resolveRefs modifies the schema, which might be undesirable.

I have a PR in the works that adds a ref check to validation so that a specification that matches the JSONschema of OpenAPI but holds invalid refs is still marked as invalid.

Kind regards,
Hans

from openapi-schema-validator.

seriousme avatar seriousme commented on May 24, 2024

Released as 2.1.3 on NPM.

npx -p @seriousme/openapi-schema-validator validate-api "invalid.spec.yaml" should work correctly now.

Kind regards,
Hans

from openapi-schema-validator.

Medvedscak avatar Medvedscak commented on May 24, 2024

Great, thanks for such a quick fix! Everything looks cool now)

from openapi-schema-validator.

Related Issues (7)

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.