Skip to content

Atom Feed Swagger Examples #3

@CumpsD

Description

@CumpsD

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:

XML Encoded Example

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.

Metadata

Metadata

Labels

addressThings related to the address registry.bugSomething isn't workingbuildingThings related to the building registry.municipalityThings related to the municipality registry.parcelThings related to the parcel registry.postalThings related to the postal registry.researchTopic being actively researched.streetnameThings related to the streetname registry.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions