Skip to content

Commit a985607

Browse files
committed
fix: use httpx in generated configuration.py
1 parent 8a4246c commit a985607

1 file changed

Lines changed: 10 additions & 4 deletions

File tree

modules/openapi-generator/src/main/resources/python/configuration.mustache

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
{{>partial_header}}
44

55

6+
import base64
67
import copy
78
import http.client as httplib
89
import logging
@@ -14,7 +15,9 @@ import sys
1415
from typing import Any, ClassVar, Dict, List, Literal, Optional, TypedDict, Union
1516
from typing_extensions import NotRequired, Self
1617

18+
{{^async}}
1719
import urllib3
20+
{{/async}}
1821

1922
{{#hasHttpSignatureMethods}}
2023
from {{packageName}}.signing import HttpSigningConfiguration
@@ -187,7 +190,7 @@ class Configuration:
187190
:param ca_cert_data: verify the peer using concatenated CA certificate data
188191
in PEM (str) or DER (bytes) format.
189192
:param cert_file: the path to a client certificate file, for mTLS.
190-
:param key_file: the path to a client key file, for mTLS.
193+
:param key_file: the path to a client key file, for mTLS.
191194

192195
{{#hasAuthMethods}}
193196
:Example:
@@ -353,7 +356,9 @@ conf = {{{packageName}}}.Configuration(
353356
"""Logging Settings
354357
"""
355358
self.logger["package_logger"] = logging.getLogger("{{packageName}}")
359+
{{^async}}
356360
self.logger["urllib3_logger"] = logging.getLogger("urllib3")
361+
{{/async}}
357362
self.logger_format = '%(asctime)s %(levelname)s %(message)s'
358363
"""Log format
359364
"""
@@ -615,9 +620,10 @@ conf = {{{packageName}}}.Configuration(
615620
password = ""
616621
if self.password is not None:
617622
password = self.password
618-
return urllib3.util.make_headers(
619-
basic_auth=username + ':' + password
620-
).get('authorization')
623+
624+
return "Basic " + base64.b64encode(
625+
(username + ":" + password).encode('utf-8')
626+
).decode('utf-8')
621627

622628
def auth_settings(self)-> AuthSettings:
623629
"""Gets Auth Settings dict for api client.

0 commit comments

Comments
 (0)