Skip to content

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

@arbelpeled

Description

@arbelpeled
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.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions