openapi-generators / openapi-generators/openapi-python-client
Linting error when class has a property with the same name after snake case
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 2k
- Forks
- 293
- Avg merge
- 34m
- Merged PRs (30d)
- 1
Description
openapi-python-client: 0.21.4
Python: 3.10
OpenAPI spec version: 3.0.3
In OpenAPI specs where a property has the same name as the snake cased class name (in the example below, the snake casing is the lower case, but if it was, ex, InstagramId, then this would happen with a property named instagram_id) the code generated has a duplicated variable name (see image below).
The suggested fix is that the return variable name should have an underscore _, in this example, email_.
"Email": {
"type": "object",
"properties": {
"email": {
"type": "string"
},
"verified": {
"type": "boolean"
}
},
"required": [
"email",
"type"
]
},
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
Reproduce the issue with the supplied OpenAPI 3.0.3 snippet using openapi-python-client 0.21.4 and inspect the generated Email model. Trace the generator path that chooses names for the return variable and the property, then verify that the generated names no longer collide and that the example remains valid Python.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- openapi, python
- Domain
- devtools
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100