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

Swagger UI / Open API - type name lost when annotating property with @Schema(nullable = true) #25078

Closed
josephearl opened this issue Apr 21, 2022 · 6 comments
Labels
area/swagger-ui kind/bug Something isn't working

Comments

@josephearl
Copy link

josephearl commented Apr 21, 2022

Describe the bug

Given the following resource response or request:

public class Parent {
  private Child firstChild;

  @Schema(nullable = true)
  private Child secondChild;

  public Child getFirstChild() {
    return firstChild;
  }

  public Child getSecondChild() {
    return secondChild;
  }
}

The schema in the documentation does not display the type name for secondChild as I would expect, instead it is blank:

Screenshot 2022-04-21 at 21 15 16

Using quarkus-smallrye-openapi and quarkus-resteasy-jackson.

Expected behavior

No response

Actual behavior

No response

How to Reproduce?

No response

Output of uname -a or ver

No response

Output of java -version

17.0.2

GraalVM version (if different from Java)

No response

Quarkus version or git rev

Quarkus 2.8.1.Final

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

Gradle 7.4.2

Additional information

No response

@josephearl josephearl added the kind/bug Something isn't working label Apr 21, 2022
@quarkus-bot
Copy link

quarkus-bot bot commented Apr 21, 2022

/cc @MikeEdgar, @phillip-kruger

@josephearl
Copy link
Author

josephearl commented Apr 21, 2022

---
openapi: 3.0.3
info:
  title: Family
  description: Family API
  version: 1.0.0
paths:
  /family/one:
    get:
      tags:
      - Family
      responses:
        "200":
          description: Parent
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Parent'
components:
  schemas:
    Child:
      type: object
      properties:
        name:
          type: string
    Parent:
      type: object
      properties:
        firstChild:
          $ref: '#/components/schemas/Child'
        secondChild:
          allOf:
          - $ref: '#/components/schemas/Child'
          - nullable: true

@josephearl
Copy link
Author

josephearl commented Apr 21, 2022

https://stackoverflow.com/a/48114924/290028

OAI/OpenAPI-Specification#1368

so I think for 3.0 it should be something like

secondChild:
  nullable: true
  allOf:
  - $ref: '#/components/schemas/Child'

@josephearl
Copy link
Author

Tested using https://editor.swagger.io with the original and the patched version and both behave the same way and have the same display issue as in Quarkus, so seems it's an in issue in Swagger UI. I'll file something there.

@gsmet
Copy link
Member

gsmet commented Apr 21, 2022

@josephearl thanks for taking the time to diagnose this thing and keep us updated!

@josephearl
Copy link
Author

Raised swagger-api/swagger-ui#7992

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/swagger-ui kind/bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants