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

XML example not rendered with oneOf, anyOf #6540

Closed
ovtep opened this issue Oct 20, 2020 · 0 comments · Fixed by #6555
Closed

XML example not rendered with oneOf, anyOf #6540

ovtep opened this issue Oct 20, 2020 · 0 comments · Fixed by #6555

Comments

@ovtep
Copy link

ovtep commented Oct 20, 2020

  • OS: Windows 10 Pro (64 bit)
  • Browser: Chrome
  • Version: 85.0.4183.121
  • Method of installation: online swagger editor
  • Swagger-UI version: online swagger editor
  • 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:
            application/json:
              schema:
                $ref: '#/components/schemas/test'
            application/xml:
              schema:
                $ref: '#/components/schemas/test'
components:
  schemas:
    test:
      type: object
      properties:
        a: 
          type: string
        b:
          type: integer
        c:
          type: array
          items:
            $ref: '#/components/schemas/Things'
        d:
          type: array
          items:
            anyOf:
              - $ref: '#/components/schemas/TextObject'
              - $ref: '#/components/schemas/ImageObject'
            
            
    Things:
      type: object
      oneOf:
      - $ref: '#/components/schemas/TextObject'
      - $ref: '#/components/schemas/ImageObject'
            
    TextObject:
      required:
      - data
      type: object
      properties:
        objectType:
          type: string
          example: Text
          xml:
            name: ObjectType
        data:
          type: string
          example: This is a text
          xml:
            name: Data
      description: Contains a text      
      
    ImageObject:
      required:
      - data
      type: object
      properties:
        objectType:
          type: string
          example: image
          xml:
            name: ObjectType
        data:
          type: string
          example: This is a image
          xml:
            name: Data
      description: Contains a image

Describe the bug you're encountering

There is an issue with XML rendering when the open api schema contains oneOf, anyOf.

To reproduce...

Steps to reproduce the behavior:

  1. Go to 'https://editor.swagger.io/'
  2. Paste the Example Swagger/OpenAPI definition.
  3. Go to response 200, select media type XML.
  4. See that the schemas with oneOf and anyOf are not rendered.

Expected behavior

Rendering the equivalent XML. The XML shall be rendered as JSON does, containing every schema from oneOf, anyOf.

Additional context or thoughts

The issue is described differently in #4943
There is marked as enhancement. I think this is a bug.

mathis-m added a commit to mathis-m/swagger-ui that referenced this issue Oct 30, 2020
mathis-m added a commit to mathis-m/swagger-ui that referenced this issue Oct 30, 2020
tim-lai added a commit that referenced this issue Nov 3, 2020
* ref: #6470 
* fixes: #6540
* fixes: #4943 

* add example override option to json
* add example override option to xml
* added basic oneOf and anyOf support
* fix anyof|oneof
* only lift xml to items


Co-authored-by: Tim Lai <timothy.lai@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants