[BUG] Strange conversion to camel case
See original GitHub issueBug Report Checklist
- Have you provided a full/minimal spec to reproduce the issue?
- Have you validated the input using an OpenAPI validator (example)?
- What’s the version of OpenAPI Generator used?
- Have you search for related issues/PRs?
- What’s the actual output vs expected output?
- [Optional] Bounty to sponsor the fix (example)
Description
Attribute names that include upper case letters are not being converted to camel case correctly. This affectes model attributes, model names etc.
This can be demostrated through a lambda in a mustache template:
1. id {{#lambda.camelcase}}id{{/lambda.camelcase}}
2. ID {{#lambda.camelcase}}ID{{/lambda.camelcase}}
3. id_more {{#lambda.camelcase}}id_more{{/lambda.camelcase}}
4. ID_MORE {{#lambda.camelcase}}ID_MORE{{/lambda.camelcase}}
This results in:
1. id id
2. ID iD
3. id_more idMore
4. ID_MORE iDMORE
I believe 2 and 4 are wrong. For 2, the upper-case token should be treated as one word, so should be converted to lower case: “id”.
For 4, there are two words, but of which should be converted to lower case, then concatenated with the second work capitalised: “idMore”.
The model data supplied to the templates does the same conversion to an “ID” in the OpenAPI description, giving this:
{
"openApiType" : "integer",
"baseName" : "ID", <<<
"getter" : "getID", <<<
"setter" : "setID", <<<
"dataType" : "int",
"datatypeWithEnum" : "int",
"dataFormat" : "int32",
"name" : "iD", <<<
...
}
Here I would expect to see “ID”, “getId”, “setId” and “id”.
openapi-generator version
The latest CLI docker container openapitools/openapi-generator-cli
5.0.0-SNAPSHOT
OpenAPI declaration file content or url
This shows the same effect, in any mustache template you like:
1. id {{#lambda.camelcase}}id{{/lambda.camelcase}}
2. ID {{#lambda.camelcase}}ID{{/lambda.camelcase}}
3. id_more {{#lambda.camelcase}}id_more{{/lambda.camelcase}}
4. ID_MORE {{#lambda.camelcase}}ID_MORE{{/lambda.camelcase}}
Or any OpenAPI description with an UPPERCASE property name.
Command line used for generation
docker run --rm openapitools/openapi-generator-cli ...
Steps to reproduce
See above.
Related issues/PRs
Not been able to find any.
Suggest a fix
I’m not a Java guy, and have tried and failed to set up an environment in the past, so can do nothing to help.
Issue Analytics
- State:
- Created 3 years ago
- Reactions:3
- Comments:8
Top GitHub Comments
Is there a way to import a custom camel case lambda at runtime, and using that to produce desired conversion?
I have the same problem with the typescript-angular converter using the option
"modelPropertyNaming": "camelCase"
: “VAT” becomes “vAT”, but I expected it to become “vat”.