卢震吧 关注:24贴子:1,200
  • 0回复贴,共1

.net core swagger 配置

只看楼主收藏回复

public void ConfigureServices(IServiceCollection services)
{
services.AddSwaggerGen(s => {
s.SwaggerDoc("v2",new Microsoft.OpenApi.Models.OpenApiInfo { Title= "Title2", Version= "Version2", Description= "Description2" });
var xmlFile = $"{Assembly.GetExecutingAssembly().GetName().Name}.xml";
var xmlPath = Path.Combine(AppContext.BaseDirectory, xmlFile);
s.IncludeXmlComments(xmlPath);
});
}
public void Configure(IApplicationBuilder app, IHostingEnvironment env)
{
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
}
app.UseSwagger();
app.UseSwaggerUI(
c => { c.SwaggerEndpoint("/swagger/v2/swagger.json", "API V1"); }
);
}


IP属地:湖北1楼2020-10-20 09:33回复