Skip to content
This repository was archived by the owner on Dec 25, 2024. It is now read-only.

Feature: overload endpoint #7

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
Original file line number Diff line number Diff line change
Expand Up @@ -386,8 +386,20 @@ _all_accept_content_types = (

class BaseApi(api_client.Api):

@typing.overload
def _{{operationId}}_oapg(
{{> endpoint_args selfType="api_client.Api" }}
{{> endpoint_args isOverload=true skipDeserialization="False"}}

@typing.overload
def _{{operationId}}_oapg(
{{> endpoint_args isOverload=true skipDeserialization="True"}}

@typing.overload
def _{{operationId}}_oapg(
{{> endpoint_args isOverload=true skipDeserialization="null"}}

def _{{operationId}}_oapg(
{{> endpoint_args isOverload=false skipDeserialization="null"}}
"""
{{#if summary}}
{{summary}}
Expand Down Expand Up @@ -533,8 +545,20 @@ class BaseApi(api_client.Api):
class {{operationIdCamelCase}}(BaseApi):
# this class is used by api classes that refer to endpoints with operationId fn names

@typing.overload
def {{operationId}}(
{{> endpoint_args isOverload=true skipDeserialization="False"}}

@typing.overload
def {{operationId}}(
{{> endpoint_args isOverload=true skipDeserialization="True"}}

@typing.overload
def {{operationId}}(
{{> endpoint_args isOverload=true skipDeserialization="null"}}

def {{operationId}}(
{{> endpoint_args selfType="BaseApi" }}
{{> endpoint_args isOverload=false skipDeserialization="null"}}
return self._{{operationId}}_oapg(
{{> endpoint_args_passed }}
)
Expand All @@ -543,8 +567,20 @@ class {{operationIdCamelCase}}(BaseApi):
class ApiFor{{httpMethod}}(BaseApi):
# this class is used by api classes that refer to endpoints by path and http method names

@typing.overload
def {{httpMethod}}(
{{> endpoint_args isOverload=true skipDeserialization="False"}}

@typing.overload
def {{httpMethod}}(
{{> endpoint_args isOverload=true skipDeserialization="True"}}

@typing.overload
def {{httpMethod}}(
{{> endpoint_args isOverload=true skipDeserialization="null"}}

def {{httpMethod}}(
{{> endpoint_args selfType="BaseApi" }}
{{> endpoint_args isOverload=false skipDeserialization="null"}}
return self._{{operationId}}_oapg(
{{> endpoint_args_passed }}
)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
self: {{selfType}},
self,
{{#if bodyParam}}
{{#with bodyParam}}
body: typing.Union[{{#each content}}{{#with this.schema}}{{baseName}}, {{> model_templates/schema_python_types }}{{/with}}{{/each}}{{#unless required}}schemas.Unset] = schemas.unset{{else}}]{{/unless}},
{{/with}}
{{#with bodyParam}}
body: typing.Union[{{#each content}}{{#with this.schema}}{{baseName}},{{> model_templates/schema_python_types }}{{/with}}{{/each}}{{#unless required}}schemas.Unset] = schemas.unset{{else}}]{{/unless}},
{{/with}}
{{/if}}
{{#if queryParams}}
query_params: RequestQueryParams = frozendict.frozendict(),
Expand All @@ -17,11 +17,11 @@
cookie_params: RequestCookieParams = frozendict.frozendict(),
{{/if}}
{{#with bodyParam}}
{{#each content}}
{{#if @first}}
{{#each content}}
{{#if @first}}
content_type: str = '{{{@key}}}',
{{/if}}
{{/each}}
{{/if}}
{{/each}}
{{/with}}
{{#if produces}}
accept_content_types: typing.Tuple[str] = _all_accept_content_types,
Expand All @@ -31,16 +31,55 @@
{{/if}}
stream: bool = False,
timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None,
{{#if isOverload}}
{{#eq skipDeserialization "True"}}
skip_deserialization: typing_extensions.Literal[True] = True,
{{/eq}}
{{#eq skipDeserialization "False"}}
skip_deserialization: typing_extensions.Literal[False] = False,
{{/eq}}
{{#eq skipDeserialization "null"}}
skip_deserialization: bool = False,
{{/eq}}
{{else}}
skip_deserialization: bool = False,
{{/if}}
{{#eq skipDeserialization "True"}}
) -> api_client.ApiResponseWithoutDeserialization:
{{/eq}}
{{#eq skipDeserialization "False"}}
) -> typing.Union[{{#each responses}}{{#if isDefault}}ApiResponseForDefault,{{else}}{{#if is2xx}}ApiResponseFor{{code}},{{/if}}{{/if}}{{/each}}api_client.ApiResponse]:
{{/eq}}
{{#eq skipDeserialization "null"}}
{{#if isOverload}}
) -> typing.Union[
{{#each responses}}
{{#if isDefault}}
{{#each responses}}
{{#if isDefault}}
ApiResponseForDefault,
{{else}}
{{#if is2xx}}
{{else}}
{{#if is2xx}}
ApiResponseFor{{code}},
{{/if}}
{{/if}}
{{/each}}
api_client.ApiResponseWithoutDeserialization
{{/if}}
{{/if}}
{{/each}}
api_client.ApiResponseWithoutDeserialization,
]:
{{else}}
) -> typing.Union[
{{#each responses}}
{{#if isDefault}}
ApiResponseForDefault,
{{else}}
{{#if is2xx}}
ApiResponseFor{{code}},
{{/if}}
{{/if}}
{{/each}}
api_client.ApiResponse,
api_client.ApiResponseWithoutDeserialization,
]:
{{/if}}
{{/eq}}
{{#if isOverload}}
...
{{/if}}
Original file line number Diff line number Diff line change
Expand Up @@ -59,16 +59,53 @@ class ApiResponseFor200(api_client.ApiResponse):

class BaseApi(api_client.Api):

@typing.overload
def _post_additionalproperties_allows_a_schema_which_should_validate_request_body_oapg(
self: api_client.Api,
body: typing.Union[SchemaForRequestBodyApplicationJson, ],
self,
body: typing.Union[SchemaForRequestBodyApplicationJson,],
content_type: str = 'application/json',
stream: bool = False,
timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None,
skip_deserialization: typing_extensions.Literal[False] = False,
) -> typing.Union[ApiResponseFor200,api_client.ApiResponse]:
...

@typing.overload
def _post_additionalproperties_allows_a_schema_which_should_validate_request_body_oapg(
self,
body: typing.Union[SchemaForRequestBodyApplicationJson,],
content_type: str = 'application/json',
stream: bool = False,
timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None,
skip_deserialization: typing_extensions.Literal[True] = True,
) -> api_client.ApiResponseWithoutDeserialization:
...

@typing.overload
def _post_additionalproperties_allows_a_schema_which_should_validate_request_body_oapg(
self,
body: typing.Union[SchemaForRequestBodyApplicationJson,],
content_type: str = 'application/json',
stream: bool = False,
timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None,
skip_deserialization: bool = False,
) -> typing.Union[
ApiResponseFor200,
api_client.ApiResponseWithoutDeserialization
api_client.ApiResponseWithoutDeserialization,
]:
...

def _post_additionalproperties_allows_a_schema_which_should_validate_request_body_oapg(
self,
body: typing.Union[SchemaForRequestBodyApplicationJson,],
content_type: str = 'application/json',
stream: bool = False,
timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None,
skip_deserialization: bool = False,
) -> typing.Union[
ApiResponseFor200,
api_client.ApiResponse,
api_client.ApiResponseWithoutDeserialization,
]:
"""
:param skip_deserialization: If true then api_response.response will be set but
Expand Down Expand Up @@ -119,16 +156,53 @@ class instances
class PostAdditionalpropertiesAllowsASchemaWhichShouldValidateRequestBody(BaseApi):
# this class is used by api classes that refer to endpoints with operationId fn names

@typing.overload
def post_additionalproperties_allows_a_schema_which_should_validate_request_body(
self,
body: typing.Union[SchemaForRequestBodyApplicationJson,],
content_type: str = 'application/json',
stream: bool = False,
timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None,
skip_deserialization: typing_extensions.Literal[False] = False,
) -> typing.Union[ApiResponseFor200,api_client.ApiResponse]:
...

@typing.overload
def post_additionalproperties_allows_a_schema_which_should_validate_request_body(
self,
body: typing.Union[SchemaForRequestBodyApplicationJson,],
content_type: str = 'application/json',
stream: bool = False,
timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None,
skip_deserialization: typing_extensions.Literal[True] = True,
) -> api_client.ApiResponseWithoutDeserialization:
...

@typing.overload
def post_additionalproperties_allows_a_schema_which_should_validate_request_body(
self: BaseApi,
body: typing.Union[SchemaForRequestBodyApplicationJson, ],
self,
body: typing.Union[SchemaForRequestBodyApplicationJson,],
content_type: str = 'application/json',
stream: bool = False,
timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None,
skip_deserialization: bool = False,
) -> typing.Union[
ApiResponseFor200,
api_client.ApiResponseWithoutDeserialization
api_client.ApiResponseWithoutDeserialization,
]:
...

def post_additionalproperties_allows_a_schema_which_should_validate_request_body(
self,
body: typing.Union[SchemaForRequestBodyApplicationJson,],
content_type: str = 'application/json',
stream: bool = False,
timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None,
skip_deserialization: bool = False,
) -> typing.Union[
ApiResponseFor200,
api_client.ApiResponse,
api_client.ApiResponseWithoutDeserialization,
]:
return self._post_additionalproperties_allows_a_schema_which_should_validate_request_body_oapg(
body=body,
Expand All @@ -142,16 +216,53 @@ def post_additionalproperties_allows_a_schema_which_should_validate_request_body
class ApiForpost(BaseApi):
# this class is used by api classes that refer to endpoints by path and http method names

@typing.overload
def post(
self,
body: typing.Union[SchemaForRequestBodyApplicationJson,],
content_type: str = 'application/json',
stream: bool = False,
timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None,
skip_deserialization: typing_extensions.Literal[False] = False,
) -> typing.Union[ApiResponseFor200,api_client.ApiResponse]:
...

@typing.overload
def post(
self,
body: typing.Union[SchemaForRequestBodyApplicationJson,],
content_type: str = 'application/json',
stream: bool = False,
timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None,
skip_deserialization: typing_extensions.Literal[True] = True,
) -> api_client.ApiResponseWithoutDeserialization:
...

@typing.overload
def post(
self,
body: typing.Union[SchemaForRequestBodyApplicationJson,],
content_type: str = 'application/json',
stream: bool = False,
timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None,
skip_deserialization: bool = False,
) -> typing.Union[
ApiResponseFor200,
api_client.ApiResponseWithoutDeserialization,
]:
...

def post(
self: BaseApi,
body: typing.Union[SchemaForRequestBodyApplicationJson, ],
self,
body: typing.Union[SchemaForRequestBodyApplicationJson,],
content_type: str = 'application/json',
stream: bool = False,
timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None,
skip_deserialization: bool = False,
) -> typing.Union[
ApiResponseFor200,
api_client.ApiResponseWithoutDeserialization
api_client.ApiResponse,
api_client.ApiResponseWithoutDeserialization,
]:
return self._post_additionalproperties_allows_a_schema_which_should_validate_request_body_oapg(
body=body,
Expand Down
Loading