Skip to content

Commit f27bd32

Browse files
committed
chore: update petstore samples
1 parent 9a64b3b commit f27bd32

6 files changed

Lines changed: 26 additions & 16 deletions

File tree

samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent/openapi_client/configuration.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ class Configuration:
166166
:param ca_cert_data: verify the peer using concatenated CA certificate data
167167
in PEM (str) or DER (bytes) format.
168168
:param cert_file: the path to a client certificate file, for mTLS.
169-
:param key_file: the path to a client key file, for mTLS.
169+
:param key_file: the path to a client key file, for mTLS.
170170
171171
:Example:
172172
@@ -504,6 +504,7 @@ def get_basic_auth_token(self) -> Optional[str]:
504504
password = ""
505505
if self.password is not None:
506506
password = self.password
507+
507508
return urllib3.util.make_headers(
508509
basic_auth=username + ':' + password
509510
).get('authorization')
@@ -587,6 +588,7 @@ def get_host_from_settings(
587588
variable_name, variable['default_value'])
588589

589590
if 'enum_values' in variable \
591+
and variable['enum_values'] \
590592
and used_value not in variable['enum_values']:
591593
raise ValueError(
592594
"The variable `{0}` in the host URL has invalid value "

samples/client/echo_api/python/openapi_client/configuration.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ class Configuration:
166166
:param ca_cert_data: verify the peer using concatenated CA certificate data
167167
in PEM (str) or DER (bytes) format.
168168
:param cert_file: the path to a client certificate file, for mTLS.
169-
:param key_file: the path to a client key file, for mTLS.
169+
:param key_file: the path to a client key file, for mTLS.
170170
171171
:Example:
172172
@@ -504,6 +504,7 @@ def get_basic_auth_token(self) -> Optional[str]:
504504
password = ""
505505
if self.password is not None:
506506
password = self.password
507+
507508
return urllib3.util.make_headers(
508509
basic_auth=username + ':' + password
509510
).get('authorization')
@@ -587,6 +588,7 @@ def get_host_from_settings(
587588
variable_name, variable['default_value'])
588589

589590
if 'enum_values' in variable \
591+
and variable['enum_values'] \
590592
and used_value not in variable['enum_values']:
591593
raise ValueError(
592594
"The variable `{0}` in the host URL has invalid value "

samples/openapi3/client/petstore/python-aiohttp/petstore_api/configuration.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
""" # noqa: E501
1313

1414

15+
import base64
1516
import copy
1617
import http.client as httplib
1718
import logging
@@ -20,7 +21,6 @@
2021
from typing import Any, ClassVar, Dict, List, Literal, Optional, TypedDict, Union
2122
from typing_extensions import NotRequired, Self
2223

23-
import urllib3
2424

2525
from petstore_api.signing import HttpSigningConfiguration
2626

@@ -171,7 +171,7 @@ class Configuration:
171171
:param ca_cert_data: verify the peer using concatenated CA certificate data
172172
in PEM (str) or DER (bytes) format.
173173
:param cert_file: the path to a client certificate file, for mTLS.
174-
:param key_file: the path to a client key file, for mTLS.
174+
:param key_file: the path to a client key file, for mTLS.
175175
176176
:Example:
177177
@@ -325,7 +325,6 @@ def __init__(
325325
"""Logging Settings
326326
"""
327327
self.logger["package_logger"] = logging.getLogger("petstore_api")
328-
self.logger["urllib3_logger"] = logging.getLogger("urllib3")
329328
self.logger_format = '%(asctime)s %(levelname)s %(message)s'
330329
"""Log format
331330
"""
@@ -574,9 +573,10 @@ def get_basic_auth_token(self) -> Optional[str]:
574573
password = ""
575574
if self.password is not None:
576575
password = self.password
577-
return urllib3.util.make_headers(
578-
basic_auth=username + ':' + password
579-
).get('authorization')
576+
577+
return "Basic " + base64.b64encode(
578+
(username + ":" + password).encode('utf-8')
579+
).decode('utf-8')
580580

581581
def auth_settings(self)-> AuthSettings:
582582
"""Gets Auth Settings dict for api client.
@@ -727,6 +727,7 @@ def get_host_from_settings(
727727
variable_name, variable['default_value'])
728728

729729
if 'enum_values' in variable \
730+
and variable['enum_values'] \
730731
and used_value not in variable['enum_values']:
731732
raise ValueError(
732733
"The variable `{0}` in the host URL has invalid value "

samples/openapi3/client/petstore/python-httpx/petstore_api/configuration.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
""" # noqa: E501
1313

1414

15+
import base64
1516
import copy
1617
import http.client as httplib
1718
import logging
@@ -20,7 +21,6 @@
2021
from typing import Any, ClassVar, Dict, List, Literal, Optional, TypedDict, Union
2122
from typing_extensions import NotRequired, Self
2223

23-
import urllib3
2424

2525
from petstore_api.signing import HttpSigningConfiguration
2626

@@ -171,7 +171,7 @@ class Configuration:
171171
:param ca_cert_data: verify the peer using concatenated CA certificate data
172172
in PEM (str) or DER (bytes) format.
173173
:param cert_file: the path to a client certificate file, for mTLS.
174-
:param key_file: the path to a client key file, for mTLS.
174+
:param key_file: the path to a client key file, for mTLS.
175175
176176
:Example:
177177
@@ -325,7 +325,6 @@ def __init__(
325325
"""Logging Settings
326326
"""
327327
self.logger["package_logger"] = logging.getLogger("petstore_api")
328-
self.logger["urllib3_logger"] = logging.getLogger("urllib3")
329328
self.logger_format = '%(asctime)s %(levelname)s %(message)s'
330329
"""Log format
331330
"""
@@ -574,9 +573,10 @@ def get_basic_auth_token(self) -> Optional[str]:
574573
password = ""
575574
if self.password is not None:
576575
password = self.password
577-
return urllib3.util.make_headers(
578-
basic_auth=username + ':' + password
579-
).get('authorization')
576+
577+
return "Basic " + base64.b64encode(
578+
(username + ":" + password).encode('utf-8')
579+
).decode('utf-8')
580580

581581
def auth_settings(self)-> AuthSettings:
582582
"""Gets Auth Settings dict for api client.
@@ -727,6 +727,7 @@ def get_host_from_settings(
727727
variable_name, variable['default_value'])
728728

729729
if 'enum_values' in variable \
730+
and variable['enum_values'] \
730731
and used_value not in variable['enum_values']:
731732
raise ValueError(
732733
"The variable `{0}` in the host URL has invalid value "

samples/openapi3/client/petstore/python-lazyImports/petstore_api/configuration.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ class Configuration:
172172
:param ca_cert_data: verify the peer using concatenated CA certificate data
173173
in PEM (str) or DER (bytes) format.
174174
:param cert_file: the path to a client certificate file, for mTLS.
175-
:param key_file: the path to a client key file, for mTLS.
175+
:param key_file: the path to a client key file, for mTLS.
176176
177177
:Example:
178178
@@ -578,6 +578,7 @@ def get_basic_auth_token(self) -> Optional[str]:
578578
password = ""
579579
if self.password is not None:
580580
password = self.password
581+
581582
return urllib3.util.make_headers(
582583
basic_auth=username + ':' + password
583584
).get('authorization')
@@ -731,6 +732,7 @@ def get_host_from_settings(
731732
variable_name, variable['default_value'])
732733

733734
if 'enum_values' in variable \
735+
and variable['enum_values'] \
734736
and used_value not in variable['enum_values']:
735737
raise ValueError(
736738
"The variable `{0}` in the host URL has invalid value "

samples/openapi3/client/petstore/python/petstore_api/configuration.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ class Configuration:
172172
:param ca_cert_data: verify the peer using concatenated CA certificate data
173173
in PEM (str) or DER (bytes) format.
174174
:param cert_file: the path to a client certificate file, for mTLS.
175-
:param key_file: the path to a client key file, for mTLS.
175+
:param key_file: the path to a client key file, for mTLS.
176176
177177
:Example:
178178
@@ -578,6 +578,7 @@ def get_basic_auth_token(self) -> Optional[str]:
578578
password = ""
579579
if self.password is not None:
580580
password = self.password
581+
581582
return urllib3.util.make_headers(
582583
basic_auth=username + ':' + password
583584
).get('authorization')
@@ -731,6 +732,7 @@ def get_host_from_settings(
731732
variable_name, variable['default_value'])
732733

733734
if 'enum_values' in variable \
735+
and variable['enum_values'] \
734736
and used_value not in variable['enum_values']:
735737
raise ValueError(
736738
"The variable `{0}` in the host URL has invalid value "

0 commit comments

Comments
 (0)