OpenAPITools / OpenAPITools/openapi-generator
[BUG] `nameInCamelCase` generates property in `PascalCase`
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 26.8k
- Forks
- 7.7k
- PR merge metrics
- PR metrics pending
Description
Bug Report Checklist
Description
There is an attribute called nameInCamelCase in class CodegenProperty. For C# server side generation this results in a name in pascal case. This works for us because we were looking for pascal case anyway, but the name nameInCamelCase is at least misleading.
| Input | Expected output as camel case | Actual output as camel case |
|---|---|---|
| myVariableName | myVariableName | MyVariableName |
openapi-generator version
3.0.3
OpenAPI declaration file content or url
https://gist.github.com/jnnwnk/6ee8d7c2102725aa367fc2135648027a
Command line used for generation
java -jar .\openapi-generator-cli-3.0.3.jar generate -i .\openapi.json -g aspnetcore -c .\config.json -o .\output\ -t .\templatesNetCore\
Steps to reproduce
- Place
model.mustachein foldertemplatesNetCore - Execute command line
- See generated name of property in
MySampleObject.cs
Related issues/PRs
https://github.com/OpenAPITools/openapi-generator/issues/3827
Suggest a fix
There two options:
- Fix naming in code (call attribute
nameInPascalCaseinstead ofnameInCamelCase) - Fix implementation, so when using
nameInCamelCasethe generated attribute / property will be using the correct case
Actually it would be nice to have the choice between the well known cases (camelCase, PascalCase, snake_case, SNAKE_CASE_ALL_CAPS, kebap-case). See link for examples. But this might be a feature request instead of a bug.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with modules/openapi-generator/src/main/java/org/openapitools/codegen/CodegenProperty.java, especially the nameInCamelCase attribute, then inspect the referenced model.mustache used by the aspnetcore generator. Reproduce the generation command with the linked OpenAPI declaration and check MySampleObject.cs. Done means the naming attribute and generated property casing are no longer misleading or inconsistent.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp, java, openapi
- Domain
- backend-api-design, tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100