Skip to content

XML example return value is rendered as escaped text, wrapped within <notagname> #2199

Description

@cristalp

I have an example of an XML document as it would be returned:

  public static final String XML = """
      <foo>
        <bar>baz</bar>
      </foo>""";

This is used within the REST endpoint:

  @APIResponse(responseCode = "200", description = "Bla bla", content = {
      @Content(mediaType = MediaType.APPLICATION_JSON, example = "JSON example"),
      @Content(mediaType = MediaType.APPLICATION_XML, example = XML),
      @Content(mediaType = MediaType.TEXT_PLAIN, example = "Text example") })

In the openapi.yml this is rendered as

            application/xml:
              example: |-
                <foo>
                  <bar>baz</bar>
                </foo>

But in SwaggerUI, I see a strange escaped text:

Image

See also fastapi/fastapi#8440

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions