simonplend / express-json-validator-middleware

Express middleware for validating requests against JSON schema

Home Page:https://npm.im/express-json-validator-middleware

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Upgrade Ajv dependency to v8

simonplend opened this issue · comments

This library is currently using Ajv v6. Upgrading to Ajv v7 was proposed in pull request #55. In the meantime, Ajv v8 has been released, so we'll upgrade to that.

See: Changes from Ajv v6.12.6 to v8.0.0

TODO

Some of these may be worth breaking out into separate issues.

  • Upgrade Ajv dependency to latest release (v8.8.2)
    • Run tests
    • Install in test application and test manually
  • Identify breaking changes between Ajv v6 and v8 which directly affect this library (none)

Hi, Ajv v8 has been released on March 27. Do you plan to support it? I may help if needed.

@jledentu Great question. I just checked the Breaking Changes between v7 and v8 and they seem fairly minor (https://github.com/ajv-validator/ajv/releases/tag/v8.0.0).

I'm hoping to get the v2.2.0 release of this library out very soon and then I can focus on the v3.0.0 release. The original plan was for that release to introduce an upgrade from Ajv v6 to v7, but it looks like we might as well skip v7 and upgrade to v8.

I'd love help with this, thank you!

Thank you for working on this. In my use case, I was trying to use ajv-formats with code like the following:

const { Validator } = require('express-json-validator-middleware');
const addFormats = require("ajv-formats");

const validator = new Validator();
addFormats(validator.ajv);

but got errors like TypeError: Cannot read property 'code' of undefined or similar.

For anyone interested, the temporary workaround is to downgrade to ajv-formats@3.2.1 which seems to work correctly with ajv@6.6.2 currently used by express-json-validator-middleware.

I've published a beta release with Ajv v8. Please give it a try and let me know if you run into any issues!

npm install express-json-validator-middleware@beta

This beta version should be compatible with the latest version of Ajv plugins such as ajv-formats.

/cc @jledentu @matpen