-
-
Notifications
You must be signed in to change notification settings - Fork 95
Open
Description
Version: 5.10.6
Scenario:
- The OpenAPI spec denotes a
requestBodywith multiple composite "datum" fields that have a commonDatumschema also defined in the OpenAPI spec (there are three of these in my example). - The
Datumschema has fieldsvalue(of typenumber) andunit(of type enum defined in the OpenAPI spec). - The example repo for this is here: https://github.com/markgreenwood/openapi-backend-validation-bug
Expected behavior:
- A composite field that fails to validate should report an error with
instancePathandschemaPaththat both reflect that field's identity (i.e. contain the name of the invalid field). - If multiple fields fail validation, there should be multiple errors that each contain the information described above.
Actual behavior:
- If any fields using the
Datumschema OTHER than the first one in the spec are provided non-numeric values, the error'sschemaPathreports validation failure with the name of the FIRST field listed that uses theDatumschema, not the one that actually failed validation. (In the example, ifweightis provided a non-numeric value, theschemaPathincorrectly reportsdistanceas the culprit that failed validation.) - If multiple fields fail validation, the errors array only contains one error, not all the ones that failed to validate. (In one of the example tests, both
weightandtemperatureare provided non-numeric values, but only one error is reported and itsschemaPathincorrectly reportsdistanceas being invalid.)
Steps to reproduce:
- Clone or fork the example repo, install dependencies with
npm ci, and then runapi.test.tsusingnpm run test. Two of the tests describing the expected behavior above should fail.
Metadata
Metadata
Assignees
Labels
No labels