【发布时间】:2021-07-27 03:56:27
【问题描述】:
我正在尝试为 Trello API 生成 C# 客户端。因此,我从 https://developer.atlassian.com/cloud/trello/swagger.v3.json 下载了 Open API 规范,并从 bash 中运行以下 nswag 命令。
nswag openapi2csclient /input:swagger.v3.json \
/classname:TrelloClient \
/namespace:Integrations.Trello \
/output:TrelloClient.cs \
/GenerateClientInterfaces:True \
/GenerateExceptionClasses:True \
/GenerateClientClasses:True \
/DisposeHttpClient:False \
/OperationGenerationMode:SingleClientFromOperationId
代码生成完成且没有错误,但生成的代码由于包含许多错误而无法编译。例如,某些生成的方法名称包含无效的表达式,如=idAsync,或者方法签名具有不明确的参数(例如,多个key 和token 类型的参数string)。为GetMembers方法生成了如下方法声明,这显然是错误的语法。
System.Threading.Tasks.Task<Member> GetMembers=idAsync(
string key, string token, string id, string actions, string boards, BoardBackgrounds? boardBackgrounds,
BoardsInvited? boardsInvited, BoardFields? boardsInvited_fields, bool? boardStars, string cards,
CustomBoardBackgrounds? customBoardBackgrounds, CustomEmoji2? customEmoji, CustomStickers? customStickers,
MemberFields? fields, string notifications, Organizations? organizations,
OrganizationFields? organization_fields, bool? organization_paid_account,
OrganizationsInvited? organizationsInvited, OrganizationFields? organizationsInvited_fields,
bool? paid_account, bool? savedSearches, Tokens? tokens);
在处理第3版的Open API规范文档时,有什么特殊的选项需要设置吗?
【问题讨论】:
标签: c# .net-core trello openapi-generator nswag