-
Notifications
You must be signed in to change notification settings - Fork 22
Swagger
L edited this page Apr 8, 2019
·
4 revisions
Internal Server Error /swagger/v1/swagger.json
需要给所有controller/action做定义[NoAction]
or [HttpXXX]
遇到这种情况,可以通过 http://your host/swagger/v1/swagger.json
查看详细报错信息
参考资料:ASP.NET Core - Swashbuckle not creating swagger.json file
接口项目,右键属性,勾选生成xml文件
设置xml文件路径
options.IncludeXmlComments(xmlFilePath);
以ABP for .net core项目举例
.Application项目勾选生成xml文件
在Startup.cs中配置xml文件
public class Startup
{
public IServiceProvider ConfigureServices(IServiceCollection services)
{
services.AddSwaggerGen(options =>
{
//......
//设置xml注释文件
var baseDirectory = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().CodeBase); ;
var xmlFileName = "\\" + typeof(XXXApplicationModule).Assembly.GetName().Name + ".XML";
var xmlFilePath = $"{baseDirectory}{xmlFileName}";
options.IncludeXmlComments(xmlFilePath);
//......
});
}
}