Comments (6)
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.
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.
Updated with some comments ^
from jsonschema.
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.
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.
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)
- Detailed output missing info
- unexpected validation error which LSP is fine with HOT 10
- Provide CLI binaries with release HOT 3
- Link in README for YAML playground example is broken HOT 1
- Issue with custom Regex Library HOT 10
- `Compiler.AddResource` for adding pre-compiled schemas HOT 5
- Feature: Adding Context to Validate Method HOT 2
- implementing json.Marshaler interface HOT 9
- Create JSONSchema from Compile()'s result HOT 2
- Wrong unevaluatedProperties validation errors HOT 6
- compiler.go bug in 171
- Invalid JSON schema does not error out HOT 2
- [bug] Not reading from stdin HOT 2
- Missing document file path in validation output when validating multiple documents HOT 5
- Error messages are revealing absolute file paths HOT 1
- YouValidateMe JSON Schema library server project built on this library
- ECMA-262 as the default regex in this library? HOT 1
- jsonschema.Compiler has no field or method CompileRegex HOT 7
- Question: parsing Schema to string HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from jsonschema.