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

Cannot set ajv instace to 2019 and 2020 #107

Closed
2 tasks done
nicobuzeta opened this issue Mar 13, 2024 · 1 comment
Closed
2 tasks done

Cannot set ajv instace to 2019 and 2020 #107

nicobuzeta opened this issue Mar 13, 2024 · 1 comment

Comments

@nicobuzeta
Copy link
Contributor

nicobuzeta commented Mar 13, 2024

Prerequisites

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

Fastify version

4.26.1

Plugin version

2.5.1

Node.js version

21.7.1

Operating system

Linux

Operating system version (i.e. 20.04, 11.3, 10)

Docker node:latest

Description

Current plugin does not allow ajv instances created with non-draft 7 schemas to be used like:
ajv/dist/2019
ajv/dist/2020

Steps to Reproduce

import ajvNew from 'ajv/dist/2020.js';

export default fp(async (fastify) => {
  const ajv = new ajvNew.default();
  await fastify.register(response_validation, {
    ajv
  });
}


### Expected Behavior

Expect it to use my ajv instance internally. Right now the check for setting the ajv instance is:

if (opts.ajv && opts.ajv instanceof Ajv) {

However, this fails for this case since the ajv I am passing in is not of type Ajv.
@nicobuzeta
Copy link
Contributor Author

I've proposed a possible fix in #108

@Eomm Eomm closed this as completed Mar 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants