voxpupuli / json-schema

Ruby JSON Schema Validator
MIT License
1.52k stars 242 forks source link

Deprecated #extend_schema_definition #335

Closed iainbeeston closed 7 years ago

iainbeeston commented 8 years ago

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 is by subclassing the base validator class (JSON::Schema::Validator) and calling extend_schema_definition in the initializer. This method merges 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 in any 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.

iainbeeston commented 8 years ago

Incidentally this also includes the fix from #315