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
I have searched existing issues to ensure the bug has not already been reported
Fastify version
4.2.0
Plugin version
3.1.0
Node.js version
17.8.0
Operating system
macOS
Operating system version (i.e. 20.04, 11.3, 10)
12.1
Description
Creating multiple schemas out of existing one using the only method is creating conflictions when used with different http methods. For instance, If two schemas for POST and PATCH is extracted from base schema using only keyword then only one of them is getting applied to both routes (first route in the file is taking precedence)
As in above snippet, when app.post is declared first then UserCreateSchema is getting applied to both POST & PATCH routes. And if we revert the order of routes like below then UserPatchSchema is getting applied to both routes ignoring rules defined in UserCreateSchema for POST
Prerequisites
Fastify version
4.2.0
Plugin version
3.1.0
Node.js version
17.8.0
Operating system
macOS
Operating system version (i.e. 20.04, 11.3, 10)
12.1
Description
Creating multiple schemas out of existing one using the
only
method is creating conflictions when used with differenthttp
methods. For instance, If two schemas forPOST
andPATCH
is extracted from base schema usingonly
keyword then only one of them is getting applied to both routes (first route in the file is taking precedence)Steps to Reproduce
Below are examples of schemas and routes.
Base schema
Schema for POST method (All fields are required)
Schema for PATCH method (Only fields mentioned in patch schema is modifiable and none of them are required.)
1. Routes
As in above snippet, when
app.post
is declared first thenUserCreateSchema
is getting applied to bothPOST
&PATCH
routes. And if we revert the order of routes like below thenUserPatchSchema
is getting applied to both routes ignoring rules defined inUserCreateSchema
forPOST
2. Routes
Expected Behavior
Ideally, schemas created using
only
keyword should work independently without conflictions.The text was updated successfully, but these errors were encountered: