Giter Club home page Giter Club logo

Comments (6)

santhosh-tekuri avatar santhosh-tekuri commented on June 8, 2024

If you can share the complete source code, and some example of what your extension is trying to do, then it would help me understand your issue.

from jsonschema.

dan-j avatar dan-j commented on June 8, 2024

I've created a fork and committed an example you can run with go test, see openapi_test.go:

https://github.com/dan-j/santhosh-tekuri-jsonschema/tree/142-extension-subschema-validation

from jsonschema.

dan-j avatar dan-j commented on June 8, 2024

Updated with some comments ^

from jsonschema.

santhosh-tekuri avatar santhosh-tekuri commented on June 8, 2024

I had a look at your source code; it seems you got confused "what is meant by extension"

openapi document is a json document. and its jsonschema is openapi_3.1.schema.json (note that you are confused that openapi_3.1.schema.json is the schema of extension. no it is not)

openapi uses jsonschema to specify schema for request and responses. but in addition to standard jsonschema it includes few additional keywords discriminator, xml, externalDocs and example (see Fixed Fields section in https://spec.openapis.org/oas/v3.1.0#schema-object)

among the above 4 keywords, only discriminator effects validation. rest of them are just for documentation purpose

so you have to write an extension for discriminator keyword. and the schema for this is at https://spec.openapis.org/oas/3.1/meta/base


now if you want to understand why you are getting validation error in your specific implementation:
you created an extension whose schema is openapi_3.1.schema.json. and openapi_3.1.schema.json says, openapi and info are required. So when you use this extension you are saying: I am introducing two new keywords openapi and info which are mandatory. So you are getting validation errors in schema compilation.

from jsonschema.

dan-j avatar dan-j commented on June 8, 2024

Ahh ok. So I was under the impression that extensions would only be applied if the ExtCompiler returned an ExtSchema, which for the full spec, it contains "openapi" so I return a noop schema, but for others I am returning nil.

I'm going to close this, thanks for your response!

from jsonschema.

santhosh-tekuri avatar santhosh-tekuri commented on June 8, 2024

extensions are always applied.

that mean your schema must be valid against all the registered extensions.
the extension.validate implement should look for its keywords and do the validation logic

from jsonschema.

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.