Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

What is the proper way to test that a schema is not empty? #1252

Unanswered
gitgrift asked this question in Q&A
Discussion options

This is a naive question but I have not found any other discussion about it.

I have learned from https://json-schema.org/understanding-json-schema/basics that an empty schema is a valid one. And so jsonschema.validate() does not raise an exception if you pass in an empty value for schema. That's fine, as it is easy enough to first test if the schema argument value is empty or.

But jsonschema.validate() also seems to accept a non-empty schema value that does not contain any useful schema keywords. So when I call jsonschema.validate() how can I be certain that the schema describes some specific properties of an instance?

Afaict the validator check_schema methods ignore unrecognized keywords so a schema full of garbage is no different than an empty one.

You must be logged in to vote

Replies: 1 comment

Comment options

The behavior you're describing is the behavior mandated by the JSON Schema spec, which allows unknown keywords in all existing versions, though which will likely disallow them in upcoming ones.

The basic general answer is "have tests which exercise your schema" if you're trying to catch bugs in it.

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants

AltStyle によって変換されたページ (->オリジナル) /