我正在尝试在 Visual Studio 2019..Net 5.0 中生成 OpenApi 服务引用。
右键单击项目>添加>连接服务>+服务引用
我正在使用 NetDocs api“https://api.vault.netvoyage.com/v2/swagger/docs/v2”。
结果:我生成了 c# 客户端代码,但它复制了类型,并出现以下错误。
Severity Code Description Project File Line Suppression State
Error CS0102 The type 'v2Client' already contains a definition for '_settings' OpenAPITest C:\Users\dryfus\source\repos\OpenAPITest\obj\v2Client.cs 4941 Active
Error CS0579 Duplicate 'System.CodeDom.Compiler.GeneratedCode' attribute OpenAPITest C:\Users\dryfus\source\repos\OpenAPITest\obj\v2Client.cs 4936 Active
Error CS0102 The type 'v2Client' already contains a definition for '_baseUrl' OpenAPITest C:\Users\dryfus\source\repos\OpenAPITest\obj\v2Client.cs 4939 Active
Error CS0102 The type 'v2Client' already contains a definition for '_httpClient' OpenAPITest C:\Users\dryfus\source\repos\OpenAPITest\obj\v2Client.cs 4940 Active
有没有一种方法可以让它与连接器方式一起工作而无需重复?或者甚至是 cli?关于为什么创建重复项有什么建议吗?
我遇到了同样的问题,事实证明代码生成不喜欢其操作 ID 中带有下划线的 enpoints。对我来说幸运的是,我使用的服务也是我们代码的一部分,因此我只需转到 API 端的 Swagger 配置并更改 CustomOperationIds 设置即可。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)