How to generate documentation using swashbuckle for WebApi 2 with Owin

前端 未结 2 1464
隐瞒了意图╮
隐瞒了意图╮ 2021-01-03 17:07

I have created a WebApi Project using this article.

Things are working fine. But now my client want to view the documentation using Swagger. I tried to do configurat

相关标签:
2条回答
  • 2021-01-03 17:12

    If I'm reading this correctly, you are calling the Register method before you are calling Configuration in Startup? If this is the case, I think you are needlessly complicating things. This is what I typically do:

    public class Startup
    {
        public void Configuration(IAppBuilder app)
        {
            var config = new HttpConfiguration();
            config.MapHttpAttributeRoutes();
            // Any additional configuration: filters, services, etc.
    
            config.EnableSwagger(x => x.SingleApiVersion("v1", "Application Name")).EnableSwaggerUi();
    
            app.UseWebApi(config)
        }
    }
    

    If you are enabling Swagger on the global configuration, and starting Web Api on a new HttpConfiguration instance, then that is most likely your problem.

    Hope that helps.

    0 讨论(0)
  • 2021-01-03 17:33

    I had tons of issues with Owin + Swashbuckle integration. I managed to solve it and created an open source repo to be used as a template for anyone who needs it!

    Please check: ASPSwaggerOwinTemplate

    0 讨论(0)
提交回复
热议问题