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 generation fails if an array has an example #6627

Closed
hkosova opened this issue Nov 17, 2020 · 0 comments · Fixed by #6634
Closed

XML example generation fails if an array has an example #6627

hkosova opened this issue Nov 17, 2020 · 0 comments · Fixed by #6634

Comments

@hkosova
Copy link
Contributor

hkosova commented Nov 17, 2020

Q&A (please complete the following information)

  • OS: Windows 10
  • Browser: Chrome, Firefox (latest)
  • Method of installation: https://editor.swagger.io
  • Swagger-UI version: 3.36.2
  • Swagger/OpenAPI version: 2.0, 3.0

Content & configuration

Example Swagger/OpenAPI definition:

openapi: 3.0.1
info:
  title: XML array schema with array-level example
  version: 1.0.0

paths:
  /users:
    get:
      responses:
        "200":
          description: ''
          content:
            application/xml:
              schema:
                $ref: '#/components/schemas/Users'

components:
  schemas:
    Users:
      type: array
      example:
        - id: 123
          name: bob
        - id: 456
          name: jane
      xml:
        name: Users
        wrapped: true
      items:
        type: object
        xml:
          name: User
        properties:
          id:
            type: integer
            xml:
              attribute: true
          name:
            type: string
            xml:
              attribute: true

Describe the bug you're encountering

If an array schema has an array-level example, XML example generation fails. This is a regression in 3.36.2, probably introduced in PR #6555. The same definition is displayed correctly in 3.36.1.

Actual behavior

Response example cannot be generated

😱 Could not render r, see the console

Expected behavior

Response example appears as:

<?xml version="1.0" encoding="UTF-8"?>
<Users>
	<User id="123" name="bob">
	</User>
	<User id="456" name="jane">
	</User>
</Users>

Screenshots

image

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.

1 participant