Reputation: 979
Is it possible to generate expanded/resolved schemas with AJV where $ref
is used? $ref
is extremely useful for keeping schemas DRY, but but not if you need an expanded representation of the schema.
When a schema is compiled, the returned function has the schema
property, but that returns the non expanded schema that was supplied to the compile function in the first place. Further, there doesn't seem to be anything in the docs about it or even from a google search.
Is it possible to get an expanded schema where $ref
is used?
Upvotes: 1
Views: 410
Reputation: 12355
While some tools provide some level of functionality to do this, it's not always possible to do this correctly, and sometimes impossible. ajv
documents that it will not implement this functionality for reasons:
- recursive $refs
- List item $ref is not equivalent to the object inclusion, because the $refs inside $ref should be resolved based on id in the source schema and not based on id of the current schema.
https://github.com/epoberezkin/ajv/issues/336#issuecomment-258538008
Upvotes: 1