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

Incorrect oneOf rendering in Swagger UI for OpenAPI 3.1.0 #10266

Open
tkramarczyk-vgw opened this issue Jan 29, 2025 · 1 comment
Open

Incorrect oneOf rendering in Swagger UI for OpenAPI 3.1.0 #10266

tkramarczyk-vgw opened this issue Jan 29, 2025 · 1 comment

Comments

@tkramarczyk-vgw
Copy link

Q&A (please complete the following information)

Content & configuration

I’m generating my OpenAPI specification using SpringDoc for my Kotlin project.

I’ve noticed that when I set the OpenAPI version to 3.0.x, Swagger UI renders my responses correctly. However, with the default version 3.1.0, it does not. The differences between the 3.0.x and 3.1.x specifications are minimal, so I believe this is an issue with Swagger UI.

To verify, I also tested the 3.1.0 specification with ReDoc, and it rendered correctly.

Swagger/OpenAPI definition:

openapi: 3.1.0
info:
  title: Example
  version: 1.0.0
paths: {}
components:
  schemas:
    Mercedes:
      allOf:
        - $ref: '#/components/schemas/Car'
        - type: object
          properties:
            foo:
              type: string
      required:
        - foo
        - name
        - type
    Bmw:
      allOf:
        - $ref: '#/components/schemas/Car'
        - type: object
          properties:
            bar:
              type: string
      required:
        - name
        - type
    Car:
      type: object
      discriminator:
        propertyName: type
      required:
        - name
        - type
      properties:
        type:
          type: string
          description: Type discriminator
        name:
          type: string
    MyResponse:
      type: object
      properties:
        cars:
          type: array
          items:
            oneOf:
              - $ref: '#/components/schemas/Mercedes'
              - $ref: '#/components/schemas/Bmw'
      required:
        - cars

Describe the bug you're encountering

This is what I get in swagger UI:

Image

To reproduce...

Paste the yaml to https://editor.swagger.io/ or https://editor-next.swagger.io/

Expected behavior

Image

3.1.0 vs 3.0.0

Image

@gmli
Copy link

gmli commented Feb 4, 2025

I’m having this error too, it’s quite frustrating because it makes Swagger-UI almost useless in OpenAPI 3.1.x

Here is a minimal definition to reproduce the issue : 

openapi: 3.1.0
info:
  title: Test
  description: ''
  license:
    name: ''
  version: 0.1.0
paths:
  /fetch:
    get:
      description: ''
      operationId: fetch
      responses:
        '200':
          description: ''
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: '#/components/schemas/model'
components:
  schemas:
    model:
      type: object
      description: ''
      required:
        - id
      properties:
        id:
          type: string

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

2 participants