Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd not remove this line but instead, I'd do the following:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's one the solution, but when we will remove the
type
from second schema, then we infer the type fromhttp://json-schema.org/draft-07/schema
and it is:https://github.com/json-schema-org/json-schema-spec/blob/draft-07/schema.json#L39
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that
oneOf
can only complicate (already complex) our JSON SchemaThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're right. Forgot that
type
can take an array. Go for it then.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fore sure not removing the
type: object
line because that would mean we accept anything and that's not true.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But the
"type": ["object", "boolean"]
is inferred from thehttp://json-schema.org/draft-07/schema
allOf
combined schema means that for every sub schema input data must be valid, so if I removed thetype
from the second schema then I have allowed types for first schemaobject
andboolean
and for second I have allowed of course everything, but then, as I wrote, the http://json-schema.org/draft-07/schema schema only allows the [object, boolean], so at the end if someone put as input the number type it will be invalid:If someone put boolean or object it will be always valid :)
You can test it with this simple schema:
in the https://www.jsonschemavalidator.net/
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But for you I will write in the second schema the
object, boolean
type 😘There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ohh sorry, I didn't notice. Nevermind, it's fine as it is 👍