[英]How to remove dashes from object namespace, generated by openapi 2.0
I use Swashbuckle.AspNetCore (v4.0.1)
to generate swagger.json
file in asp .net core. 我使用Swashbuckle.AspNetCore (v4.0.1)
在asp .net核心中生成swagger.json
文件。 After the import in Azure API Management we see the following types that we don't expect: SwaggerGenerationSample-Models-EmployeeArray
and SwaggerGenerationSample-Models-EmployeeArray-1
etc. . 在Azure API Management中导入后,我们会看到以下不期望的类型: SwaggerGenerationSample-Models-EmployeeArray
和SwaggerGenerationSample-Models-EmployeeArray-1
等。
I expect to have dots instead of dashes SwaggerGenerationSample.Models.EmployeeArray
. 我希望有点而不是破折号SwaggerGenerationSample.Models.EmployeeArray
。
I tried to use 我试着用
CustomSchemaIds(t => t.Name), instead of CustomSchemaIds(t => t.FullName)
but don't work due to some duplicated object names (Request.Employee and Response.Employee).
但由于某些重复的对象名称(Request.Employee and Response.Employee).
而无法工作(Request.Employee and Response.Employee).
I currently have the following configuration in AspNetCore. 我目前在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" });
});
I believe , this is because of the recent changes how Open API import and export works in APIM. 我相信,这是因为Open API导入和导出在APIM中的最新变化。 You can find the semantics here as it aligns with it. 您可以在此处找到语义,因为它与之对齐。
Here is the normalization rule for the same: 以下是相同的规范化规则:
Normalization rules for operationId operationId的规范化规则
GET-/foo/{bar}?buzz={1}
will be transformed into get-foo-bar-buzz-1-
. 用一个短划线替换每个非字母数字字符序列,例如GET-/foo/{bar}?buzz={1}
将转换为get-foo-bar-buzz-1-
。 get-foo-bar-
will become get-foo-bar
修剪双方的破折号,例如get-foo-bar-
将成为get-foo-bar
You can read more about it here : 你可以在这里阅读更多相关信息:
https://blogs.msdn.microsoft.com/apimanagement/2018/04/11/important-changes-to-openapi-import-and-export/ https://blogs.msdn.microsoft.com/apimanagement/2018/04/11/important-changes-to-openapi-import-and-export/
Hope it helps. 希望能帮助到你。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.