swagger-api / swagger-api/swagger-codegen
[Python]Generated code has naming conflict
Nobody has claimed this yet.
- Dominant language
- Mustache
- Stars
- 17.8k
- Forks
- 6k
- PR merge metrics
- No merged PRs in 30d
Description
Description
The generated Python code renamed the camelCase property to under_score format and conflict with another property.
Swagger-codegen version
swagger-codegen-cli-2.4.14
Swagger declaration file content or url
definitions:
RestrictedBanInfo:
type: object
required:
- ban_type
properties:
ban_type:
type: string
banType:
type: string
description: the same value as ban_type
readOnly: true
Command line used for generation
java -jar swagger-codegen-cli-2.4.14.jar generate -i swagger.json -g python --library asyncio -o ./
Steps to reproduce
- define an object with 2 properties. Using the camelCase and under_score case to name those 2 properties. e.g. xY and x_y
- generate python client code
- check generated model code
class RestrictedBanInfo(object):
openapi_types = {
'ban_type': 'str',
'ban_type': 'str',
}
attribute_map = {
'ban_type': 'ban_type',
'ban_type': 'banType',
}
def __init__(self, ban_type=None, ban_type=None):
...
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 RestrictedBanInfo YAML definition and the swagger-codegen-cli-2.4.14 Python asyncio generation command. Inspect the generated model's openapi_types, attribute_map, and init; done means both ban_type and banType remain distinct properties without duplicate dictionary keys or constructor arguments.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100