Deprecated #extend_schema_definition #335
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There are two ways right now to extend a schema, one is by subclassing
either an existing validator (eg.
JSON::Schema::Draft4
) and the other isby subclassing the base validator class (
JSON::Schema::Validator
) andcalling
extend_schema_definition
in the initializer. This methodmerges the recognised json schema properties of another validator into
your new validator. Unfortunately this is effectively the same as
subclassing. What's worse,
extend_schema_definition
does not merge inany of the other characteristics of a validator (eg. the formats or
names etc needed for a schema to work). All of the validator classes
that come with json-schema use subclassing, rather than
extend_schema_definition
.Because of this, I propose that we should deprecate
extend_schema_definition
and encourage people to subclass instead.