Atom Feed Swagger Examples #3
Labels
address
Things related to the address registry.
bug
Something isn't working
building
Things related to the building registry.
municipality
Things related to the municipality registry.
parcel
Things related to the parcel registry.
postal
Things related to the postal registry.
research
Topic being actively researched.
streetname
Things related to the streetname registry.
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 forxmlns="http://www.w3.org/2005/Atom"
to determine it is an Atom example and not encode it.The text was updated successfully, but these errors were encountered: