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

OpenAPI schema adding "enum" : [ null ] when field description is added #45708

Closed
cristianonicolai opened this issue Jan 20, 2025 · 3 comments · Fixed by #45802
Closed

OpenAPI schema adding "enum" : [ null ] when field description is added #45708

cristianonicolai opened this issue Jan 20, 2025 · 3 comments · Fixed by #45802
Labels
Milestone

Comments

@cristianonicolai
Copy link
Contributor

Describe the bug

When adding @Schema information to a POJO attribute, the generated schema information on OpenAPI diverges when adding a description. The target description is meant only for the field information and not the type.
For example:

@Schema(nullable = true) RunConfiguration run

Generates:

"run" : {
            "allOf" : [ {
              "$ref" : "#/components/schemas/RunConfiguration"
            } ],
            "nullable" : true
          }

Wheres the same place you add:

@Schema(nullable = true, description = "The run configuration.") RunConfiguration run

Ends up generating:

"run" : {
            "description" : "The run configuration.",
            "type" : "object",
            "anyOf" : [ {
              "$ref" : "#/components/schemas/RunConfiguration"
            }, {
              "enum" : [ null ]
            } ],
            "nullable" : true
          }

Expected behavior

"properties" : {
          "run" : {
           "description" : "The run configuration.",
            "allOf" : [ {
              "$ref" : "#/components/schemas/RunConfiguration"
            } ],
            "nullable" : true
          }
        }

Actual behavior

"properties" : {
          "run" : {
            "description" : "The run configuration.",
            "type" : "object",
            "anyOf" : [ {
              "$ref" : "#/components/schemas/RunConfiguration"
            }, {
              "enum" : [ null ]
            } ],
            "nullable" : true
          }

How to Reproduce?

Created sample project with annotated POJOs here: https://github.com/cristianonicolai/quarkus-playground

Sample annotated field: https://github.com/cristianonicolai/quarkus-playground/blob/main/src/main/java/org/acme/Configuration.java#L7
Generated OpenAPI schema: https://github.com/cristianonicolai/quarkus-playground/blob/main/openapi/openapi.json#L14

Output of uname -a or ver

No response

Output of java -version

No response

Quarkus version or git rev

3.17.7

Build tool (ie. output of mvnw --version or gradlew --version)

Apache Maven 3.9.9

Additional information

No response

Copy link

quarkus-bot bot commented Jan 20, 2025

/cc @EricWittmann (openapi), @MikeEdgar (openapi), @phillip-kruger (openapi)

@cristianonicolai
Copy link
Contributor Author

Possibly related to #45624

@MikeEdgar
Copy link
Contributor

I think this should be fixed with smallrye/smallrye-open-api#2152 and will be included in smallrye-open-api 4.0.7.

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

Successfully merging a pull request may close this issue.

2 participants