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
An invalid request body is being passed off as valid by validator when a shared schema is being referenced by other endpoint.
Current Behavior
Running mock with --errors flag on OpenAPI that satisfy the condition above returns 2xx even on invalid request body (e.g., missing required property).
Expected Behavior
Invalid request body should return 422.
Possible Workaround/Solution
A workaround is to make sure that no two or more endpoints make reference to a same schema.
Send an invalid request (i.e., missing name): curl --request POST --url http://127.0.0.1:4010/pets --header 'Content-Type: application/json' --data '{"id" : 1}'
This invalid request passes as a success, responding with 201
To see the validation working again:
5. Update the yaml file, remove all other endpoints except the createPets endpoint.
6. Run the same cURL request curl --request POST --url http://127.0.0.1:4010/pets --header 'Content-Type: application/json' --data '{"id" : 1}'
7. This now works as expected, responding with 422
After testing around this validation issue occur whenever the schema #/components/schemas/Pet is being reference by multiple endpoint.
Environment
macOS
prism v5.8.3
node v22.5.1
The text was updated successfully, but these errors were encountered:
Context
An invalid request body is being passed off as valid by validator when a shared schema is being referenced by other endpoint.
Current Behavior
Running mock with --errors flag on OpenAPI that satisfy the condition above returns 2xx even on invalid request body (e.g., missing required property).
Expected Behavior
Invalid request body should return 422.
Possible Workaround/Solution
A workaround is to make sure that no two or more endpoints make reference to a same schema.
Steps to Reproduce
prism mock petstore.yaml --errors
curl --request POST --url http://127.0.0.1:4010/pets --header 'Content-Type: application/json' --data '{"id" : 1}'
To see the validation working again:
5. Update the yaml file, remove all other endpoints except the
createPets
endpoint.6. Run the same cURL request
curl --request POST --url http://127.0.0.1:4010/pets --header 'Content-Type: application/json' --data '{"id" : 1}'
7. This now works as expected, responding with 422
After testing around this validation issue occur whenever the schema
#/components/schemas/Pet
is being reference by multiple endpoint.Environment
The text was updated successfully, but these errors were encountered: