-
Notifications
You must be signed in to change notification settings - Fork 9.2k
Closed
Description
- OS: Windows 10 Pro (64 bit)
- Browser: Chrome
- Version: 69.0.3497.100 (Official Build) (64-bit)
- Method of installation: dist assets
- Swagger-UI version: 3.19.3
- 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:
oneOf:
- type: object
- type: array
- type: boolean
- type: integer
- type: numberSwagger-UI configuration options:
SwaggerUI({
url: 'v1.yaml',
dom_id: '#swagger-ui-container',
deepLinking: false,
presets: [
SwaggerUIBundle.presets.apis
],
plugins: [],
docExpansion: "none",
validatorUrl: null
})Describe the bug you're encountering
XML schema is not rendered correctly when I use oneOf for one of the model properties. It just display the first element in the generated example and skips the other two. With reference to my example, it skips properties 'b' and 'c'. It displays the example like below:
<?xml version="1.0" encoding="UTF-8"?>
<test>
<a>string</a>
</test>
To reproduce...
Steps to reproduce the behavior:
- Go to https://editor.swagger.io/
- Copy paste the provided spec
- Click on POST /test endpoint
- Under Responses, change the Response Content Type/Accept to "application/xml"
Expected behavior
It must display atleast the first two attributes which has a valid type.
<?xml version="1.0" encoding="UTF-8"?>
<test>
<a>string</a>
<b>0</b>
</test>
Additional context or thoughts
Unrelated Question:
Is there a way to display property 'c' as well in the response example? I understand that the type can be one of the specified types and cannot be displayed like property 'a' & 'b'. However, I just wanted to make sure that I have not missed anything.