Skip to content

Swagger UI XML example generator does not self-close empty tags #11055

Description

@adrianodpdiaz

Content & configuration

Swagger/OpenAPI definition:

openapi: 3.0.3
info:
  title: XML Empty Tag Example
  version: 1.0.0

paths:
  /example:
    get:
      responses:
        '200':
          description: Example XML response
          content:
            application/xml:
              schema:
                type: object
                xml:
                  name: Response
                properties:
                  id:
                    type: string
                  name:
                    type: string
                  emptyTag:
                    type: object
                    xml:
                      name: EmptyTag

Swagger-UI configuration options:

SwaggerUI({
  // default configuration
})

Is your feature request related to a problem?

Yes. When Swagger UI generates an XML example for an empty XML element, it does not self-close the element (EmptyTag in the following example):

<?xml version="1.0" encoding="UTF-8"?>
<Response>
  <id>string</id>
  <name>string</name>
  <EmptyTag>
  </EmptyTag>
</Response>

Describe the solution you'd like

When generating XML examples, Swagger UI should generate empty elements using the self-closing XML syntax:

<EmptyTag/>

instead of:

<EmptyTag>
</EmptyTag>

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions