json-schema-org / json-schema-spec

The JSON Schema specification
http://json-schema.org/
Other
3.82k stars 266 forks source link

Forbid custom keywords that start with `$` #1321

Closed gregsdennis closed 1 year ago

gregsdennis commented 2 years ago

The Core keywords are easily identifiable by the fact that they start with $.

The specification recommends against defining custom keywords which also start with $, but this recommendation seems to be repeatedly ignored by implementations ($data seems to be a common violator).

While the "$" prefix is not formally reserved for the Core vocabulary, it is RECOMMENDED that extension keywords (in vocabularies or otherwise) begin with a character other than "$" to avoid possible future collisions.

Since this recommendation has been in the spec for multiple iterations, maybe it's time to move this to a MUST NOT requirement.

handrews commented 2 years ago

We avoided doing that because plenty of implementations support weird custom $-prefixed keywords. However, if we remove support for non-vocabulary keywords, I can see forbidding other vocabulary keywords from using it. Those older cases were non-vocabulary extensions.

gregsdennis commented 1 year ago

We've decided that unknown (non-vocab) keywords will be unsupported moving forward (pending some additional options).