Skip to content

Commit 3284205

Browse files
Merge pull request #19 from hinthornw/william/fix_api_config_setter
Fix APIConfig Setter
2 parents cc7c151 + 1a0d1d7 commit 3284205

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

src/openapi_python_generator/language_converters/python/templates/apiconfig.jinja2

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ class APIConfig():
2525
{% if env_token_name is not none %}
2626
raise Exception("This client was generated with an environment variable for the access token. Please set the environment variable '{{ env_token_name }}' to the access token.")
2727
{% else %}
28-
_access_token = value
28+
APIConfig._access_token = value
2929
{% endif %}
3030

3131
class HTTPException(Exception):

tests/test_generated_code.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,22 @@ def test_get_auth_token_without_env(model_data_with_cleanup):
2929
)
3030

3131

32+
def test_set_auth_token():
33+
generate_data(test_data_path, test_result_path)
34+
35+
_locals = locals()
36+
program = """from .test_result import APIConfig
37+
assert APIConfig.get_access_token() is None
38+
APIConfig.set_access_token('foo_bar')
39+
assert APIConfig.get_access_token() == 'foo_bar'
40+
"""
41+
exec(
42+
program,
43+
globals(),
44+
_locals,
45+
)
46+
47+
3248
@pytest.mark.parametrize(
3349
"library, use_orjson",
3450
[

0 commit comments

Comments
 (0)