You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
After a route is added a function afterRouteAdded is invoked which in turn invokes validation.build => schemas.getSchemaAnyway (via schema.resolveRefs) to build out schemas. This getSchemaAnyway function is injecting new properties into the schema object before passing the schema to the defined schema compiler. If said schema compiler does not recognize these newly added properties then it can fail to return a compiled schema that will validate as expected.
Let's say you use Joi schemas and that your have a custom Joi schema compiler that recognizes some internal extensions to Joi. If you define a route like:
Then a request to /foo/42 will fail the assertion because the custom compiler will return a schema that does not recognize any properties in the param schema due to the extra data being inserted by getSchemaAnyway.
Expected behavior
getSchemaAnyway should not mutate schema definitions it does not recognize.
Your Environment
node version: 10
fastify version: >=2.6.0
os: Mac
The text was updated successfully, but these errors were encountered:
馃悰 Bug Report
After a route is added a function
afterRouteAdded
is invoked which in turn invokesvalidation.build
=>schemas.getSchemaAnyway
(viaschema.resolveRefs
) to build out schemas. ThisgetSchemaAnyway
function is injecting new properties into the schema object before passing the schema to the defined schema compiler. If said schema compiler does not recognize these newly added properties then it can fail to return a compiled schema that will validate as expected.fastify/lib/schemas.js
Lines 121 to 126 in 9b233e8
To Reproduce
Let's say you use Joi schemas and that your have a custom Joi schema compiler that recognizes some internal extensions to Joi. If you define a route like:
Then a request to
/foo/42
will fail the assertion because the custom compiler will return a schema that does not recognize any properties in theparam
schema due to the extra data being inserted bygetSchemaAnyway
.Expected behavior
getSchemaAnyway
should not mutate schema definitions it does not recognize.Your Environment
The text was updated successfully, but these errors were encountered: