Reference local files, by schema/property idSee original GitHub issue
I’m currently using the ajv lib and some custom logic to dereference my schemas, and then I found this lib which will probably do a better job. Is there a way to add schemas so this lib is aware of them? My JSON schemas reference by id, so for example in ajv I’m loading all my schemas
schemas.forEach(schema => ajv.addSchema(schema)) and then trying to parse the $refs. Is there something similar I can do for this lib? Or is the example in the docs the only way
- Created 7 years ago
- Comments:12 (4 by maintainers)
Top GitHub Comments
@5amfung It looks like custom resolvers are supported: https://github.com/James-Messinger/json-schema-ref-parser/blob/master/docs/plugins/resolvers.md
If you’re willing to write a resolver plugin which replaces the HTTP resolver, please do, and make a PR for it.
An issue with that solution is that schemas which use a mixture of addressable and non addressable URLs would run into problem. Maybe you could add provision in your resolver to only resolve specific domains, otherwise pass through the URL to the standard resolver.
Like @brettstack, I have a set of schema files that are not accessible through http but only accessible from a file directory. These schema are unfortunately referenced by their
$id. I know
$id is not supported as explained above. But is there a way for me to provide the schema instead of the parser to go downloading it through http? Perhaps a custom parser?
@James-Messinger Any pointer would be very much appreciated.