-
Notifications
You must be signed in to change notification settings - Fork 422
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
make schema nullable instead of adding null-types into the apispec schema #3331
Conversation
Thanks for the investigation! It seems there are some test failures, though - maybe changes are required in both apispec & tapir. |
I see, though, I actually have difficulties building locally, even on master. I am on nix, so I did
or
Do you have an idea, why this happens? |
Hm this looks quite weird, are you sure you have an up-to-date codebase? I'm not familiar with |
I am on the current master (commit 5350715). Using java version 20. Running just sbt "openapiDocs/compile" works, other sub-projects seem to have issues though. |
In the github-action logs, I cannot really see which tests are failing. Wondering what could be the reason that this change fails for java version 11 but not for java version 21 (only JVM though). |
Well, let's stick with that then :)The test that fails is |
Thank you. I fixed the test, but I am guessing, we will now want to adapt sttp-apispec, to give us some encoding for the nullability for ref types in openapi 3.0.3. But this would make the spec valid again. Imho, this should be something like in this stack-overflow thread: https://stackoverflow.com/questions/40920441/how-to-specify-a-property-can-be-null-or-a-reference-with-swagger |
Thanks - though the test does expect a |
Additionally, we should have a test for openapi 3.1.0 and openapi 3.0.3. So, we are sure that all works. Currently, we are testing only 3.1.0 with regards to nullability. For json, this line (https://github.com/softwaremill/sttp-apispec/blob/master/jsonschema-circe/src/main/scala/sttp/apispec/internal/JsonSchemaCirceEncoders.scala#L28) will probably take care of it. One question about the openapi 3.0.3 support in apispec: Which of the two proposed solution makes sense for us? The first one with |
Ok, actually I am a bit confused now. The yaml-codec uses the json codec internally, so I am wondering, why this code in sttp-apispec (https://github.com/softwaremill/sttp-apispec/blob/master/jsonschema-circe/src/main/scala/sttp/apispec/internal/JsonSchemaCirceEncoders.scala?rgh-link-date=2023-11-21T18%3A04%3A48Z#L28) does not have any effect when setting nullable to true. |
I have now added a PR in sttp-apispec: softwaremill/sttp-apispec#131 The tests now pass again and I have added additional tests for openapi 3.0.3. |
c88f4b0
to
d607fa5
Compare
…hema These null-types are only supported in openapi 3.1.0. For 3.0.3, we need a different encoding. Therefore, we should leave the distinction to sttp-apispec, instead of deciding here in tapir.
5cc7719
to
659d27d
Compare
Thanks! |
Would you mind making a new release soonish? I am in dire need for this patch :) |
Ah yes sorry, on its way :) |
These null-types are only supported in openapi 3.1.0. For 3.0.3, we need a different encoding.
Therefore, we should leave the distinction to sttp-apispec which handles this already, instead of deciding here in tapir.