Skip to content

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

Closed

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.

Activity

  1. wing328 commented on Nov 17, 2019

    @wing328
    Member

    Closed via #4485

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

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