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
This is probably not a problem with schemasafe, just a question:
Is it possible to have a property either be a reference or null?
In Webstorm for example this works if I want media to be nullable:
{ "$schema": "https://json-schema.org/draft/2020-12/schema", "$id": "my.schema", "type": "object", "additionalProperties": false, "title": "my secret schema", "required": [ "ownerNumber" ], "media": { "oneOf": [ { "type": "null" }, { "$ref": "media.schema.json" } ] } }
If I send media as object everything works as it should, but if I send media: null I get this error message from schemasafe:
{ "keywordLocation": "#/properties/objects/items/$ref/properties/media/oneOf/1/$ref/type", "instanceLocation": "#/objects/0/media" }
So is it possible to allow both null and the reference?
The text was updated successfully, but these errors were encountered:
Media is actually under "properties", I didn't want to post my whole schema.
Sorry, something went wrong.
Perhaps it satisfies both conditions, and oneOf is looking for exactly one per spec?
oneOf
Does using anyOf help? It's hard to tell without media.schema.json (i.e. does null pass it or not).
anyOf
media.schema.json
null
See https://json-schema.org/understanding-json-schema/reference/combining.html#oneof for an explainer.
Also, sorry for the late response.
Going to close as answered, please comment if this should be reopened.
No branches or pull requests
This is probably not a problem with schemasafe, just a question:
Is it possible to have a property either be a reference or null?
In Webstorm for example this works if I want media to be nullable:
If I send media as object everything works as it should, but if I send media: null I get this error message from schemasafe:
So is it possible to allow both null and the reference?
The text was updated successfully, but these errors were encountered: