Unknown keywords annotation #512
Replies: 4 comments 8 replies
-
I'm glad you included an example, because I wasn't following what you were proposing without it. It's like a virtual annotation keyword. It doesn't actually exist in the schema. It's an interesting idea, but definitely a new behavior, so we shouldn't think carefully about it. |
Beta Was this translation helpful? Give feedback.
-
When you say "just", do you mean "as opposed to the other solutions"? |
Beta Was this translation helpful? Give feedback.
-
Another idea would be to update the output format. @jdesrosiers has casually mentioned (somewhere) that the root of the output could house additional information about an evaluation, things like dialect. A list of unknown keywords could be added to that instead of being an annotation. |
Beta Was this translation helpful? Give feedback.
-
The decision to not support unknown keywords has resulted in requiring implementations to refuse to process such schemas, which means this proposal is no longer relevant. Closing. |
Beta Was this translation helpful? Give feedback.
-
The primary argument against supporting unknown keywords is that, because they're just skipped (or their values collected as annotations), there isn't a good way to catch mis-typed keywords. That leads to unexpected validation results, where a keyword is expected to perform some validation but doesn't because what should have been a keyword wasn't recognized as one.
The proposed solutions to this were to
additionalProperties: false
in the meta-schemaWe've opted for the second approach with a little bit of the first (we'll have one open and one closed meta-schema).
But what if we just require an annotation that is a list of the unknown keywords?
(If the validation is false, then the annotation would appear in
droppedAnnotations
, or we could require that it's always there.)Note that this isn't a meta-schema validation.
$unknownKeywords
as an annotation would be commenting on the schema itself rather than the instance.I'm going to add this to my implementation as an option and expose it in the online validator so people can play with it.
UPDATE ☝️ is done. Play with it at https://json-everything.net/json-schema, and select the Unknown keyword annotation option on the left.
Examples
Schema:
Instance:
Result:
Beta Was this translation helpful? Give feedback.
All reactions