#11023·swagger-ui

Issue with Rendering XML Examples

Author: whoareyoukidCreated Aug 25, 2026Updated Aug 25, 2026

Q&A (please complete the following information)

  • OS: macOS
  • Browser: Google chrome
  • Version: 151.0.7922.138 (Official Build) (arm64)
  • Method of installation: npm
  • Swagger-UI version: 5.20.5
  • Swagger/OpenAPI version: OpenAPI 3.0

Content & configuration

Example Swagger/OpenAPI definition:

json
{
  "openapi": "3.0.0",
  "info": {
    "title": "Data Upload",
    "version": "1.22.1"
  },
  "security": [
    {
      "OAuth2": ["{x_pname}.InboundProcessing"]
    }
  ],
  "paths": {
    "/idocinbound": {
      "post": {
        "security": [
          {
            "OAuth2": ["{x_pname}.InboundProcessing"]
          }
        ],
        "requestBody": {
          "content": {
            "application/xml": {
              "schema": {
                "oneOf": [
                  { "$ref": "#/components/schemas/Schema1" },
                  { "$ref": "#/components/schemas/Schema2" }
                ]
              },
              "examples": {
                "example1": {
                  "$ref": "#/components/examples/XmlExample1"
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Success"
          }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "OAuth2": {
        "type": "oauth2",
        "flows": {
          "clientCredentials": {
            "tokenUrl": "https://example.com/token",
            "scopes": {
              "{x_pname}.InboundProcessing": "Inbound Processing"
            }
          }
        }
      }
    },
    "schemas": {
      "Schema1": {
        "type": "object",
        "properties": {
          "data": { "type": "string" }
        }
      },
      "Schema2": {
        "type": "object",
        "properties": {
          "data": { "type": "string" }
        }
      }
    },
    "examples": {
      "XmlExample1": {
        "value": "<?xml version=\"1.0\"?><Root><Data>Test</Data></Root>"
      }
    }
  }
}

Swagger-UI configuration options:

javascript
SwaggerUI({
      spec: apiSpec,
      dom_id: '#api-ui-container',
      defaultModelRendering: 'model',
      showExtensions: true,
      deepLinking: true,
      plugins: [DisableTryItOutPlugin],
      onComplete(): void {
        setTimeout(() => that.swaggerUiOnComplete(that), 500);
      }
});

Describe the bug you're encountering

In Swagger-UI v5.20.5, XML examples provided in our OpenAPI documentation file are not rendered properly. Specifically, characters such as '<' are converted into '<', '>' are converted to '>' and similarly for other XML special characters. This makes the XML examples harder to understand and unusable in certain circumstances.

To reproduce...

  1. Go to POST /idocinbound
  2. Click on application/xml option for request body parameters.
  3. Observe the example value.

Expected behavior

The XML request payload examples should render properly, showing XML characters (<, >, etc.) without conversion into HTML entities (such as <, >).

Screenshots

Image

Additional context or thoughts

An initial analysis points that this issue is reproducible if we have oneOf or anyOf.