Skip to content

Slight inconsistency in the definition of empty schemas #1283

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

Closed
Julian opened this issue Aug 28, 2022 · 2 comments · Fixed by #1298
Closed

Slight inconsistency in the definition of empty schemas #1283

Julian opened this issue Aug 28, 2022 · 2 comments · Fixed by #1298
Assignees

Comments

@Julian
Copy link
Member

Julian commented Aug 28, 2022

§4.3.1 ends with:

An empty schema is a JSON Schema with no properties, or only unknown properties.

(emphasis mine)

while §4.3.2 ends with:

While the empty schema object is unambiguous, there are many possible equivalents to the "false" schema. Using the boolean values ensures that the intent is clear to both human readers and implementations.

(emphasis again mine)

But if schemas with unknown properties are also defined to be "empty", then they indeed aren't unambiguous, there are instead an infinite number of them.

I'm not sure why we define empty schemas to include those with unknown keywords, though it seems that has been there forever.

If we stick with that definition it seems we should remove the offhand remark in 4.3.2 and just treat them the same (i.e. say something like both true and false are intended to be "canonical ways" to express those notions).

But personally if there's not a good reason to I'd re-define empty schemas to refer simply to the schema {} (n.b. or if there's some complication there due to $schema being mandatory, perhaps be either {} or {"$schema" : "..."} though that seems hairy...)

@gregsdennis
Copy link
Member

This is a good find.

I would argue that objects with only unrecognized keywords aren't "empty schemas." These schemas would produce annotations for each of the unknown keywords. This is explicitly different behavior than the true and zero-property-object schemas.

@handrews
Copy link
Contributor

Yes, this should be fixed, thanks! The first part dates from when unknown keywords SHOULD be ignored but really now that they're SHOULD collect as annotations it makes even less sense.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants