Skip to content

Commit 62a0603

Browse files
committed
ci: regenerated with OpenAPI Doc 0.3.0, Speakeay CLI 1.7.1
1 parent 6227953 commit 62a0603

File tree

5 files changed

+62
-37
lines changed

5 files changed

+62
-37
lines changed

RELEASES.md

+9-1
Original file line numberDiff line numberDiff line change
@@ -110,4 +110,12 @@ Based on:
110110
- OpenAPI Doc 0.3.0 https://docs.speakeasyapi.dev/openapi.yaml
111111
- Speakeasy CLI 1.6.0 https://github.com/speakeasy-api/speakeasy
112112
### Releases
113-
- [PyPI v1.6.0] https://pypi.org/project/speakeasy-client-sdk-python/1.6.0 - .
113+
- [PyPI v1.6.0] https://pypi.org/project/speakeasy-client-sdk-python/1.6.0 - .
114+
115+
## 2023-03-02 00:11:32
116+
### Changes
117+
Based on:
118+
- OpenAPI Doc 0.3.0 https://docs.speakeasyapi.dev/openapi.yaml
119+
- Speakeasy CLI 1.7.1 https://github.com/speakeasy-api/speakeasy
120+
### Releases
121+
- [PyPI v1.7.0] https://pypi.org/project/speakeasy-client-sdk-python/1.7.0 - .

gen.yaml

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@ configVersion: 1.0.0
22
management:
33
docChecksum: 2bba3b8f9d211b02569b3f9aff0d34b4
44
docVersion: 0.3.0
5-
speakeasyVersion: 1.6.0
5+
speakeasyVersion: 1.7.1
66
generation:
77
telemetryEnabled: true
88
sdkClassName: SDK
99
sdkFlattening: false
1010
python:
11-
version: 1.6.0
11+
version: 1.7.0
1212
author: Speakeasy
1313
description: Speakeasy API Client SDK for Python
1414
packageName: speakeasy-client-sdk-python

setup.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
setuptools.setup(
1010
name="speakeasy-client-sdk-python",
11-
version="1.6.0",
11+
version="1.7.0",
1212
author="Speakeasy",
1313
description="Speakeasy API Client SDK for Python",
1414
long_description=long_description,

src/sdk/sdk.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@ class SDK:
3232
_security: shared.Security
3333
_server_url: str = SERVERS[SERVER_PROD]
3434
_language: str = "python"
35-
_sdk_version: str = "1.6.0"
36-
_gen_version: str = "1.6.0"
35+
_sdk_version: str = "1.7.0"
36+
_gen_version: str = "1.7.1"
3737

3838
def __init__(self) -> None:
3939
self._client = requests.Session()

src/sdk/utils/utils.py

+48-31
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,13 @@ def configure_security_client(client: requests.Session, security: dataclass):
4141
continue
4242
if metadata.get('option'):
4343
_parse_security_option(client, value)
44-
return
44+
return client
4545
elif metadata.get('scheme'):
46-
_parse_security_scheme(client, metadata, value)
46+
# Special case for basic auth which could be a flattened struct
47+
if metadata.get("sub_type") == "basic" and not is_dataclass(value):
48+
_parse_security_scheme(client, metadata, security)
49+
else:
50+
_parse_security_scheme(client, metadata, value)
4751

4852
return client
4953

@@ -54,47 +58,60 @@ def _parse_security_option(client: SecurityClient, option: dataclass):
5458
metadata = opt_field.metadata.get('security')
5559
if metadata is None or metadata.get('scheme') is None:
5660
continue
57-
_parse_security_scheme(client, metadata.get(
58-
'scheme'), getattr(option, opt_field.name))
61+
_parse_security_scheme(
62+
client, metadata, getattr(option, opt_field.name))
5963

6064

61-
def _parse_security_scheme(client: SecurityClient, scheme_metadata: dict, scheme: dataclass):
65+
def _parse_security_scheme(client: SecurityClient, scheme_metadata: dict, scheme: any):
6266
scheme_type = scheme_metadata.get('type')
6367
sub_type = scheme_metadata.get('sub_type')
6468

65-
if scheme_type == 'http' and sub_type == 'basic':
66-
_parse_basic_auth_scheme(client, scheme)
67-
return
69+
if is_dataclass(scheme):
70+
if scheme_type == 'http' and sub_type == 'basic':
71+
_parse_basic_auth_scheme(client, scheme)
72+
return
6873

69-
scheme_fields: Tuple[Field, ...] = fields(scheme)
70-
for scheme_field in scheme_fields:
71-
metadata = scheme_field.metadata.get('security')
72-
if metadata is None or metadata.get('field_name') is None:
73-
continue
74+
scheme_fields: Tuple[Field, ...] = fields(scheme)
75+
for scheme_field in scheme_fields:
76+
metadata = scheme_field.metadata.get('security')
77+
if metadata is None or metadata.get('field_name') is None:
78+
continue
7479

75-
header_name = metadata.get('field_name')
76-
value = getattr(scheme, scheme_field.name)
80+
value = getattr(scheme, scheme_field.name)
7781

78-
if scheme_type == "apiKey":
79-
if sub_type == 'header':
80-
client.client.headers[header_name] = value
81-
elif sub_type == 'query':
82-
client.query_params[header_name] = value
83-
elif sub_type == 'cookie':
84-
client.client.cookies[header_name] = value
85-
else:
86-
raise Exception('not supported')
87-
elif scheme_type == "openIdConnect":
82+
_parse_security_scheme_value(
83+
client, scheme_metadata, metadata, value)
84+
else:
85+
_parse_security_scheme_value(
86+
client, scheme_metadata, scheme_metadata, scheme)
87+
88+
89+
def _parse_security_scheme_value(client: SecurityClient, scheme_metadata: dict, security_metadata: dict, value: any):
90+
scheme_type = scheme_metadata.get('type')
91+
sub_type = scheme_metadata.get('sub_type')
92+
93+
header_name = security_metadata.get('field_name')
94+
95+
if scheme_type == "apiKey":
96+
if sub_type == 'header':
8897
client.client.headers[header_name] = value
89-
elif scheme_type == 'oauth2':
98+
elif sub_type == 'query':
99+
client.query_params[header_name] = value
100+
elif sub_type == 'cookie':
101+
client.client.cookies[header_name] = value
102+
else:
103+
raise Exception('not supported')
104+
elif scheme_type == "openIdConnect":
105+
client.client.headers[header_name] = value
106+
elif scheme_type == 'oauth2':
107+
client.client.headers[header_name] = value
108+
elif scheme_type == 'http':
109+
if sub_type == 'bearer':
90110
client.client.headers[header_name] = value
91-
elif scheme_type == 'http':
92-
if sub_type == 'bearer':
93-
client.client.headers[header_name] = value
94-
else:
95-
raise Exception('not supported')
96111
else:
97112
raise Exception('not supported')
113+
else:
114+
raise Exception('not supported')
98115

99116

100117
def _parse_basic_auth_scheme(client: SecurityClient, scheme: dataclass):

0 commit comments

Comments
 (0)