-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Closed
Labels
Description
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.24.3
Plugin version
No response
Node.js version
18.18.2
Operating system
Linux
Operating system version (i.e. 20.04, 11.3, 10)
bookworm
Description
At this location:
fastify/lib/schema-controller.js
Line 112 in 1891f24
| this.validatorCompiler = this.getValidatorBuilder()(this.schemaBucket.getSchemas(), serverOptions.ajv) |
Any custom schema support is removed if any schemas were added, because the default builder is used to overwrite the installed validatorCompiler.
The order of operations does not appear to matter, because both registering the custom schema support and adding schemas by id will happen before listen and this initialization is run at that time.
Steps to Reproduce
const server: Fastify = fastify({
logger: true
});
server.setValidatorCompiler(...)
server.addSchema(...)
server.setValidatorCompiler(...) // again if you want to, it won't help
server.listen(...)
Any validation schema that needs the customization from setValidatorCompiler(...) will fail to compile because the default compiler is actually used.
Expected Behavior
if this.isCustomSerializerCompiler then it should not overwrite the installed compiler
Reactions are currently unavailable