【发布时间】:2019-08-23 13:07:41
【问题描述】:
我使用Swashbuckle.AspNetCore (v4.0.1) 在asp .net core 中生成swagger.json 文件。在 Azure API 管理中导入后,我们会看到以下我们不期望的类型:
SwaggerGenerationSample-Models-EmployeeArray 和 SwaggerGenerationSample-Models-EmployeeArray-1 等等。
我希望用点而不是破折号SwaggerGenerationSample.Models.EmployeeArray。
我尝试使用
CustomSchemaIds(t => t.Name), instead of CustomSchemaIds(t => t.FullName)
但由于某些重复的对象名称而无法工作(Request.Employee and Response.Employee).
我目前在 AspNetCore 中有如下配置。
services.AddSwaggerGen(config => {
config.DescribeAllEnumsAsStrings();
config.CustomSchemaIds(type => type.FullName);
config.SwaggerDoc("v1", new Info { Title = "SampleAPI", Version = "v1" });
config.MapType<decimal>(() => new Schema { Type = "number", Format = "double" });
config.MapType<decimal?>(() => new Schema { Type = "number", Format = "double" });
});
【问题讨论】:
标签: c# asp.net-core swagger azure-api-management openapi