| | |
| | | if (services == null) throw new ArgumentNullException(nameof(services)); |
| | | |
| | | var basePath = AppContext.BaseDirectory; |
| | | //var basePath2 = Microsoft.DotNet.PlatformAbstractions.ApplicationEnvironment.ApplicationBasePath; |
| | | var ApiName = AppSettings.app(new string[] { "ApiName" }); |
| | | var ApiName = AppSettings.Get(new string[] { "ApiName" }); |
| | | |
| | | services.AddSwaggerGen(c => |
| | | { |
| | | //遍历出全部的版本,做文档信息展示 |
| | | typeof(ApiVersions).GetEnumNames().ToList().ForEach(version => |
| | | //typeof(ApiVersions).GetEnumNames().ToList().ForEach(version => |
| | | //{ |
| | | c.SwaggerDoc("v1", new OpenApiInfo |
| | | { |
| | | c.SwaggerDoc(version, new OpenApiInfo |
| | | { |
| | | Version = version, |
| | | Title = $"{ApiName} 接口文档——{RuntimeInformation.FrameworkDescription}", |
| | | Description = $"{ApiName} HTTP API " + version, |
| | | }); |
| | | c.OrderActionsBy(o => o.RelativePath); |
| | | Version = "v1", |
| | | Title = $"{ApiName} 接口文档——{RuntimeInformation.FrameworkDescription}", |
| | | Description = $"{ApiName} HTTP API " + "v1" |
| | | }); |
| | | c.OrderActionsBy(o => o.RelativePath); |
| | | //}); |
| | | |
| | | c.UseInlineDefinitionsForEnums(); |
| | | try |
| | | { |
| | | //这个就是刚刚配置的xml文件名 |
| | | //var xmlPath = Path.Combine(basePath, "WIDESEAWCS_Server.xml"); |
| | | var xmlPath = Path.Combine(basePath, "WIDESEAWCS_Server.xml"); |
| | | //默认的第二个参数是false,这个是controller的注释,记得修改 |
| | | //c.IncludeXmlComments(xmlPath, true); |
| | | c.IncludeXmlComments(xmlPath, true); |
| | | |
| | | //这个就是Model层的xml文件名 |
| | | //var xmlModelPath = Path.Combine(basePath, "WIDESEAWCS_Server.Model.xml"); |
| | | //c.IncludeXmlComments(xmlModelPath); |
| | | var xmlModelPath = Path.Combine(basePath, "WIDESEAWCS_Server.Model.xml"); |
| | | c.IncludeXmlComments(xmlModelPath); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | |
| | | /// <summary> |
| | | /// V1 版本 |
| | | /// </summary> |
| | | V1 = 1, |
| | | /// <summary> |
| | | /// V2 版本 |
| | | /// </summary> |
| | | V2 = 2, |
| | | V1 = 1 |
| | | } |
| | | } |
| | | } |