-
Is there any way (in the main library or check-jsonschema) to allow you to validate the examples within the JSON schema? I want to ensure the examples provided in the schema are actually valid |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 2 replies
-
Hi there! I assume you mean "I want to ensure that things in the There's not a public API built in at the moment for walking schemas (to e.g. find instances of the keyword) if you want to do this dynamically without knowledge of the specific schema -- such an API will come some day. In the interim of course though you could either write the (fairly simple) function which walks a schema looking for the keyword, and just call |
Beta Was this translation helpful? Give feedback.
-
In case it helps anyone else, I've lashed together a
It needs a little more work to count as a CI error if there are invalid examples, but it's hopefully a useful start. |
Beta Was this translation helpful? Give feedback.
Hi there!
I assume you mean "I want to ensure that things in the
examples
keyword are valid under the schema they live inside"?That's behavior not part of the specification (which basically says to do nothing with that keyword), though of course it's reasonable to want it.
There's not a public API built in at the moment for walking schemas (to e.g. find instances of the keyword) if you want to do this dynamically without knowledge of the specific schema -- such an API will come some day.
In the interim of course though you could either write the (fairly simple) function which walks a schema looking for the keyword, and just call
validate
.