Skip to content

Incorrect oneOf rendering in Swagger UI for OpenAPI 3.1.0 #10266

Open
@tkramarczyk-vgw

Description

@tkramarczyk-vgw

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions