Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG][Python] Configuration objects share a common api_key dict #4389

Closed
arbelpeled opened this issue Nov 6, 2019 · 1 comment
Closed

[BUG][Python] Configuration objects share a common api_key dict #4389

arbelpeled opened this issue Nov 6, 2019 · 1 comment

Comments

@arbelpeled
Copy link

arbelpeled commented Nov 6, 2019

Description

When creating multiple Configurations using Configuration(), the dictionary in the field api_key is shared across these multiple (different) configurations.

openapi-generator version

3.3.3

OpenAPI declaration file content or url

Doesn't matter which declaration

Steps to reproduce

In any generated API:

c1 = Configuration()
c1.api_key['x-auth-token']="mytoken"
c2 = Configuration()
assert(c2.api_key['x-auth-token']=="mytoken")

The assertion should fail but it actually does not.

Suggest a fix

It's probably a problem with the default value supplied to the constructor of Configuration. If you supply a {} default value the same dict will be shared between different invocations of the constructor. The standard way to solve this is by putting a default None value and if the value is indeed None then create a new {} inside the constructor.

@wing328
Copy link
Member

wing328 commented Nov 17, 2019

Closed via #4485

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants