Swagger in Asp.NET Core

首先,使用NuGet安装 SwashBuckle.AspNetCore

然后,在StartUp的ConfigureServices中,加入

  Services.AddSwaggerGen(c=>{c.SwaggerDoc("V1", new Info("Services API", Version="V1")};

然后,在Configure中,加入

  app.UseSwagger();

 app.UseSwaggerUI(c=>{

    c.SwaggerEndPoint(“Swagger/V1/Swagger.json", "Services API V1")});

 

运行,在url中,加入/swagger/

你可能感兴趣的:(C#开发)