ajv-validator/ajv-pack

Compile all/multiple schemas from the instance into a single file

epoberezkin opened this issue · 3 comments

To allow for mutually recursive references and to reduce total code size (in case two schemas reference the same schema)

@epoberezkin I was just pinging to see if this is still on your radar.

If not, would you mind going into a bit more detail on the work involved to accomplish this?

Not sure the how to best approach this from the scope of ajv-pack, but I think the route we are going is to do a transform merging our schemas into one--making sure the $refs are $id'd and appended to root.schema.json#/definitions--before sending our single schema object to Ajv

Edit: To anyone looking for a solution, we also considered just shipping with Ajv or using a yaml ext like yaml-include or yaml-import to include multiple files into a single object before sending to Ajv. Figured our own loader/transforms provide flexibility we may need in the future

In the first instance, it’s worth just trying to compile without merging with/without inlineRefs option and if it succeeds to run some tests to see if it works as expected.

This issue is specifically about multiple schemas that can be used with Ajv but cannot be compiled with Ajv-pack - many such schemas are impossible to merge into a single file anyway (because of recursion). But no harm trying.