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

Media Type appearing in the UI for examples #12

Closed
freeranger opened this issue Aug 30, 2017 · 11 comments
Closed

Media Type appearing in the UI for examples #12

freeranger opened this issue Aug 30, 2017 · 11 comments

Comments

@freeranger
Copy link

Hi,

I'm using Swashbuckle.AstNetCore 1.0.0 with Swashbuckle.AspNetCore.Examples with version 2.1.1 of your package.

In the swagger UI I am seeing the media type as part of the model:

image

Which I wasn't expecting - is there a way to stop this happening

@mattfrear
Copy link
Owner

mattfrear commented Aug 30, 2017 via email

@mattfrear
Copy link
Owner

OK I've figure out why it's doing that, but I have to find time to write a fix and publish the NuGet package.

Offending line of code is in ExampleOperationFilter.cs:

            var examples = new Dictionary<string, object>
            {
                {
                    "application/json", provider.GetExamples()
                }
            };

I can't even remember why I create a Dictionary, it might have been to get the Request examples working cos it seems it's not needed for the Response examples...

@freeranger
Copy link
Author

Thanks for the quick response - I'll take a look

@freeranger
Copy link
Author

Hi - I took it out completely, so not used for request or response and it works fine in both cases.

@mattfrear
Copy link
Owner

Hmm when I took it out I wasn't seeing the Request examples being set correctly

@freeranger
Copy link
Author

How strange - my requests and my responses are both fine now I have taken application/json out completely:
image
and
image

@mattfrear
Copy link
Owner

Can you post the code you've changed?

@mattfrear
Copy link
Owner

@freeranger
Copy link
Author

Here is my code with the change: freeranger@ee9469d

@mattfrear
Copy link
Owner

Thanks @freeranger, works great, so I was able to tidy up the code more. ac0090b

@mattfrear
Copy link
Owner

I have reverted this change in 2.2.2, because the previous response example with the application/json was correct as per the Swagger 2.0 spec. So maybe it's a bug with either Swashbuckle or Swagger-ui as to why application/json is appearing in the UI.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants