I'm developing an RESTful web service using Microsoft Web API 2 and SwaggerUi.
I've removed default Global.asax and I've configured my Web API using OWIN. This is my Startup.cs code:
public void Configuration(IAppBuilder app)
{
HttpConfiguration config = new HttpConfiguration();
WebApiConfig.Register(config);
config.MessageHandlers.Add(new JWTAuthenticationHandler() { StopPipelineHandling = true });
config.Filters.Add(new MyActionFilter());
SwaggerConfig.Register();
app.UseWebApi(config);
}
This is my SwaggerConfig.cs code:
GlobalConfiguration.Configuration
.EnableSwagger(c =>
{
c.SingleApiVersion("v1", "MyNamespace.WebApi");
})
.EnableSwaggerUi(c =>
{});
After this operation I cannot view the actions on swagger like following images:
Please, can you help me?
Thank you a lot
I've resolved changing:
Startup.cs
public void Configuration(IAppBuilder app)
{
HttpConfiguration config = new HttpConfiguration();
// Swagger
SwaggerConfig.Register(config);
// Authentication token
ConfigureOAuth(app);
// SignalR configuration
ConfigureSignalR(app);
// Register routes
WebApiConfig.Register(config);
// Allow cross-domain requests
app.UseCors(CorsOptions.AllowAll);
app.UseWebApi(config);
}
SwaggerConfig.cs
using Swashbuckle.Application;
using System.Web.Http;
namespace Name.API
{
public class SwaggerConfig
{
public static void Register(HttpConfiguration config)
{
config.EnableSwagger(c =>
{
c.SingleApiVersion("v1", "Name.API");
})
.EnableSwaggerUi(c =>
{
});
}
}
}
I've find the solution on https://github.com/domaindrivendev/Swashbuckle/issues/196
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With