We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
oneOf
const
Given the schema
{ "$schema": "http://json-schema.org/draft-07/schema#", "oneOf": [ { "$ref": "#/definitions/First" }, { "$ref": "#/definitions/Second" } ], "definitions": { "First": { "type": "object", "properties": { "type": {"const": "one"}, "value": {"type": "number"} }, "required": ["type", "value"] }, "Second": { "type": "object", "properties": { "type": {"const": "two"}, "value": {"type": "number"} }, "required": ["type", "value"] } } }
I would expect these two schemas to be seen as different shapes and should correctly match these two examples
{"type": "one", "value": 5}
{"type": "two", "value": 5}
And for this to be invald
{"type": "three", "value": 5}
Using the python-rapidjson library:
>>> import rapidjson >>> compiled = rapidjson.Validator(open('example.schema.json').read()) >>> compiled('{"type": "one", "value": 5}') Traceback (most recent call last): File "<stdin>", line 1, in <module> rapidjson.ValidationError: ('oneOf', '#', '#') >>> compiled('{"type": "two", "value": 5}') Traceback (most recent call last): File "<stdin>", line 1, in <module> rapidjson.ValidationError: ('oneOf', '#', '#') >>> compiled('{"type": "three", "value": 5}') Traceback (most recent call last): File "<stdin>", line 1, in <module> rapidjson.ValidationError: ('oneOf', '#', '#')
If I change the type from using const to something like enum: ["one"] this works.
type
enum: ["one"]
I would expect const as a shape discriminator to work.
The text was updated successfully, but these errors were encountered:
fix(crons): Switch to enum as a shape Discriminator in clock tasks
enum
59549c9
This is due to the issue Tencent/rapidjson#2314
fix(crons): Switch to enum as a shape Discriminator in clock tasks (#…
3868aea
…342) This is due to the issue Tencent/rapidjson#2314
No branches or pull requests
Given the schema
I would expect these two schemas to be seen as different shapes and should correctly match these two examples
And for this to be invald
Using the python-rapidjson library:
If I change the
type
from usingconst
to something likeenum: ["one"]
this works.I would expect const as a shape discriminator to work.
The text was updated successfully, but these errors were encountered: