Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support passing in a custom Ajv instance #93

Closed
2 tasks done
felixfbecker opened this issue May 9, 2023 · 2 comments
Closed
2 tasks done

Support passing in a custom Ajv instance #93

felixfbecker opened this issue May 9, 2023 · 2 comments
Labels
enhancement New feature or request good first issue Good for newcomers

Comments

@felixfbecker
Copy link
Contributor

Prerequisites

  • I have written a descriptive issue title
  • I have searched existing issues to ensure the feature has not already been requested

🚀 Feature Proposal

Please provide the ability to pass in your own Ajv instance.

Motivation

Currently, one can only pass in ajv options, and the plugin instantiates ajv.
But to use latest drafts of JSON Schema, one has to import a different Ajv class than the default export: https://ajv.js.org/json-schema.html#draft-2020-12

In Fastify request validation, this is possible with setCompileFactory(), but it won't work for response validation.

Example

const ajv = new Ajv2020({ ... })
fastify.register(responseValidation, { ajv })
@felixfbecker felixfbecker changed the title Support passing in a custom a Support passing in a custom Ajv instance May 9, 2023
@mcollina
Copy link
Member

Thanks for reporting! Would you like to send a Pull Request to address this issue? Remember to add unit tests.

@mcollina mcollina added enhancement New feature or request good first issue Good for newcomers labels May 10, 2023
dancastillo added a commit to dancastillo/fastify-response-validation that referenced this issue Jun 25, 2023
dancastillo added a commit to dancastillo/fastify-response-validation that referenced this issue Jul 1, 2023
@Fdawgs
Copy link
Member

Fdawgs commented Jul 2, 2023

Closed by #94

@Fdawgs Fdawgs closed this as completed Jul 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

3 participants