feat: upgrade to Ajv v8 for v3.0.0-rc.1#116
Conversation
- Bump Ajv from v6 to v8.20.0 - Bump ajv-keywords to v5.1.0 - Add nullable support via schema conversion for Ajv v8 - Convert Ajv v8 instancePath to dataPath for backward compatibility - Remove message normalization to accept Ajv v8 'must be' messages - Update all test assertions to match Ajv v8 error format - Update ajv-keywords import paths for v5 - Fix error ordering in tests to match Ajv v8 output - Add MIGRATION.md with detailed v2→v3 guide - Update CHANGELOG and README with migration info - Update Node.js minimum version to 18
- Update package.json engines from >=18 to >=24 - Update README.md requirements - Update MIGRATION.md Node version references - Update CHANGELOG.md Node version references - Update GitHub Actions to Node 24 compatible versions: - actions/checkout@v4 → @v5 - actions/upload-artifact@v4 → @v6 - actions/download-artifact@v4 → @v6
- Change 'should be string' to 'must be string' in code examples - Aligns with MIGRATION.md and Ajv v8 behavior
|
@kibertoad, @kobik, @ilanKushnir Hi maintainers, I've opened this PR (#116) to upgrade this library to Ajv v8 and modernize the project infrastructure. This is a major version bump (v3.0.0-rc.1) that brings the library back on track with current Node.js and dependency versions. Key highlights:
This library is important to my project and I imagine many others depend on it. The upgrade addresses several security concerns from outdated dependencies and ensures compatibility with modern Node.js versions. I've included detailed documentation, a full error message mapping table for migration, and all tests have been updated to pass. The changes are well-tested and documented. Would appreciate a review when you have a chance. Happy to discuss any concerns or make adjustments as needed. Thanks for maintaining this project! |
PR Description
Summary
This PR upgrades the project to Ajv v8 and updates the minimum Node.js version to 24, representing a major version bump to v3.0.0-rc.1. This upgrade includes breaking changes to validation error messages, dependency updates, and modernized CI/CD infrastructure.
Changes
Breaking Changes
requirederrors may appear beforeadditionalProperties)ajv-keywordsv5 has differentschemaPathandparamsformat for sub-keyword errorseslint.config.js)eslint-config-standard,eslint-plugin-node,eslint-plugin-standard, andeslint-plugin-import(incompatible with ESLint v10)>=18to>=24New Features
nullablesupport —nullable: trueis automatically converted to Ajv v8-compatibletype: [T, "null"]instancePath→dataPathnormalization — Ajv v8'sinstancePath(JSON Pointer format) is automatically converted to dot-notationdataPathfor backward compatibilityDependency Updates
Core dependencies:
ajv:^6.12.6→^8.20.0ajv-formats: (new)^3.0.1— formats are now a separate package in Ajv v8ajv-keywords:^3.5.2→^5.1.0openapi-schema-validator:^3.0.3→^12.1.3js-yaml:^3.14.1→^4.2.0decimal.js:^10.3.1→^10.6.0Dev dependencies:
eslint:^8.5.0→^10.5.0mocha:^8.4.0→^11.7.6nyc:^15.1.0→^18.0.0uuid:^8.3.2→^14.0.0chai:^4.3.4→^4.5.0chai-as-promised:^7.1.1→^7.1.2eslint-plugin-n:^11.1.0→^16.6.2eslint-plugin-promise:^4.3.1→^7.3.0eslint-plugin-chai-friendly:^0.6.0→^1.2.1Code Changes
normalizeAjvErrorsutility to convert Ajv v8 errors (instancePath) to v6-compatible format (dataPath)nullable: trueto Ajv v8-compatibletypearraysaddKeywordcalls to use Ajv v8 API format ({ keyword, ...definition })ajv-formatssupport for Ajv v8 format validatorsaddFormats(ajv)andstrict: falsefor v8 compatibilityajv-keywordsimport paths for v5 compatibility (keywords/→dist/keywords/)nullableoption from Ajv configurationseslint.config.jsfor ESLint v10 flat config formateslint.config.jsfrom nyc coverage reportingCI/CD Updates
[18, 20, 22, 24]to[24]actions/checkout@v4→@v5actions/setup-node@v4→@v6actions/upload-artifact@v4→@v6actions/download-artifact@v4→@v7github/codeql-action/*@v1→@v3coverallsapp/github-action@master→@v2Documentation
Migration
See MIGRATION.md for a detailed migration guide including:
Quick Migration Steps
npm install api-schema-builder@3ajv-keywordsimports if you use them directly:keywords/→dist/keywords/Testing
Checklist