Skip to content

Commit 10cc7ec

Browse files
committed
fix: api templates
1 parent 9c3c201 commit 10cc7ec

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

templates/python/api.mustache

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,8 @@ class {{classname}}{{#isSyncClient}}Sync{{/isSyncClient}}:
5252
transporter = Transporter{{#isSyncClient}}Sync{{/isSyncClient}}(config)
5353
self._transporter = transporter
5454

55-
def create_with_config(config: {{#lambda.pascalcase}}{{client}}Config{{/lambda.pascalcase}}, transporter: Optional[Transporter{{#isSyncClient}}Sync{{/isSyncClient}}] = None) -> Self:
55+
@classmethod
56+
def create_with_config(cls, config: {{#lambda.pascalcase}}{{client}}Config{{/lambda.pascalcase}}, transporter: Optional[Transporter{{#isSyncClient}}Sync{{/isSyncClient}}] = None) -> {{classname}}{{#isSyncClient}}Sync{{/isSyncClient}}:
5657
"""Allows creating a client with a customized `{{#lambda.pascalcase}}{{client}}Config{{/lambda.pascalcase}}` and `Transporter{{#isSyncClient}}Sync{{/isSyncClient}}`. If `transporter` is not provided, the default one will be initialized from the given `config`.
5758

5859
Args:
@@ -72,7 +73,7 @@ class {{classname}}{{#isSyncClient}}Sync{{/isSyncClient}}:
7273
return {{classname}}{{#isSyncClient}}Sync{{/isSyncClient}}(app_id=config.app_id, api_key=config.api_key, {{#hasRegionalHost}}region=config.region, {{/hasRegionalHost}}transporter=transporter, config=config)
7374

7475
{{^isSyncClient}}
75-
async def __aenter__(self) -> None:
76+
async def __aenter__(self) -> Self:
7677
return self
7778

7879
async def __aexit__(self, exc_type, exc_value, traceback) -> None:
@@ -202,7 +203,8 @@ class {{classname}}{{#isSyncClient}}Sync{{/isSyncClient}}:
202203
:return: Returns the deserialized response in a '{{{returnType}}}' result object.
203204
{{/returnType}}
204205
"""
205-
return ({{^isSyncClient}}await {{/isSyncClient}}self.{{operationId}}_with_http_info({{#allParams}}{{paramName}},{{/allParams}}request_options)).deserialize({{{returnType}}})
206+
resp = {{^isSyncClient}}await {{/isSyncClient}}self.{{operationId}}_with_http_info({{#allParams}}{{paramName}},{{/allParams}}request_options)
207+
return resp.deserialize({{#returnType}}{{{.}}}{{/returnType}}{{^returnType}}None{{/returnType}}, resp.raw_data)
206208

207209
{{/operation}}
208210
{{/operations}}

0 commit comments

Comments
 (0)