karenetheridge / JSON-Schema-Modern

Validate data against a schema using a JSON Schema
https://metacpan.org/release/JSON-Schema-Modern/
Other
10 stars 1 forks source link

support different dialects: parse $schema resource for $vocabularies #13

Closed karenetheridge closed 2 years ago

karenetheridge commented 4 years ago

When preparing a schema for use, its $schema resource must be examined for $vocabularies. Parsing of some standard keywords may be disabled, and additionally some nonstandard vocabularies (to be covered in a subsequent issue) could be enabled.

The 'core' vocabulary can never be disabled, as per the spec (citation needed). Other vocabularies are fair game.

https://json-schema.org/draft/2019-09/json-schema-core.html#rfc.section.8.1.2

karenetheridge commented 4 years ago

Not in scope for this issue: supporting arbitrary external vocabularies other than those defined and used by draft-2019-09.

This thread has some things to consider: https://github.com/json-schema-org/json-schema-spec/issues/936

karenetheridge commented 4 years ago

Blocked on #33 and other renovation tasks.

karenetheridge commented 3 years ago

see also https://github.com/json-schema-org/json-schema-spec/pull/985

this points towards a new object type that stores dialect goodies, such as the list of vocabularies that should be enabled (and also lets us special-case the format vocabulary by still calling into that keyword for annotation collection even when it is disabled in the metaspec - can do this with a custom flag set in the dialect that only the format vocabulary will understand).

karenetheridge commented 3 years ago
karenetheridge commented 3 years ago

A more coherent algorithm for doing this is described in #45.

karenetheridge commented 3 years ago

$js->add_vocabulary($class) -- where $class must compose the JSON::Schema::Modern::Vocabulary role. The vocabulary's $vocabulary uri is added to a registry and then can be used by other metaschemas.

Remember that { "$vocabulary": { <uri>: false } } is not an error if the uri is not known - we still proceed without it. but if boolean true is used, and we don't know that vocabulary, then we cannot use the metaschema.

karenetheridge commented 2 years ago

This is now done, as of release 0.521.