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

Wrong attribute rendering, in an example of a XML response #6615

Closed
eduardoj opened this issue Nov 13, 2020 · 0 comments · Fixed by #7045
Closed

Wrong attribute rendering, in an example of a XML response #6615

eduardoj opened this issue Nov 13, 2020 · 0 comments · Fixed by #7045

Comments

@eduardoj
Copy link

eduardoj commented Nov 13, 2020

Q&A

  • OS: openSUSE Tumbleweed, VERSION="20201111"
  • Browser: Google Chrome
  • Version: 86.0.4240.198
  • Method of installation: dist assets
  • Swagger-UI version: 3.36.2
  • Swagger/OpenAPI version: Swagger 2.0, OpenAPI 3.0.0

Tested also with Firefox 82.0.3, and Chromium 86.0.4240.183.

Content & configuration

Example Swagger/OpenAPI definition:

openapi: 3.0.0
info:
  description: Wrong attribute rendering in an example of a XML response
  version: "1.0.0"
  title: XML Test
paths:
  /about:
    get:
      summary: About
      description: Retrieves generic information
      responses:
        '200':
          description: Generic information.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/api_response'
              example:                                   
                code: ok_json
                summary: Ok JSON
            application/xml; charset=utf-8:
              schema:
                $ref: '#/components/schemas/api_response'
              example:                                   
                code: ok_xml
                summary: Ok XML
components:
  schemas:
    api_response:
      description: OK. The request has succeeded.
      properties:
        code:
          type: string
          xml:
            attribute: true
        summary:
          type: string
      xml:
        name: status
      example:
        code: ok_default
        summary: Ok default

Describe the bug you're encountering

Switching the "Media type" to "application/xml; charset=utf8" results in this xml:

<?xml version="1.0" encoding="UTF-8"?>
<status code="ok_default">
	<summary>Ok xml</summary>
</status>

The code attribute should have the value ok_xml.

To reproduce...

Steps to reproduce the behavior:

  1. Go to your Swagger-UI local instance.
  2. Load the provided example yaml file.
  3. Click in the "GET /about" endpoint section.
  4. Chose the "application/xml; charset=utf8" option from the select box "Media type".
  5. See wrong xml response, with a wrong value in the code attribute.

Expected behavior

The code attribute should have the value ok_xml.

<?xml version="1.0" encoding="UTF-8"?>
<status code="ok_xml">
	<summary>Ok xml</summary>
</status>

Additional context or thoughts

This does not happen in SwaggerHub. Only in my local Swagger-UI instance, created from the dist assets.

Link to a working example, in SwaggerHub: https://app.swaggerhub.com/apis/eduardoj/xmlExampleWrongAttribute/1.0.0

@eduardoj eduardoj changed the title Wrong attributte rendering, in an example of a XML response Wrong attribute rendering, in an example of a XML response Nov 13, 2020
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