How to use Swagger as Welcome Page of IAppBuilder in WebAPI

后端 未结 12 1522
遥遥无期
遥遥无期 2020-12-24 05:59

I try to use Swagger with Microsoft WebAPI 2.

For the moment, I\'ve the following call in a method.

appBuilder
   .ConfigureOAuth()
   .UseWebApi(con         


        
12条回答
  •  梦毁少年i
    2020-12-24 06:40

    Following the example from here:

    https://docs.microsoft.com/en-us/aspnet/core/tutorials/getting-started-with-swashbuckle?view=aspnetcore-2.2&tabs=visual-studio

    public class Startup {
       public void Configure(IApplicationBuilder app) {
          ...
          app.UseSwaggerUI( c => {
             c.SwaggerEndpoint("/swagger/v1/swagger.json", "My API V1");
             c.RoutePrefix = string.Empty;
          });
          app.UseMvc(); // <-- must be after 
       }
    }
    

    I couldn't get it to work until I placed the app.UseMvc() after the call to app.UseSwaggerUI().

提交回复
热议问题