ajv-keywords icon indicating copy to clipboard operation
ajv-keywords copied to clipboard

fastify v3 requires using ajv v6 and ajv-keywords v3

Open matt212 opened this issue 3 years ago • 7 comments

Hi Below is Details ,

Node version : v14.16.0 Npm version: 7.7.6 Dependencies Details "ajv": "^8.0.1", "ajv-keywords": "^5.0.0",

Code Snippet

const fastify = require("fastify")({
   ajv: {
    plugins: [[require("ajv-keywords"), ["transform"]]],
  },
});

stack trace Error

image

Help here would great !

matt212 avatar Mar 30 '21 20:03 matt212

Fastify v3 does not support ajv 8 out of the box

You need to configure your server with ajv6 compatibility plugins, or follow this pr https://github.com/fastify/fastify/pull/2862

Or customizer the validator compiler by yourself

Eomm avatar Mar 30 '21 21:03 Eomm

Hi @Eomm , I downgraded to "ajv-keywords": "^3.5.2", and removed "ajv": "^8.0.1", altogether and error seems to go away. However it would better to keep this issue open until the dependency with fastify 3 is resolved

matt212 avatar Mar 31 '21 05:03 matt212

@Eomm thank you - I was thinking it is probably this issue.

let me know if you need any advice on migrating to v8 in fastify v4.

epoberezkin avatar Mar 31 '21 19:03 epoberezkin

@Eomm thank you - I was thinking it is probably this issue.

let me know if you need any advice on migrating to v8 in fastify v4.

I'd like to know how we'd migrate to v8 in fastify v4

devlzcode avatar Apr 22 '21 18:04 devlzcode

We don't have a release date for fastify v4 yet, but for sure it will support ajv 8 by default 👍🏼

Eomm avatar Apr 22 '21 19:04 Eomm