Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Atom Feed Swagger Examples #3

Open
CumpsD opened this issue Nov 9, 2020 · 2 comments
Open

Atom Feed Swagger Examples #3

CumpsD opened this issue Nov 9, 2020 · 2 comments
Assignees
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.

Comments

@CumpsD
Copy link
Contributor

CumpsD commented Nov 9, 2020

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.

@CumpsD CumpsD added the research Topic being actively researched. label Nov 9, 2020
@CumpsD CumpsD added the bug Something isn't working label Nov 9, 2020
@CumpsD
Copy link
Contributor Author

CumpsD commented Nov 13, 2020

While debugging this issue, it turns out the issue above already linked to newer Swashbuckle code, which had this commit applied: mattfrear/Swashbuckle.AspNetCore.Filters@140601b

Which in turn should solve the issue about XML serialisation. Upgrading the library is the only work left to do. Which in itself needs some research because it has breaking changes.

After the first upgrade it looks fixed, but in some services it doesn't yet. More debugging is needed.

@CumpsD CumpsD added address Things related to the address registry. 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. streetname Things related to the streetname registry. labels Nov 15, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
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.
Projects
None yet
Development

No branches or pull requests

2 participants