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:

See also fastapi/fastapi#8440