Open jakobkogler opened 3 years ago
I bumped into a similar problem, but with @
instead of $
@jakobkogler Did you find a workaround?
@StudioSpindle , @jakobkogler ,
In my project, we discovered a workaround (our project using Angular and Dotnet). I described it here, hope it would still relavant and help you guys: https://github.com/swagger-api/swagger-codegen/issues/12055#issuecomment-1532426777
Description
When model properties have dollar symbols
$
, then theswagger-codegen
strips out these characters. This can lead to duplicated function arguments (and also duplicated class members) in the Python code.E.g. when a model has the properties
bar
and$bar
:This creates a class with an
__init__
method with duplicated parameters:Swagger-codegen version
2.4.17 and 3.0.23
Swagger declaration file content or url
Full swagger file: https://gist.github.com/jakobkogler/d54d50e8188adf70a668b70d087f8a7e
Command line used for generation
Steps to reproduce
./run-in-docker.sh generate -i foo.yaml -l python -o /gen/foo
pip install -e foo
import swagger_client
fails because of duplicated function argumentsRelated issues/PRs
https://github.com/swagger-api/swagger-codegen/issues/10276 https://github.com/swagger-api/swagger-codegen/issues/10447
Suggest a fix/enhancement
Looks like the dollar sign gets removed at https://github.com/swagger-api/swagger-codegen/blob/master/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/PythonClientCodegen.java#L397 Not sure what a good solution is, maybe replace
$
with_dollar_
, if the stripped out variable name clashes with another one.