Skip to content
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

Wrong null-type for optional ref-type in openapi 3.0.3 #130

Closed
cornerman opened this issue Nov 18, 2023 · 3 comments
Closed

Wrong null-type for optional ref-type in openapi 3.0.3 #130

cornerman opened this issue Nov 18, 2023 · 3 comments

Comments

@cornerman
Copy link
Contributor

cornerman commented Nov 18, 2023

When updating to sttp-apispec 0.7.1, I think, I found a regression regarding nullability.

Having defined:

case class ConfirmationModalDescription(title: String)
case class PublishInput(confirmationModal: Option[ConfirmationModalDescription])

This results in the following openapi definitions:

sttp-apispec 0.3.2 (openapi: 3.0.3):

      "PublishInput" : {
        "properties" : {
          "confirmationModal" : {
            "$ref" : "#/components/schemas/ConfirmationModalDescription"
          }
        },
        "type" : "object"
      }

sttp-apispec 0.7.1 (openapi: 3.0.3):

      "PublishInput" : {
        "properties" : {
          "confirmationModal" : {
            "oneOf" : [
              {
                "$ref" : "#/components/schemas/ConfirmationModalDescription"
              },
              {
                "type" : "null"
              }
            ]
          }
        },
        "type" : "object"
      }

sttp-apispec 0.7.1 (openapi: 3.1.0):

      "PublishInput" : {
        "properties" : {
          "confirmationModal" : {
            "oneOf" : [
              {
                "$ref" : "#/components/schemas/ConfirmationModalDescription"
              },
              {
                "type" : "null"
              }
            ]
          }
        },
        "type" : "object"
      }

After updating, we get type: "null" in our openapi spec (version 3.0.3), which seems be invalid (see: https://swagger.io/docs/specification/data-models/data-types/). I think, it is only introduced in openapi version 3.1.0.

@cornerman
Copy link
Contributor Author

Sorry, I mixed up something in my configuration. It actually works correct now.

@cornerman cornerman reopened this Nov 20, 2023
@cornerman
Copy link
Contributor Author

cornerman commented Nov 20, 2023

Sorry for the confusion, I have updated the description. It was the other way around. In sttp-apispec 0.7.1, we get type: "null", which is not valid in openapi 3.0.3 (according to https://swagger.io/docs/specification/data-models/data-types/).

@cornerman cornerman changed the title Missing nullability for optional ref-type in openapi 3.0.3 Wrong null-type for optional ref-type in openapi 3.0.3 Nov 20, 2023
@cornerman
Copy link
Contributor Author

cornerman commented Nov 21, 2023

Now, I understand that this is actually coming from tapir. I opened a PR there: softwaremill/tapir#3331

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant