简体   繁体   English

Swagger Codegen选项可更改TypeScript中的大小写

[英]Swagger codegen option to change casing in TypeScript

We are using swagger codegen to generate a TypeScript client. 我们正在使用swagger代码生成生成TypeScript客户端。 Its working fine but when it generates the objects it converting our pascal casing into camel casing and failing as it doesnt match the JSON object casing getting returned form the web server. 它工作正常,但是当它生成对象时,将我们的pascal大小写转换为骆驼大小写,并由于与Web服务器返回的JSON对象大小写不匹配而失败。

Note: we are using a C# WebAPIv2 project, hence the pascal casing. 注意:我们使用的是C#WebAPIv2项目,因此使用的是pascal大小写。

We use the online API for generating 我们使用在线API生成

http://generator.swagger.io/#!/clients/generateClient http://generator.swagger.io/#!/clients/generateClient

Have noticed the options property but cannot find any documentation on it. 已经注意到options属性,但是找不到关于它的任何文档。

{
"spec": {},
"options": {},
"swaggerUrl": "http://petstore.swagger.io/v2/swagger.json",
"securityDefinition": {
  "type": "string",
  "description": "string"
}
}

Is there a configuration option to change this? 是否有配置选项可以更改此设置? or can someone point me to any documentation on the option property? 或者有人可以将我指向选项属性的任何文档?

Thanks, 谢谢,

Joel 乔尔

Found the issue in the GitHub source code and proposed a solution, someone posted back with a workaround, however i think we were going about it the wrong way 在GitHub源代码中找到了问题并提出了解决方案,有人回发了解决方法,但是我认为我们的解决方法是错误的

https://github.com/swagger-api/swagger-codegen/issues/1926 https://github.com/swagger-api/swagger-codegen/issues/1926

I think the best approach for language compatibility is to: 我认为语言兼容性的最佳方法是:

Regards, Joel 问候,乔尔

The NSwag project ( https://github.com/NSwag/NSwag ) is a toolchain that handles the generation of swagger specifications, TypeScript and clients either from .NET assemblies or from a Swagger specification. NSwag项目( https://github.com/NSwag/NSwag )是一个工具链,用于处理.NET程序集或Swagger规范生成的swagger规范,TypeScript和客户端。 It allows you to import your swagger JSON specification and generate TypeScripts from it, keeping the right case for your properties. 它允许您导入庞大的JSON规范并从中生成TypeScript,同时保持属性的正确大小写。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM