From e9e98826d60d208c56bb7d93a8fa082e9c3d4688 Mon Sep 17 00:00:00 2001 From: speakeasybot Date: Fri, 29 Sep 2023 01:13:11 +0000 Subject: [PATCH] ci: regenerated with OpenAPI Doc 1.0.0, Speakeay CLI 1.91.3 --- RELEASES.md | 10 ++- docs/models/operations/createpetsresponse.md | 6 +- docs/models/operations/listpetsresponse.md | 8 +- docs/models/operations/showpetbyidrequest.md | 2 +- docs/models/operations/showpetbyidresponse.md | 8 +- docs/models/shared/error.md | 4 +- docs/models/shared/pet.md | 4 +- docs/sdks/pets/README.md | 4 +- gen.yaml | 8 +- pylintrc | 4 +- setup.py | 2 +- src/test/pets.py | 6 +- src/test/sdkconfiguration.py | 5 +- src/test/utils/utils.py | 79 ++++++++++++++++--- 14 files changed, 109 insertions(+), 41 deletions(-) diff --git a/RELEASES.md b/RELEASES.md index 9cb55cf..0efaa62 100644 --- a/RELEASES.md +++ b/RELEASES.md @@ -102,4 +102,12 @@ Based on: - OpenAPI Doc 1.0.0 - Speakeasy CLI 1.91.2 (2.131.1) https://github.com/speakeasy-api/speakeasy ### Generated -- [python v0.5.1] . \ No newline at end of file +- [python v0.5.1] . + +## 2023-09-29 01:12:54 +### Changes +Based on: +- OpenAPI Doc 1.0.0 +- Speakeasy CLI 1.91.3 (2.139.1) https://github.com/speakeasy-api/speakeasy +### Generated +- [python v0.6.0] . \ No newline at end of file diff --git a/docs/models/operations/createpetsresponse.md b/docs/models/operations/createpetsresponse.md index 69f310a..62cab82 100755 --- a/docs/models/operations/createpetsresponse.md +++ b/docs/models/operations/createpetsresponse.md @@ -5,7 +5,7 @@ | Field | Type | Required | Description | | ------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------- | -| `content_type` | *str* | :heavy_check_mark: | HTTP response content type for this operation | -| `error` | [Optional[shared.Error]](../../models/shared/error.md) | :heavy_minus_sign: | unexpected error | -| `status_code` | *int* | :heavy_check_mark: | HTTP response status code for this operation | +| `content_type` | *Optional[str]* | :heavy_check_mark: | HTTP response content type for this operation | +| `error` | [Optional[shared.Error]](undefined/models/shared/error.md) | :heavy_minus_sign: | unexpected error | +| `status_code` | *Optional[int]* | :heavy_check_mark: | HTTP response status code for this operation | | `raw_response` | [requests.Response](https://requests.readthedocs.io/en/latest/api/#requests.Response) | :heavy_minus_sign: | Raw HTTP response; suitable for custom response parsing | \ No newline at end of file diff --git a/docs/models/operations/listpetsresponse.md b/docs/models/operations/listpetsresponse.md index bc18c52..e3d09b7 100755 --- a/docs/models/operations/listpetsresponse.md +++ b/docs/models/operations/listpetsresponse.md @@ -5,9 +5,9 @@ | Field | Type | Required | Description | | ------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------- | -| `content_type` | *str* | :heavy_check_mark: | HTTP response content type for this operation | -| `error` | [Optional[shared.Error]](../../models/shared/error.md) | :heavy_minus_sign: | unexpected error | +| `content_type` | *Optional[str]* | :heavy_check_mark: | HTTP response content type for this operation | +| `error` | [Optional[shared.Error]](undefined/models/shared/error.md) | :heavy_minus_sign: | unexpected error | | `headers` | dict[str, list[*str*]] | :heavy_minus_sign: | N/A | -| `pets` | list[[shared.Pet](../../models/shared/pet.md)] | :heavy_minus_sign: | A paged array of pets | -| `status_code` | *int* | :heavy_check_mark: | HTTP response status code for this operation | +| `pets` | list[[shared.Pet](undefined/models/shared/pet.md)] | :heavy_minus_sign: | A paged array of pets | +| `status_code` | *Optional[int]* | :heavy_check_mark: | HTTP response status code for this operation | | `raw_response` | [requests.Response](https://requests.readthedocs.io/en/latest/api/#requests.Response) | :heavy_minus_sign: | Raw HTTP response; suitable for custom response parsing | \ No newline at end of file diff --git a/docs/models/operations/showpetbyidrequest.md b/docs/models/operations/showpetbyidrequest.md index 97a054a..2702db1 100755 --- a/docs/models/operations/showpetbyidrequest.md +++ b/docs/models/operations/showpetbyidrequest.md @@ -5,4 +5,4 @@ | Field | Type | Required | Description | | ----------------------------- | ----------------------------- | ----------------------------- | ----------------------------- | -| `pet_id` | *str* | :heavy_check_mark: | The id of the pet to retrieve | \ No newline at end of file +| `pet_id` | *Optional[str]* | :heavy_check_mark: | The id of the pet to retrieve | \ No newline at end of file diff --git a/docs/models/operations/showpetbyidresponse.md b/docs/models/operations/showpetbyidresponse.md index f9b8826..c6e07e1 100755 --- a/docs/models/operations/showpetbyidresponse.md +++ b/docs/models/operations/showpetbyidresponse.md @@ -5,8 +5,8 @@ | Field | Type | Required | Description | | ------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------- | -| `content_type` | *str* | :heavy_check_mark: | HTTP response content type for this operation | -| `error` | [Optional[shared.Error]](../../models/shared/error.md) | :heavy_minus_sign: | unexpected error | -| `pet` | [Optional[shared.Pet]](../../models/shared/pet.md) | :heavy_minus_sign: | Expected response to a valid request | -| `status_code` | *int* | :heavy_check_mark: | HTTP response status code for this operation | +| `content_type` | *Optional[str]* | :heavy_check_mark: | HTTP response content type for this operation | +| `error` | [Optional[shared.Error]](undefined/models/shared/error.md) | :heavy_minus_sign: | unexpected error | +| `pet` | [Optional[shared.Pet]](undefined/models/shared/pet.md) | :heavy_minus_sign: | Expected response to a valid request | +| `status_code` | *Optional[int]* | :heavy_check_mark: | HTTP response status code for this operation | | `raw_response` | [requests.Response](https://requests.readthedocs.io/en/latest/api/#requests.Response) | :heavy_minus_sign: | Raw HTTP response; suitable for custom response parsing | \ No newline at end of file diff --git a/docs/models/shared/error.md b/docs/models/shared/error.md index 2046cb9..9e2ad16 100755 --- a/docs/models/shared/error.md +++ b/docs/models/shared/error.md @@ -5,5 +5,5 @@ | Field | Type | Required | Description | | ------------------ | ------------------ | ------------------ | ------------------ | -| `code` | *int* | :heavy_check_mark: | N/A | -| `message` | *str* | :heavy_check_mark: | N/A | \ No newline at end of file +| `code` | *Optional[int]* | :heavy_check_mark: | N/A | +| `message` | *Optional[str]* | :heavy_check_mark: | N/A | \ No newline at end of file diff --git a/docs/models/shared/pet.md b/docs/models/shared/pet.md index 518988f..c206156 100755 --- a/docs/models/shared/pet.md +++ b/docs/models/shared/pet.md @@ -5,6 +5,6 @@ | Field | Type | Required | Description | | ------------------ | ------------------ | ------------------ | ------------------ | -| `id` | *int* | :heavy_check_mark: | N/A | -| `name` | *str* | :heavy_check_mark: | N/A | +| `id` | *Optional[int]* | :heavy_check_mark: | N/A | +| `name` | *Optional[str]* | :heavy_check_mark: | N/A | | `tag` | *Optional[str]* | :heavy_minus_sign: | N/A | \ No newline at end of file diff --git a/docs/sdks/pets/README.md b/docs/sdks/pets/README.md index 45faf79..e7bb59a 100755 --- a/docs/sdks/pets/README.md +++ b/docs/sdks/pets/README.md @@ -45,7 +45,7 @@ from test.models import operations s = test.Test() req = operations.ListPetsRequest( - limit=548814, + limit=21453, ) res = s.pets.list_pets(req) @@ -79,7 +79,7 @@ from test.models import operations s = test.Test() req = operations.ShowPetByIDRequest( - pet_id='provident', + pet_id='South bandwidth male', ) res = s.pets.show_pet_by_id(req) diff --git a/gen.yaml b/gen.yaml index b5b000d..9d94cd7 100644 --- a/gen.yaml +++ b/gen.yaml @@ -2,8 +2,8 @@ configVersion: 1.0.0 management: docChecksum: 2516596125ef223fbbef6c434d22eaac docVersion: 1.0.0 - speakeasyVersion: 1.91.2 - generationVersion: 2.131.1 + speakeasyVersion: 1.91.3 + generationVersion: 2.139.1 generation: comments: disableComments: false @@ -14,10 +14,10 @@ generation: tagNamespacingDisabled: false features: python: - core: 2.86.1 + core: 2.87.0 globalServerURLs: 2.82.0 python: - version: 0.5.1 + version: 0.6.0 author: my-test clientServerStatusCodesAsErrors: true description: Python Client SDK Generated by Speakeasy diff --git a/pylintrc b/pylintrc index ab6495d..2a6cf69 100755 --- a/pylintrc +++ b/pylintrc @@ -116,12 +116,12 @@ argument-naming-style=snake_case #argument-rgx= # Naming style matching correct attribute names. -attr-naming-style=snake_case +#attr-naming-style=snake_case # Regular expression matching correct attribute names. Overrides attr-naming- # style. If left empty, attribute names will be checked with the set naming # style. -#attr-rgx= +attr-rgx=[^\W\d][^\W]*|__.*__$ # Bad variable names which should always be refused, separated by a comma. bad-names= diff --git a/setup.py b/setup.py index 54820bc..6bebcbb 100755 --- a/setup.py +++ b/setup.py @@ -10,7 +10,7 @@ setuptools.setup( name="test", - version="0.5.1", + version="0.6.0", author="my-test", description="Python Client SDK Generated by Speakeasy", long_description=long_description, diff --git a/src/test/pets.py b/src/test/pets.py index 395271b..8c3c929 100755 --- a/src/test/pets.py +++ b/src/test/pets.py @@ -19,7 +19,7 @@ def create_pets(self) -> operations.CreatePetsResponse: url = base_url + '/pets' headers = {} headers['Accept'] = 'application/json' - headers['user-agent'] = f'speakeasy-sdk/{self.sdk_configuration.language} {self.sdk_configuration.sdk_version} {self.sdk_configuration.gen_version} {self.sdk_configuration.openapi_doc_version}' + headers['user-agent'] = self.sdk_configuration.user_agent client = self.sdk_configuration.client @@ -50,7 +50,7 @@ def list_pets(self, request: operations.ListPetsRequest) -> operations.ListPetsR headers = {} query_params = utils.get_query_params(operations.ListPetsRequest, request) headers['Accept'] = 'application/json' - headers['user-agent'] = f'speakeasy-sdk/{self.sdk_configuration.language} {self.sdk_configuration.sdk_version} {self.sdk_configuration.gen_version} {self.sdk_configuration.openapi_doc_version}' + headers['user-agent'] = self.sdk_configuration.user_agent client = self.sdk_configuration.client @@ -86,7 +86,7 @@ def show_pet_by_id(self, request: operations.ShowPetByIDRequest) -> operations.S url = utils.generate_url(operations.ShowPetByIDRequest, base_url, '/pets/{petId}', request) headers = {} headers['Accept'] = 'application/json' - headers['user-agent'] = f'speakeasy-sdk/{self.sdk_configuration.language} {self.sdk_configuration.sdk_version} {self.sdk_configuration.gen_version} {self.sdk_configuration.openapi_doc_version}' + headers['user-agent'] = self.sdk_configuration.user_agent client = self.sdk_configuration.client diff --git a/src/test/sdkconfiguration.py b/src/test/sdkconfiguration.py index 26b1d7a..c491be5 100755 --- a/src/test/sdkconfiguration.py +++ b/src/test/sdkconfiguration.py @@ -19,8 +19,9 @@ class SDKConfiguration: server_idx: int = 0 language: str = 'python' openapi_doc_version: str = '1.0.0' - sdk_version: str = '0.5.1' - gen_version: str = '2.131.1' + sdk_version: str = '0.6.0' + gen_version: str = '2.139.1' + user_agent: str = 'speakeasy-sdk/python 0.6.0 2.139.1 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 b0aeb54..4388f3b 100755 --- a/src/test/utils/utils.py +++ b/src/test/utils/utils.py @@ -1,9 +1,9 @@ """Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT.""" -import sys import base64 import json import re +import sys from dataclasses import Field, dataclass, fields, is_dataclass, make_dataclass from datetime import date, datetime from decimal import Decimal @@ -393,17 +393,22 @@ def _get_delimited_query_params(metadata: dict, field_name: str, obj: any, delim } -def serialize_request_body(request: dataclass, request_field_name: str, serialization_method: str) -> Tuple[ +def serialize_request_body(request: dataclass, request_field_name: str, nullable: bool, optional: bool, serialization_method: str, encoder=None) -> Tuple[ str, any, any]: if request is None: - return None, None, 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], - request) + request, encoder) request_val = getattr(request, request_field_name) + if request_val is None: + if not nullable and optional: + return None, None, None + request_fields: Tuple[Field, ...] = fields(request) request_metadata = None @@ -419,9 +424,9 @@ def serialize_request_body(request: dataclass, request_field_name: str, serializ request_val) -def serialize_content_type(field_name: str, media_type: str, request: dataclass) -> Tuple[str, any, list[list[any]]]: +def serialize_content_type(field_name: str, 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), None + return media_type, marshal_json(request, 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: @@ -678,7 +683,7 @@ def _serialize_header(explode: bool, obj: any) -> str: return '' -def unmarshal_json(data, typ): +def unmarshal_json(data, typ, decoder=None): unmarshal = make_dataclass('Unmarshal', [('res', typ)], bases=(DataClassJsonMixin,)) json_dict = json.loads(data) @@ -687,15 +692,19 @@ def unmarshal_json(data, typ): except AttributeError as attr_err: raise AttributeError( f'unable to unmarshal {data} as {typ}') from attr_err - return out.res + + return out.res if decoder is None else decoder(out.res) -def marshal_json(val): +def marshal_json(val, encoder=None): marshal = make_dataclass('Marshal', [('res', type(val))], bases=(DataClassJsonMixin,)) marshaller = marshal(res=val) json_dict = marshaller.to_dict() - return json.dumps(json_dict["res"]) + + val = json_dict["res"] if encoder is None else encoder(json_dict["res"]) + + return json.dumps(val) def match_content_type(content_type: str, pattern: str) -> boolean: @@ -769,6 +778,56 @@ def decimaldecoder(val): return Decimal(str(val)) +def map_encoder(optional: bool, value_encoder: Callable): + def map_encode(val: dict): + if optional and val is None: + return None + + encoded = {} + for key, value in val.items(): + encoded[key] = value_encoder(value) + + return encoded + + return map_encode + + +def map_decoder(value_decoder: Callable): + def map_decode(val: dict): + decoded = {} + for key, value in val.items(): + decoded[key] = value_decoder(value) + + return decoded + + return map_decode + + +def list_encoder(optional: bool, value_encoder: Callable): + def list_encode(val: list): + if optional and val is None: + return None + + encoded = [] + for value in val: + encoded.append(value_encoder(value)) + + return encoded + + return list_encode + + +def list_decoder(value_decoder: Callable): + def list_decode(val: list): + decoded = [] + for value in val: + decoded.append(value_decoder(value)) + + return decoded + + return list_decode + + def get_field_name(name): def override(_, _field_name=name): return _field_name