OpenAPITools / OpenAPITools/openapi-generator

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

Open
#8,499 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Server: Python
Dominant language
Java
Stars
26.8k
Forks
7.7k
PR merge metrics
PR metrics pending

Description

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.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the Python legacy templates and the generated Configuration and Configurator usage described in the issue. Reproduce the problem with the provided OpenAPI Generator command and inspect a generated model. Done means generated models use Configuration.get_default_copy() so options persisted with set_default(), including client-side validation settings, affect future instances.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
tooling
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.