OpenAPITools / openapi-generator

OpenAPI Generator allows generation of API client libraries (SDK generation), server stubs, documentation and configuration automatically given an OpenAPI Spec (v2, v3)
https://openapi-generator.tech
Apache License 2.0
22.04k stars 6.61k forks source link

[PYTHON-LEGACY] Use programmer-provided Configuration() objects when possible #8499

Open adpoliak opened 3 years ago

adpoliak commented 3 years ago
Description

The generated PACKAGENAME.configuration.Configuration() class has means of persisting options via its set_default() class method.
However, in order for the persisted options to be used on future instances, the Configuration.get_default_copy() class method must be used instead of the Configurator() constructor. This isn't currently done in any of the generated models, so the programmer is unable to override self.local_vars_configuration.client_side_validation to help deal with non-conforming server responses. Updating the Python templates to use the get_default_copy() class method solves this.

openapi-generator version

5.0.1-SNAPSHOT (commit 3d23b99242ad80f440d4ca3eb9f90103a4ec208b)

OpenAPI declaration file content or url

https://bitwarden.com/help/api/specs/public/swagger.json (relevant to why I'm working with openapi-generator, but unrelated to the issue itself)

Command line used for generation
PYTHON_POST_PROCESS_FILE="/opt/local/bin/yapf -i" \
java -jar modules/openapi-generator-cli/target/openapi-generator-cli.jar generate --skip-validate-spec \
-i ../PROJECT/input/swagger.json -g python-legacy -o ../PROJECT --enable-post-process-file \
--library=asyncio --verbose --package-name=PACKAGE_NAME --git-host=GIT-SERVER --git-user-id=GIT-USER \
--git-repo-id=GIT-REPO-ID --additional-properties=hideGenerationTimestamp=false,projectName=PROJECT_NAME
Steps to reproduce

Generate the API Client with the existing templates

Related issues/PRs

N/A

Suggest a fix/enhancement

The Contributing Guidelines say to submit an issue before submitting a PR. It will be submitted shortly.

auto-labeler[bot] commented 3 years ago

šŸ‘ 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.