“Response Content Type” has 4 values. Are we supporting all 4 response content types or just application/json? If not is there way of restricting swagger to only show what we support?
Swashbuckle will expose out the media types from each SupportedResponseBodyFormatters & SupportedResponseFormatters from the ApiDescription for each api in Swagger's produces & consumes section.
Is there something more specifically that isn't working?
Hi Merick,
Thank you for you valuable feedback. Based on XMLDocument the response content type will generated right? But I send a response like "application/Json" and "text/Json". Is there any option to hide remaining two ("application/xml" and "text/xml").
In my API I have both the "application/xml" and "text/xml" options so I decided to just hide the control since it really provides no value. You can do this pretty easily by first configuring via something like the following to inject your own custom CSS:
configuration.EnableSwaggerUi( c =>
{
c.InjectStylesheet( typeof( Startup ).Assembly, "Directory.Path.File.Name.css" );
}
Then, in the CSS, you can do something like the following:
.resource .content .response-content-type {
display:none;
}
Note that I think the CSS needs to be an embedded resource, and any changes you make to it while in development will require you to do a build to actually see those changes in the UI.
Again, Swashbuckler respects your WebAPI settings, try just configuring WebAPI to remove the formatters you don't want.
By default WebApi comes with several formatters by default, including the XmlMediaTypeFormatter.
Try adding something like the following to your WebApiConfig
``` C#
public class WebApiConfig
{
public static void Register(HttpConfiguration config)
{
config.Formatters.Remove(config.Formatters.XmlFormatter);
// etc etc etc
}
}
```
Thank you for you valuable feedback
Most helpful comment
Again, Swashbuckler respects your WebAPI settings, try just configuring WebAPI to remove the formatters you don't want.
By default WebApi comes with several formatters by default, including the XmlMediaTypeFormatter.
Try adding something like the following to your WebApiConfig
``` C#
public class WebApiConfig
{
public static void Register(HttpConfiguration config)
{
config.Formatters.Remove(config.Formatters.XmlFormatter);
```