swagger-editor icon indicating copy to clipboard operation
swagger-editor copied to clipboard

oneOf fails to render response body when application type is XML

Open HCA97 opened this issue 2 years ago • 0 comments

Q&A (please complete the following information)

  • OS: Ubuntu
  • Browser: Chrome
  • Version: 18.04
  • Method of installation: ?
  • Swagger-Editor version: ?
  • Swagger/OpenAPI version: OpenAPI 3.0

Content & configuration

Example Swagger/OpenAPI definition:

openapi: 3.0.0
info:
  description: Test API
  version: v1
  title: Test API
tags:
  - name: Test
    description: Test API
servers:
  - url: /v1
paths:
  /test:
    post:
      tags:
        - Test
      summary: Test endpoint
      description: Test
      operationId: postTest
      responses:
        '200':
          description: Returns response
          content:
            # Rendered successfully
            # application/json:
            #   schema:
            #     oneOf:
            #       - $ref: '#/components/schemas/test'     

            # Rendered successfully
            # application/xml:
            #   schema:
            #     $ref: '#/components/schemas/test'

            # Rendered Failed!
            application/xml:
              schema:
                oneOf:
                  - $ref: '#/components/schemas/test'   

components:
  schemas:
    test:
      type: object
      properties:
        a:
          type: string
          example: "test"
        b:
          type: integer
          example: 1

Describe the bug you're encountering

If I add oneOf, it fails to render the response body when the application type is XML but it successfully renders when the application type is JSON. Therefore I believe this unexpected behavior is a bug.

To reproduce...

Steps to reproduce the behavior:

  1. Go to https://editor.swagger.io/
  2. Copy-paste the YAML above
  3. See the bug

Expected behavior

Successfully rendering the XML response. image

Actual behavior

Displaying (no example available) image

Additional context or thoughts

If I change the application type to JSON then it renders the body successfully. image

HCA97 avatar Aug 10 '22 19:08 HCA97