-
-
Notifications
You must be signed in to change notification settings - Fork 222
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[OpenAPI Schema Validator] Nullable support with allOf, anyOf & oneOf #1318
Labels
Milestone
Comments
aeoncl
added a commit
to aeoncl/microcks
that referenced
this issue
Sep 12, 2024
aeoncl
added a commit
to aeoncl/microcks
that referenced
this issue
Sep 12, 2024
Thanks a lot for opening this issue. It's super clear and super documented. I'll have a look at the PR asap. |
aeoncl
added a commit
to aeoncl/microcks
that referenced
this issue
Sep 13, 2024
Signed-off-by: aeoncl <48886723+aeoncl@users.noreply.github.com>
aeoncl
added a commit
to aeoncl/microcks
that referenced
this issue
Sep 13, 2024
Signed-off-by: aeoncl <48886723+aeoncl@users.noreply.github.com>
Great job on the PR! Thanks! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Describe the bug
Hello there, i come once again with an OpenAPI edge case 🥳🥳🥳🥳
In order to make a schema that we want to $ref nullable, in OpenAPI < 3.1, we are forced to use this syntax:
source
If i run a contract test on an endpoint that uses this mechanism and the real API returns null, the OpenAPI Validator will fail. because it doesn't handle this case.
Expected behavior
nullable is set to true, so null is a valid value.
Actual behavior
nullable is not considered in the handling of composition structures by the OpenAPISchemaValidator
How to Reproduce?
You can import the following contract and use microcks to run contract test on himself (using microcks mock url as targetUrl)
Microcks version or git rev
1.10.0-fix2
Install method (
docker-compose
,helm chart
,operator
,docker-desktop extension
,...)Microcks Uber through docker
Additional information
The proposed fix that i have linked to this PR adds some behavior in the OpenAPISchemaValidator.convertType() method:
The idea is:
we nest their content into a oneOf and add a null type to a branch of the oneOf.
we just add a null type if it's not already here (because this method is called recursively, this prevents treating the same structure twice)
The text was updated successfully, but these errors were encountered: