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
When using the Stoplight mock server, I encountered an issue where the validation does not work as expected when an object uses allOf and includes constraints such as required, minLength, maxLength, etc. This issue affects users who rely on accurate validation responses for API testing and mocking.
Current Behavior
Instead of throwing an error for invalid data, the mock server returns a 200 OK status, incorrectly indicating that the validation passed. For instance, sending an empty string for a required field does not trigger any validation errors.
Expected Behavior
The mock server should return a validation error when the input does not meet the defined schema constraints, such as missing required fields or failing to meet minLength requirements.
Possible Workaround/Solution
After investigating, I found that downgrading the @stoplight/json package to version 3.21.3 resolves the issue. It seems that newer versions might have introduced a regression or incompatibility with the current Prism setup.
Steps to Reproduce
Define a new path with request body (object) in the Stoplight project using allOf with validation constraints.
Send a request with data that does not meet the validation criteria (e.g., missing required fields or invalid field lengths).
Observe that the server incorrectly returns a 200 OK status.
The text was updated successfully, but these errors were encountered:
darkoandreev
changed the title
Validation Not Working for allOf Objects with Constraints
Request body validation is not working for allOf object referencing
Aug 1, 2024
Context
When using the Stoplight mock server, I encountered an issue where the validation does not work as expected when an object uses
allOf
and includes constraints such asrequired
,minLength
,maxLength
, etc. This issue affects users who rely on accurate validation responses for API testing and mocking.Current Behavior
Instead of throwing an error for invalid data, the mock server returns a 200 OK status, incorrectly indicating that the validation passed. For instance, sending an empty string for a required field does not trigger any validation errors.
Expected Behavior
The mock server should return a validation error when the input does not meet the defined schema constraints, such as missing required fields or failing to meet
minLength
requirements.Possible Workaround/Solution
After investigating, I found that downgrading the
@stoplight/json
package to version3.21.3
resolves the issue. It seems that newer versions might have introduced a regression or incompatibility with the current Prism setup.Steps to Reproduce
Part of the YAML API specification:
Example request body:
The text was updated successfully, but these errors were encountered: