[BUG] [python] Endpoint required enums of length one unset
Created by: spacether
Bug Report Checklist
-
Have you provided a full/minimal spec to reproduce the issue? -
Have you validated the input using an OpenAPI validator (example)? -
What's the version of OpenAPI Generator used? -
Have you search for related issues/PRs? -
What's the actual output vs expected output? -
[Optional] Bounty to sponsor the fix (example)
Description
For required enums of length one, the python-experimental generator should be setting the default value to what the spec defines. We were previously doing this but a PR update accidentally wiped out this feature.
Endpoint parameter example Spec https://github.com/OpenAPITools/openapi-generator/blob/master/modules/openapi-generator/src/test/resources/2_0/python-client-experimental/petstore-with-fake-endpoints-models-for-testing.yaml#L1066 Generated code https://github.com/OpenAPITools/openapi-generator/blob/master/samples/client/petstore/python-experimental/petstore_api/api/fake_api.py#L1016 I am not seeing a test of this, it looks like we are not correctly loading these default values into the function definition
openapi-generator version
master branch
OpenAPI declaration file content or url
Command line used for generation
Steps to reproduce
Related issues/PRs
Suggest a fix
Please update the template here: https://github.com/OpenAPITools/openapi-generator/blob/master/modules/openapi-generator/src/main/resources/python/python-experimental/api.mustache#L48
- for required params with defaultValues, use the value
- switch to using the {{requiredVars}} and {{optional}} parameter tags and **kwargs like the model template does here https://github.com/OpenAPITools/openapi-generator/blob/master/modules/openapi-generator/src/main/resources/python/python-experimental/model_templates/method_init_shared.mustache#L1
- remove the sortParamsByRequiredFlag CLI option because this generator is hard coding us to
- passing required params positionally in the function signature
- add an endpoint test to ensure that this feature is tested
A dev user can:
- passing required params positionally OR
- passing required params as **kwargs (this is a general python feature where positional args can be passed as keyword args)