5

I'm using a mustache template in order to generate some code using Java.

I'd like to downcase the first letter of a field.

Is there some way to get it?

I need to transform it directly. I'm generating C# code.

EDIT

I'm using Swagger Codegen tool in order to be able to generate a client according to a API Specification.

This tool is using mustache templates for generating an output. So, there's a template for each language you need. See here, in order to watch the mustache templates that Swagger Codegen provides.

I'm modifying these in order to customize the C# code I want to reach.

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

It has to generate something like:

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

I'd like to get:

this.userAPI = new Api.UserAPI(this.Configuration);
Jordi
  • 20,868
  • 39
  • 149
  • 333
  • 3
    It's definitely not the same. – Jordi Oct 18 '16 at 11:12
  • The answer would be quite the same, mustache doesn't give you the opportunity to update the value. So you will need to update it in Java (in this case) – AxelH Oct 18 '16 at 11:20
  • More information is required, as well as code. You are using Java/C#/mustache? What? Do you mean Javascript rather than Java? Please give evidence of your javascript object literal, your view and any backend code you find appropriate. – IronAces Oct 18 '16 at 12:12
  • I've detailed a bit more my needs. I hope I've explained so well. – Jordi Oct 18 '16 at 13:07
  • This is not explained well. Provide full but succinct code to accompany your question. – IronAces Oct 19 '16 at 10:51

1 Answers1

8

Since the question is specific to swagger codegen tool they have lambda functions for mustache.

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

Try:

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

Look for examples in template: https://github.com/swagger-api/swagger-codegen/blob/master/modules/swagger-codegen/src/main/resources/csharp/modelGeneric.mustache

serg
  • 537
  • 6
  • 14