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
Describe the bug
It looks like removeAdditional: "failing" response validation fails. I feel like the validator first tries to validate against type A and in progress removes property "extra", then it passes this to validate against B and it now also fails since "extra" field is missing. Note that the schema works if I change the order of TypeA and TypeB in the oneOf property.
To Reproduce
I've added a test case that fails in my fork of this repo, link to commit:
I am running into the same issue here and after some debugging, I find that express-openapi-validator does not pass distriminator: true to ajv and the generated validate function is incorrect. To generate the correct one, discriminator: true has to be set. But there is no way to explicitly config ajv as express-openapi-validator only extracts coerceTypes, removeAdditional.
Seems like a lot of these problems are due to the OpenAPI spec itself simply does not support using additionalProperties: false this way with combinators like anyOf, allOf.
From other discussion it seems this is fixed by the unevaluatedProperties: false which is now supported by JSON Schema (and thus OAS 3.1), and AJV.
Describe the bug
It looks like removeAdditional: "failing" response validation fails. I feel like the validator first tries to validate against type A and in progress removes property "extra", then it passes this to validate against B and it now also fails since "extra" field is missing. Note that the schema works if I change the order of TypeA and TypeB in the oneOf property.
To Reproduce
I've added a test case that fails in my fork of this repo, link to commit:
vileanco@1963bd6
Actual behavior
Response validation fails with 500 "Internal server error". Errors returned
Expected behavior
Response validation should pass.
Examples and context
Validator options:
Spec:
The text was updated successfully, but these errors were encountered: