From 4d1ed63d914130d7d1c077f580ad5537e79e20ac Mon Sep 17 00:00:00 2001 From: Bryan Newbold Date: Wed, 18 Sep 2019 23:56:47 -0700 Subject: fix another python codegen auth contamination bug Seems to be the classic one where a dict as a default arg gets mutated then reused across instances. Blech. --- python_openapi_client/codegen_python_client.sh | 35 ++++++++++++++++++++++ .../fatcat_openapi_client/configuration.py | 7 ++--- 2 files changed, 37 insertions(+), 5 deletions(-) (limited to 'python_openapi_client') diff --git a/python_openapi_client/codegen_python_client.sh b/python_openapi_client/codegen_python_client.sh index 1058fd17..80a7f698 100755 --- a/python_openapi_client/codegen_python_client.sh +++ b/python_openapi_client/codegen_python_client.sh @@ -45,6 +45,41 @@ patch -p0 << END_PATCH Ref: https://openapi-generator.tech END_PATCH +# Another patch to fix nasty auth cross-contamination between instances of +# Configuration object. +patch -p0 << END_PATCH +--- fatcat_openapi_client/configuration.py ++++ fatcat_openapi_client/configuration.py +@@ -44,14 +44,11 @@ class Configuration(object): + Do not edit the class manually. + + :param host: Base url +- :param api_key: Dict to store API key(s) +- :param api_key_prefix: Dict to store API prefix (e.g. Bearer) + :param username: Username for HTTP basic authentication + :param password: Password for HTTP basic authentication + """ + + def __init__(self, host="https://api.fatcat.wiki/v0", +- api_key={}, api_key_prefix={}, + username="", password=""): + """Constructor + """ +@@ -62,10 +59,10 @@ class Configuration(object): + """Temp file folder for downloading files + """ + # Authentication Settings +- self.api_key = api_key ++ self.api_key = {} + """dict to store API key(s) + """ +- self.api_key_prefix = api_key_prefix ++ self.api_key_prefix = {} + """dict to store API prefix (e.g. Bearer) + """ + self.refresh_api_key_hook = None +END_PATCH + # these tests are basically no-ops mkdir -p tests/codegen cp -r $OUTPUT/test/* tests/codegen diff --git a/python_openapi_client/fatcat_openapi_client/configuration.py b/python_openapi_client/fatcat_openapi_client/configuration.py index 0cd7e1f2..b4aeff09 100644 --- a/python_openapi_client/fatcat_openapi_client/configuration.py +++ b/python_openapi_client/fatcat_openapi_client/configuration.py @@ -44,14 +44,11 @@ class Configuration(object): Do not edit the class manually. :param host: Base url - :param api_key: Dict to store API key(s) - :param api_key_prefix: Dict to store API prefix (e.g. Bearer) :param username: Username for HTTP basic authentication :param password: Password for HTTP basic authentication """ def __init__(self, host="https://api.fatcat.wiki/v0", - api_key={}, api_key_prefix={}, username="", password=""): """Constructor """ @@ -62,10 +59,10 @@ class Configuration(object): """Temp file folder for downloading files """ # Authentication Settings - self.api_key = api_key + self.api_key = {} """dict to store API key(s) """ - self.api_key_prefix = api_key_prefix + self.api_key_prefix = {} """dict to store API prefix (e.g. Bearer) """ self.refresh_api_key_hook = None -- cgit v1.2.3