Request: ability to use ajv-oai as an AJV plugin.
Closed this issue · 1 comments
Hi,
I'm the author of fastify-openapi-glue which adds OpenAPI support to the Fastify webserver.
fastify-openapi-glue uses your ajv-oai to implement the additional types on AJV.
Currently I create a new AJV instance using ajv-oai and pass that to Fastify. (see https://github.com/seriousme/fastify-openapi-glue/blob/master/index.js#L50)
That works great (thanks for that !) but also means that I need to track changes in Fastify's config of AJV.
Fastify exposes a parameter 'ajv' (see https://www.fastify.io/docs/latest/Server/#ajv) to pass AJV plugins to the default AJV instance.
Now If I could pass ajv-oai as a plugin to AJV then I would not need to track changes in Fastify's AJV config anymore.
I checked other AJV plugins (e.g. https://github.com/luzlab/ajv-formats/blob/master/index.js) and the main difference is that AJV needs to be passed as a parameter.
Is it possible to add a plugin option to ajv-oai ?
I can write a PR.
Kind regards,
Hans
It turns out the fastify 'ajv' parameter can only be used on new instances and not on plugins like mine.
Sorry to have bothered you.
Kind regards,
Hans