gpt4 book ai didi

java - mustache :如何将第一个字母小写

转载 作者:行者123 更新时间:2023-11-30 08:32:31 32 4
gpt4 key购买 nike

我正在使用 mustache 模板以使用 Java 生成一些代码。

我想将字段的第一个字母小写。

有什么办法可以得到吗?

我需要直接转换它。我正在生成 C# 代码。

编辑

我正在使用 Swagger Codegen tool以便能够根据 API 规范生成客户端。

此工具使用 mustache 模板生成输出。因此,您需要的每种语言都有一个模板。参见 here , 为了观看 Swagger Codegen 提供的 mustache 模板。

我正在修改这些以自定义我想要访问的 C# 代码。

{{#apiInfo}}
{{#apis}}
this.{{classname}} = new {{apiPackage}}.{{classname}}(this.Configuration);
{{/apis}}
{{/apiInfo}}

它必须生成如下内容:

this.UserAPI = new Api.UserAPI(this.Configuration);

我想得到:

this.userAPI = new Api.UserAPI(this.Configuration);

最佳答案

由于该问题特定于 swagger codegen 工具,因此他们具有用于 mustache 的 lambda 函数。

{{#lambda.camelcase_param}}{{name}}{{/lambda.camelcase_param}}

尝试:

this.{{#lambda.camelcase_param}}{{classname}}{{/lambda.camelcase_param}} = new {{apiPackage}}.{{classname}}(this.Configuration);

在模板中查找示例: https://github.com/swagger-api/swagger-codegen/blob/master/modules/swagger-codegen/src/main/resources/csharp/modelGeneric.mustache

关于java - mustache :如何将第一个字母小写,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40106188/

32 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com