-
-
Notifications
You must be signed in to change notification settings - Fork 880
New issue
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
add property to object with additionalProperties: false from switch #205
Comments
additionalProperties are scoped to the current schema, they don't have global visibility... In this case it means that You need:
|
And you don't need v5 switch for that, oneOf will work too. |
Maybe it will all make more sense if you think about it in this way: JSON Schema may seem like it is about declaring what is allowed, but it is not. JSON Schema is about imposing restrictions. So you can easily extend the restrictions by adding them to any schema (like in the case with |
@epoberezkin no you've been quite clear, I think it was I who was not so clear in the initial case. What I'm looking for here is to explicitly disallow |
you can use |
oh really? I had thought that would just remove it from the required list, that's a bit of a semantic misnomer I'd say as the negation of requirement isn't necessarily prohibition 😄 Totally works, thank you very much for your help |
|
But semantically it is funny indeed |
it might make sense to suggest an alias
|
You don't have to wait for the standard change :) ajv.addKeyword('present', {
macro: (schema) => ({ required: schema });
}); |
should this be possible:
It seems unclear from the documentation, but shouldn't I technically be able to even set
additionalProperties: true
in the switch'sthen
?The text was updated successfully, but these errors were encountered: