Skip to content

Conversation

@elaine-mattos
Copy link
Contributor

@elaine-mattos elaine-mattos commented Jan 2, 2026

Description

This PR addresses query parameter type handling changes introduced by Express 5. (see #1340)

Express 5 introduced a breaking change where req.query is now a read-only getter instead of a writable property. This means that custom middleware can no longer reassign req.query to convert types, causing schema validation to fail when expecting any type but a string.

The solution uses Ajv's built-in coerceTypes feature to handle type conversion during schema validation.

Changes made

1 - Enabled Ajv type coercion: allows for automatic type conversion of query string values;
2 - Removed custom querystring middleware and its tests: no longer needed since Ajv handles type coercion;

@elaine-mattos elaine-mattos changed the title feat: Add Ajv type coercion for Express 5 query parameter compatibility fix: Add Ajv type coercion for Express 5 query parameter compatibility Jan 2, 2026
@JamieMagee JamieMagee force-pushed the feat/express5-migration-query-coercion branch from f8d5bcc to f21fc58 Compare January 14, 2026 19:37
Copy link
Contributor

@JamieMagee JamieMagee left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

If you want, I think you can also simplify some of the defensive code. definitions-1.0.0.js can be simplified from const force = req.query.force === true || req.query.force === 'true' to const force = req.query.force === true and definitions.js can be simplified from const matchCasing = !(request.query.matchCasing === 'false' || request.query.matchCasing === false) to const matchCasing = request.query.matchCasing === true

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

Successfully merging this pull request may close these issues.

2 participants