Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • O openapi-generator
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 3,476
    • Issues 3,476
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 402
    • Merge requests 402
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Package Registry
    • Infrastructure Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • OpenAPI Tools
  • openapi-generator
  • Issues
  • #5126
Closed
Open
Issue created Jan 27, 2020 by Administrator@rootContributor0 of 6 checklist items completed0/6 checklist items

[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

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

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)
Assignee
Assign to
Time tracking