其他分享
首页 > 其他分享> > swagger

swagger

作者:互联网

swagger:
1.Nuget安装Swashbuckle依赖
2.修改SwaggerConfig.cs
GlobalConfiguration.Configuration
.EnableSwagger(c =>
{
c.SingleApiVersion("v1", "ZJCD.User.Service");
c.IncludeXmlComments(string.Format("{0}/bin/ZJCD.User.Service.xml", System.AppDomain.CurrentDomain.BaseDirectory));
c.IncludeXmlComments(string.Format("{0}/bin/ZJCD.User.Model.xml", System.AppDomain.CurrentDomain.BaseDirectory));
})
3.右键model项目,webapi接口项目生成中,输出xml文档,将modle.xml service.xml输出
4.修改WebApiConfig.cs中Register方法路由配置:
config.Routes.MapHttpRoute(
name: "DefaultApi",
routeTemplate: "{controller}/{action}/{id}",
defaults: new { id = RouteParameter.Optional }
);

5.发布项目,ip:port/swagger/ui/index 浏览接口文档

标签:xml,Service,System,ZJCD,User,CurrentDomain,swagger
来源: https://www.cnblogs.com/liuqiyun/p/10435090.html