-
Notifications
You must be signed in to change notification settings - Fork 2
Description
Swagger Examples
Problem
We use ReDoc + Swashbuckle + Swashbuckle filters to generate our OpenAPI specification and documentation: swagger repo
Some of our endpoints are Atom feeds, which only return XML as a response. An example of this is [SwaggerResponseExample(StatusCodes.Status200OK, typeof(MunicipalitySyndicationResponseExamples))]
This example returns an XML string: MunicipalitySyndicationResponseExamples
Our current setup parses this string as if it is XML and thus encodes it:
In effect, there is nothing wrong with Swashbuckle, it is serialising XML as it is supposed. But there is no way to tell Swashbuckle it should treat the example as a raw string.
Research
We believe this example is set at Swashbuckle.AspNetCore.Filters.ResponseExample.SetSingleResponseExampleForStatusCode
Our current research is to focus on checking if content.Value.Example = xmlExample.Value; already contains the encoded value or not.
If it does, one option might be to allow injecting an ExamplesConverter which has some tricks to deal with our raw strings.
This could be something simple such as inheriting from the current ExamplesConverter and looking for xmlns="http://www.w3.org/2005/Atom" to determine it is an Atom example and not encode it.
