[Python/General] Underscore Conversion Method Does not Work with Acronyms
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 45/100
- Issue type
- Bug
- Clarity
- Mostly clear
- Activity status
- Stale
- Domain
- backend-api-design, tooling
Research direction
Start in DefaultCodegen.java and inspect the underscore method and its replacement patterns. Reproduce the issue with the provided SomeIDs/someIDs schema using standard Python client generation, then verify that acronym and initialism names receive underscores at the end of capital-letter sequences rather than between each capital.
Written by the indexing model from the issue text.
Description
This is copied over from swagger-codegen project as it exists in openapi-generator code also. This is the originally reported issue;
--------------------------copied over-------------------------------------
Description
In DefaultCodegen.java the underscore method does not work with acronyms, initialisms, or any multi capital letter phrases. This is because these lines of code:
// Replace capital letter with _ plus lowercase letter.
word = word.replaceAll(firstPattern, replacementPattern);
word = word.replaceAll(secondPattern, replacementPattern);
are designed to add an underscore before each capital letter (ignoring the first letter). For example, SomeIDs would be converted to some_i_ds instead of some_ids.
I discovered this bug while generating a Python client but presumably this issue exists in other languages.
Swagger-codegen version
2.4.0.SNAPSHOT up to date with PR 8748 (September 26th).
Swagger declaration file content or url
A model class similar to:
"SomeIDs": {
"type": "object",
"properties": {
"someIDs": {
"type": "array",
"items": {
"type": "integer",
"format": "int32"
}
}
}
}
in a Swagger schema will produce the bug.
Command line used for generation
The standard python client generation command will produce this bug.
Steps to reproduce
Generate Python Client from Swagger schema containing an acronym, initialisms, or any multi capital letter phrases
Look at corresponding name in Python client.
Related issues/PRs
Suggest a fix/enhancement
Changing the logic to place the underscores at the end of a series of capital letters instead of after each capital letter will solve this issue.
- Dominant language
- Java
- Stars
- 26.8k
- Forks
- 7.7k
- Avg merge
- 1d 6h
- Merged PRs (30d)
- 100
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.
More from OpenAPITools/openapi-generator
-
Issue: Bug
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
OpenAPITools/openapi-generator#24859 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
OpenAPITools/openapi-generator#24852 · 1 comment ·
-
[BUG][KOTLIN] Fails to compile after updating to 7.25.0 with useJackson3=false useSpringBoot4=true OpenIssue: Bug
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
OpenAPITools/openapi-generator#24842 · 1 comment ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 86/100
OpenAPITools/openapi-generator#24830 ·
-
Issue: Bug
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
OpenAPITools/openapi-generator#24816 · 1 comment ·
All issues in OpenAPITools/openapi-generator
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
-
bug needs triage
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
-
Difficulty 1/5 Under an hour Newbie friendliness 94/100
objectionary/hone-maven-plugin#1061 ·
-
type:bug
Difficulty 2/5 1-3 hours Newbie friendliness 72/100