Our project is wrote on camelCase convention. Is possible to generate python client following camelCase instead of the pythonic snake_case?
I looked at mustache templates on:
And the instructions under openapi-generator config-help -g python.
Also I looked at PythonClientCodegen.java but I didn't find the answer.
➜ openapi-generator version
4.0.3
https://gitlab.com/snippets/1882068/raw
Note: this YAML is auto generated from a Doxygen documentation for RetroShare project using this
openapi-generator generate -i wrapper_openapi.yml -g python -o ../openapi-python-retroshare-api-wrapper
👍 Thanks for opening this issue!
🏷 I have applied any labels matching special text in your issue.
The team will review the labels and make any necessary changes.
Is pythonic snake_case causing issues (e.g. JSON payload serialization/deserialization)?
For the moment it don't seems so, but we would like to use only CamelCase on our project, also in python wrappers, breaking with the pythonic rules.
Is there a way to modify the template to disable snake_case and use CamelCase for variable names an others?
We have a similar issue at the moment, a resolution would be great thanks
There is not yet a way to do this in the python clients.
Just so you know, the variable names that you are suggesting shapeType, go against the PEP8 python style guide, which would instead use shape_type
This is partially implemented in python-experimental when instantiating models.
See this example
Where we make a model like:
inst = petstore_api.Shape(_spec_property_naming=True, shapeType="Triangle", triangleType="IsoscelesTriangle")
But that only allows you to assign properties at initialization with spec variable names.
To access the property instances we are assuming that the the context is python and that the user wants:
inst.shape_type
I see a couple of ways to get this working:
@convert_js_args_to_python_args like we do in the model __init__ methodWe welcome any contributions on this.
in Java add a CLI option to a python generator which uses the spec naming for all endpoint variable names and object variable names. This will probably involve editing functions to use this CLI option and change the property names that are use in Java.
@spacether Can you guide me little on where should I look in the code for this above approach ?
Sure thing :)
So I think that this is where the parameter names are set in the python client
And here is an example of a PR that adds a CLI parameter in a python generator:
https://github.com/OpenAPITools/openapi-generator/pull/4765
Most helpful comment
We have a similar issue at the moment, a resolution would be great thanks