restructure the 'traverse' phase
karenetheridge opened this issue · comments
see karenetheridge/OpenAPI-Modern#36.
Alter JSM::Document::BUILD so that it evaluates the document against its metaschema with keyword callbacks (for the purpose of populating the resource index).
Specification metaschemas would need to have their resource index entries 'baked in' because we can't evaluate these schemas against themselves until their resource indexes are populated.
Therefore add_schema
will need to bootstrap the specification metaschemas on first use.
This may or may not save time; some benchmarking is needed.
This lets us get rid of the traverse phase entirely, which is going to make things a little easier on the openapi front because the way that document is structured is a little different, and we have to jump through hoops to make its 'traverse' sub behave the same way. Also there is a bit of confusion when constructing and validating an openapi document object, whether we report errors in 'instanceLocation' or 'keywordLocation'.
Also, the 'callback' subs in 'evaluate' are going to start producing errors (for checks that can't be represented by the spec metaschema itself), so during the evaluation loop we need to also check the callback return value and use that for short-circuiting decisions.
(This is now done.)
once the problem of bootstrapping specification metaschemas is solved, traverse()
can be rewritten simply as an evaluate()
where the data instance is the schema and the schema is either extracted out of the schema's $schema
keyword or is overridden with metaschema_uri
.