From 86db3c7a9f14f697e278d8958a130265d4d2ed6b Mon Sep 17 00:00:00 2001 From: speakeasybot Date: Tue, 12 Dec 2023 01:32:38 +0000 Subject: [PATCH] ci: regenerated with OpenAPI Doc 1.0.0, Speakeasy CLI 1.126.0 --- RELEASES.md | 10 +++++++++- gen.yaml | 8 ++++---- setup.py | 2 +- src/test/sdkconfiguration.py | 6 +++--- src/test/utils/utils.py | 32 +++++++++++++++++--------------- 5 files changed, 34 insertions(+), 24 deletions(-) diff --git a/RELEASES.md b/RELEASES.md index 70cb176..576a1f1 100644 --- a/RELEASES.md +++ b/RELEASES.md @@ -222,4 +222,12 @@ Based on: - OpenAPI Doc 1.0.0 - Speakeasy CLI 1.125.2 (2.210.6) https://github.com/speakeasy-api/speakeasy ### Generated -- [python v0.10.5] . \ No newline at end of file +- [python v0.10.5] . + +## 2023-12-12 01:32:28 +### Changes +Based on: +- OpenAPI Doc 1.0.0 +- Speakeasy CLI 1.126.0 (2.213.3) https://github.com/speakeasy-api/speakeasy +### Generated +- [python v0.11.0] . \ No newline at end of file diff --git a/gen.yaml b/gen.yaml index 3c1050d..442ab69 100644 --- a/gen.yaml +++ b/gen.yaml @@ -2,8 +2,8 @@ configVersion: 1.0.0 management: docChecksum: 2516596125ef223fbbef6c434d22eaac docVersion: 1.0.0 - speakeasyVersion: 1.125.2 - generationVersion: 2.210.6 + speakeasyVersion: 1.126.0 + generationVersion: 2.213.3 generation: comments: {} sdkClassName: test @@ -12,10 +12,10 @@ generation: optionalPropertyRendering: withExample features: python: - core: 4.1.6 + core: 4.3.0 globalServerURLs: 2.82.1 python: - version: 0.10.5 + version: 0.11.0 author: my-test clientServerStatusCodesAsErrors: true description: Python Client SDK Generated by Speakeasy diff --git a/setup.py b/setup.py index 3a9a9ae..93a09da 100644 --- a/setup.py +++ b/setup.py @@ -10,7 +10,7 @@ setuptools.setup( name="test", - version="0.10.5", + version="0.11.0", author="my-test", description="Python Client SDK Generated by Speakeasy", long_description=long_description, diff --git a/src/test/sdkconfiguration.py b/src/test/sdkconfiguration.py index 5096672..5106eec 100644 --- a/src/test/sdkconfiguration.py +++ b/src/test/sdkconfiguration.py @@ -19,9 +19,9 @@ class SDKConfiguration: server_idx: int = 0 language: str = 'python' openapi_doc_version: str = '1.0.0' - sdk_version: str = '0.10.5' - gen_version: str = '2.210.6' - user_agent: str = 'speakeasy-sdk/python 0.10.5 2.210.6 1.0.0 test' + sdk_version: str = '0.11.0' + gen_version: str = '2.213.3' + user_agent: str = 'speakeasy-sdk/python 0.11.0 2.213.3 1.0.0 test' retry_config: RetryConfig = None def get_server_details(self) -> Tuple[str, Dict[str, str]]: diff --git a/src/test/utils/utils.py b/src/test/utils/utils.py index 416ef79..1a60d40 100644 --- a/src/test/utils/utils.py +++ b/src/test/utils/utils.py @@ -12,7 +12,7 @@ from typing import (Any, Callable, Dict, List, Optional, Tuple, Union, get_args, get_origin) from xmlrpc.client import boolean - +from typing_inspect import is_optional_type import dateutil.parser import requests from dataclasses_json import DataClassJsonMixin @@ -169,7 +169,7 @@ def generate_url(clazz: type, server_url: str, path: str, path_params: dataclass serialization = param_metadata.get('serialization', '') if serialization != '': serialized_params = _get_serialized_params( - param_metadata, f_name, param) + param_metadata, field.type, f_name, param) for key, value in serialized_params.items(): path = path.replace( '{' + key + '}', value, 1) @@ -261,7 +261,7 @@ def get_query_params(clazz: type, query_params: dataclass, gbls: Dict[str, Dict[ f_name = metadata.get("field_name") serialization = metadata.get('serialization', '') if serialization != '': - serialized_parms = _get_serialized_params(metadata, f_name, value) + serialized_parms = _get_serialized_params(metadata, field.type, f_name, value) for key, value in serialized_parms.items(): if key in params: params[key].extend(value) @@ -304,12 +304,12 @@ def get_headers(headers_params: dataclass) -> Dict[str, str]: return headers -def _get_serialized_params(metadata: Dict, field_name: str, obj: any) -> Dict[str, str]: +def _get_serialized_params(metadata: Dict, field_type: type, field_name: str, obj: any) -> Dict[str, str]: params: Dict[str, str] = {} serialization = metadata.get('serialization', '') if serialization == 'json': - params[metadata.get("field_name", field_name)] = marshal_json(obj) + params[metadata.get("field_name", field_name)] = marshal_json(obj, field_type) return params @@ -394,14 +394,14 @@ def _get_delimited_query_params(metadata: Dict, field_name: str, obj: any, delim } -def serialize_request_body(request: dataclass, request_field_name: str, nullable: bool, optional: bool, serialization_method: str, encoder=None) -> Tuple[ +def serialize_request_body(request: dataclass, request_type: type, request_field_name: str, nullable: bool, optional: bool, serialization_method: str, encoder=None) -> Tuple[ str, any, any]: if request is None: if not nullable and optional: return None, None, None if not is_dataclass(request) or not hasattr(request, request_field_name): - return serialize_content_type(request_field_name, SERIALIZATION_METHOD_TO_CONTENT_TYPE[serialization_method], + return serialize_content_type(request_field_name, request_type, SERIALIZATION_METHOD_TO_CONTENT_TYPE[serialization_method], request, encoder) request_val = getattr(request, request_field_name) @@ -421,13 +421,13 @@ def serialize_request_body(request: dataclass, request_field_name: str, nullable if request_metadata is None: raise Exception('invalid request type') - return serialize_content_type(request_field_name, request_metadata.get('media_type', 'application/octet-stream'), + return serialize_content_type(request_field_name, request_type, request_metadata.get('media_type', 'application/octet-stream'), request_val) -def serialize_content_type(field_name: str, media_type: str, request: dataclass, encoder=None) -> Tuple[str, any, List[List[any]]]: +def serialize_content_type(field_name: str, request_type: any, media_type: str, request: dataclass, encoder=None) -> Tuple[str, any, List[List[any]]]: if re.match(r'(application|text)\/.*?\+*json.*', media_type) is not None: - return media_type, marshal_json(request, encoder), None + return media_type, marshal_json(request, request_type, encoder), None if re.match(r'multipart\/.*', media_type) is not None: return serialize_multipart_form(media_type, request) if re.match(r'application\/x-www-form-urlencoded.*', media_type) is not None: @@ -478,7 +478,7 @@ def serialize_multipart_form(media_type: str, request: dataclass) -> Tuple[str, form.append([field_name, [file_name, content]]) elif field_metadata.get("json") is True: to_append = [field_metadata.get("field_name", field.name), [ - None, marshal_json(val), "application/json"]] + None, marshal_json(val, field.type), "application/json"]] form.append(to_append) else: field_name = field_metadata.get( @@ -531,7 +531,7 @@ def serialize_form_data(field_name: str, data: dataclass) -> Dict[str, any]: field_name = metadata.get('field_name', field.name) if metadata.get('json'): - form[field_name] = [marshal_json(val)] + form[field_name] = [marshal_json(val, field.type)] else: if metadata.get('style', 'form') == 'form': form = {**form, **_populate_form( @@ -697,12 +697,14 @@ def unmarshal_json(data, typ, decoder=None): return out.res if decoder is None else decoder(out.res) -def marshal_json(val, encoder=None): - marshal = make_dataclass('Marshal', [('res', type(val))], +def marshal_json(val, typ, encoder=None): + if not is_optional_type(typ) and val is None: + raise ValueError(f"Could not marshal None into non-optional type: {typ}") + + marshal = make_dataclass('Marshal', [('res', typ)], bases=(DataClassJsonMixin,)) marshaller = marshal(res=val) json_dict = marshaller.to_dict() - val = json_dict["res"] if encoder is None else encoder(json_dict["res"]) return json.dumps(val, separators=(',', ':'), sort_keys=True)