.net core 3.0 swagger

1.安装swagger包

2.startup里configservers

 Configure

 3.可能出现的错误

提示error  xxxxnot found

扫描二维码关注公众号,回复: 9366148 查看本文章

由于我创建的webapi是restful风格的所以当出现多个同类型的接口时会出错【其实就是找不到哪一个接口】

解决方法:

a.在接口上指定路由,比如[Route("xxx")]或[httpget("xxx/xxx/{id}")]

b.由于我实在是不喜欢restful的接口所以我在startup上指定了路由

app.UseEndpoints(endpoints =>
            {
                endpoints.MapControllerRoute(
                    name: "default",
                    pattern: "{controller=WeatherForecast}/{action=Get}/{id?}");
            });

猜你喜欢

转载自www.cnblogs.com/weiruanojbk/p/12355433.html