是否可以使用 swagger codegen 指定客户端库?

Is it possible to specify the client library using swagger codegen?

在基于 Swagger 元数据生成客户端时,是否可以指定或配置输出应使用其他客户端库的内容?

所以如果它是一个 C# 客户端,例如,用一些自定义库自动替换 HttpClient 或 RestSharp 客户端(我不记得现在是什么了,因为我已经有一段时间没有使用它了)?

是的,这是可能的,

codegen 使用模板和配置 java 类 生成不同语言的代码。如果您愿意修改这些模板,类 这将是一个非常简单的修改。

您可以在此处找到开源存储库 Swagger-Codegen

可在此处找到每种语言的模板文件:

https://github.com/swagger-api/swagger-codegen/tree/master/modules/swagger-codegen/src/main/resources

Java 配置 类:

https://github.com/swagger-api/swagger-codegen/tree/master/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages

模板变量列表:

https://github.com/swagger-api/swagger-codegen/wiki/Mustache-Template-Variables

模板是用小胡子写的: https://mustache.github.io/mustache.5.html

如果你想从头开始读起来很有趣:

https://github.com/swagger-api/swagger-codegen/wiki/How-to-add-a-generator-for-a-new-language-or-framework