在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
项目类型:asp.net core webapi 1.NuGet安装:Swashbuckle.AspNetCore 2.Startup.cs下的:ConfigureServices()加入: services.AddSwaggerGen(c => { c.SwaggerDoc("v1", new Info { Version = "v1", Title = "Swagger测试接口文档", Description = "this is just a test" }); var basePath = PlatformServices.Default.Application.ApplicationBasePath;var xmlPath = Path.Combine(basePath, "SwaggerTest.xml"); c.IncludeXmlComments(xmlPath); // c.OperationFilter<HttpHeaderOperation>(); // 添加httpHeader参数 }); app.UseSwagger(); // Enable middleware to serve swagger-ui (HTML, JS, CSS etc.), specifying the Swagger JSON endpoint. app.UseSwaggerUI(c => { c.SwaggerEndpoint("/swagger/v1/swagger.json", "其实,我是一个演员。"); c.ShowRequestHeaders(); }); 3.打开Swagger-UI:http://localhost:64969/swagger/ 将LunchUrl改为“swagger” |
请发表评论