diff --git a/modules/openapi-generator/src/main/resources/python/api_client.mustache b/modules/openapi-generator/src/main/resources/python/api_client.mustache index 3da894ae0ef..6744afb40c0 100644 --- a/modules/openapi-generator/src/main/resources/python/api_client.mustache +++ b/modules/openapi-generator/src/main/resources/python/api_client.mustache @@ -289,7 +289,7 @@ class ApiClient: def response_deserialize( self, - response_data=None, + response_data: rest.RESTResponse = None, response_types_map=None ) -> ApiResponse: """Deserializes response into an object. @@ -304,39 +304,29 @@ class ApiClient: # if not found, look for '1XX', '2XX', etc. response_type = response_types_map.get(str(response_data.status)[0] + "XX", None) - if not 200 <= response_data.status <= 299: - if response_data.status == 400: - raise BadRequestException(http_resp=response_data) - - if response_data.status == 401: - raise UnauthorizedException(http_resp=response_data) - - if response_data.status == 403: - raise ForbiddenException(http_resp=response_data) - - if response_data.status == 404: - raise NotFoundException(http_resp=response_data) - - if 500 <= response_data.status <= 599: - raise ServiceException(http_resp=response_data) - raise ApiException(http_resp=response_data) - # deserialize response data - - if response_type == "bytearray": - return_data = response_data.data - elif response_type is None: - return_data = None - elif response_type == "file": - return_data = self.__deserialize_file(response_data) - else: - match = None - content_type = response_data.getheader('content-type') - if content_type is not None: - match = re.search(r"charset=([a-zA-Z\-\d]+)[\s;]?", content_type) - encoding = match.group(1) if match else "utf-8" - response_text = response_data.data.decode(encoding) - return_data = self.deserialize(response_text, response_type) + response_text = None + return_data = None + try: + if response_type == "bytearray": + return_data = response_data.data + elif response_type == "file": + return_data = self.__deserialize_file(response_data) + elif response_type is not None: + match = None + content_type = response_data.getheader('content-type') + if content_type is not None: + match = re.search(r"charset=([a-zA-Z\-\d]+)[\s;]?", content_type) + encoding = match.group(1) if match else "utf-8" + response_text = response_data.data.decode(encoding) + return_data = self.deserialize(response_text, response_type) + finally: + if not 200 <= response_data.status <= 299: + raise ApiException.from_response( + http_resp=response_data, + body=response_text, + data=return_data, + ) return ApiResponse( status_code = response_data.status, diff --git a/modules/openapi-generator/src/main/resources/python/exceptions.mustache b/modules/openapi-generator/src/main/resources/python/exceptions.mustache index 4310da38537..82f9b7da080 100644 --- a/modules/openapi-generator/src/main/resources/python/exceptions.mustache +++ b/modules/openapi-generator/src/main/resources/python/exceptions.mustache @@ -1,6 +1,9 @@ # coding: utf-8 {{>partial_header}} +from typing import Any, Optional + +from typing_extensions import Self class OpenApiException(Exception): """The base exception class for all OpenAPIExceptions""" @@ -91,17 +94,56 @@ class ApiKeyError(OpenApiException, KeyError): class ApiException(OpenApiException): - def __init__(self, status=None, reason=None, http_resp=None) -> None: + def __init__( + self, + status=None, + reason=None, + http_resp=None, + *, + body: Optional[str] = None, + data: Optional[Any] = None, + ) -> None: + self.status = status + self.reason = reason + self.body = body + self.data = data + self.headers = None + if http_resp: - self.status = http_resp.status - self.reason = http_resp.reason - self.body = http_resp.data.decode('utf-8') + if self.status is None: + self.status = http_resp.status + if self.reason is None: + self.reason = http_resp.reason + if self.body is None: + try: + self.body = http_resp.data.decode('utf-8') + except Exception: + pass self.headers = http_resp.getheaders() - else: - self.status = status - self.reason = reason - self.body = None - self.headers = None + + @classmethod + def from_response( + cls, + *, + http_resp, + body: Optional[str], + data: Optional[Any], + ) -> Self: + if http_resp.status == 400: + raise BadRequestException(http_resp=http_resp, body=body, data=data) + + if http_resp.status == 401: + raise UnauthorizedException(http_resp=http_resp, body=body, data=data) + + if http_resp.status == 403: + raise ForbiddenException(http_resp=http_resp, body=body, data=data) + + if http_resp.status == 404: + raise NotFoundException(http_resp=http_resp, body=body, data=data) + + if 500 <= http_resp.status <= 599: + raise ServiceException(http_resp=http_resp, body=body, data=data) + raise ApiException(http_resp=http_resp, body=body, data=data) def __str__(self): """Custom error messages for exception""" @@ -111,38 +153,30 @@ class ApiException(OpenApiException): error_message += "HTTP response headers: {0}\n".format( self.headers) - if self.body: - error_message += "HTTP response body: {0}\n".format(self.body) + if self.data or self.body: + error_message += "HTTP response body: {0}\n".format(self.data or self.body) return error_message -class BadRequestException(ApiException): - def __init__(self, status=None, reason=None, http_resp=None) -> None: - super(BadRequestException, self).__init__(status, reason, http_resp) +class BadRequestException(ApiException): + pass + class NotFoundException(ApiException): - - def __init__(self, status=None, reason=None, http_resp=None) -> None: - super(NotFoundException, self).__init__(status, reason, http_resp) + pass class UnauthorizedException(ApiException): - - def __init__(self, status=None, reason=None, http_resp=None) -> None: - super(UnauthorizedException, self).__init__(status, reason, http_resp) + pass class ForbiddenException(ApiException): - - def __init__(self, status=None, reason=None, http_resp=None) -> None: - super(ForbiddenException, self).__init__(status, reason, http_resp) + pass class ServiceException(ApiException): - - def __init__(self, status=None, reason=None, http_resp=None) -> None: - super(ServiceException, self).__init__(status, reason, http_resp) + pass def render_path(path_to_item): diff --git a/modules/openapi-generator/src/main/resources/python/partial_api.mustache b/modules/openapi-generator/src/main/resources/python/partial_api.mustache index 39f219e58b4..dd3a9a1fa12 100644 --- a/modules/openapi-generator/src/main/resources/python/partial_api.mustache +++ b/modules/openapi-generator/src/main/resources/python/partial_api.mustache @@ -44,6 +44,9 @@ ) _response_types_map: Dict[str, Optional[str]] = { - {{#returnType}}{{#responses}}{{^isWildcard}}'{{code}}': {{#dataType}}"{{.}}"{{/dataType}}{{^dataType}}None{{/dataType}}{{/isWildcard}}{{^-last}},{{/-last}} - {{/responses}}{{/returnType}} + {{#responses}} + {{^isWildcard}} + '{{code}}': {{#dataType}}"{{.}}"{{/dataType}}{{^dataType}}None{{/dataType}}, + {{/isWildcard}} + {{/responses}} } \ No newline at end of file diff --git a/modules/openapi-generator/src/test/resources/3_0/python/petstore-with-fake-endpoints-models-for-testing.yaml b/modules/openapi-generator/src/test/resources/3_0/python/petstore-with-fake-endpoints-models-for-testing.yaml index 6c6a10dc464..3b6219f79e5 100644 --- a/modules/openapi-generator/src/test/resources/3_0/python/petstore-with-fake-endpoints-models-for-testing.yaml +++ b/modules/openapi-generator/src/test/resources/3_0/python/petstore-with-fake-endpoints-models-for-testing.yaml @@ -1063,6 +1063,49 @@ paths: schema: $ref: '#/components/schemas/User' required: true + /fake/empty_and_non_empty_responses: + post: + tags: + - fake + summary: test empty and non-empty responses + description: '' + operationId: testEmptyAndNonEmptyResponses + responses: + '204': + description: Success, but no response content + '206': + description: Partial response content + content: + text/plain: + schema: + type: string + /fake/error_responses_with_model: + post: + tags: + - fake + summary: test error responses with model + operationId: testErrorResponsesWithModel + responses: + '204': + description: Success, but no response content + '400': + description: '' + content: + application/json: + schema: + type: object + properties: + reason400: + type: string + '404': + description: '' + content: + application/json: + schema: + type: object + properties: + reason404: + type: string /another-fake/dummy: patch: tags: diff --git a/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent-true/openapi_client/api/auth_api.py b/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent-true/openapi_client/api/auth_api.py index 6084a540daf..5068d7cbf62 100644 --- a/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent-true/openapi_client/api/auth_api.py +++ b/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent-true/openapi_client/api/auth_api.py @@ -93,8 +93,7 @@ class AuthApi: ) _response_types_map: Dict[str, Optional[str]] = { - '200': "str" - + '200': "str", } response_data = self.api_client.call_api( *_param, @@ -157,8 +156,7 @@ class AuthApi: ) _response_types_map: Dict[str, Optional[str]] = { - '200': "str" - + '200': "str", } response_data = self.api_client.call_api( *_param, @@ -221,8 +219,7 @@ class AuthApi: ) _response_types_map: Dict[str, Optional[str]] = { - '200': "str" - + '200': "str", } response_data = self.api_client.call_api( *_param, diff --git a/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent-true/openapi_client/api/body_api.py b/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent-true/openapi_client/api/body_api.py index e84a432c436..ce402ce6252 100644 --- a/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent-true/openapi_client/api/body_api.py +++ b/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent-true/openapi_client/api/body_api.py @@ -101,8 +101,7 @@ class BodyApi: ) _response_types_map: Dict[str, Optional[str]] = { - '200': "bytearray" - + '200': "bytearray", } response_data = self.api_client.call_api( *_param, @@ -165,8 +164,7 @@ class BodyApi: ) _response_types_map: Dict[str, Optional[str]] = { - '200': "bytearray" - + '200': "bytearray", } response_data = self.api_client.call_api( *_param, @@ -229,8 +227,7 @@ class BodyApi: ) _response_types_map: Dict[str, Optional[str]] = { - '200': "bytearray" - + '200': "bytearray", } response_data = self.api_client.call_api( *_param, @@ -351,8 +348,7 @@ class BodyApi: ) _response_types_map: Dict[str, Optional[str]] = { - '200': "str" - + '200': "str", } response_data = self.api_client.call_api( *_param, @@ -419,8 +415,7 @@ class BodyApi: ) _response_types_map: Dict[str, Optional[str]] = { - '200': "str" - + '200': "str", } response_data = self.api_client.call_api( *_param, @@ -487,8 +482,7 @@ class BodyApi: ) _response_types_map: Dict[str, Optional[str]] = { - '200': "str" - + '200': "str", } response_data = self.api_client.call_api( *_param, @@ -630,8 +624,7 @@ class BodyApi: ) _response_types_map: Dict[str, Optional[str]] = { - '200': "str" - + '200': "str", } response_data = self.api_client.call_api( *_param, @@ -698,8 +691,7 @@ class BodyApi: ) _response_types_map: Dict[str, Optional[str]] = { - '200': "str" - + '200': "str", } response_data = self.api_client.call_api( *_param, @@ -766,8 +758,7 @@ class BodyApi: ) _response_types_map: Dict[str, Optional[str]] = { - '200': "str" - + '200': "str", } response_data = self.api_client.call_api( *_param, @@ -905,8 +896,7 @@ class BodyApi: ) _response_types_map: Dict[str, Optional[str]] = { - '200': "Pet" - + '200': "Pet", } response_data = self.api_client.call_api( *_param, @@ -973,8 +963,7 @@ class BodyApi: ) _response_types_map: Dict[str, Optional[str]] = { - '200': "Pet" - + '200': "Pet", } response_data = self.api_client.call_api( *_param, @@ -1041,8 +1030,7 @@ class BodyApi: ) _response_types_map: Dict[str, Optional[str]] = { - '200': "Pet" - + '200': "Pet", } response_data = self.api_client.call_api( *_param, @@ -1179,8 +1167,7 @@ class BodyApi: ) _response_types_map: Dict[str, Optional[str]] = { - '200': "str" - + '200': "str", } response_data = self.api_client.call_api( *_param, @@ -1247,8 +1234,7 @@ class BodyApi: ) _response_types_map: Dict[str, Optional[str]] = { - '200': "str" - + '200': "str", } response_data = self.api_client.call_api( *_param, @@ -1315,8 +1301,7 @@ class BodyApi: ) _response_types_map: Dict[str, Optional[str]] = { - '200': "str" - + '200': "str", } response_data = self.api_client.call_api( *_param, @@ -1453,8 +1438,7 @@ class BodyApi: ) _response_types_map: Dict[str, Optional[str]] = { - '200': "Pet" - + '200': "Pet", } response_data = self.api_client.call_api( *_param, @@ -1521,8 +1505,7 @@ class BodyApi: ) _response_types_map: Dict[str, Optional[str]] = { - '200': "Pet" - + '200': "Pet", } response_data = self.api_client.call_api( *_param, @@ -1589,8 +1572,7 @@ class BodyApi: ) _response_types_map: Dict[str, Optional[str]] = { - '200': "Pet" - + '200': "Pet", } response_data = self.api_client.call_api( *_param, @@ -1727,8 +1709,7 @@ class BodyApi: ) _response_types_map: Dict[str, Optional[str]] = { - '200': "str" - + '200': "str", } response_data = self.api_client.call_api( *_param, @@ -1795,8 +1776,7 @@ class BodyApi: ) _response_types_map: Dict[str, Optional[str]] = { - '200': "str" - + '200': "str", } response_data = self.api_client.call_api( *_param, @@ -1863,8 +1843,7 @@ class BodyApi: ) _response_types_map: Dict[str, Optional[str]] = { - '200': "str" - + '200': "str", } response_data = self.api_client.call_api( *_param, @@ -2001,8 +1980,7 @@ class BodyApi: ) _response_types_map: Dict[str, Optional[str]] = { - '200': "str" - + '200': "str", } response_data = self.api_client.call_api( *_param, @@ -2069,8 +2047,7 @@ class BodyApi: ) _response_types_map: Dict[str, Optional[str]] = { - '200': "str" - + '200': "str", } response_data = self.api_client.call_api( *_param, @@ -2137,8 +2114,7 @@ class BodyApi: ) _response_types_map: Dict[str, Optional[str]] = { - '200': "str" - + '200': "str", } response_data = self.api_client.call_api( *_param, diff --git a/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent-true/openapi_client/api/form_api.py b/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent-true/openapi_client/api/form_api.py index 4dcde5c6903..21d287cc789 100644 --- a/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent-true/openapi_client/api/form_api.py +++ b/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent-true/openapi_client/api/form_api.py @@ -109,8 +109,7 @@ class FormApi: ) _response_types_map: Dict[str, Optional[str]] = { - '200': "str" - + '200': "str", } response_data = self.api_client.call_api( *_param, @@ -185,8 +184,7 @@ class FormApi: ) _response_types_map: Dict[str, Optional[str]] = { - '200': "str" - + '200': "str", } response_data = self.api_client.call_api( *_param, @@ -261,8 +259,7 @@ class FormApi: ) _response_types_map: Dict[str, Optional[str]] = { - '200': "str" - + '200': "str", } response_data = self.api_client.call_api( *_param, @@ -425,8 +422,7 @@ class FormApi: ) _response_types_map: Dict[str, Optional[str]] = { - '200': "str" - + '200': "str", } response_data = self.api_client.call_api( *_param, @@ -513,8 +509,7 @@ class FormApi: ) _response_types_map: Dict[str, Optional[str]] = { - '200': "str" - + '200': "str", } response_data = self.api_client.call_api( *_param, @@ -601,8 +596,7 @@ class FormApi: ) _response_types_map: Dict[str, Optional[str]] = { - '200': "str" - + '200': "str", } response_data = self.api_client.call_api( *_param, diff --git a/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent-true/openapi_client/api/header_api.py b/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent-true/openapi_client/api/header_api.py index d08d722ee89..95a123d998e 100644 --- a/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent-true/openapi_client/api/header_api.py +++ b/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent-true/openapi_client/api/header_api.py @@ -118,8 +118,7 @@ class HeaderApi: ) _response_types_map: Dict[str, Optional[str]] = { - '200': "str" - + '200': "str", } response_data = self.api_client.call_api( *_param, @@ -202,8 +201,7 @@ class HeaderApi: ) _response_types_map: Dict[str, Optional[str]] = { - '200': "str" - + '200': "str", } response_data = self.api_client.call_api( *_param, @@ -286,8 +284,7 @@ class HeaderApi: ) _response_types_map: Dict[str, Optional[str]] = { - '200': "str" - + '200': "str", } response_data = self.api_client.call_api( *_param, diff --git a/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent-true/openapi_client/api/path_api.py b/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent-true/openapi_client/api/path_api.py index 0be317d5827..9ff10b52d39 100644 --- a/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent-true/openapi_client/api/path_api.py +++ b/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent-true/openapi_client/api/path_api.py @@ -112,8 +112,7 @@ class PathApi: ) _response_types_map: Dict[str, Optional[str]] = { - '200': "str" - + '200': "str", } response_data = self.api_client.call_api( *_param, @@ -192,8 +191,7 @@ class PathApi: ) _response_types_map: Dict[str, Optional[str]] = { - '200': "str" - + '200': "str", } response_data = self.api_client.call_api( *_param, @@ -272,8 +270,7 @@ class PathApi: ) _response_types_map: Dict[str, Optional[str]] = { - '200': "str" - + '200': "str", } response_data = self.api_client.call_api( *_param, diff --git a/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent-true/openapi_client/api/query_api.py b/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent-true/openapi_client/api/query_api.py index c910defeb42..dd0603a1fa3 100644 --- a/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent-true/openapi_client/api/query_api.py +++ b/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent-true/openapi_client/api/query_api.py @@ -110,8 +110,7 @@ class QueryApi: ) _response_types_map: Dict[str, Optional[str]] = { - '200': "str" - + '200': "str", } response_data = self.api_client.call_api( *_param, @@ -182,8 +181,7 @@ class QueryApi: ) _response_types_map: Dict[str, Optional[str]] = { - '200': "str" - + '200': "str", } response_data = self.api_client.call_api( *_param, @@ -254,8 +252,7 @@ class QueryApi: ) _response_types_map: Dict[str, Optional[str]] = { - '200': "str" - + '200': "str", } response_data = self.api_client.call_api( *_param, @@ -394,8 +391,7 @@ class QueryApi: ) _response_types_map: Dict[str, Optional[str]] = { - '200': "str" - + '200': "str", } response_data = self.api_client.call_api( *_param, @@ -470,8 +466,7 @@ class QueryApi: ) _response_types_map: Dict[str, Optional[str]] = { - '200': "str" - + '200': "str", } response_data = self.api_client.call_api( *_param, @@ -546,8 +541,7 @@ class QueryApi: ) _response_types_map: Dict[str, Optional[str]] = { - '200': "str" - + '200': "str", } response_data = self.api_client.call_api( *_param, @@ -709,8 +703,7 @@ class QueryApi: ) _response_types_map: Dict[str, Optional[str]] = { - '200': "str" - + '200': "str", } response_data = self.api_client.call_api( *_param, @@ -785,8 +778,7 @@ class QueryApi: ) _response_types_map: Dict[str, Optional[str]] = { - '200': "str" - + '200': "str", } response_data = self.api_client.call_api( *_param, @@ -861,8 +853,7 @@ class QueryApi: ) _response_types_map: Dict[str, Optional[str]] = { - '200': "str" - + '200': "str", } response_data = self.api_client.call_api( *_param, @@ -998,8 +989,7 @@ class QueryApi: ) _response_types_map: Dict[str, Optional[str]] = { - '200': "str" - + '200': "str", } response_data = self.api_client.call_api( *_param, @@ -1066,8 +1056,7 @@ class QueryApi: ) _response_types_map: Dict[str, Optional[str]] = { - '200': "str" - + '200': "str", } response_data = self.api_client.call_api( *_param, @@ -1134,8 +1123,7 @@ class QueryApi: ) _response_types_map: Dict[str, Optional[str]] = { - '200': "str" - + '200': "str", } response_data = self.api_client.call_api( *_param, @@ -1261,8 +1249,7 @@ class QueryApi: ) _response_types_map: Dict[str, Optional[str]] = { - '200': "str" - + '200': "str", } response_data = self.api_client.call_api( *_param, @@ -1329,8 +1316,7 @@ class QueryApi: ) _response_types_map: Dict[str, Optional[str]] = { - '200': "str" - + '200': "str", } response_data = self.api_client.call_api( *_param, @@ -1397,8 +1383,7 @@ class QueryApi: ) _response_types_map: Dict[str, Optional[str]] = { - '200': "str" - + '200': "str", } response_data = self.api_client.call_api( *_param, @@ -1524,8 +1509,7 @@ class QueryApi: ) _response_types_map: Dict[str, Optional[str]] = { - '200': "str" - + '200': "str", } response_data = self.api_client.call_api( *_param, @@ -1592,8 +1576,7 @@ class QueryApi: ) _response_types_map: Dict[str, Optional[str]] = { - '200': "str" - + '200': "str", } response_data = self.api_client.call_api( *_param, @@ -1660,8 +1643,7 @@ class QueryApi: ) _response_types_map: Dict[str, Optional[str]] = { - '200': "str" - + '200': "str", } response_data = self.api_client.call_api( *_param, @@ -1787,8 +1769,7 @@ class QueryApi: ) _response_types_map: Dict[str, Optional[str]] = { - '200': "str" - + '200': "str", } response_data = self.api_client.call_api( *_param, @@ -1855,8 +1836,7 @@ class QueryApi: ) _response_types_map: Dict[str, Optional[str]] = { - '200': "str" - + '200': "str", } response_data = self.api_client.call_api( *_param, @@ -1923,8 +1903,7 @@ class QueryApi: ) _response_types_map: Dict[str, Optional[str]] = { - '200': "str" - + '200': "str", } response_data = self.api_client.call_api( *_param, @@ -2050,8 +2029,7 @@ class QueryApi: ) _response_types_map: Dict[str, Optional[str]] = { - '200': "str" - + '200': "str", } response_data = self.api_client.call_api( *_param, @@ -2118,8 +2096,7 @@ class QueryApi: ) _response_types_map: Dict[str, Optional[str]] = { - '200': "str" - + '200': "str", } response_data = self.api_client.call_api( *_param, @@ -2186,8 +2163,7 @@ class QueryApi: ) _response_types_map: Dict[str, Optional[str]] = { - '200': "str" - + '200': "str", } response_data = self.api_client.call_api( *_param, diff --git a/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent-true/openapi_client/api_client.py b/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent-true/openapi_client/api_client.py index cee9963034e..bdf8ec05b2d 100644 --- a/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent-true/openapi_client/api_client.py +++ b/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent-true/openapi_client/api_client.py @@ -282,7 +282,7 @@ class ApiClient: def response_deserialize( self, - response_data=None, + response_data: rest.RESTResponse = None, response_types_map=None ) -> ApiResponse: """Deserializes response into an object. @@ -297,39 +297,29 @@ class ApiClient: # if not found, look for '1XX', '2XX', etc. response_type = response_types_map.get(str(response_data.status)[0] + "XX", None) - if not 200 <= response_data.status <= 299: - if response_data.status == 400: - raise BadRequestException(http_resp=response_data) - - if response_data.status == 401: - raise UnauthorizedException(http_resp=response_data) - - if response_data.status == 403: - raise ForbiddenException(http_resp=response_data) - - if response_data.status == 404: - raise NotFoundException(http_resp=response_data) - - if 500 <= response_data.status <= 599: - raise ServiceException(http_resp=response_data) - raise ApiException(http_resp=response_data) - # deserialize response data - - if response_type == "bytearray": - return_data = response_data.data - elif response_type is None: - return_data = None - elif response_type == "file": - return_data = self.__deserialize_file(response_data) - else: - match = None - content_type = response_data.getheader('content-type') - if content_type is not None: - match = re.search(r"charset=([a-zA-Z\-\d]+)[\s;]?", content_type) - encoding = match.group(1) if match else "utf-8" - response_text = response_data.data.decode(encoding) - return_data = self.deserialize(response_text, response_type) + response_text = None + return_data = None + try: + if response_type == "bytearray": + return_data = response_data.data + elif response_type == "file": + return_data = self.__deserialize_file(response_data) + elif response_type is not None: + match = None + content_type = response_data.getheader('content-type') + if content_type is not None: + match = re.search(r"charset=([a-zA-Z\-\d]+)[\s;]?", content_type) + encoding = match.group(1) if match else "utf-8" + response_text = response_data.data.decode(encoding) + return_data = self.deserialize(response_text, response_type) + finally: + if not 200 <= response_data.status <= 299: + raise ApiException.from_response( + http_resp=response_data, + body=response_text, + data=return_data, + ) return ApiResponse( status_code = response_data.status, diff --git a/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent-true/openapi_client/exceptions.py b/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent-true/openapi_client/exceptions.py index d68e30b72de..4ddc870f3e0 100644 --- a/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent-true/openapi_client/exceptions.py +++ b/samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent-true/openapi_client/exceptions.py @@ -12,6 +12,9 @@ Do not edit the class manually. """ # noqa: E501 +from typing import Any, Optional + +from typing_extensions import Self class OpenApiException(Exception): """The base exception class for all OpenAPIExceptions""" @@ -102,17 +105,56 @@ class ApiKeyError(OpenApiException, KeyError): class ApiException(OpenApiException): - def __init__(self, status=None, reason=None, http_resp=None) -> None: + def __init__( + self, + status=None, + reason=None, + http_resp=None, + *, + body: Optional[str] = None, + data: Optional[Any] = None, + ) -> None: + self.status = status + self.reason = reason + self.body = body + self.data = data + self.headers = None + if http_resp: - self.status = http_resp.status - self.reason = http_resp.reason - self.body = http_resp.data.decode('utf-8') + if self.status is None: + self.status = http_resp.status + if self.reason is None: + self.reason = http_resp.reason + if self.body is None: + try: + self.body = http_resp.data.decode('utf-8') + except Exception: + pass self.headers = http_resp.getheaders() - else: - self.status = status - self.reason = reason - self.body = None - self.headers = None + + @classmethod + def from_response( + cls, + *, + http_resp, + body: Optional[str], + data: Optional[Any], + ) -> Self: + if http_resp.status == 400: + raise BadRequestException(http_resp=http_resp, body=body, data=data) + + if http_resp.status == 401: + raise UnauthorizedException(http_resp=http_resp, body=body, data=data) + + if http_resp.status == 403: + raise ForbiddenException(http_resp=http_resp, body=body, data=data) + + if http_resp.status == 404: + raise NotFoundException(http_resp=http_resp, body=body, data=data) + + if 500 <= http_resp.status <= 599: + raise ServiceException(http_resp=http_resp, body=body, data=data) + raise ApiException(http_resp=http_resp, body=body, data=data) def __str__(self): """Custom error messages for exception""" @@ -122,38 +164,30 @@ class ApiException(OpenApiException): error_message += "HTTP response headers: {0}\n".format( self.headers) - if self.body: - error_message += "HTTP response body: {0}\n".format(self.body) + if self.data or self.body: + error_message += "HTTP response body: {0}\n".format(self.data or self.body) return error_message -class BadRequestException(ApiException): - def __init__(self, status=None, reason=None, http_resp=None) -> None: - super(BadRequestException, self).__init__(status, reason, http_resp) +class BadRequestException(ApiException): + pass + class NotFoundException(ApiException): - - def __init__(self, status=None, reason=None, http_resp=None) -> None: - super(NotFoundException, self).__init__(status, reason, http_resp) + pass class UnauthorizedException(ApiException): - - def __init__(self, status=None, reason=None, http_resp=None) -> None: - super(UnauthorizedException, self).__init__(status, reason, http_resp) + pass class ForbiddenException(ApiException): - - def __init__(self, status=None, reason=None, http_resp=None) -> None: - super(ForbiddenException, self).__init__(status, reason, http_resp) + pass class ServiceException(ApiException): - - def __init__(self, status=None, reason=None, http_resp=None) -> None: - super(ServiceException, self).__init__(status, reason, http_resp) + pass def render_path(path_to_item): diff --git a/samples/client/echo_api/python/openapi_client/api/auth_api.py b/samples/client/echo_api/python/openapi_client/api/auth_api.py index 6084a540daf..5068d7cbf62 100644 --- a/samples/client/echo_api/python/openapi_client/api/auth_api.py +++ b/samples/client/echo_api/python/openapi_client/api/auth_api.py @@ -93,8 +93,7 @@ class AuthApi: ) _response_types_map: Dict[str, Optional[str]] = { - '200': "str" - + '200': "str", } response_data = self.api_client.call_api( *_param, @@ -157,8 +156,7 @@ class AuthApi: ) _response_types_map: Dict[str, Optional[str]] = { - '200': "str" - + '200': "str", } response_data = self.api_client.call_api( *_param, @@ -221,8 +219,7 @@ class AuthApi: ) _response_types_map: Dict[str, Optional[str]] = { - '200': "str" - + '200': "str", } response_data = self.api_client.call_api( *_param, diff --git a/samples/client/echo_api/python/openapi_client/api/body_api.py b/samples/client/echo_api/python/openapi_client/api/body_api.py index e84a432c436..ce402ce6252 100644 --- a/samples/client/echo_api/python/openapi_client/api/body_api.py +++ b/samples/client/echo_api/python/openapi_client/api/body_api.py @@ -101,8 +101,7 @@ class BodyApi: ) _response_types_map: Dict[str, Optional[str]] = { - '200': "bytearray" - + '200': "bytearray", } response_data = self.api_client.call_api( *_param, @@ -165,8 +164,7 @@ class BodyApi: ) _response_types_map: Dict[str, Optional[str]] = { - '200': "bytearray" - + '200': "bytearray", } response_data = self.api_client.call_api( *_param, @@ -229,8 +227,7 @@ class BodyApi: ) _response_types_map: Dict[str, Optional[str]] = { - '200': "bytearray" - + '200': "bytearray", } response_data = self.api_client.call_api( *_param, @@ -351,8 +348,7 @@ class BodyApi: ) _response_types_map: Dict[str, Optional[str]] = { - '200': "str" - + '200': "str", } response_data = self.api_client.call_api( *_param, @@ -419,8 +415,7 @@ class BodyApi: ) _response_types_map: Dict[str, Optional[str]] = { - '200': "str" - + '200': "str", } response_data = self.api_client.call_api( *_param, @@ -487,8 +482,7 @@ class BodyApi: ) _response_types_map: Dict[str, Optional[str]] = { - '200': "str" - + '200': "str", } response_data = self.api_client.call_api( *_param, @@ -630,8 +624,7 @@ class BodyApi: ) _response_types_map: Dict[str, Optional[str]] = { - '200': "str" - + '200': "str", } response_data = self.api_client.call_api( *_param, @@ -698,8 +691,7 @@ class BodyApi: ) _response_types_map: Dict[str, Optional[str]] = { - '200': "str" - + '200': "str", } response_data = self.api_client.call_api( *_param, @@ -766,8 +758,7 @@ class BodyApi: ) _response_types_map: Dict[str, Optional[str]] = { - '200': "str" - + '200': "str", } response_data = self.api_client.call_api( *_param, @@ -905,8 +896,7 @@ class BodyApi: ) _response_types_map: Dict[str, Optional[str]] = { - '200': "Pet" - + '200': "Pet", } response_data = self.api_client.call_api( *_param, @@ -973,8 +963,7 @@ class BodyApi: ) _response_types_map: Dict[str, Optional[str]] = { - '200': "Pet" - + '200': "Pet", } response_data = self.api_client.call_api( *_param, @@ -1041,8 +1030,7 @@ class BodyApi: ) _response_types_map: Dict[str, Optional[str]] = { - '200': "Pet" - + '200': "Pet", } response_data = self.api_client.call_api( *_param, @@ -1179,8 +1167,7 @@ class BodyApi: ) _response_types_map: Dict[str, Optional[str]] = { - '200': "str" - + '200': "str", } response_data = self.api_client.call_api( *_param, @@ -1247,8 +1234,7 @@ class BodyApi: ) _response_types_map: Dict[str, Optional[str]] = { - '200': "str" - + '200': "str", } response_data = self.api_client.call_api( *_param, @@ -1315,8 +1301,7 @@ class BodyApi: ) _response_types_map: Dict[str, Optional[str]] = { - '200': "str" - + '200': "str", } response_data = self.api_client.call_api( *_param, @@ -1453,8 +1438,7 @@ class BodyApi: ) _response_types_map: Dict[str, Optional[str]] = { - '200': "Pet" - + '200': "Pet", } response_data = self.api_client.call_api( *_param, @@ -1521,8 +1505,7 @@ class BodyApi: ) _response_types_map: Dict[str, Optional[str]] = { - '200': "Pet" - + '200': "Pet", } response_data = self.api_client.call_api( *_param, @@ -1589,8 +1572,7 @@ class BodyApi: ) _response_types_map: Dict[str, Optional[str]] = { - '200': "Pet" - + '200': "Pet", } response_data = self.api_client.call_api( *_param, @@ -1727,8 +1709,7 @@ class BodyApi: ) _response_types_map: Dict[str, Optional[str]] = { - '200': "str" - + '200': "str", } response_data = self.api_client.call_api( *_param, @@ -1795,8 +1776,7 @@ class BodyApi: ) _response_types_map: Dict[str, Optional[str]] = { - '200': "str" - + '200': "str", } response_data = self.api_client.call_api( *_param, @@ -1863,8 +1843,7 @@ class BodyApi: ) _response_types_map: Dict[str, Optional[str]] = { - '200': "str" - + '200': "str", } response_data = self.api_client.call_api( *_param, @@ -2001,8 +1980,7 @@ class BodyApi: ) _response_types_map: Dict[str, Optional[str]] = { - '200': "str" - + '200': "str", } response_data = self.api_client.call_api( *_param, @@ -2069,8 +2047,7 @@ class BodyApi: ) _response_types_map: Dict[str, Optional[str]] = { - '200': "str" - + '200': "str", } response_data = self.api_client.call_api( *_param, @@ -2137,8 +2114,7 @@ class BodyApi: ) _response_types_map: Dict[str, Optional[str]] = { - '200': "str" - + '200': "str", } response_data = self.api_client.call_api( *_param, diff --git a/samples/client/echo_api/python/openapi_client/api/form_api.py b/samples/client/echo_api/python/openapi_client/api/form_api.py index 4dcde5c6903..21d287cc789 100644 --- a/samples/client/echo_api/python/openapi_client/api/form_api.py +++ b/samples/client/echo_api/python/openapi_client/api/form_api.py @@ -109,8 +109,7 @@ class FormApi: ) _response_types_map: Dict[str, Optional[str]] = { - '200': "str" - + '200': "str", } response_data = self.api_client.call_api( *_param, @@ -185,8 +184,7 @@ class FormApi: ) _response_types_map: Dict[str, Optional[str]] = { - '200': "str" - + '200': "str", } response_data = self.api_client.call_api( *_param, @@ -261,8 +259,7 @@ class FormApi: ) _response_types_map: Dict[str, Optional[str]] = { - '200': "str" - + '200': "str", } response_data = self.api_client.call_api( *_param, @@ -425,8 +422,7 @@ class FormApi: ) _response_types_map: Dict[str, Optional[str]] = { - '200': "str" - + '200': "str", } response_data = self.api_client.call_api( *_param, @@ -513,8 +509,7 @@ class FormApi: ) _response_types_map: Dict[str, Optional[str]] = { - '200': "str" - + '200': "str", } response_data = self.api_client.call_api( *_param, @@ -601,8 +596,7 @@ class FormApi: ) _response_types_map: Dict[str, Optional[str]] = { - '200': "str" - + '200': "str", } response_data = self.api_client.call_api( *_param, diff --git a/samples/client/echo_api/python/openapi_client/api/header_api.py b/samples/client/echo_api/python/openapi_client/api/header_api.py index d08d722ee89..95a123d998e 100644 --- a/samples/client/echo_api/python/openapi_client/api/header_api.py +++ b/samples/client/echo_api/python/openapi_client/api/header_api.py @@ -118,8 +118,7 @@ class HeaderApi: ) _response_types_map: Dict[str, Optional[str]] = { - '200': "str" - + '200': "str", } response_data = self.api_client.call_api( *_param, @@ -202,8 +201,7 @@ class HeaderApi: ) _response_types_map: Dict[str, Optional[str]] = { - '200': "str" - + '200': "str", } response_data = self.api_client.call_api( *_param, @@ -286,8 +284,7 @@ class HeaderApi: ) _response_types_map: Dict[str, Optional[str]] = { - '200': "str" - + '200': "str", } response_data = self.api_client.call_api( *_param, diff --git a/samples/client/echo_api/python/openapi_client/api/path_api.py b/samples/client/echo_api/python/openapi_client/api/path_api.py index 0be317d5827..9ff10b52d39 100644 --- a/samples/client/echo_api/python/openapi_client/api/path_api.py +++ b/samples/client/echo_api/python/openapi_client/api/path_api.py @@ -112,8 +112,7 @@ class PathApi: ) _response_types_map: Dict[str, Optional[str]] = { - '200': "str" - + '200': "str", } response_data = self.api_client.call_api( *_param, @@ -192,8 +191,7 @@ class PathApi: ) _response_types_map: Dict[str, Optional[str]] = { - '200': "str" - + '200': "str", } response_data = self.api_client.call_api( *_param, @@ -272,8 +270,7 @@ class PathApi: ) _response_types_map: Dict[str, Optional[str]] = { - '200': "str" - + '200': "str", } response_data = self.api_client.call_api( *_param, diff --git a/samples/client/echo_api/python/openapi_client/api/query_api.py b/samples/client/echo_api/python/openapi_client/api/query_api.py index c910defeb42..dd0603a1fa3 100644 --- a/samples/client/echo_api/python/openapi_client/api/query_api.py +++ b/samples/client/echo_api/python/openapi_client/api/query_api.py @@ -110,8 +110,7 @@ class QueryApi: ) _response_types_map: Dict[str, Optional[str]] = { - '200': "str" - + '200': "str", } response_data = self.api_client.call_api( *_param, @@ -182,8 +181,7 @@ class QueryApi: ) _response_types_map: Dict[str, Optional[str]] = { - '200': "str" - + '200': "str", } response_data = self.api_client.call_api( *_param, @@ -254,8 +252,7 @@ class QueryApi: ) _response_types_map: Dict[str, Optional[str]] = { - '200': "str" - + '200': "str", } response_data = self.api_client.call_api( *_param, @@ -394,8 +391,7 @@ class QueryApi: ) _response_types_map: Dict[str, Optional[str]] = { - '200': "str" - + '200': "str", } response_data = self.api_client.call_api( *_param, @@ -470,8 +466,7 @@ class QueryApi: ) _response_types_map: Dict[str, Optional[str]] = { - '200': "str" - + '200': "str", } response_data = self.api_client.call_api( *_param, @@ -546,8 +541,7 @@ class QueryApi: ) _response_types_map: Dict[str, Optional[str]] = { - '200': "str" - + '200': "str", } response_data = self.api_client.call_api( *_param, @@ -709,8 +703,7 @@ class QueryApi: ) _response_types_map: Dict[str, Optional[str]] = { - '200': "str" - + '200': "str", } response_data = self.api_client.call_api( *_param, @@ -785,8 +778,7 @@ class QueryApi: ) _response_types_map: Dict[str, Optional[str]] = { - '200': "str" - + '200': "str", } response_data = self.api_client.call_api( *_param, @@ -861,8 +853,7 @@ class QueryApi: ) _response_types_map: Dict[str, Optional[str]] = { - '200': "str" - + '200': "str", } response_data = self.api_client.call_api( *_param, @@ -998,8 +989,7 @@ class QueryApi: ) _response_types_map: Dict[str, Optional[str]] = { - '200': "str" - + '200': "str", } response_data = self.api_client.call_api( *_param, @@ -1066,8 +1056,7 @@ class QueryApi: ) _response_types_map: Dict[str, Optional[str]] = { - '200': "str" - + '200': "str", } response_data = self.api_client.call_api( *_param, @@ -1134,8 +1123,7 @@ class QueryApi: ) _response_types_map: Dict[str, Optional[str]] = { - '200': "str" - + '200': "str", } response_data = self.api_client.call_api( *_param, @@ -1261,8 +1249,7 @@ class QueryApi: ) _response_types_map: Dict[str, Optional[str]] = { - '200': "str" - + '200': "str", } response_data = self.api_client.call_api( *_param, @@ -1329,8 +1316,7 @@ class QueryApi: ) _response_types_map: Dict[str, Optional[str]] = { - '200': "str" - + '200': "str", } response_data = self.api_client.call_api( *_param, @@ -1397,8 +1383,7 @@ class QueryApi: ) _response_types_map: Dict[str, Optional[str]] = { - '200': "str" - + '200': "str", } response_data = self.api_client.call_api( *_param, @@ -1524,8 +1509,7 @@ class QueryApi: ) _response_types_map: Dict[str, Optional[str]] = { - '200': "str" - + '200': "str", } response_data = self.api_client.call_api( *_param, @@ -1592,8 +1576,7 @@ class QueryApi: ) _response_types_map: Dict[str, Optional[str]] = { - '200': "str" - + '200': "str", } response_data = self.api_client.call_api( *_param, @@ -1660,8 +1643,7 @@ class QueryApi: ) _response_types_map: Dict[str, Optional[str]] = { - '200': "str" - + '200': "str", } response_data = self.api_client.call_api( *_param, @@ -1787,8 +1769,7 @@ class QueryApi: ) _response_types_map: Dict[str, Optional[str]] = { - '200': "str" - + '200': "str", } response_data = self.api_client.call_api( *_param, @@ -1855,8 +1836,7 @@ class QueryApi: ) _response_types_map: Dict[str, Optional[str]] = { - '200': "str" - + '200': "str", } response_data = self.api_client.call_api( *_param, @@ -1923,8 +1903,7 @@ class QueryApi: ) _response_types_map: Dict[str, Optional[str]] = { - '200': "str" - + '200': "str", } response_data = self.api_client.call_api( *_param, @@ -2050,8 +2029,7 @@ class QueryApi: ) _response_types_map: Dict[str, Optional[str]] = { - '200': "str" - + '200': "str", } response_data = self.api_client.call_api( *_param, @@ -2118,8 +2096,7 @@ class QueryApi: ) _response_types_map: Dict[str, Optional[str]] = { - '200': "str" - + '200': "str", } response_data = self.api_client.call_api( *_param, @@ -2186,8 +2163,7 @@ class QueryApi: ) _response_types_map: Dict[str, Optional[str]] = { - '200': "str" - + '200': "str", } response_data = self.api_client.call_api( *_param, diff --git a/samples/client/echo_api/python/openapi_client/api_client.py b/samples/client/echo_api/python/openapi_client/api_client.py index cee9963034e..bdf8ec05b2d 100644 --- a/samples/client/echo_api/python/openapi_client/api_client.py +++ b/samples/client/echo_api/python/openapi_client/api_client.py @@ -282,7 +282,7 @@ class ApiClient: def response_deserialize( self, - response_data=None, + response_data: rest.RESTResponse = None, response_types_map=None ) -> ApiResponse: """Deserializes response into an object. @@ -297,39 +297,29 @@ class ApiClient: # if not found, look for '1XX', '2XX', etc. response_type = response_types_map.get(str(response_data.status)[0] + "XX", None) - if not 200 <= response_data.status <= 299: - if response_data.status == 400: - raise BadRequestException(http_resp=response_data) - - if response_data.status == 401: - raise UnauthorizedException(http_resp=response_data) - - if response_data.status == 403: - raise ForbiddenException(http_resp=response_data) - - if response_data.status == 404: - raise NotFoundException(http_resp=response_data) - - if 500 <= response_data.status <= 599: - raise ServiceException(http_resp=response_data) - raise ApiException(http_resp=response_data) - # deserialize response data - - if response_type == "bytearray": - return_data = response_data.data - elif response_type is None: - return_data = None - elif response_type == "file": - return_data = self.__deserialize_file(response_data) - else: - match = None - content_type = response_data.getheader('content-type') - if content_type is not None: - match = re.search(r"charset=([a-zA-Z\-\d]+)[\s;]?", content_type) - encoding = match.group(1) if match else "utf-8" - response_text = response_data.data.decode(encoding) - return_data = self.deserialize(response_text, response_type) + response_text = None + return_data = None + try: + if response_type == "bytearray": + return_data = response_data.data + elif response_type == "file": + return_data = self.__deserialize_file(response_data) + elif response_type is not None: + match = None + content_type = response_data.getheader('content-type') + if content_type is not None: + match = re.search(r"charset=([a-zA-Z\-\d]+)[\s;]?", content_type) + encoding = match.group(1) if match else "utf-8" + response_text = response_data.data.decode(encoding) + return_data = self.deserialize(response_text, response_type) + finally: + if not 200 <= response_data.status <= 299: + raise ApiException.from_response( + http_resp=response_data, + body=response_text, + data=return_data, + ) return ApiResponse( status_code = response_data.status, diff --git a/samples/client/echo_api/python/openapi_client/exceptions.py b/samples/client/echo_api/python/openapi_client/exceptions.py index d68e30b72de..4ddc870f3e0 100644 --- a/samples/client/echo_api/python/openapi_client/exceptions.py +++ b/samples/client/echo_api/python/openapi_client/exceptions.py @@ -12,6 +12,9 @@ Do not edit the class manually. """ # noqa: E501 +from typing import Any, Optional + +from typing_extensions import Self class OpenApiException(Exception): """The base exception class for all OpenAPIExceptions""" @@ -102,17 +105,56 @@ class ApiKeyError(OpenApiException, KeyError): class ApiException(OpenApiException): - def __init__(self, status=None, reason=None, http_resp=None) -> None: + def __init__( + self, + status=None, + reason=None, + http_resp=None, + *, + body: Optional[str] = None, + data: Optional[Any] = None, + ) -> None: + self.status = status + self.reason = reason + self.body = body + self.data = data + self.headers = None + if http_resp: - self.status = http_resp.status - self.reason = http_resp.reason - self.body = http_resp.data.decode('utf-8') + if self.status is None: + self.status = http_resp.status + if self.reason is None: + self.reason = http_resp.reason + if self.body is None: + try: + self.body = http_resp.data.decode('utf-8') + except Exception: + pass self.headers = http_resp.getheaders() - else: - self.status = status - self.reason = reason - self.body = None - self.headers = None + + @classmethod + def from_response( + cls, + *, + http_resp, + body: Optional[str], + data: Optional[Any], + ) -> Self: + if http_resp.status == 400: + raise BadRequestException(http_resp=http_resp, body=body, data=data) + + if http_resp.status == 401: + raise UnauthorizedException(http_resp=http_resp, body=body, data=data) + + if http_resp.status == 403: + raise ForbiddenException(http_resp=http_resp, body=body, data=data) + + if http_resp.status == 404: + raise NotFoundException(http_resp=http_resp, body=body, data=data) + + if 500 <= http_resp.status <= 599: + raise ServiceException(http_resp=http_resp, body=body, data=data) + raise ApiException(http_resp=http_resp, body=body, data=data) def __str__(self): """Custom error messages for exception""" @@ -122,38 +164,30 @@ class ApiException(OpenApiException): error_message += "HTTP response headers: {0}\n".format( self.headers) - if self.body: - error_message += "HTTP response body: {0}\n".format(self.body) + if self.data or self.body: + error_message += "HTTP response body: {0}\n".format(self.data or self.body) return error_message -class BadRequestException(ApiException): - def __init__(self, status=None, reason=None, http_resp=None) -> None: - super(BadRequestException, self).__init__(status, reason, http_resp) +class BadRequestException(ApiException): + pass + class NotFoundException(ApiException): - - def __init__(self, status=None, reason=None, http_resp=None) -> None: - super(NotFoundException, self).__init__(status, reason, http_resp) + pass class UnauthorizedException(ApiException): - - def __init__(self, status=None, reason=None, http_resp=None) -> None: - super(UnauthorizedException, self).__init__(status, reason, http_resp) + pass class ForbiddenException(ApiException): - - def __init__(self, status=None, reason=None, http_resp=None) -> None: - super(ForbiddenException, self).__init__(status, reason, http_resp) + pass class ServiceException(ApiException): - - def __init__(self, status=None, reason=None, http_resp=None) -> None: - super(ServiceException, self).__init__(status, reason, http_resp) + pass def render_path(path_to_item): diff --git a/samples/openapi3/client/petstore/python-aiohttp/.openapi-generator/FILES b/samples/openapi3/client/petstore/python-aiohttp/.openapi-generator/FILES index 00dc818606f..1ef5f596fa1 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/.openapi-generator/FILES +++ b/samples/openapi3/client/petstore/python-aiohttp/.openapi-generator/FILES @@ -84,6 +84,8 @@ docs/SpecialModelName.md docs/SpecialName.md docs/StoreApi.md docs/Tag.md +docs/TestErrorResponsesWithModel400Response.md +docs/TestErrorResponsesWithModel404Response.md docs/TestInlineFreeformAdditionalPropertiesRequest.md docs/Tiger.md docs/UnnamedDictWithAdditionalModelListProperties.md @@ -181,6 +183,8 @@ petstore_api/models/special_character_enum.py petstore_api/models/special_model_name.py petstore_api/models/special_name.py petstore_api/models/tag.py +petstore_api/models/test_error_responses_with_model400_response.py +petstore_api/models/test_error_responses_with_model404_response.py petstore_api/models/test_inline_freeform_additional_properties_request.py petstore_api/models/tiger.py petstore_api/models/unnamed_dict_with_additional_model_list_properties.py diff --git a/samples/openapi3/client/petstore/python-aiohttp/README.md b/samples/openapi3/client/petstore/python-aiohttp/README.md index 88ea04ad16e..6784ec797ec 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/README.md +++ b/samples/openapi3/client/petstore/python-aiohttp/README.md @@ -103,7 +103,9 @@ Class | Method | HTTP request | Description *FakeApi* | [**test_body_with_query_params**](docs/FakeApi.md#test_body_with_query_params) | **PUT** /fake/body-with-query-params | *FakeApi* | [**test_client_model**](docs/FakeApi.md#test_client_model) | **PATCH** /fake | To test \"client\" model *FakeApi* | [**test_date_time_query_parameter**](docs/FakeApi.md#test_date_time_query_parameter) | **PUT** /fake/date-time-query-params | +*FakeApi* | [**test_empty_and_non_empty_responses**](docs/FakeApi.md#test_empty_and_non_empty_responses) | **POST** /fake/empty_and_non_empty_responses | test empty and non-empty responses *FakeApi* | [**test_endpoint_parameters**](docs/FakeApi.md#test_endpoint_parameters) | **POST** /fake | Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 +*FakeApi* | [**test_error_responses_with_model**](docs/FakeApi.md#test_error_responses_with_model) | **POST** /fake/error_responses_with_model | test error responses with model *FakeApi* | [**test_group_parameters**](docs/FakeApi.md#test_group_parameters) | **DELETE** /fake | Fake endpoint to test group parameters (optional) *FakeApi* | [**test_inline_additional_properties**](docs/FakeApi.md#test_inline_additional_properties) | **POST** /fake/inline-additionalProperties | test inline additionalProperties *FakeApi* | [**test_inline_freeform_additional_properties**](docs/FakeApi.md#test_inline_freeform_additional_properties) | **POST** /fake/inline-freeform-additionalProperties | test inline free-form additionalProperties @@ -210,6 +212,8 @@ Class | Method | HTTP request | Description - [SpecialModelName](docs/SpecialModelName.md) - [SpecialName](docs/SpecialName.md) - [Tag](docs/Tag.md) + - [TestErrorResponsesWithModel400Response](docs/TestErrorResponsesWithModel400Response.md) + - [TestErrorResponsesWithModel404Response](docs/TestErrorResponsesWithModel404Response.md) - [TestInlineFreeformAdditionalPropertiesRequest](docs/TestInlineFreeformAdditionalPropertiesRequest.md) - [Tiger](docs/Tiger.md) - [UnnamedDictWithAdditionalModelListProperties](docs/UnnamedDictWithAdditionalModelListProperties.md) diff --git a/samples/openapi3/client/petstore/python-aiohttp/docs/FakeApi.md b/samples/openapi3/client/petstore/python-aiohttp/docs/FakeApi.md index 5ffe9b3f068..fccd1bb90b6 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/docs/FakeApi.md +++ b/samples/openapi3/client/petstore/python-aiohttp/docs/FakeApi.md @@ -20,7 +20,9 @@ Method | HTTP request | Description [**test_body_with_query_params**](FakeApi.md#test_body_with_query_params) | **PUT** /fake/body-with-query-params | [**test_client_model**](FakeApi.md#test_client_model) | **PATCH** /fake | To test \"client\" model [**test_date_time_query_parameter**](FakeApi.md#test_date_time_query_parameter) | **PUT** /fake/date-time-query-params | +[**test_empty_and_non_empty_responses**](FakeApi.md#test_empty_and_non_empty_responses) | **POST** /fake/empty_and_non_empty_responses | test empty and non-empty responses [**test_endpoint_parameters**](FakeApi.md#test_endpoint_parameters) | **POST** /fake | Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 +[**test_error_responses_with_model**](FakeApi.md#test_error_responses_with_model) | **POST** /fake/error_responses_with_model | test error responses with model [**test_group_parameters**](FakeApi.md#test_group_parameters) | **DELETE** /fake | Fake endpoint to test group parameters (optional) [**test_inline_additional_properties**](FakeApi.md#test_inline_additional_properties) | **POST** /fake/inline-additionalProperties | test inline additionalProperties [**test_inline_freeform_additional_properties**](FakeApi.md#test_inline_freeform_additional_properties) | **POST** /fake/inline-freeform-additionalProperties | test inline free-form additionalProperties @@ -1119,6 +1121,67 @@ No authorization required [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) +# **test_empty_and_non_empty_responses** +> test_empty_and_non_empty_responses() + +test empty and non-empty responses + + + +### Example + +```python +import time +import os +import petstore_api +from petstore_api.rest import ApiException +from pprint import pprint + +# Defining the host is optional and defaults to http://petstore.swagger.io:80/v2 +# See configuration.py for a list of all supported configuration parameters. +configuration = petstore_api.Configuration( + host = "http://petstore.swagger.io:80/v2" +) + + +# Enter a context with an instance of the API client +async with petstore_api.ApiClient(configuration) as api_client: + # Create an instance of the API class + api_instance = petstore_api.FakeApi(api_client) + + try: + # test empty and non-empty responses + await api_instance.test_empty_and_non_empty_responses() + except Exception as e: + print("Exception when calling FakeApi->test_empty_and_non_empty_responses: %s\n" % e) +``` + + + +### Parameters +This endpoint does not need any parameter. + +### Return type + +void (empty response body) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: text/plain + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +**204** | Success, but no response content | - | +**206** | Partial response content | - | + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + # **test_endpoint_parameters** > test_endpoint_parameters(number, double, pattern_without_delimiter, byte, integer=integer, int32=int32, int64=int64, var_float=var_float, string=string, binary=binary, byte_with_max_length=byte_with_max_length, var_date=var_date, date_time=date_time, password=password, param_callback=param_callback) @@ -1223,6 +1286,66 @@ void (empty response body) [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) +# **test_error_responses_with_model** +> test_error_responses_with_model() + +test error responses with model + +### Example + +```python +import time +import os +import petstore_api +from petstore_api.rest import ApiException +from pprint import pprint + +# Defining the host is optional and defaults to http://petstore.swagger.io:80/v2 +# See configuration.py for a list of all supported configuration parameters. +configuration = petstore_api.Configuration( + host = "http://petstore.swagger.io:80/v2" +) + + +# Enter a context with an instance of the API client +async with petstore_api.ApiClient(configuration) as api_client: + # Create an instance of the API class + api_instance = petstore_api.FakeApi(api_client) + + try: + # test error responses with model + await api_instance.test_error_responses_with_model() + except Exception as e: + print("Exception when calling FakeApi->test_error_responses_with_model: %s\n" % e) +``` + + + +### Parameters +This endpoint does not need any parameter. + +### Return type + +void (empty response body) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/json + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +**204** | Success, but no response content | - | +**400** | | - | +**404** | | - | + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + # **test_group_parameters** > test_group_parameters(required_string_group, required_boolean_group, required_int64_group, string_group=string_group, boolean_group=boolean_group, int64_group=int64_group) diff --git a/samples/openapi3/client/petstore/python-aiohttp/docs/TestErrorResponsesWithModel400Response.md b/samples/openapi3/client/petstore/python-aiohttp/docs/TestErrorResponsesWithModel400Response.md new file mode 100644 index 00000000000..1ef43ce4cad --- /dev/null +++ b/samples/openapi3/client/petstore/python-aiohttp/docs/TestErrorResponsesWithModel400Response.md @@ -0,0 +1,28 @@ +# TestErrorResponsesWithModel400Response + + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**reason400** | **str** | | [optional] + +## Example + +```python +from petstore_api.models.test_error_responses_with_model400_response import TestErrorResponsesWithModel400Response + +# TODO update the JSON string below +json = "{}" +# create an instance of TestErrorResponsesWithModel400Response from a JSON string +test_error_responses_with_model400_response_instance = TestErrorResponsesWithModel400Response.from_json(json) +# print the JSON string representation of the object +print TestErrorResponsesWithModel400Response.to_json() + +# convert the object into a dict +test_error_responses_with_model400_response_dict = test_error_responses_with_model400_response_instance.to_dict() +# create an instance of TestErrorResponsesWithModel400Response from a dict +test_error_responses_with_model400_response_form_dict = test_error_responses_with_model400_response.from_dict(test_error_responses_with_model400_response_dict) +``` +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/samples/openapi3/client/petstore/python-aiohttp/docs/TestErrorResponsesWithModel404Response.md b/samples/openapi3/client/petstore/python-aiohttp/docs/TestErrorResponsesWithModel404Response.md new file mode 100644 index 00000000000..9fda9553784 --- /dev/null +++ b/samples/openapi3/client/petstore/python-aiohttp/docs/TestErrorResponsesWithModel404Response.md @@ -0,0 +1,28 @@ +# TestErrorResponsesWithModel404Response + + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**reason404** | **str** | | [optional] + +## Example + +```python +from petstore_api.models.test_error_responses_with_model404_response import TestErrorResponsesWithModel404Response + +# TODO update the JSON string below +json = "{}" +# create an instance of TestErrorResponsesWithModel404Response from a JSON string +test_error_responses_with_model404_response_instance = TestErrorResponsesWithModel404Response.from_json(json) +# print the JSON string representation of the object +print TestErrorResponsesWithModel404Response.to_json() + +# convert the object into a dict +test_error_responses_with_model404_response_dict = test_error_responses_with_model404_response_instance.to_dict() +# create an instance of TestErrorResponsesWithModel404Response from a dict +test_error_responses_with_model404_response_form_dict = test_error_responses_with_model404_response.from_dict(test_error_responses_with_model404_response_dict) +``` +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/__init__.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/__init__.py index c1c56eb8115..72d39b9c55e 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/__init__.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/__init__.py @@ -113,6 +113,8 @@ from petstore_api.models.special_character_enum import SpecialCharacterEnum from petstore_api.models.special_model_name import SpecialModelName from petstore_api.models.special_name import SpecialName from petstore_api.models.tag import Tag +from petstore_api.models.test_error_responses_with_model400_response import TestErrorResponsesWithModel400Response +from petstore_api.models.test_error_responses_with_model404_response import TestErrorResponsesWithModel404Response from petstore_api.models.test_inline_freeform_additional_properties_request import TestInlineFreeformAdditionalPropertiesRequest from petstore_api.models.tiger import Tiger from petstore_api.models.unnamed_dict_with_additional_model_list_properties import UnnamedDictWithAdditionalModelListProperties diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/api/another_fake_api.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/api/another_fake_api.py index ceb2d82b167..249d397b9d2 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/api/another_fake_api.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/api/another_fake_api.py @@ -99,8 +99,7 @@ class AnotherFakeApi: ) _response_types_map: Dict[str, Optional[str]] = { - '200': "Client" - + '200': "Client", } response_data = await self.api_client.call_api( *_param, @@ -167,8 +166,7 @@ class AnotherFakeApi: ) _response_types_map: Dict[str, Optional[str]] = { - '200': "Client" - + '200': "Client", } response_data = await self.api_client.call_api( *_param, @@ -235,8 +233,7 @@ class AnotherFakeApi: ) _response_types_map: Dict[str, Optional[str]] = { - '200': "Client" - + '200': "Client", } response_data = await self.api_client.call_api( *_param, diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/api/default_api.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/api/default_api.py index e205376f019..401f2118d92 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/api/default_api.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/api/default_api.py @@ -92,8 +92,6 @@ class DefaultApi: ) _response_types_map: Dict[str, Optional[str]] = { - - } response_data = await self.api_client.call_api( *_param, @@ -155,8 +153,6 @@ class DefaultApi: ) _response_types_map: Dict[str, Optional[str]] = { - - } response_data = await self.api_client.call_api( *_param, @@ -218,8 +214,6 @@ class DefaultApi: ) _response_types_map: Dict[str, Optional[str]] = { - - } response_data = await self.api_client.call_api( *_param, diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/api/fake_api.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/api/fake_api.py index eb4df7fca8d..22172e4627f 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/api/fake_api.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/api/fake_api.py @@ -113,7 +113,7 @@ class FakeApi: ) _response_types_map: Dict[str, Optional[str]] = { - + '200': None, } response_data = await self.api_client.call_api( *_param, @@ -179,7 +179,7 @@ class FakeApi: ) _response_types_map: Dict[str, Optional[str]] = { - + '200': None, } response_data = await self.api_client.call_api( *_param, @@ -245,7 +245,7 @@ class FakeApi: ) _response_types_map: Dict[str, Optional[str]] = { - + '200': None, } response_data = await self.api_client.call_api( *_param, @@ -375,7 +375,7 @@ class FakeApi: ) _response_types_map: Dict[str, Optional[str]] = { - + '200': None, } response_data = await self.api_client.call_api( *_param, @@ -441,7 +441,7 @@ class FakeApi: ) _response_types_map: Dict[str, Optional[str]] = { - + '200': None, } response_data = await self.api_client.call_api( *_param, @@ -507,7 +507,7 @@ class FakeApi: ) _response_types_map: Dict[str, Optional[str]] = { - + '200': None, } response_data = await self.api_client.call_api( *_param, @@ -622,8 +622,7 @@ class FakeApi: ) _response_types_map: Dict[str, Optional[str]] = { - '200': "HealthCheckResult" - + '200': "HealthCheckResult", } response_data = await self.api_client.call_api( *_param, @@ -685,8 +684,7 @@ class FakeApi: ) _response_types_map: Dict[str, Optional[str]] = { - '200': "HealthCheckResult" - + '200': "HealthCheckResult", } response_data = await self.api_client.call_api( *_param, @@ -748,8 +746,7 @@ class FakeApi: ) _response_types_map: Dict[str, Optional[str]] = { - '200': "HealthCheckResult" - + '200': "HealthCheckResult", } response_data = await self.api_client.call_api( *_param, @@ -877,7 +874,7 @@ class FakeApi: ) _response_types_map: Dict[str, Optional[str]] = { - + '200': None, } response_data = await self.api_client.call_api( *_param, @@ -951,7 +948,7 @@ class FakeApi: ) _response_types_map: Dict[str, Optional[str]] = { - + '200': None, } response_data = await self.api_client.call_api( *_param, @@ -1025,7 +1022,7 @@ class FakeApi: ) _response_types_map: Dict[str, Optional[str]] = { - + '200': None, } response_data = await self.api_client.call_api( *_param, @@ -1166,8 +1163,7 @@ class FakeApi: ) _response_types_map: Dict[str, Optional[str]] = { - '200': "bool" - + '200': "bool", } response_data = await self.api_client.call_api( *_param, @@ -1234,8 +1230,7 @@ class FakeApi: ) _response_types_map: Dict[str, Optional[str]] = { - '200': "bool" - + '200': "bool", } response_data = await self.api_client.call_api( *_param, @@ -1302,8 +1297,7 @@ class FakeApi: ) _response_types_map: Dict[str, Optional[str]] = { - '200': "bool" - + '200': "bool", } response_data = await self.api_client.call_api( *_param, @@ -1440,8 +1434,7 @@ class FakeApi: ) _response_types_map: Dict[str, Optional[str]] = { - '200': "OuterComposite" - + '200': "OuterComposite", } response_data = await self.api_client.call_api( *_param, @@ -1508,8 +1501,7 @@ class FakeApi: ) _response_types_map: Dict[str, Optional[str]] = { - '200': "OuterComposite" - + '200': "OuterComposite", } response_data = await self.api_client.call_api( *_param, @@ -1576,8 +1568,7 @@ class FakeApi: ) _response_types_map: Dict[str, Optional[str]] = { - '200': "OuterComposite" - + '200': "OuterComposite", } response_data = await self.api_client.call_api( *_param, @@ -1714,8 +1705,7 @@ class FakeApi: ) _response_types_map: Dict[str, Optional[str]] = { - '200': "float" - + '200': "float", } response_data = await self.api_client.call_api( *_param, @@ -1782,8 +1772,7 @@ class FakeApi: ) _response_types_map: Dict[str, Optional[str]] = { - '200': "float" - + '200': "float", } response_data = await self.api_client.call_api( *_param, @@ -1850,8 +1839,7 @@ class FakeApi: ) _response_types_map: Dict[str, Optional[str]] = { - '200': "float" - + '200': "float", } response_data = await self.api_client.call_api( *_param, @@ -1988,8 +1976,7 @@ class FakeApi: ) _response_types_map: Dict[str, Optional[str]] = { - '200': "str" - + '200': "str", } response_data = await self.api_client.call_api( *_param, @@ -2056,8 +2043,7 @@ class FakeApi: ) _response_types_map: Dict[str, Optional[str]] = { - '200': "str" - + '200': "str", } response_data = await self.api_client.call_api( *_param, @@ -2124,8 +2110,7 @@ class FakeApi: ) _response_types_map: Dict[str, Optional[str]] = { - '200': "str" - + '200': "str", } response_data = await self.api_client.call_api( *_param, @@ -2262,8 +2247,7 @@ class FakeApi: ) _response_types_map: Dict[str, Optional[str]] = { - '200': "OuterObjectWithEnumProperty" - + '200': "OuterObjectWithEnumProperty", } response_data = await self.api_client.call_api( *_param, @@ -2330,8 +2314,7 @@ class FakeApi: ) _response_types_map: Dict[str, Optional[str]] = { - '200': "OuterObjectWithEnumProperty" - + '200': "OuterObjectWithEnumProperty", } response_data = await self.api_client.call_api( *_param, @@ -2398,8 +2381,7 @@ class FakeApi: ) _response_types_map: Dict[str, Optional[str]] = { - '200': "OuterObjectWithEnumProperty" - + '200': "OuterObjectWithEnumProperty", } response_data = await self.api_client.call_api( *_param, @@ -2531,8 +2513,7 @@ class FakeApi: ) _response_types_map: Dict[str, Optional[str]] = { - '200': "List[List[Tag]]" - + '200': "List[List[Tag]]", } response_data = await self.api_client.call_api( *_param, @@ -2594,8 +2575,7 @@ class FakeApi: ) _response_types_map: Dict[str, Optional[str]] = { - '200': "List[List[Tag]]" - + '200': "List[List[Tag]]", } response_data = await self.api_client.call_api( *_param, @@ -2657,8 +2637,7 @@ class FakeApi: ) _response_types_map: Dict[str, Optional[str]] = { - '200': "List[List[Tag]]" - + '200': "List[List[Tag]]", } response_data = await self.api_client.call_api( *_param, @@ -2778,7 +2757,7 @@ class FakeApi: ) _response_types_map: Dict[str, Optional[str]] = { - + '200': None, } response_data = await self.api_client.call_api( *_param, @@ -2844,7 +2823,7 @@ class FakeApi: ) _response_types_map: Dict[str, Optional[str]] = { - + '200': None, } response_data = await self.api_client.call_api( *_param, @@ -2910,7 +2889,7 @@ class FakeApi: ) _response_types_map: Dict[str, Optional[str]] = { - + '200': None, } response_data = await self.api_client.call_api( *_param, @@ -3030,7 +3009,7 @@ class FakeApi: ) _response_types_map: Dict[str, Optional[str]] = { - + '200': None, } response_data = await self.api_client.call_api( *_param, @@ -3097,7 +3076,7 @@ class FakeApi: ) _response_types_map: Dict[str, Optional[str]] = { - + '200': None, } response_data = await self.api_client.call_api( *_param, @@ -3164,7 +3143,7 @@ class FakeApi: ) _response_types_map: Dict[str, Optional[str]] = { - + '200': None, } response_data = await self.api_client.call_api( *_param, @@ -3300,7 +3279,7 @@ class FakeApi: ) _response_types_map: Dict[str, Optional[str]] = { - + '200': None, } response_data = await self.api_client.call_api( *_param, @@ -3367,7 +3346,7 @@ class FakeApi: ) _response_types_map: Dict[str, Optional[str]] = { - + '200': None, } response_data = await self.api_client.call_api( *_param, @@ -3434,7 +3413,7 @@ class FakeApi: ) _response_types_map: Dict[str, Optional[str]] = { - + '200': None, } response_data = await self.api_client.call_api( *_param, @@ -3568,7 +3547,7 @@ class FakeApi: ) _response_types_map: Dict[str, Optional[str]] = { - + '200': None, } response_data = await self.api_client.call_api( *_param, @@ -3638,7 +3617,7 @@ class FakeApi: ) _response_types_map: Dict[str, Optional[str]] = { - + '200': None, } response_data = await self.api_client.call_api( *_param, @@ -3708,7 +3687,7 @@ class FakeApi: ) _response_types_map: Dict[str, Optional[str]] = { - + '200': None, } response_data = await self.api_client.call_api( *_param, @@ -3844,8 +3823,7 @@ class FakeApi: ) _response_types_map: Dict[str, Optional[str]] = { - '200': "Client" - + '200': "Client", } response_data = await self.api_client.call_api( *_param, @@ -3912,8 +3890,7 @@ class FakeApi: ) _response_types_map: Dict[str, Optional[str]] = { - '200': "Client" - + '200': "Client", } response_data = await self.api_client.call_api( *_param, @@ -3980,8 +3957,7 @@ class FakeApi: ) _response_types_map: Dict[str, Optional[str]] = { - '200': "Client" - + '200': "Client", } response_data = await self.api_client.call_api( *_param, @@ -4121,7 +4097,7 @@ class FakeApi: ) _response_types_map: Dict[str, Optional[str]] = { - + '200': None, } response_data = await self.api_client.call_api( *_param, @@ -4191,7 +4167,7 @@ class FakeApi: ) _response_types_map: Dict[str, Optional[str]] = { - + '200': None, } response_data = await self.api_client.call_api( *_param, @@ -4261,7 +4237,7 @@ class FakeApi: ) _response_types_map: Dict[str, Optional[str]] = { - + '200': None, } response_data = await self.api_client.call_api( *_param, @@ -4341,6 +4317,252 @@ class FakeApi: + @validate_call + async def test_empty_and_non_empty_responses( + self, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> None: + """test empty and non-empty responses + + + + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._test_empty_and_non_empty_responses_serialize( + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '204': None, + '206': "str", + } + response_data = await self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + await response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ).data + + + @validate_call + async def test_empty_and_non_empty_responses_with_http_info( + self, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> ApiResponse[None]: + """test empty and non-empty responses + + + + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._test_empty_and_non_empty_responses_serialize( + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '204': None, + '206': "str", + } + response_data = await self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + await response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ) + + + @validate_call + async def test_empty_and_non_empty_responses_without_preload_content( + self, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> RESTResponseType: + """test empty and non-empty responses + + + + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._test_empty_and_non_empty_responses_serialize( + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '204': None, + '206': "str", + } + response_data = await self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + return response_data.response + + + def _test_empty_and_non_empty_responses_serialize( + self, + _request_auth, + _content_type, + _headers, + _host_index, + ) -> Tuple: + + _host = None + + _collection_formats: Dict[str, str] = { + + } + + _path_params: Dict[str, str] = {} + _query_params: List[Tuple[str, str]] = [] + _header_params: Dict[str, Optional[str]] = _headers or {} + _form_params: List[Tuple[str, str]] = [] + _files: Dict[str, str] = {} + _body_params: Optional[bytes] = None + + # process the path parameters + # process the query parameters + # process the header parameters + # process the form parameters + # process the body parameter + + + # set the HTTP header `Accept` + _header_params['Accept'] = self.api_client.select_header_accept( + [ + 'text/plain' + ] + ) + + + # authentication setting + _auth_settings: List[str] = [ + ] + + return self.api_client.param_serialize( + method='POST', + resource_path='/fake/empty_and_non_empty_responses', + path_params=_path_params, + query_params=_query_params, + header_params=_header_params, + body=_body_params, + post_params=_form_params, + files=_files, + auth_settings=_auth_settings, + collection_formats=_collection_formats, + _host=_host, + _request_auth=_request_auth + ) + + + + @validate_call async def test_endpoint_parameters( self, @@ -4451,7 +4673,8 @@ class FakeApi: ) _response_types_map: Dict[str, Optional[str]] = { - + '400': None, + '404': None, } response_data = await self.api_client.call_api( *_param, @@ -4574,7 +4797,8 @@ class FakeApi: ) _response_types_map: Dict[str, Optional[str]] = { - + '400': None, + '404': None, } response_data = await self.api_client.call_api( *_param, @@ -4697,7 +4921,8 @@ class FakeApi: ) _response_types_map: Dict[str, Optional[str]] = { - + '400': None, + '404': None, } response_data = await self.api_client.call_api( *_param, @@ -4817,6 +5042,252 @@ class FakeApi: + @validate_call + async def test_error_responses_with_model( + self, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> None: + """test error responses with model + + + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._test_error_responses_with_model_serialize( + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '204': None, + '400': "TestErrorResponsesWithModel400Response", + '404': "TestErrorResponsesWithModel404Response", + } + response_data = await self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + await response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ).data + + + @validate_call + async def test_error_responses_with_model_with_http_info( + self, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> ApiResponse[None]: + """test error responses with model + + + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._test_error_responses_with_model_serialize( + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '204': None, + '400': "TestErrorResponsesWithModel400Response", + '404': "TestErrorResponsesWithModel404Response", + } + response_data = await self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + await response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ) + + + @validate_call + async def test_error_responses_with_model_without_preload_content( + self, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> RESTResponseType: + """test error responses with model + + + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._test_error_responses_with_model_serialize( + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '204': None, + '400': "TestErrorResponsesWithModel400Response", + '404': "TestErrorResponsesWithModel404Response", + } + response_data = await self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + return response_data.response + + + def _test_error_responses_with_model_serialize( + self, + _request_auth, + _content_type, + _headers, + _host_index, + ) -> Tuple: + + _host = None + + _collection_formats: Dict[str, str] = { + + } + + _path_params: Dict[str, str] = {} + _query_params: List[Tuple[str, str]] = [] + _header_params: Dict[str, Optional[str]] = _headers or {} + _form_params: List[Tuple[str, str]] = [] + _files: Dict[str, str] = {} + _body_params: Optional[bytes] = None + + # process the path parameters + # process the query parameters + # process the header parameters + # process the form parameters + # process the body parameter + + + # set the HTTP header `Accept` + _header_params['Accept'] = self.api_client.select_header_accept( + [ + 'application/json' + ] + ) + + + # authentication setting + _auth_settings: List[str] = [ + ] + + return self.api_client.param_serialize( + method='POST', + resource_path='/fake/error_responses_with_model', + path_params=_path_params, + query_params=_query_params, + header_params=_header_params, + body=_body_params, + post_params=_form_params, + files=_files, + auth_settings=_auth_settings, + collection_formats=_collection_formats, + _host=_host, + _request_auth=_request_auth + ) + + + + @validate_call async def test_group_parameters( self, @@ -4891,7 +5362,7 @@ class FakeApi: ) _response_types_map: Dict[str, Optional[str]] = { - + '400': None, } response_data = await self.api_client.call_api( *_param, @@ -4978,7 +5449,7 @@ class FakeApi: ) _response_types_map: Dict[str, Optional[str]] = { - + '400': None, } response_data = await self.api_client.call_api( *_param, @@ -5065,7 +5536,7 @@ class FakeApi: ) _response_types_map: Dict[str, Optional[str]] = { - + '400': None, } response_data = await self.api_client.call_api( *_param, @@ -5207,7 +5678,7 @@ class FakeApi: ) _response_types_map: Dict[str, Optional[str]] = { - + '200': None, } response_data = await self.api_client.call_api( *_param, @@ -5274,7 +5745,7 @@ class FakeApi: ) _response_types_map: Dict[str, Optional[str]] = { - + '200': None, } response_data = await self.api_client.call_api( *_param, @@ -5341,7 +5812,7 @@ class FakeApi: ) _response_types_map: Dict[str, Optional[str]] = { - + '200': None, } response_data = await self.api_client.call_api( *_param, @@ -5472,7 +5943,7 @@ class FakeApi: ) _response_types_map: Dict[str, Optional[str]] = { - + '200': None, } response_data = await self.api_client.call_api( *_param, @@ -5539,7 +6010,7 @@ class FakeApi: ) _response_types_map: Dict[str, Optional[str]] = { - + '200': None, } response_data = await self.api_client.call_api( *_param, @@ -5606,7 +6077,7 @@ class FakeApi: ) _response_types_map: Dict[str, Optional[str]] = { - + '200': None, } response_data = await self.api_client.call_api( *_param, @@ -5741,7 +6212,7 @@ class FakeApi: ) _response_types_map: Dict[str, Optional[str]] = { - + '200': None, } response_data = await self.api_client.call_api( *_param, @@ -5812,7 +6283,7 @@ class FakeApi: ) _response_types_map: Dict[str, Optional[str]] = { - + '200': None, } response_data = await self.api_client.call_api( *_param, @@ -5883,7 +6354,7 @@ class FakeApi: ) _response_types_map: Dict[str, Optional[str]] = { - + '200': None, } response_data = await self.api_client.call_api( *_param, @@ -6041,7 +6512,7 @@ class FakeApi: ) _response_types_map: Dict[str, Optional[str]] = { - + '200': None, } response_data = await self.api_client.call_api( *_param, @@ -6132,7 +6603,7 @@ class FakeApi: ) _response_types_map: Dict[str, Optional[str]] = { - + '200': None, } response_data = await self.api_client.call_api( *_param, @@ -6223,7 +6694,7 @@ class FakeApi: ) _response_types_map: Dict[str, Optional[str]] = { - + '200': None, } response_data = await self.api_client.call_api( *_param, diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/api/fake_classname_tags123_api.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/api/fake_classname_tags123_api.py index a2554d13803..eb627e7defb 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/api/fake_classname_tags123_api.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/api/fake_classname_tags123_api.py @@ -99,8 +99,7 @@ class FakeClassnameTags123Api: ) _response_types_map: Dict[str, Optional[str]] = { - '200': "Client" - + '200': "Client", } response_data = await self.api_client.call_api( *_param, @@ -167,8 +166,7 @@ class FakeClassnameTags123Api: ) _response_types_map: Dict[str, Optional[str]] = { - '200': "Client" - + '200': "Client", } response_data = await self.api_client.call_api( *_param, @@ -235,8 +233,7 @@ class FakeClassnameTags123Api: ) _response_types_map: Dict[str, Optional[str]] = { - '200': "Client" - + '200': "Client", } response_data = await self.api_client.call_api( *_param, diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/api/pet_api.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/api/pet_api.py index 59a23ece328..e6130a864c1 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/api/pet_api.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/api/pet_api.py @@ -104,7 +104,8 @@ class PetApi: ) _response_types_map: Dict[str, Optional[str]] = { - + '200': None, + '405': None, } response_data = await self.api_client.call_api( *_param, @@ -171,7 +172,8 @@ class PetApi: ) _response_types_map: Dict[str, Optional[str]] = { - + '200': None, + '405': None, } response_data = await self.api_client.call_api( *_param, @@ -238,7 +240,8 @@ class PetApi: ) _response_types_map: Dict[str, Optional[str]] = { - + '200': None, + '405': None, } response_data = await self.api_client.call_api( *_param, @@ -376,7 +379,8 @@ class PetApi: ) _response_types_map: Dict[str, Optional[str]] = { - + '200': None, + '400': None, } response_data = await self.api_client.call_api( *_param, @@ -447,7 +451,8 @@ class PetApi: ) _response_types_map: Dict[str, Optional[str]] = { - + '200': None, + '400': None, } response_data = await self.api_client.call_api( *_param, @@ -518,7 +523,8 @@ class PetApi: ) _response_types_map: Dict[str, Optional[str]] = { - + '200': None, + '400': None, } response_data = await self.api_client.call_api( *_param, @@ -641,8 +647,7 @@ class PetApi: _response_types_map: Dict[str, Optional[str]] = { '200': "List[Pet]", - '400': None - + '400': None, } response_data = await self.api_client.call_api( *_param, @@ -710,8 +715,7 @@ class PetApi: _response_types_map: Dict[str, Optional[str]] = { '200': "List[Pet]", - '400': None - + '400': None, } response_data = await self.api_client.call_api( *_param, @@ -779,8 +783,7 @@ class PetApi: _response_types_map: Dict[str, Optional[str]] = { '200': "List[Pet]", - '400': None - + '400': None, } response_data = await self.api_client.call_api( *_param, @@ -912,8 +915,7 @@ class PetApi: _response_types_map: Dict[str, Optional[str]] = { '200': "List[Pet]", - '400': None - + '400': None, } response_data = await self.api_client.call_api( *_param, @@ -982,8 +984,7 @@ class PetApi: _response_types_map: Dict[str, Optional[str]] = { '200': "List[Pet]", - '400': None - + '400': None, } response_data = await self.api_client.call_api( *_param, @@ -1052,8 +1053,7 @@ class PetApi: _response_types_map: Dict[str, Optional[str]] = { '200': "List[Pet]", - '400': None - + '400': None, } response_data = await self.api_client.call_api( *_param, @@ -1185,8 +1185,7 @@ class PetApi: _response_types_map: Dict[str, Optional[str]] = { '200': "Pet", '400': None, - '404': None - + '404': None, } response_data = await self.api_client.call_api( *_param, @@ -1255,8 +1254,7 @@ class PetApi: _response_types_map: Dict[str, Optional[str]] = { '200': "Pet", '400': None, - '404': None - + '404': None, } response_data = await self.api_client.call_api( *_param, @@ -1325,8 +1323,7 @@ class PetApi: _response_types_map: Dict[str, Optional[str]] = { '200': "Pet", '400': None, - '404': None - + '404': None, } response_data = await self.api_client.call_api( *_param, @@ -1452,7 +1449,10 @@ class PetApi: ) _response_types_map: Dict[str, Optional[str]] = { - + '200': None, + '400': None, + '404': None, + '405': None, } response_data = await self.api_client.call_api( *_param, @@ -1519,7 +1519,10 @@ class PetApi: ) _response_types_map: Dict[str, Optional[str]] = { - + '200': None, + '400': None, + '404': None, + '405': None, } response_data = await self.api_client.call_api( *_param, @@ -1586,7 +1589,10 @@ class PetApi: ) _response_types_map: Dict[str, Optional[str]] = { - + '200': None, + '400': None, + '404': None, + '405': None, } response_data = await self.api_client.call_api( *_param, @@ -1728,7 +1734,8 @@ class PetApi: ) _response_types_map: Dict[str, Optional[str]] = { - + '200': None, + '405': None, } response_data = await self.api_client.call_api( *_param, @@ -1803,7 +1810,8 @@ class PetApi: ) _response_types_map: Dict[str, Optional[str]] = { - + '200': None, + '405': None, } response_data = await self.api_client.call_api( *_param, @@ -1878,7 +1886,8 @@ class PetApi: ) _response_types_map: Dict[str, Optional[str]] = { - + '200': None, + '405': None, } response_data = await self.api_client.call_api( *_param, @@ -2024,8 +2033,7 @@ class PetApi: ) _response_types_map: Dict[str, Optional[str]] = { - '200': "ApiResponse" - + '200': "ApiResponse", } response_data = await self.api_client.call_api( *_param, @@ -2100,8 +2108,7 @@ class PetApi: ) _response_types_map: Dict[str, Optional[str]] = { - '200': "ApiResponse" - + '200': "ApiResponse", } response_data = await self.api_client.call_api( *_param, @@ -2176,8 +2183,7 @@ class PetApi: ) _response_types_map: Dict[str, Optional[str]] = { - '200': "ApiResponse" - + '200': "ApiResponse", } response_data = await self.api_client.call_api( *_param, @@ -2329,8 +2335,7 @@ class PetApi: ) _response_types_map: Dict[str, Optional[str]] = { - '200': "ApiResponse" - + '200': "ApiResponse", } response_data = await self.api_client.call_api( *_param, @@ -2405,8 +2410,7 @@ class PetApi: ) _response_types_map: Dict[str, Optional[str]] = { - '200': "ApiResponse" - + '200': "ApiResponse", } response_data = await self.api_client.call_api( *_param, @@ -2481,8 +2485,7 @@ class PetApi: ) _response_types_map: Dict[str, Optional[str]] = { - '200': "ApiResponse" - + '200': "ApiResponse", } response_data = await self.api_client.call_api( *_param, diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/api/store_api.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/api/store_api.py index fd878851fe4..a06aa360e48 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/api/store_api.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/api/store_api.py @@ -103,7 +103,8 @@ class StoreApi: ) _response_types_map: Dict[str, Optional[str]] = { - + '400': None, + '404': None, } response_data = await self.api_client.call_api( *_param, @@ -170,7 +171,8 @@ class StoreApi: ) _response_types_map: Dict[str, Optional[str]] = { - + '400': None, + '404': None, } response_data = await self.api_client.call_api( *_param, @@ -237,7 +239,8 @@ class StoreApi: ) _response_types_map: Dict[str, Optional[str]] = { - + '400': None, + '404': None, } response_data = await self.api_client.call_api( *_param, @@ -351,8 +354,7 @@ class StoreApi: ) _response_types_map: Dict[str, Optional[str]] = { - '200': "Dict[str, int]" - + '200': "Dict[str, int]", } response_data = await self.api_client.call_api( *_param, @@ -415,8 +417,7 @@ class StoreApi: ) _response_types_map: Dict[str, Optional[str]] = { - '200': "Dict[str, int]" - + '200': "Dict[str, int]", } response_data = await self.api_client.call_api( *_param, @@ -479,8 +480,7 @@ class StoreApi: ) _response_types_map: Dict[str, Optional[str]] = { - '200': "Dict[str, int]" - + '200': "Dict[str, int]", } response_data = await self.api_client.call_api( *_param, @@ -604,8 +604,7 @@ class StoreApi: _response_types_map: Dict[str, Optional[str]] = { '200': "Order", '400': None, - '404': None - + '404': None, } response_data = await self.api_client.call_api( *_param, @@ -674,8 +673,7 @@ class StoreApi: _response_types_map: Dict[str, Optional[str]] = { '200': "Order", '400': None, - '404': None - + '404': None, } response_data = await self.api_client.call_api( *_param, @@ -744,8 +742,7 @@ class StoreApi: _response_types_map: Dict[str, Optional[str]] = { '200': "Order", '400': None, - '404': None - + '404': None, } response_data = await self.api_client.call_api( *_param, @@ -871,8 +868,7 @@ class StoreApi: _response_types_map: Dict[str, Optional[str]] = { '200': "Order", - '400': None - + '400': None, } response_data = await self.api_client.call_api( *_param, @@ -940,8 +936,7 @@ class StoreApi: _response_types_map: Dict[str, Optional[str]] = { '200': "Order", - '400': None - + '400': None, } response_data = await self.api_client.call_api( *_param, @@ -1009,8 +1004,7 @@ class StoreApi: _response_types_map: Dict[str, Optional[str]] = { '200': "Order", - '400': None - + '400': None, } response_data = await self.api_client.call_api( *_param, diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/api/user_api.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/api/user_api.py index f8728def22b..679a1a9a9b9 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/api/user_api.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/api/user_api.py @@ -103,7 +103,6 @@ class UserApi: ) _response_types_map: Dict[str, Optional[str]] = { - } response_data = await self.api_client.call_api( *_param, @@ -170,7 +169,6 @@ class UserApi: ) _response_types_map: Dict[str, Optional[str]] = { - } response_data = await self.api_client.call_api( *_param, @@ -237,7 +235,6 @@ class UserApi: ) _response_types_map: Dict[str, Optional[str]] = { - } response_data = await self.api_client.call_api( *_param, @@ -373,7 +370,6 @@ class UserApi: ) _response_types_map: Dict[str, Optional[str]] = { - } response_data = await self.api_client.call_api( *_param, @@ -440,7 +436,6 @@ class UserApi: ) _response_types_map: Dict[str, Optional[str]] = { - } response_data = await self.api_client.call_api( *_param, @@ -507,7 +502,6 @@ class UserApi: ) _response_types_map: Dict[str, Optional[str]] = { - } response_data = await self.api_client.call_api( *_param, @@ -639,7 +633,6 @@ class UserApi: ) _response_types_map: Dict[str, Optional[str]] = { - } response_data = await self.api_client.call_api( *_param, @@ -706,7 +699,6 @@ class UserApi: ) _response_types_map: Dict[str, Optional[str]] = { - } response_data = await self.api_client.call_api( *_param, @@ -773,7 +765,6 @@ class UserApi: ) _response_types_map: Dict[str, Optional[str]] = { - } response_data = await self.api_client.call_api( *_param, @@ -905,7 +896,8 @@ class UserApi: ) _response_types_map: Dict[str, Optional[str]] = { - + '400': None, + '404': None, } response_data = await self.api_client.call_api( *_param, @@ -972,7 +964,8 @@ class UserApi: ) _response_types_map: Dict[str, Optional[str]] = { - + '400': None, + '404': None, } response_data = await self.api_client.call_api( *_param, @@ -1039,7 +1032,8 @@ class UserApi: ) _response_types_map: Dict[str, Optional[str]] = { - + '400': None, + '404': None, } response_data = await self.api_client.call_api( *_param, @@ -1159,8 +1153,7 @@ class UserApi: _response_types_map: Dict[str, Optional[str]] = { '200': "User", '400': None, - '404': None - + '404': None, } response_data = await self.api_client.call_api( *_param, @@ -1229,8 +1222,7 @@ class UserApi: _response_types_map: Dict[str, Optional[str]] = { '200': "User", '400': None, - '404': None - + '404': None, } response_data = await self.api_client.call_api( *_param, @@ -1299,8 +1291,7 @@ class UserApi: _response_types_map: Dict[str, Optional[str]] = { '200': "User", '400': None, - '404': None - + '404': None, } response_data = await self.api_client.call_api( *_param, @@ -1430,8 +1421,7 @@ class UserApi: _response_types_map: Dict[str, Optional[str]] = { '200': "str", - '400': None - + '400': None, } response_data = await self.api_client.call_api( *_param, @@ -1503,8 +1493,7 @@ class UserApi: _response_types_map: Dict[str, Optional[str]] = { '200': "str", - '400': None - + '400': None, } response_data = await self.api_client.call_api( *_param, @@ -1576,8 +1565,7 @@ class UserApi: _response_types_map: Dict[str, Optional[str]] = { '200': "str", - '400': None - + '400': None, } response_data = await self.api_client.call_api( *_param, @@ -1705,7 +1693,6 @@ class UserApi: ) _response_types_map: Dict[str, Optional[str]] = { - } response_data = await self.api_client.call_api( *_param, @@ -1768,7 +1755,6 @@ class UserApi: ) _response_types_map: Dict[str, Optional[str]] = { - } response_data = await self.api_client.call_api( *_param, @@ -1831,7 +1817,6 @@ class UserApi: ) _response_types_map: Dict[str, Optional[str]] = { - } response_data = await self.api_client.call_api( *_param, @@ -1950,7 +1935,8 @@ class UserApi: ) _response_types_map: Dict[str, Optional[str]] = { - + '400': None, + '404': None, } response_data = await self.api_client.call_api( *_param, @@ -2021,7 +2007,8 @@ class UserApi: ) _response_types_map: Dict[str, Optional[str]] = { - + '400': None, + '404': None, } response_data = await self.api_client.call_api( *_param, @@ -2092,7 +2079,8 @@ class UserApi: ) _response_types_map: Dict[str, Optional[str]] = { - + '400': None, + '404': None, } response_data = await self.api_client.call_api( *_param, diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/api_client.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/api_client.py index fa4caabb835..fe0b6e141bf 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/api_client.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/api_client.py @@ -284,7 +284,7 @@ class ApiClient: def response_deserialize( self, - response_data=None, + response_data: rest.RESTResponse = None, response_types_map=None ) -> ApiResponse: """Deserializes response into an object. @@ -299,39 +299,29 @@ class ApiClient: # if not found, look for '1XX', '2XX', etc. response_type = response_types_map.get(str(response_data.status)[0] + "XX", None) - if not 200 <= response_data.status <= 299: - if response_data.status == 400: - raise BadRequestException(http_resp=response_data) - - if response_data.status == 401: - raise UnauthorizedException(http_resp=response_data) - - if response_data.status == 403: - raise ForbiddenException(http_resp=response_data) - - if response_data.status == 404: - raise NotFoundException(http_resp=response_data) - - if 500 <= response_data.status <= 599: - raise ServiceException(http_resp=response_data) - raise ApiException(http_resp=response_data) - # deserialize response data - - if response_type == "bytearray": - return_data = response_data.data - elif response_type is None: - return_data = None - elif response_type == "file": - return_data = self.__deserialize_file(response_data) - else: - match = None - content_type = response_data.getheader('content-type') - if content_type is not None: - match = re.search(r"charset=([a-zA-Z\-\d]+)[\s;]?", content_type) - encoding = match.group(1) if match else "utf-8" - response_text = response_data.data.decode(encoding) - return_data = self.deserialize(response_text, response_type) + response_text = None + return_data = None + try: + if response_type == "bytearray": + return_data = response_data.data + elif response_type == "file": + return_data = self.__deserialize_file(response_data) + elif response_type is not None: + match = None + content_type = response_data.getheader('content-type') + if content_type is not None: + match = re.search(r"charset=([a-zA-Z\-\d]+)[\s;]?", content_type) + encoding = match.group(1) if match else "utf-8" + response_text = response_data.data.decode(encoding) + return_data = self.deserialize(response_text, response_type) + finally: + if not 200 <= response_data.status <= 299: + raise ApiException.from_response( + http_resp=response_data, + body=response_text, + data=return_data, + ) return ApiResponse( status_code = response_data.status, diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/exceptions.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/exceptions.py index ab74ce953c7..363d0d9f874 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/exceptions.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/exceptions.py @@ -11,6 +11,9 @@ Do not edit the class manually. """ # noqa: E501 +from typing import Any, Optional + +from typing_extensions import Self class OpenApiException(Exception): """The base exception class for all OpenAPIExceptions""" @@ -101,17 +104,56 @@ class ApiKeyError(OpenApiException, KeyError): class ApiException(OpenApiException): - def __init__(self, status=None, reason=None, http_resp=None) -> None: + def __init__( + self, + status=None, + reason=None, + http_resp=None, + *, + body: Optional[str] = None, + data: Optional[Any] = None, + ) -> None: + self.status = status + self.reason = reason + self.body = body + self.data = data + self.headers = None + if http_resp: - self.status = http_resp.status - self.reason = http_resp.reason - self.body = http_resp.data.decode('utf-8') + if self.status is None: + self.status = http_resp.status + if self.reason is None: + self.reason = http_resp.reason + if self.body is None: + try: + self.body = http_resp.data.decode('utf-8') + except Exception: + pass self.headers = http_resp.getheaders() - else: - self.status = status - self.reason = reason - self.body = None - self.headers = None + + @classmethod + def from_response( + cls, + *, + http_resp, + body: Optional[str], + data: Optional[Any], + ) -> Self: + if http_resp.status == 400: + raise BadRequestException(http_resp=http_resp, body=body, data=data) + + if http_resp.status == 401: + raise UnauthorizedException(http_resp=http_resp, body=body, data=data) + + if http_resp.status == 403: + raise ForbiddenException(http_resp=http_resp, body=body, data=data) + + if http_resp.status == 404: + raise NotFoundException(http_resp=http_resp, body=body, data=data) + + if 500 <= http_resp.status <= 599: + raise ServiceException(http_resp=http_resp, body=body, data=data) + raise ApiException(http_resp=http_resp, body=body, data=data) def __str__(self): """Custom error messages for exception""" @@ -121,38 +163,30 @@ class ApiException(OpenApiException): error_message += "HTTP response headers: {0}\n".format( self.headers) - if self.body: - error_message += "HTTP response body: {0}\n".format(self.body) + if self.data or self.body: + error_message += "HTTP response body: {0}\n".format(self.data or self.body) return error_message -class BadRequestException(ApiException): - def __init__(self, status=None, reason=None, http_resp=None) -> None: - super(BadRequestException, self).__init__(status, reason, http_resp) +class BadRequestException(ApiException): + pass + class NotFoundException(ApiException): - - def __init__(self, status=None, reason=None, http_resp=None) -> None: - super(NotFoundException, self).__init__(status, reason, http_resp) + pass class UnauthorizedException(ApiException): - - def __init__(self, status=None, reason=None, http_resp=None) -> None: - super(UnauthorizedException, self).__init__(status, reason, http_resp) + pass class ForbiddenException(ApiException): - - def __init__(self, status=None, reason=None, http_resp=None) -> None: - super(ForbiddenException, self).__init__(status, reason, http_resp) + pass class ServiceException(ApiException): - - def __init__(self, status=None, reason=None, http_resp=None) -> None: - super(ServiceException, self).__init__(status, reason, http_resp) + pass def render_path(path_to_item): diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/__init__.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/__init__.py index dd9388d355d..c106409daa9 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/__init__.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/__init__.py @@ -89,6 +89,8 @@ from petstore_api.models.special_character_enum import SpecialCharacterEnum from petstore_api.models.special_model_name import SpecialModelName from petstore_api.models.special_name import SpecialName from petstore_api.models.tag import Tag +from petstore_api.models.test_error_responses_with_model400_response import TestErrorResponsesWithModel400Response +from petstore_api.models.test_error_responses_with_model404_response import TestErrorResponsesWithModel404Response from petstore_api.models.test_inline_freeform_additional_properties_request import TestInlineFreeformAdditionalPropertiesRequest from petstore_api.models.tiger import Tiger from petstore_api.models.unnamed_dict_with_additional_model_list_properties import UnnamedDictWithAdditionalModelListProperties diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/test_error_responses_with_model400_response.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/test_error_responses_with_model400_response.py new file mode 100644 index 00000000000..fdc57158317 --- /dev/null +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/test_error_responses_with_model400_response.py @@ -0,0 +1,87 @@ +# coding: utf-8 + +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + + The version of the OpenAPI document: 1.0.0 + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + + +from typing import Any, ClassVar, Dict, List, Optional +from pydantic import BaseModel, StrictStr +try: + from typing import Self +except ImportError: + from typing_extensions import Self + +class TestErrorResponsesWithModel400Response(BaseModel): + """ + TestErrorResponsesWithModel400Response + """ # noqa: E501 + reason400: Optional[StrictStr] = None + __properties: ClassVar[List[str]] = ["reason400"] + + model_config = { + "populate_by_name": True, + "validate_assignment": True + } + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Self: + """Create an instance of TestErrorResponsesWithModel400Response from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + """ + _dict = self.model_dump( + by_alias=True, + exclude={ + }, + exclude_none=True, + ) + return _dict + + @classmethod + def from_dict(cls, obj: Dict) -> Self: + """Create an instance of TestErrorResponsesWithModel400Response from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "reason400": obj.get("reason400") + }) + return _obj + + diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/test_error_responses_with_model404_response.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/test_error_responses_with_model404_response.py new file mode 100644 index 00000000000..2b950183f9d --- /dev/null +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/test_error_responses_with_model404_response.py @@ -0,0 +1,87 @@ +# coding: utf-8 + +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + + The version of the OpenAPI document: 1.0.0 + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + + +from typing import Any, ClassVar, Dict, List, Optional +from pydantic import BaseModel, StrictStr +try: + from typing import Self +except ImportError: + from typing_extensions import Self + +class TestErrorResponsesWithModel404Response(BaseModel): + """ + TestErrorResponsesWithModel404Response + """ # noqa: E501 + reason404: Optional[StrictStr] = None + __properties: ClassVar[List[str]] = ["reason404"] + + model_config = { + "populate_by_name": True, + "validate_assignment": True + } + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Self: + """Create an instance of TestErrorResponsesWithModel404Response from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + """ + _dict = self.model_dump( + by_alias=True, + exclude={ + }, + exclude_none=True, + ) + return _dict + + @classmethod + def from_dict(cls, obj: Dict) -> Self: + """Create an instance of TestErrorResponsesWithModel404Response from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "reason404": obj.get("reason404") + }) + return _obj + + diff --git a/samples/openapi3/client/petstore/python-aiohttp/test/test_test_error_responses_with_model400_response.py b/samples/openapi3/client/petstore/python-aiohttp/test/test_test_error_responses_with_model400_response.py new file mode 100644 index 00000000000..35db7ba74fb --- /dev/null +++ b/samples/openapi3/client/petstore/python-aiohttp/test/test_test_error_responses_with_model400_response.py @@ -0,0 +1,52 @@ +# coding: utf-8 + +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + + The version of the OpenAPI document: 1.0.0 + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +import unittest +import datetime + +from petstore_api.models.test_error_responses_with_model400_response import TestErrorResponsesWithModel400Response + +class TestTestErrorResponsesWithModel400Response(unittest.TestCase): + """TestErrorResponsesWithModel400Response unit test stubs""" + + def setUp(self): + pass + + def tearDown(self): + pass + + def make_instance(self, include_optional) -> TestErrorResponsesWithModel400Response: + """Test TestErrorResponsesWithModel400Response + include_option is a boolean, when False only required + params are included, when True both required and + optional params are included """ + # uncomment below to create an instance of `TestErrorResponsesWithModel400Response` + """ + model = TestErrorResponsesWithModel400Response() + if include_optional: + return TestErrorResponsesWithModel400Response( + reason400 = '' + ) + else: + return TestErrorResponsesWithModel400Response( + ) + """ + + def testTestErrorResponsesWithModel400Response(self): + """Test TestErrorResponsesWithModel400Response""" + # inst_req_only = self.make_instance(include_optional=False) + # inst_req_and_optional = self.make_instance(include_optional=True) + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/petstore/python-aiohttp/test/test_test_error_responses_with_model404_response.py b/samples/openapi3/client/petstore/python-aiohttp/test/test_test_error_responses_with_model404_response.py new file mode 100644 index 00000000000..e9c97c0f484 --- /dev/null +++ b/samples/openapi3/client/petstore/python-aiohttp/test/test_test_error_responses_with_model404_response.py @@ -0,0 +1,52 @@ +# coding: utf-8 + +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + + The version of the OpenAPI document: 1.0.0 + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +import unittest +import datetime + +from petstore_api.models.test_error_responses_with_model404_response import TestErrorResponsesWithModel404Response + +class TestTestErrorResponsesWithModel404Response(unittest.TestCase): + """TestErrorResponsesWithModel404Response unit test stubs""" + + def setUp(self): + pass + + def tearDown(self): + pass + + def make_instance(self, include_optional) -> TestErrorResponsesWithModel404Response: + """Test TestErrorResponsesWithModel404Response + include_option is a boolean, when False only required + params are included, when True both required and + optional params are included """ + # uncomment below to create an instance of `TestErrorResponsesWithModel404Response` + """ + model = TestErrorResponsesWithModel404Response() + if include_optional: + return TestErrorResponsesWithModel404Response( + reason404 = '' + ) + else: + return TestErrorResponsesWithModel404Response( + ) + """ + + def testTestErrorResponsesWithModel404Response(self): + """Test TestErrorResponsesWithModel404Response""" + # inst_req_only = self.make_instance(include_optional=False) + # inst_req_and_optional = self.make_instance(include_optional=True) + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/petstore/python-pydantic-v1-aiohttp/.openapi-generator/FILES b/samples/openapi3/client/petstore/python-pydantic-v1-aiohttp/.openapi-generator/FILES index 00dc818606f..1ef5f596fa1 100644 --- a/samples/openapi3/client/petstore/python-pydantic-v1-aiohttp/.openapi-generator/FILES +++ b/samples/openapi3/client/petstore/python-pydantic-v1-aiohttp/.openapi-generator/FILES @@ -84,6 +84,8 @@ docs/SpecialModelName.md docs/SpecialName.md docs/StoreApi.md docs/Tag.md +docs/TestErrorResponsesWithModel400Response.md +docs/TestErrorResponsesWithModel404Response.md docs/TestInlineFreeformAdditionalPropertiesRequest.md docs/Tiger.md docs/UnnamedDictWithAdditionalModelListProperties.md @@ -181,6 +183,8 @@ petstore_api/models/special_character_enum.py petstore_api/models/special_model_name.py petstore_api/models/special_name.py petstore_api/models/tag.py +petstore_api/models/test_error_responses_with_model400_response.py +petstore_api/models/test_error_responses_with_model404_response.py petstore_api/models/test_inline_freeform_additional_properties_request.py petstore_api/models/tiger.py petstore_api/models/unnamed_dict_with_additional_model_list_properties.py diff --git a/samples/openapi3/client/petstore/python-pydantic-v1-aiohttp/README.md b/samples/openapi3/client/petstore/python-pydantic-v1-aiohttp/README.md index 9aa800b4f2b..bb23b64132e 100644 --- a/samples/openapi3/client/petstore/python-pydantic-v1-aiohttp/README.md +++ b/samples/openapi3/client/petstore/python-pydantic-v1-aiohttp/README.md @@ -103,7 +103,9 @@ Class | Method | HTTP request | Description *FakeApi* | [**test_body_with_query_params**](docs/FakeApi.md#test_body_with_query_params) | **PUT** /fake/body-with-query-params | *FakeApi* | [**test_client_model**](docs/FakeApi.md#test_client_model) | **PATCH** /fake | To test \"client\" model *FakeApi* | [**test_date_time_query_parameter**](docs/FakeApi.md#test_date_time_query_parameter) | **PUT** /fake/date-time-query-params | +*FakeApi* | [**test_empty_and_non_empty_responses**](docs/FakeApi.md#test_empty_and_non_empty_responses) | **POST** /fake/empty_and_non_empty_responses | test empty and non-empty responses *FakeApi* | [**test_endpoint_parameters**](docs/FakeApi.md#test_endpoint_parameters) | **POST** /fake | Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 +*FakeApi* | [**test_error_responses_with_model**](docs/FakeApi.md#test_error_responses_with_model) | **POST** /fake/error_responses_with_model | test error responses with model *FakeApi* | [**test_group_parameters**](docs/FakeApi.md#test_group_parameters) | **DELETE** /fake | Fake endpoint to test group parameters (optional) *FakeApi* | [**test_inline_additional_properties**](docs/FakeApi.md#test_inline_additional_properties) | **POST** /fake/inline-additionalProperties | test inline additionalProperties *FakeApi* | [**test_inline_freeform_additional_properties**](docs/FakeApi.md#test_inline_freeform_additional_properties) | **POST** /fake/inline-freeform-additionalProperties | test inline free-form additionalProperties @@ -210,6 +212,8 @@ Class | Method | HTTP request | Description - [SpecialModelName](docs/SpecialModelName.md) - [SpecialName](docs/SpecialName.md) - [Tag](docs/Tag.md) + - [TestErrorResponsesWithModel400Response](docs/TestErrorResponsesWithModel400Response.md) + - [TestErrorResponsesWithModel404Response](docs/TestErrorResponsesWithModel404Response.md) - [TestInlineFreeformAdditionalPropertiesRequest](docs/TestInlineFreeformAdditionalPropertiesRequest.md) - [Tiger](docs/Tiger.md) - [UnnamedDictWithAdditionalModelListProperties](docs/UnnamedDictWithAdditionalModelListProperties.md) diff --git a/samples/openapi3/client/petstore/python-pydantic-v1-aiohttp/docs/FakeApi.md b/samples/openapi3/client/petstore/python-pydantic-v1-aiohttp/docs/FakeApi.md index be5d5e850c7..ffff4acfb3e 100644 --- a/samples/openapi3/client/petstore/python-pydantic-v1-aiohttp/docs/FakeApi.md +++ b/samples/openapi3/client/petstore/python-pydantic-v1-aiohttp/docs/FakeApi.md @@ -20,7 +20,9 @@ Method | HTTP request | Description [**test_body_with_query_params**](FakeApi.md#test_body_with_query_params) | **PUT** /fake/body-with-query-params | [**test_client_model**](FakeApi.md#test_client_model) | **PATCH** /fake | To test \"client\" model [**test_date_time_query_parameter**](FakeApi.md#test_date_time_query_parameter) | **PUT** /fake/date-time-query-params | +[**test_empty_and_non_empty_responses**](FakeApi.md#test_empty_and_non_empty_responses) | **POST** /fake/empty_and_non_empty_responses | test empty and non-empty responses [**test_endpoint_parameters**](FakeApi.md#test_endpoint_parameters) | **POST** /fake | Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 +[**test_error_responses_with_model**](FakeApi.md#test_error_responses_with_model) | **POST** /fake/error_responses_with_model | test error responses with model [**test_group_parameters**](FakeApi.md#test_group_parameters) | **DELETE** /fake | Fake endpoint to test group parameters (optional) [**test_inline_additional_properties**](FakeApi.md#test_inline_additional_properties) | **POST** /fake/inline-additionalProperties | test inline additionalProperties [**test_inline_freeform_additional_properties**](FakeApi.md#test_inline_freeform_additional_properties) | **POST** /fake/inline-freeform-additionalProperties | test inline free-form additionalProperties @@ -1119,6 +1121,67 @@ No authorization required [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) +# **test_empty_and_non_empty_responses** +> test_empty_and_non_empty_responses() + +test empty and non-empty responses + + + +### Example + +```python +import time +import os +import petstore_api +from petstore_api.rest import ApiException +from pprint import pprint + +# Defining the host is optional and defaults to http://petstore.swagger.io:80/v2 +# See configuration.py for a list of all supported configuration parameters. +configuration = petstore_api.Configuration( + host = "http://petstore.swagger.io:80/v2" +) + + +# Enter a context with an instance of the API client +async with petstore_api.ApiClient(configuration) as api_client: + # Create an instance of the API class + api_instance = petstore_api.FakeApi(api_client) + + try: + # test empty and non-empty responses + await api_instance.test_empty_and_non_empty_responses() + except Exception as e: + print("Exception when calling FakeApi->test_empty_and_non_empty_responses: %s\n" % e) +``` + + + +### Parameters +This endpoint does not need any parameter. + +### Return type + +void (empty response body) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: text/plain + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +**204** | Success, but no response content | - | +**206** | Partial response content | - | + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + # **test_endpoint_parameters** > test_endpoint_parameters(number, double, pattern_without_delimiter, byte, integer=integer, int32=int32, int64=int64, float=float, string=string, binary=binary, byte_with_max_length=byte_with_max_length, var_date=var_date, date_time=date_time, password=password, param_callback=param_callback) @@ -1223,6 +1286,66 @@ void (empty response body) [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) +# **test_error_responses_with_model** +> test_error_responses_with_model() + +test error responses with model + +### Example + +```python +import time +import os +import petstore_api +from petstore_api.rest import ApiException +from pprint import pprint + +# Defining the host is optional and defaults to http://petstore.swagger.io:80/v2 +# See configuration.py for a list of all supported configuration parameters. +configuration = petstore_api.Configuration( + host = "http://petstore.swagger.io:80/v2" +) + + +# Enter a context with an instance of the API client +async with petstore_api.ApiClient(configuration) as api_client: + # Create an instance of the API class + api_instance = petstore_api.FakeApi(api_client) + + try: + # test error responses with model + await api_instance.test_error_responses_with_model() + except Exception as e: + print("Exception when calling FakeApi->test_error_responses_with_model: %s\n" % e) +``` + + + +### Parameters +This endpoint does not need any parameter. + +### Return type + +void (empty response body) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/json + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +**204** | Success, but no response content | - | +**400** | | - | +**404** | | - | + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + # **test_group_parameters** > test_group_parameters(required_string_group, required_boolean_group, required_int64_group, string_group=string_group, boolean_group=boolean_group, int64_group=int64_group) diff --git a/samples/openapi3/client/petstore/python-pydantic-v1-aiohttp/docs/TestErrorResponsesWithModel400Response.md b/samples/openapi3/client/petstore/python-pydantic-v1-aiohttp/docs/TestErrorResponsesWithModel400Response.md new file mode 100644 index 00000000000..1ef43ce4cad --- /dev/null +++ b/samples/openapi3/client/petstore/python-pydantic-v1-aiohttp/docs/TestErrorResponsesWithModel400Response.md @@ -0,0 +1,28 @@ +# TestErrorResponsesWithModel400Response + + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**reason400** | **str** | | [optional] + +## Example + +```python +from petstore_api.models.test_error_responses_with_model400_response import TestErrorResponsesWithModel400Response + +# TODO update the JSON string below +json = "{}" +# create an instance of TestErrorResponsesWithModel400Response from a JSON string +test_error_responses_with_model400_response_instance = TestErrorResponsesWithModel400Response.from_json(json) +# print the JSON string representation of the object +print TestErrorResponsesWithModel400Response.to_json() + +# convert the object into a dict +test_error_responses_with_model400_response_dict = test_error_responses_with_model400_response_instance.to_dict() +# create an instance of TestErrorResponsesWithModel400Response from a dict +test_error_responses_with_model400_response_form_dict = test_error_responses_with_model400_response.from_dict(test_error_responses_with_model400_response_dict) +``` +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/samples/openapi3/client/petstore/python-pydantic-v1-aiohttp/docs/TestErrorResponsesWithModel404Response.md b/samples/openapi3/client/petstore/python-pydantic-v1-aiohttp/docs/TestErrorResponsesWithModel404Response.md new file mode 100644 index 00000000000..9fda9553784 --- /dev/null +++ b/samples/openapi3/client/petstore/python-pydantic-v1-aiohttp/docs/TestErrorResponsesWithModel404Response.md @@ -0,0 +1,28 @@ +# TestErrorResponsesWithModel404Response + + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**reason404** | **str** | | [optional] + +## Example + +```python +from petstore_api.models.test_error_responses_with_model404_response import TestErrorResponsesWithModel404Response + +# TODO update the JSON string below +json = "{}" +# create an instance of TestErrorResponsesWithModel404Response from a JSON string +test_error_responses_with_model404_response_instance = TestErrorResponsesWithModel404Response.from_json(json) +# print the JSON string representation of the object +print TestErrorResponsesWithModel404Response.to_json() + +# convert the object into a dict +test_error_responses_with_model404_response_dict = test_error_responses_with_model404_response_instance.to_dict() +# create an instance of TestErrorResponsesWithModel404Response from a dict +test_error_responses_with_model404_response_form_dict = test_error_responses_with_model404_response.from_dict(test_error_responses_with_model404_response_dict) +``` +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/samples/openapi3/client/petstore/python-pydantic-v1-aiohttp/petstore_api/__init__.py b/samples/openapi3/client/petstore/python-pydantic-v1-aiohttp/petstore_api/__init__.py index c1c56eb8115..72d39b9c55e 100644 --- a/samples/openapi3/client/petstore/python-pydantic-v1-aiohttp/petstore_api/__init__.py +++ b/samples/openapi3/client/petstore/python-pydantic-v1-aiohttp/petstore_api/__init__.py @@ -113,6 +113,8 @@ from petstore_api.models.special_character_enum import SpecialCharacterEnum from petstore_api.models.special_model_name import SpecialModelName from petstore_api.models.special_name import SpecialName from petstore_api.models.tag import Tag +from petstore_api.models.test_error_responses_with_model400_response import TestErrorResponsesWithModel400Response +from petstore_api.models.test_error_responses_with_model404_response import TestErrorResponsesWithModel404Response from petstore_api.models.test_inline_freeform_additional_properties_request import TestInlineFreeformAdditionalPropertiesRequest from petstore_api.models.tiger import Tiger from petstore_api.models.unnamed_dict_with_additional_model_list_properties import UnnamedDictWithAdditionalModelListProperties diff --git a/samples/openapi3/client/petstore/python-pydantic-v1-aiohttp/petstore_api/api/fake_api.py b/samples/openapi3/client/petstore/python-pydantic-v1-aiohttp/petstore_api/api/fake_api.py index 975e70cad80..526cd7113bd 100644 --- a/samples/openapi3/client/petstore/python-pydantic-v1-aiohttp/petstore_api/api/fake_api.py +++ b/samples/openapi3/client/petstore/python-pydantic-v1-aiohttp/petstore_api/api/fake_api.py @@ -2078,6 +2078,120 @@ class FakeApi: collection_formats=_collection_formats, _request_auth=_params.get('_request_auth')) + @validate_arguments + async def test_empty_and_non_empty_responses(self, **kwargs) -> None: # noqa: E501 + """test empty and non-empty responses # noqa: E501 + + # noqa: E501 + + :param _request_timeout: timeout setting for this request. + If one number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :return: Returns the result object. + If the method is called asynchronously, + returns the request thread. + :rtype: None + """ + kwargs['_return_http_data_only'] = True + if '_preload_content' in kwargs: + message = "Error! Please call the test_empty_and_non_empty_responses_with_http_info method with `_preload_content` instead and obtain raw data from ApiResponse.raw_data" # noqa: E501 + raise ValueError(message) + return await self.test_empty_and_non_empty_responses_with_http_info(**kwargs) # noqa: E501 + + @validate_arguments + async def test_empty_and_non_empty_responses_with_http_info(self, **kwargs) -> ApiResponse: # noqa: E501 + """test empty and non-empty responses # noqa: E501 + + # noqa: E501 + + :param _preload_content: if False, the ApiResponse.data will + be set to none and raw_data will store the + HTTP response body without reading/decoding. + Default is True. + :type _preload_content: bool, optional + :param _return_http_data_only: response data instead of ApiResponse + object with status code, headers, etc + :type _return_http_data_only: bool, optional + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the authentication + in the spec for a single request. + :type _request_auth: dict, optional + :type _content_type: string, optional: force content-type for the request + :return: Returns the result object. + If the method is called asynchronously, + returns the request thread. + :rtype: None + """ + + _params = locals() + + _all_params = [ + ] + _all_params.extend( + [ + '_return_http_data_only', + '_preload_content', + '_request_timeout', + '_request_auth', + '_content_type', + '_headers' + ] + ) + + # validate the arguments + for _key, _val in _params['kwargs'].items(): + if _key not in _all_params: + raise ApiTypeError( + "Got an unexpected keyword argument '%s'" + " to method test_empty_and_non_empty_responses" % _key + ) + _params[_key] = _val + del _params['kwargs'] + + _collection_formats = {} + + # process the path parameters + _path_params = {} + + # process the query parameters + _query_params = [] + # process the header parameters + _header_params = dict(_params.get('_headers', {})) + # process the form parameters + _form_params = [] + _files = {} + # process the body parameter + _body_params = None + # set the HTTP header `Accept` + _header_params['Accept'] = self.api_client.select_header_accept( + ['text/plain']) # noqa: E501 + + # authentication setting + _auth_settings = [] # noqa: E501 + + _response_types_map = {} + + return await self.api_client.call_api( + '/fake/empty_and_non_empty_responses', 'POST', + _path_params, + _query_params, + _header_params, + body=_body_params, + post_params=_form_params, + files=_files, + response_types_map=_response_types_map, + auth_settings=_auth_settings, + _return_http_data_only=_params.get('_return_http_data_only'), # noqa: E501 + _preload_content=_params.get('_preload_content', True), + _request_timeout=_params.get('_request_timeout'), + collection_formats=_collection_formats, + _request_auth=_params.get('_request_auth')) + @validate_arguments async def test_endpoint_parameters(self, number : Annotated[confloat(le=543.2, ge=32.1), Field(..., description="None")], double : Annotated[confloat(le=123.4, ge=67.8), Field(..., description="None")], pattern_without_delimiter : Annotated[constr(strict=True), Field(..., description="None")], byte : Annotated[Union[StrictBytes, StrictStr], Field(..., description="None")], integer : Annotated[Optional[conint(strict=True, le=100, ge=10)], Field(description="None")] = None, int32 : Annotated[Optional[conint(strict=True, le=200, ge=20)], Field(description="None")] = None, int64 : Annotated[Optional[StrictInt], Field(description="None")] = None, float : Annotated[Optional[confloat(le=987.6)], Field(description="None")] = None, string : Annotated[Optional[constr(strict=True)], Field(description="None")] = None, binary : Annotated[Optional[Union[StrictBytes, StrictStr]], Field(description="None")] = None, byte_with_max_length : Annotated[Optional[Union[conbytes(strict=True, max_length=64), constr(strict=True, max_length=64)]], Field(description="None")] = None, var_date : Annotated[Optional[date], Field(description="None")] = None, date_time : Annotated[Optional[datetime], Field(description="None")] = None, password : Annotated[Optional[constr(strict=True, max_length=64, min_length=10)], Field(description="None")] = None, param_callback : Annotated[Optional[StrictStr], Field(description="None")] = None, **kwargs) -> None: # noqa: E501 """Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 # noqa: E501 @@ -2315,6 +2429,118 @@ class FakeApi: collection_formats=_collection_formats, _request_auth=_params.get('_request_auth')) + @validate_arguments + async def test_error_responses_with_model(self, **kwargs) -> None: # noqa: E501 + """test error responses with model # noqa: E501 + + + :param _request_timeout: timeout setting for this request. + If one number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :return: Returns the result object. + If the method is called asynchronously, + returns the request thread. + :rtype: None + """ + kwargs['_return_http_data_only'] = True + if '_preload_content' in kwargs: + message = "Error! Please call the test_error_responses_with_model_with_http_info method with `_preload_content` instead and obtain raw data from ApiResponse.raw_data" # noqa: E501 + raise ValueError(message) + return await self.test_error_responses_with_model_with_http_info(**kwargs) # noqa: E501 + + @validate_arguments + async def test_error_responses_with_model_with_http_info(self, **kwargs) -> ApiResponse: # noqa: E501 + """test error responses with model # noqa: E501 + + + :param _preload_content: if False, the ApiResponse.data will + be set to none and raw_data will store the + HTTP response body without reading/decoding. + Default is True. + :type _preload_content: bool, optional + :param _return_http_data_only: response data instead of ApiResponse + object with status code, headers, etc + :type _return_http_data_only: bool, optional + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the authentication + in the spec for a single request. + :type _request_auth: dict, optional + :type _content_type: string, optional: force content-type for the request + :return: Returns the result object. + If the method is called asynchronously, + returns the request thread. + :rtype: None + """ + + _params = locals() + + _all_params = [ + ] + _all_params.extend( + [ + '_return_http_data_only', + '_preload_content', + '_request_timeout', + '_request_auth', + '_content_type', + '_headers' + ] + ) + + # validate the arguments + for _key, _val in _params['kwargs'].items(): + if _key not in _all_params: + raise ApiTypeError( + "Got an unexpected keyword argument '%s'" + " to method test_error_responses_with_model" % _key + ) + _params[_key] = _val + del _params['kwargs'] + + _collection_formats = {} + + # process the path parameters + _path_params = {} + + # process the query parameters + _query_params = [] + # process the header parameters + _header_params = dict(_params.get('_headers', {})) + # process the form parameters + _form_params = [] + _files = {} + # process the body parameter + _body_params = None + # set the HTTP header `Accept` + _header_params['Accept'] = self.api_client.select_header_accept( + ['application/json']) # noqa: E501 + + # authentication setting + _auth_settings = [] # noqa: E501 + + _response_types_map = {} + + return await self.api_client.call_api( + '/fake/error_responses_with_model', 'POST', + _path_params, + _query_params, + _header_params, + body=_body_params, + post_params=_form_params, + files=_files, + response_types_map=_response_types_map, + auth_settings=_auth_settings, + _return_http_data_only=_params.get('_return_http_data_only'), # noqa: E501 + _preload_content=_params.get('_preload_content', True), + _request_timeout=_params.get('_request_timeout'), + collection_formats=_collection_formats, + _request_auth=_params.get('_request_auth')) + @validate_arguments async def test_group_parameters(self, required_string_group : Annotated[StrictInt, Field(..., description="Required String in group parameters")], required_boolean_group : Annotated[StrictBool, Field(..., description="Required Boolean in group parameters")], required_int64_group : Annotated[StrictInt, Field(..., description="Required Integer in group parameters")], string_group : Annotated[Optional[StrictInt], Field(description="String in group parameters")] = None, boolean_group : Annotated[Optional[StrictBool], Field(description="Boolean in group parameters")] = None, int64_group : Annotated[Optional[StrictInt], Field(description="Integer in group parameters")] = None, **kwargs) -> None: # noqa: E501 """Fake endpoint to test group parameters (optional) # noqa: E501 diff --git a/samples/openapi3/client/petstore/python-pydantic-v1-aiohttp/petstore_api/models/__init__.py b/samples/openapi3/client/petstore/python-pydantic-v1-aiohttp/petstore_api/models/__init__.py index dd9388d355d..c106409daa9 100644 --- a/samples/openapi3/client/petstore/python-pydantic-v1-aiohttp/petstore_api/models/__init__.py +++ b/samples/openapi3/client/petstore/python-pydantic-v1-aiohttp/petstore_api/models/__init__.py @@ -89,6 +89,8 @@ from petstore_api.models.special_character_enum import SpecialCharacterEnum from petstore_api.models.special_model_name import SpecialModelName from petstore_api.models.special_name import SpecialName from petstore_api.models.tag import Tag +from petstore_api.models.test_error_responses_with_model400_response import TestErrorResponsesWithModel400Response +from petstore_api.models.test_error_responses_with_model404_response import TestErrorResponsesWithModel404Response from petstore_api.models.test_inline_freeform_additional_properties_request import TestInlineFreeformAdditionalPropertiesRequest from petstore_api.models.tiger import Tiger from petstore_api.models.unnamed_dict_with_additional_model_list_properties import UnnamedDictWithAdditionalModelListProperties diff --git a/samples/openapi3/client/petstore/python-pydantic-v1-aiohttp/petstore_api/models/test_error_responses_with_model400_response.py b/samples/openapi3/client/petstore/python-pydantic-v1-aiohttp/petstore_api/models/test_error_responses_with_model400_response.py new file mode 100644 index 00000000000..c4904af2905 --- /dev/null +++ b/samples/openapi3/client/petstore/python-pydantic-v1-aiohttp/petstore_api/models/test_error_responses_with_model400_response.py @@ -0,0 +1,71 @@ +# coding: utf-8 + +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + + The version of the OpenAPI document: 1.0.0 + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + + +from typing import Optional +from pydantic import BaseModel, StrictStr + +class TestErrorResponsesWithModel400Response(BaseModel): + """ + TestErrorResponsesWithModel400Response + """ + reason400: Optional[StrictStr] = None + __properties = ["reason400"] + + class Config: + """Pydantic configuration""" + allow_population_by_field_name = True + validate_assignment = True + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.dict(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> TestErrorResponsesWithModel400Response: + """Create an instance of TestErrorResponsesWithModel400Response from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self): + """Returns the dictionary representation of the model using alias""" + _dict = self.dict(by_alias=True, + exclude={ + }, + exclude_none=True) + return _dict + + @classmethod + def from_dict(cls, obj: dict) -> TestErrorResponsesWithModel400Response: + """Create an instance of TestErrorResponsesWithModel400Response from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return TestErrorResponsesWithModel400Response.parse_obj(obj) + + _obj = TestErrorResponsesWithModel400Response.parse_obj({ + "reason400": obj.get("reason400") + }) + return _obj + + diff --git a/samples/openapi3/client/petstore/python-pydantic-v1-aiohttp/petstore_api/models/test_error_responses_with_model404_response.py b/samples/openapi3/client/petstore/python-pydantic-v1-aiohttp/petstore_api/models/test_error_responses_with_model404_response.py new file mode 100644 index 00000000000..96b5f6c5871 --- /dev/null +++ b/samples/openapi3/client/petstore/python-pydantic-v1-aiohttp/petstore_api/models/test_error_responses_with_model404_response.py @@ -0,0 +1,71 @@ +# coding: utf-8 + +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + + The version of the OpenAPI document: 1.0.0 + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + + +from typing import Optional +from pydantic import BaseModel, StrictStr + +class TestErrorResponsesWithModel404Response(BaseModel): + """ + TestErrorResponsesWithModel404Response + """ + reason404: Optional[StrictStr] = None + __properties = ["reason404"] + + class Config: + """Pydantic configuration""" + allow_population_by_field_name = True + validate_assignment = True + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.dict(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> TestErrorResponsesWithModel404Response: + """Create an instance of TestErrorResponsesWithModel404Response from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self): + """Returns the dictionary representation of the model using alias""" + _dict = self.dict(by_alias=True, + exclude={ + }, + exclude_none=True) + return _dict + + @classmethod + def from_dict(cls, obj: dict) -> TestErrorResponsesWithModel404Response: + """Create an instance of TestErrorResponsesWithModel404Response from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return TestErrorResponsesWithModel404Response.parse_obj(obj) + + _obj = TestErrorResponsesWithModel404Response.parse_obj({ + "reason404": obj.get("reason404") + }) + return _obj + + diff --git a/samples/openapi3/client/petstore/python-pydantic-v1-aiohttp/test/test_test_error_responses_with_model400_response.py b/samples/openapi3/client/petstore/python-pydantic-v1-aiohttp/test/test_test_error_responses_with_model400_response.py new file mode 100644 index 00000000000..b4e2d50dc6f --- /dev/null +++ b/samples/openapi3/client/petstore/python-pydantic-v1-aiohttp/test/test_test_error_responses_with_model400_response.py @@ -0,0 +1,52 @@ +# coding: utf-8 + +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + + The version of the OpenAPI document: 1.0.0 + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +import unittest +import datetime + +from petstore_api.models.test_error_responses_with_model400_response import TestErrorResponsesWithModel400Response # noqa: E501 + +class TestTestErrorResponsesWithModel400Response(unittest.TestCase): + """TestErrorResponsesWithModel400Response unit test stubs""" + + def setUp(self): + pass + + def tearDown(self): + pass + + def make_instance(self, include_optional) -> TestErrorResponsesWithModel400Response: + """Test TestErrorResponsesWithModel400Response + include_option is a boolean, when False only required + params are included, when True both required and + optional params are included """ + # uncomment below to create an instance of `TestErrorResponsesWithModel400Response` + """ + model = TestErrorResponsesWithModel400Response() # noqa: E501 + if include_optional: + return TestErrorResponsesWithModel400Response( + reason400 = '' + ) + else: + return TestErrorResponsesWithModel400Response( + ) + """ + + def testTestErrorResponsesWithModel400Response(self): + """Test TestErrorResponsesWithModel400Response""" + # inst_req_only = self.make_instance(include_optional=False) + # inst_req_and_optional = self.make_instance(include_optional=True) + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/petstore/python-pydantic-v1-aiohttp/test/test_test_error_responses_with_model404_response.py b/samples/openapi3/client/petstore/python-pydantic-v1-aiohttp/test/test_test_error_responses_with_model404_response.py new file mode 100644 index 00000000000..caf587ddb03 --- /dev/null +++ b/samples/openapi3/client/petstore/python-pydantic-v1-aiohttp/test/test_test_error_responses_with_model404_response.py @@ -0,0 +1,52 @@ +# coding: utf-8 + +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + + The version of the OpenAPI document: 1.0.0 + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +import unittest +import datetime + +from petstore_api.models.test_error_responses_with_model404_response import TestErrorResponsesWithModel404Response # noqa: E501 + +class TestTestErrorResponsesWithModel404Response(unittest.TestCase): + """TestErrorResponsesWithModel404Response unit test stubs""" + + def setUp(self): + pass + + def tearDown(self): + pass + + def make_instance(self, include_optional) -> TestErrorResponsesWithModel404Response: + """Test TestErrorResponsesWithModel404Response + include_option is a boolean, when False only required + params are included, when True both required and + optional params are included """ + # uncomment below to create an instance of `TestErrorResponsesWithModel404Response` + """ + model = TestErrorResponsesWithModel404Response() # noqa: E501 + if include_optional: + return TestErrorResponsesWithModel404Response( + reason404 = '' + ) + else: + return TestErrorResponsesWithModel404Response( + ) + """ + + def testTestErrorResponsesWithModel404Response(self): + """Test TestErrorResponsesWithModel404Response""" + # inst_req_only = self.make_instance(include_optional=False) + # inst_req_and_optional = self.make_instance(include_optional=True) + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/petstore/python-pydantic-v1/.openapi-generator/FILES b/samples/openapi3/client/petstore/python-pydantic-v1/.openapi-generator/FILES index 00dc818606f..1ef5f596fa1 100644 --- a/samples/openapi3/client/petstore/python-pydantic-v1/.openapi-generator/FILES +++ b/samples/openapi3/client/petstore/python-pydantic-v1/.openapi-generator/FILES @@ -84,6 +84,8 @@ docs/SpecialModelName.md docs/SpecialName.md docs/StoreApi.md docs/Tag.md +docs/TestErrorResponsesWithModel400Response.md +docs/TestErrorResponsesWithModel404Response.md docs/TestInlineFreeformAdditionalPropertiesRequest.md docs/Tiger.md docs/UnnamedDictWithAdditionalModelListProperties.md @@ -181,6 +183,8 @@ petstore_api/models/special_character_enum.py petstore_api/models/special_model_name.py petstore_api/models/special_name.py petstore_api/models/tag.py +petstore_api/models/test_error_responses_with_model400_response.py +petstore_api/models/test_error_responses_with_model404_response.py petstore_api/models/test_inline_freeform_additional_properties_request.py petstore_api/models/tiger.py petstore_api/models/unnamed_dict_with_additional_model_list_properties.py diff --git a/samples/openapi3/client/petstore/python-pydantic-v1/README.md b/samples/openapi3/client/petstore/python-pydantic-v1/README.md index 3628ec73d27..71954df3745 100644 --- a/samples/openapi3/client/petstore/python-pydantic-v1/README.md +++ b/samples/openapi3/client/petstore/python-pydantic-v1/README.md @@ -103,7 +103,9 @@ Class | Method | HTTP request | Description *FakeApi* | [**test_body_with_query_params**](docs/FakeApi.md#test_body_with_query_params) | **PUT** /fake/body-with-query-params | *FakeApi* | [**test_client_model**](docs/FakeApi.md#test_client_model) | **PATCH** /fake | To test \"client\" model *FakeApi* | [**test_date_time_query_parameter**](docs/FakeApi.md#test_date_time_query_parameter) | **PUT** /fake/date-time-query-params | +*FakeApi* | [**test_empty_and_non_empty_responses**](docs/FakeApi.md#test_empty_and_non_empty_responses) | **POST** /fake/empty_and_non_empty_responses | test empty and non-empty responses *FakeApi* | [**test_endpoint_parameters**](docs/FakeApi.md#test_endpoint_parameters) | **POST** /fake | Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 +*FakeApi* | [**test_error_responses_with_model**](docs/FakeApi.md#test_error_responses_with_model) | **POST** /fake/error_responses_with_model | test error responses with model *FakeApi* | [**test_group_parameters**](docs/FakeApi.md#test_group_parameters) | **DELETE** /fake | Fake endpoint to test group parameters (optional) *FakeApi* | [**test_inline_additional_properties**](docs/FakeApi.md#test_inline_additional_properties) | **POST** /fake/inline-additionalProperties | test inline additionalProperties *FakeApi* | [**test_inline_freeform_additional_properties**](docs/FakeApi.md#test_inline_freeform_additional_properties) | **POST** /fake/inline-freeform-additionalProperties | test inline free-form additionalProperties @@ -210,6 +212,8 @@ Class | Method | HTTP request | Description - [SpecialModelName](docs/SpecialModelName.md) - [SpecialName](docs/SpecialName.md) - [Tag](docs/Tag.md) + - [TestErrorResponsesWithModel400Response](docs/TestErrorResponsesWithModel400Response.md) + - [TestErrorResponsesWithModel404Response](docs/TestErrorResponsesWithModel404Response.md) - [TestInlineFreeformAdditionalPropertiesRequest](docs/TestInlineFreeformAdditionalPropertiesRequest.md) - [Tiger](docs/Tiger.md) - [UnnamedDictWithAdditionalModelListProperties](docs/UnnamedDictWithAdditionalModelListProperties.md) diff --git a/samples/openapi3/client/petstore/python-pydantic-v1/docs/FakeApi.md b/samples/openapi3/client/petstore/python-pydantic-v1/docs/FakeApi.md index 5bd0489ae55..dc894179ff0 100644 --- a/samples/openapi3/client/petstore/python-pydantic-v1/docs/FakeApi.md +++ b/samples/openapi3/client/petstore/python-pydantic-v1/docs/FakeApi.md @@ -20,7 +20,9 @@ Method | HTTP request | Description [**test_body_with_query_params**](FakeApi.md#test_body_with_query_params) | **PUT** /fake/body-with-query-params | [**test_client_model**](FakeApi.md#test_client_model) | **PATCH** /fake | To test \"client\" model [**test_date_time_query_parameter**](FakeApi.md#test_date_time_query_parameter) | **PUT** /fake/date-time-query-params | +[**test_empty_and_non_empty_responses**](FakeApi.md#test_empty_and_non_empty_responses) | **POST** /fake/empty_and_non_empty_responses | test empty and non-empty responses [**test_endpoint_parameters**](FakeApi.md#test_endpoint_parameters) | **POST** /fake | Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 +[**test_error_responses_with_model**](FakeApi.md#test_error_responses_with_model) | **POST** /fake/error_responses_with_model | test error responses with model [**test_group_parameters**](FakeApi.md#test_group_parameters) | **DELETE** /fake | Fake endpoint to test group parameters (optional) [**test_inline_additional_properties**](FakeApi.md#test_inline_additional_properties) | **POST** /fake/inline-additionalProperties | test inline additionalProperties [**test_inline_freeform_additional_properties**](FakeApi.md#test_inline_freeform_additional_properties) | **POST** /fake/inline-freeform-additionalProperties | test inline free-form additionalProperties @@ -1119,6 +1121,67 @@ No authorization required [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) +# **test_empty_and_non_empty_responses** +> test_empty_and_non_empty_responses() + +test empty and non-empty responses + + + +### Example + +```python +import time +import os +import petstore_api +from petstore_api.rest import ApiException +from pprint import pprint + +# Defining the host is optional and defaults to http://petstore.swagger.io:80/v2 +# See configuration.py for a list of all supported configuration parameters. +configuration = petstore_api.Configuration( + host = "http://petstore.swagger.io:80/v2" +) + + +# Enter a context with an instance of the API client +with petstore_api.ApiClient(configuration) as api_client: + # Create an instance of the API class + api_instance = petstore_api.FakeApi(api_client) + + try: + # test empty and non-empty responses + api_instance.test_empty_and_non_empty_responses() + except Exception as e: + print("Exception when calling FakeApi->test_empty_and_non_empty_responses: %s\n" % e) +``` + + + +### Parameters +This endpoint does not need any parameter. + +### Return type + +void (empty response body) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: text/plain + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +**204** | Success, but no response content | - | +**206** | Partial response content | - | + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + # **test_endpoint_parameters** > test_endpoint_parameters(number, double, pattern_without_delimiter, byte, integer=integer, int32=int32, int64=int64, float=float, string=string, binary=binary, byte_with_max_length=byte_with_max_length, var_date=var_date, date_time=date_time, password=password, param_callback=param_callback) @@ -1223,6 +1286,66 @@ void (empty response body) [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) +# **test_error_responses_with_model** +> test_error_responses_with_model() + +test error responses with model + +### Example + +```python +import time +import os +import petstore_api +from petstore_api.rest import ApiException +from pprint import pprint + +# Defining the host is optional and defaults to http://petstore.swagger.io:80/v2 +# See configuration.py for a list of all supported configuration parameters. +configuration = petstore_api.Configuration( + host = "http://petstore.swagger.io:80/v2" +) + + +# Enter a context with an instance of the API client +with petstore_api.ApiClient(configuration) as api_client: + # Create an instance of the API class + api_instance = petstore_api.FakeApi(api_client) + + try: + # test error responses with model + api_instance.test_error_responses_with_model() + except Exception as e: + print("Exception when calling FakeApi->test_error_responses_with_model: %s\n" % e) +``` + + + +### Parameters +This endpoint does not need any parameter. + +### Return type + +void (empty response body) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/json + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +**204** | Success, but no response content | - | +**400** | | - | +**404** | | - | + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + # **test_group_parameters** > test_group_parameters(required_string_group, required_boolean_group, required_int64_group, string_group=string_group, boolean_group=boolean_group, int64_group=int64_group) diff --git a/samples/openapi3/client/petstore/python-pydantic-v1/docs/TestErrorResponsesWithModel400Response.md b/samples/openapi3/client/petstore/python-pydantic-v1/docs/TestErrorResponsesWithModel400Response.md new file mode 100644 index 00000000000..1ef43ce4cad --- /dev/null +++ b/samples/openapi3/client/petstore/python-pydantic-v1/docs/TestErrorResponsesWithModel400Response.md @@ -0,0 +1,28 @@ +# TestErrorResponsesWithModel400Response + + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**reason400** | **str** | | [optional] + +## Example + +```python +from petstore_api.models.test_error_responses_with_model400_response import TestErrorResponsesWithModel400Response + +# TODO update the JSON string below +json = "{}" +# create an instance of TestErrorResponsesWithModel400Response from a JSON string +test_error_responses_with_model400_response_instance = TestErrorResponsesWithModel400Response.from_json(json) +# print the JSON string representation of the object +print TestErrorResponsesWithModel400Response.to_json() + +# convert the object into a dict +test_error_responses_with_model400_response_dict = test_error_responses_with_model400_response_instance.to_dict() +# create an instance of TestErrorResponsesWithModel400Response from a dict +test_error_responses_with_model400_response_form_dict = test_error_responses_with_model400_response.from_dict(test_error_responses_with_model400_response_dict) +``` +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/samples/openapi3/client/petstore/python-pydantic-v1/docs/TestErrorResponsesWithModel404Response.md b/samples/openapi3/client/petstore/python-pydantic-v1/docs/TestErrorResponsesWithModel404Response.md new file mode 100644 index 00000000000..9fda9553784 --- /dev/null +++ b/samples/openapi3/client/petstore/python-pydantic-v1/docs/TestErrorResponsesWithModel404Response.md @@ -0,0 +1,28 @@ +# TestErrorResponsesWithModel404Response + + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**reason404** | **str** | | [optional] + +## Example + +```python +from petstore_api.models.test_error_responses_with_model404_response import TestErrorResponsesWithModel404Response + +# TODO update the JSON string below +json = "{}" +# create an instance of TestErrorResponsesWithModel404Response from a JSON string +test_error_responses_with_model404_response_instance = TestErrorResponsesWithModel404Response.from_json(json) +# print the JSON string representation of the object +print TestErrorResponsesWithModel404Response.to_json() + +# convert the object into a dict +test_error_responses_with_model404_response_dict = test_error_responses_with_model404_response_instance.to_dict() +# create an instance of TestErrorResponsesWithModel404Response from a dict +test_error_responses_with_model404_response_form_dict = test_error_responses_with_model404_response.from_dict(test_error_responses_with_model404_response_dict) +``` +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/samples/openapi3/client/petstore/python-pydantic-v1/petstore_api/__init__.py b/samples/openapi3/client/petstore/python-pydantic-v1/petstore_api/__init__.py index c1c56eb8115..72d39b9c55e 100644 --- a/samples/openapi3/client/petstore/python-pydantic-v1/petstore_api/__init__.py +++ b/samples/openapi3/client/petstore/python-pydantic-v1/petstore_api/__init__.py @@ -113,6 +113,8 @@ from petstore_api.models.special_character_enum import SpecialCharacterEnum from petstore_api.models.special_model_name import SpecialModelName from petstore_api.models.special_name import SpecialName from petstore_api.models.tag import Tag +from petstore_api.models.test_error_responses_with_model400_response import TestErrorResponsesWithModel400Response +from petstore_api.models.test_error_responses_with_model404_response import TestErrorResponsesWithModel404Response from petstore_api.models.test_inline_freeform_additional_properties_request import TestInlineFreeformAdditionalPropertiesRequest from petstore_api.models.tiger import Tiger from petstore_api.models.unnamed_dict_with_additional_model_list_properties import UnnamedDictWithAdditionalModelListProperties diff --git a/samples/openapi3/client/petstore/python-pydantic-v1/petstore_api/api/fake_api.py b/samples/openapi3/client/petstore/python-pydantic-v1/petstore_api/api/fake_api.py index a5c02f94ab7..35f06ac5b91 100644 --- a/samples/openapi3/client/petstore/python-pydantic-v1/petstore_api/api/fake_api.py +++ b/samples/openapi3/client/petstore/python-pydantic-v1/petstore_api/api/fake_api.py @@ -2333,6 +2333,136 @@ class FakeApi: collection_formats=_collection_formats, _request_auth=_params.get('_request_auth')) + @validate_arguments + def test_empty_and_non_empty_responses(self, **kwargs) -> None: # noqa: E501 + """test empty and non-empty responses # noqa: E501 + + # noqa: E501 + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please pass async_req=True + + >>> thread = api.test_empty_and_non_empty_responses(async_req=True) + >>> result = thread.get() + + :param async_req: Whether to execute the request asynchronously. + :type async_req: bool, optional + :param _request_timeout: timeout setting for this request. + If one number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :return: Returns the result object. + If the method is called asynchronously, + returns the request thread. + :rtype: None + """ + kwargs['_return_http_data_only'] = True + if '_preload_content' in kwargs: + message = "Error! Please call the test_empty_and_non_empty_responses_with_http_info method with `_preload_content` instead and obtain raw data from ApiResponse.raw_data" # noqa: E501 + raise ValueError(message) + return self.test_empty_and_non_empty_responses_with_http_info(**kwargs) # noqa: E501 + + @validate_arguments + def test_empty_and_non_empty_responses_with_http_info(self, **kwargs) -> ApiResponse: # noqa: E501 + """test empty and non-empty responses # noqa: E501 + + # noqa: E501 + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please pass async_req=True + + >>> thread = api.test_empty_and_non_empty_responses_with_http_info(async_req=True) + >>> result = thread.get() + + :param async_req: Whether to execute the request asynchronously. + :type async_req: bool, optional + :param _preload_content: if False, the ApiResponse.data will + be set to none and raw_data will store the + HTTP response body without reading/decoding. + Default is True. + :type _preload_content: bool, optional + :param _return_http_data_only: response data instead of ApiResponse + object with status code, headers, etc + :type _return_http_data_only: bool, optional + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the authentication + in the spec for a single request. + :type _request_auth: dict, optional + :type _content_type: string, optional: force content-type for the request + :return: Returns the result object. + If the method is called asynchronously, + returns the request thread. + :rtype: None + """ + + _params = locals() + + _all_params = [ + ] + _all_params.extend( + [ + 'async_req', + '_return_http_data_only', + '_preload_content', + '_request_timeout', + '_request_auth', + '_content_type', + '_headers' + ] + ) + + # validate the arguments + for _key, _val in _params['kwargs'].items(): + if _key not in _all_params: + raise ApiTypeError( + "Got an unexpected keyword argument '%s'" + " to method test_empty_and_non_empty_responses" % _key + ) + _params[_key] = _val + del _params['kwargs'] + + _collection_formats = {} + + # process the path parameters + _path_params = {} + + # process the query parameters + _query_params = [] + # process the header parameters + _header_params = dict(_params.get('_headers', {})) + # process the form parameters + _form_params = [] + _files = {} + # process the body parameter + _body_params = None + # set the HTTP header `Accept` + _header_params['Accept'] = self.api_client.select_header_accept( + ['text/plain']) # noqa: E501 + + # authentication setting + _auth_settings = [] # noqa: E501 + + _response_types_map = {} + + return self.api_client.call_api( + '/fake/empty_and_non_empty_responses', 'POST', + _path_params, + _query_params, + _header_params, + body=_body_params, + post_params=_form_params, + files=_files, + response_types_map=_response_types_map, + auth_settings=_auth_settings, + async_req=_params.get('async_req'), + _return_http_data_only=_params.get('_return_http_data_only'), # noqa: E501 + _preload_content=_params.get('_preload_content', True), + _request_timeout=_params.get('_request_timeout'), + collection_formats=_collection_formats, + _request_auth=_params.get('_request_auth')) + @validate_arguments def test_endpoint_parameters(self, number : Annotated[confloat(le=543.2, ge=32.1, strict=True), Field(..., description="None")], double : Annotated[confloat(le=123.4, ge=67.8, strict=True), Field(..., description="None")], pattern_without_delimiter : Annotated[constr(strict=True), Field(..., description="None")], byte : Annotated[Union[StrictBytes, StrictStr], Field(..., description="None")], integer : Annotated[Optional[conint(strict=True, le=100, ge=10)], Field(description="None")] = None, int32 : Annotated[Optional[conint(strict=True, le=200, ge=20)], Field(description="None")] = None, int64 : Annotated[Optional[StrictInt], Field(description="None")] = None, float : Annotated[Optional[confloat(le=987.6, strict=True)], Field(description="None")] = None, string : Annotated[Optional[constr(strict=True)], Field(description="None")] = None, binary : Annotated[Optional[Union[StrictBytes, StrictStr]], Field(description="None")] = None, byte_with_max_length : Annotated[Optional[Union[conbytes(strict=True, max_length=64), constr(strict=True, max_length=64)]], Field(description="None")] = None, var_date : Annotated[Optional[date], Field(description="None")] = None, date_time : Annotated[Optional[datetime], Field(description="None")] = None, password : Annotated[Optional[constr(strict=True, max_length=64, min_length=10)], Field(description="None")] = None, param_callback : Annotated[Optional[StrictStr], Field(description="None")] = None, **kwargs) -> None: # noqa: E501 """Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 # noqa: E501 @@ -2586,6 +2716,134 @@ class FakeApi: collection_formats=_collection_formats, _request_auth=_params.get('_request_auth')) + @validate_arguments + def test_error_responses_with_model(self, **kwargs) -> None: # noqa: E501 + """test error responses with model # noqa: E501 + + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please pass async_req=True + + >>> thread = api.test_error_responses_with_model(async_req=True) + >>> result = thread.get() + + :param async_req: Whether to execute the request asynchronously. + :type async_req: bool, optional + :param _request_timeout: timeout setting for this request. + If one number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :return: Returns the result object. + If the method is called asynchronously, + returns the request thread. + :rtype: None + """ + kwargs['_return_http_data_only'] = True + if '_preload_content' in kwargs: + message = "Error! Please call the test_error_responses_with_model_with_http_info method with `_preload_content` instead and obtain raw data from ApiResponse.raw_data" # noqa: E501 + raise ValueError(message) + return self.test_error_responses_with_model_with_http_info(**kwargs) # noqa: E501 + + @validate_arguments + def test_error_responses_with_model_with_http_info(self, **kwargs) -> ApiResponse: # noqa: E501 + """test error responses with model # noqa: E501 + + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please pass async_req=True + + >>> thread = api.test_error_responses_with_model_with_http_info(async_req=True) + >>> result = thread.get() + + :param async_req: Whether to execute the request asynchronously. + :type async_req: bool, optional + :param _preload_content: if False, the ApiResponse.data will + be set to none and raw_data will store the + HTTP response body without reading/decoding. + Default is True. + :type _preload_content: bool, optional + :param _return_http_data_only: response data instead of ApiResponse + object with status code, headers, etc + :type _return_http_data_only: bool, optional + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the authentication + in the spec for a single request. + :type _request_auth: dict, optional + :type _content_type: string, optional: force content-type for the request + :return: Returns the result object. + If the method is called asynchronously, + returns the request thread. + :rtype: None + """ + + _params = locals() + + _all_params = [ + ] + _all_params.extend( + [ + 'async_req', + '_return_http_data_only', + '_preload_content', + '_request_timeout', + '_request_auth', + '_content_type', + '_headers' + ] + ) + + # validate the arguments + for _key, _val in _params['kwargs'].items(): + if _key not in _all_params: + raise ApiTypeError( + "Got an unexpected keyword argument '%s'" + " to method test_error_responses_with_model" % _key + ) + _params[_key] = _val + del _params['kwargs'] + + _collection_formats = {} + + # process the path parameters + _path_params = {} + + # process the query parameters + _query_params = [] + # process the header parameters + _header_params = dict(_params.get('_headers', {})) + # process the form parameters + _form_params = [] + _files = {} + # process the body parameter + _body_params = None + # set the HTTP header `Accept` + _header_params['Accept'] = self.api_client.select_header_accept( + ['application/json']) # noqa: E501 + + # authentication setting + _auth_settings = [] # noqa: E501 + + _response_types_map = {} + + return self.api_client.call_api( + '/fake/error_responses_with_model', 'POST', + _path_params, + _query_params, + _header_params, + body=_body_params, + post_params=_form_params, + files=_files, + response_types_map=_response_types_map, + auth_settings=_auth_settings, + async_req=_params.get('async_req'), + _return_http_data_only=_params.get('_return_http_data_only'), # noqa: E501 + _preload_content=_params.get('_preload_content', True), + _request_timeout=_params.get('_request_timeout'), + collection_formats=_collection_formats, + _request_auth=_params.get('_request_auth')) + @validate_arguments def test_group_parameters(self, required_string_group : Annotated[StrictInt, Field(..., description="Required String in group parameters")], required_boolean_group : Annotated[StrictBool, Field(..., description="Required Boolean in group parameters")], required_int64_group : Annotated[StrictInt, Field(..., description="Required Integer in group parameters")], string_group : Annotated[Optional[StrictInt], Field(description="String in group parameters")] = None, boolean_group : Annotated[Optional[StrictBool], Field(description="Boolean in group parameters")] = None, int64_group : Annotated[Optional[StrictInt], Field(description="Integer in group parameters")] = None, **kwargs) -> None: # noqa: E501 """Fake endpoint to test group parameters (optional) # noqa: E501 diff --git a/samples/openapi3/client/petstore/python-pydantic-v1/petstore_api/models/__init__.py b/samples/openapi3/client/petstore/python-pydantic-v1/petstore_api/models/__init__.py index dd9388d355d..c106409daa9 100644 --- a/samples/openapi3/client/petstore/python-pydantic-v1/petstore_api/models/__init__.py +++ b/samples/openapi3/client/petstore/python-pydantic-v1/petstore_api/models/__init__.py @@ -89,6 +89,8 @@ from petstore_api.models.special_character_enum import SpecialCharacterEnum from petstore_api.models.special_model_name import SpecialModelName from petstore_api.models.special_name import SpecialName from petstore_api.models.tag import Tag +from petstore_api.models.test_error_responses_with_model400_response import TestErrorResponsesWithModel400Response +from petstore_api.models.test_error_responses_with_model404_response import TestErrorResponsesWithModel404Response from petstore_api.models.test_inline_freeform_additional_properties_request import TestInlineFreeformAdditionalPropertiesRequest from petstore_api.models.tiger import Tiger from petstore_api.models.unnamed_dict_with_additional_model_list_properties import UnnamedDictWithAdditionalModelListProperties diff --git a/samples/openapi3/client/petstore/python-pydantic-v1/petstore_api/models/test_error_responses_with_model400_response.py b/samples/openapi3/client/petstore/python-pydantic-v1/petstore_api/models/test_error_responses_with_model400_response.py new file mode 100644 index 00000000000..40855d008cc --- /dev/null +++ b/samples/openapi3/client/petstore/python-pydantic-v1/petstore_api/models/test_error_responses_with_model400_response.py @@ -0,0 +1,83 @@ +# coding: utf-8 + +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + + The version of the OpenAPI document: 1.0.0 + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + + +from typing import Any, Dict, Optional +from pydantic import BaseModel, StrictStr + +class TestErrorResponsesWithModel400Response(BaseModel): + """ + TestErrorResponsesWithModel400Response + """ + reason400: Optional[StrictStr] = None + additional_properties: Dict[str, Any] = {} + __properties = ["reason400"] + + class Config: + """Pydantic configuration""" + allow_population_by_field_name = True + validate_assignment = True + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.dict(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> TestErrorResponsesWithModel400Response: + """Create an instance of TestErrorResponsesWithModel400Response from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self): + """Returns the dictionary representation of the model using alias""" + _dict = self.dict(by_alias=True, + exclude={ + "additional_properties" + }, + exclude_none=True) + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: dict) -> TestErrorResponsesWithModel400Response: + """Create an instance of TestErrorResponsesWithModel400Response from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return TestErrorResponsesWithModel400Response.parse_obj(obj) + + _obj = TestErrorResponsesWithModel400Response.parse_obj({ + "reason400": obj.get("reason400") + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/samples/openapi3/client/petstore/python-pydantic-v1/petstore_api/models/test_error_responses_with_model404_response.py b/samples/openapi3/client/petstore/python-pydantic-v1/petstore_api/models/test_error_responses_with_model404_response.py new file mode 100644 index 00000000000..77c77d903f5 --- /dev/null +++ b/samples/openapi3/client/petstore/python-pydantic-v1/petstore_api/models/test_error_responses_with_model404_response.py @@ -0,0 +1,83 @@ +# coding: utf-8 + +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + + The version of the OpenAPI document: 1.0.0 + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + + +from typing import Any, Dict, Optional +from pydantic import BaseModel, StrictStr + +class TestErrorResponsesWithModel404Response(BaseModel): + """ + TestErrorResponsesWithModel404Response + """ + reason404: Optional[StrictStr] = None + additional_properties: Dict[str, Any] = {} + __properties = ["reason404"] + + class Config: + """Pydantic configuration""" + allow_population_by_field_name = True + validate_assignment = True + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.dict(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> TestErrorResponsesWithModel404Response: + """Create an instance of TestErrorResponsesWithModel404Response from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self): + """Returns the dictionary representation of the model using alias""" + _dict = self.dict(by_alias=True, + exclude={ + "additional_properties" + }, + exclude_none=True) + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: dict) -> TestErrorResponsesWithModel404Response: + """Create an instance of TestErrorResponsesWithModel404Response from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return TestErrorResponsesWithModel404Response.parse_obj(obj) + + _obj = TestErrorResponsesWithModel404Response.parse_obj({ + "reason404": obj.get("reason404") + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/samples/openapi3/client/petstore/python-pydantic-v1/test/test_test_error_responses_with_model400_response.py b/samples/openapi3/client/petstore/python-pydantic-v1/test/test_test_error_responses_with_model400_response.py new file mode 100644 index 00000000000..b4e2d50dc6f --- /dev/null +++ b/samples/openapi3/client/petstore/python-pydantic-v1/test/test_test_error_responses_with_model400_response.py @@ -0,0 +1,52 @@ +# coding: utf-8 + +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + + The version of the OpenAPI document: 1.0.0 + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +import unittest +import datetime + +from petstore_api.models.test_error_responses_with_model400_response import TestErrorResponsesWithModel400Response # noqa: E501 + +class TestTestErrorResponsesWithModel400Response(unittest.TestCase): + """TestErrorResponsesWithModel400Response unit test stubs""" + + def setUp(self): + pass + + def tearDown(self): + pass + + def make_instance(self, include_optional) -> TestErrorResponsesWithModel400Response: + """Test TestErrorResponsesWithModel400Response + include_option is a boolean, when False only required + params are included, when True both required and + optional params are included """ + # uncomment below to create an instance of `TestErrorResponsesWithModel400Response` + """ + model = TestErrorResponsesWithModel400Response() # noqa: E501 + if include_optional: + return TestErrorResponsesWithModel400Response( + reason400 = '' + ) + else: + return TestErrorResponsesWithModel400Response( + ) + """ + + def testTestErrorResponsesWithModel400Response(self): + """Test TestErrorResponsesWithModel400Response""" + # inst_req_only = self.make_instance(include_optional=False) + # inst_req_and_optional = self.make_instance(include_optional=True) + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/petstore/python-pydantic-v1/test/test_test_error_responses_with_model404_response.py b/samples/openapi3/client/petstore/python-pydantic-v1/test/test_test_error_responses_with_model404_response.py new file mode 100644 index 00000000000..caf587ddb03 --- /dev/null +++ b/samples/openapi3/client/petstore/python-pydantic-v1/test/test_test_error_responses_with_model404_response.py @@ -0,0 +1,52 @@ +# coding: utf-8 + +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + + The version of the OpenAPI document: 1.0.0 + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +import unittest +import datetime + +from petstore_api.models.test_error_responses_with_model404_response import TestErrorResponsesWithModel404Response # noqa: E501 + +class TestTestErrorResponsesWithModel404Response(unittest.TestCase): + """TestErrorResponsesWithModel404Response unit test stubs""" + + def setUp(self): + pass + + def tearDown(self): + pass + + def make_instance(self, include_optional) -> TestErrorResponsesWithModel404Response: + """Test TestErrorResponsesWithModel404Response + include_option is a boolean, when False only required + params are included, when True both required and + optional params are included """ + # uncomment below to create an instance of `TestErrorResponsesWithModel404Response` + """ + model = TestErrorResponsesWithModel404Response() # noqa: E501 + if include_optional: + return TestErrorResponsesWithModel404Response( + reason404 = '' + ) + else: + return TestErrorResponsesWithModel404Response( + ) + """ + + def testTestErrorResponsesWithModel404Response(self): + """Test TestErrorResponsesWithModel404Response""" + # inst_req_only = self.make_instance(include_optional=False) + # inst_req_and_optional = self.make_instance(include_optional=True) + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/petstore/python/.openapi-generator/FILES b/samples/openapi3/client/petstore/python/.openapi-generator/FILES index ff22e285512..06be01a3bab 100755 --- a/samples/openapi3/client/petstore/python/.openapi-generator/FILES +++ b/samples/openapi3/client/petstore/python/.openapi-generator/FILES @@ -84,6 +84,8 @@ docs/SpecialModelName.md docs/SpecialName.md docs/StoreApi.md docs/Tag.md +docs/TestErrorResponsesWithModel400Response.md +docs/TestErrorResponsesWithModel404Response.md docs/TestInlineFreeformAdditionalPropertiesRequest.md docs/Tiger.md docs/UnnamedDictWithAdditionalModelListProperties.md @@ -181,6 +183,8 @@ petstore_api/models/special_character_enum.py petstore_api/models/special_model_name.py petstore_api/models/special_name.py petstore_api/models/tag.py +petstore_api/models/test_error_responses_with_model400_response.py +petstore_api/models/test_error_responses_with_model404_response.py petstore_api/models/test_inline_freeform_additional_properties_request.py petstore_api/models/tiger.py petstore_api/models/unnamed_dict_with_additional_model_list_properties.py diff --git a/samples/openapi3/client/petstore/python/README.md b/samples/openapi3/client/petstore/python/README.md index cf91d3ad0ce..5555cd3d60b 100755 --- a/samples/openapi3/client/petstore/python/README.md +++ b/samples/openapi3/client/petstore/python/README.md @@ -103,7 +103,9 @@ Class | Method | HTTP request | Description *FakeApi* | [**test_body_with_query_params**](docs/FakeApi.md#test_body_with_query_params) | **PUT** /fake/body-with-query-params | *FakeApi* | [**test_client_model**](docs/FakeApi.md#test_client_model) | **PATCH** /fake | To test \"client\" model *FakeApi* | [**test_date_time_query_parameter**](docs/FakeApi.md#test_date_time_query_parameter) | **PUT** /fake/date-time-query-params | +*FakeApi* | [**test_empty_and_non_empty_responses**](docs/FakeApi.md#test_empty_and_non_empty_responses) | **POST** /fake/empty_and_non_empty_responses | test empty and non-empty responses *FakeApi* | [**test_endpoint_parameters**](docs/FakeApi.md#test_endpoint_parameters) | **POST** /fake | Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 +*FakeApi* | [**test_error_responses_with_model**](docs/FakeApi.md#test_error_responses_with_model) | **POST** /fake/error_responses_with_model | test error responses with model *FakeApi* | [**test_group_parameters**](docs/FakeApi.md#test_group_parameters) | **DELETE** /fake | Fake endpoint to test group parameters (optional) *FakeApi* | [**test_inline_additional_properties**](docs/FakeApi.md#test_inline_additional_properties) | **POST** /fake/inline-additionalProperties | test inline additionalProperties *FakeApi* | [**test_inline_freeform_additional_properties**](docs/FakeApi.md#test_inline_freeform_additional_properties) | **POST** /fake/inline-freeform-additionalProperties | test inline free-form additionalProperties @@ -210,6 +212,8 @@ Class | Method | HTTP request | Description - [SpecialModelName](docs/SpecialModelName.md) - [SpecialName](docs/SpecialName.md) - [Tag](docs/Tag.md) + - [TestErrorResponsesWithModel400Response](docs/TestErrorResponsesWithModel400Response.md) + - [TestErrorResponsesWithModel404Response](docs/TestErrorResponsesWithModel404Response.md) - [TestInlineFreeformAdditionalPropertiesRequest](docs/TestInlineFreeformAdditionalPropertiesRequest.md) - [Tiger](docs/Tiger.md) - [UnnamedDictWithAdditionalModelListProperties](docs/UnnamedDictWithAdditionalModelListProperties.md) diff --git a/samples/openapi3/client/petstore/python/docs/FakeApi.md b/samples/openapi3/client/petstore/python/docs/FakeApi.md index 4a998d2c062..1038655b193 100644 --- a/samples/openapi3/client/petstore/python/docs/FakeApi.md +++ b/samples/openapi3/client/petstore/python/docs/FakeApi.md @@ -20,7 +20,9 @@ Method | HTTP request | Description [**test_body_with_query_params**](FakeApi.md#test_body_with_query_params) | **PUT** /fake/body-with-query-params | [**test_client_model**](FakeApi.md#test_client_model) | **PATCH** /fake | To test \"client\" model [**test_date_time_query_parameter**](FakeApi.md#test_date_time_query_parameter) | **PUT** /fake/date-time-query-params | +[**test_empty_and_non_empty_responses**](FakeApi.md#test_empty_and_non_empty_responses) | **POST** /fake/empty_and_non_empty_responses | test empty and non-empty responses [**test_endpoint_parameters**](FakeApi.md#test_endpoint_parameters) | **POST** /fake | Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 +[**test_error_responses_with_model**](FakeApi.md#test_error_responses_with_model) | **POST** /fake/error_responses_with_model | test error responses with model [**test_group_parameters**](FakeApi.md#test_group_parameters) | **DELETE** /fake | Fake endpoint to test group parameters (optional) [**test_inline_additional_properties**](FakeApi.md#test_inline_additional_properties) | **POST** /fake/inline-additionalProperties | test inline additionalProperties [**test_inline_freeform_additional_properties**](FakeApi.md#test_inline_freeform_additional_properties) | **POST** /fake/inline-freeform-additionalProperties | test inline free-form additionalProperties @@ -1119,6 +1121,67 @@ No authorization required [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) +# **test_empty_and_non_empty_responses** +> test_empty_and_non_empty_responses() + +test empty and non-empty responses + + + +### Example + +```python +import time +import os +import petstore_api +from petstore_api.rest import ApiException +from pprint import pprint + +# Defining the host is optional and defaults to http://petstore.swagger.io:80/v2 +# See configuration.py for a list of all supported configuration parameters. +configuration = petstore_api.Configuration( + host = "http://petstore.swagger.io:80/v2" +) + + +# Enter a context with an instance of the API client +with petstore_api.ApiClient(configuration) as api_client: + # Create an instance of the API class + api_instance = petstore_api.FakeApi(api_client) + + try: + # test empty and non-empty responses + api_instance.test_empty_and_non_empty_responses() + except Exception as e: + print("Exception when calling FakeApi->test_empty_and_non_empty_responses: %s\n" % e) +``` + + + +### Parameters +This endpoint does not need any parameter. + +### Return type + +void (empty response body) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: text/plain + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +**204** | Success, but no response content | - | +**206** | Partial response content | - | + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + # **test_endpoint_parameters** > test_endpoint_parameters(number, double, pattern_without_delimiter, byte, integer=integer, int32=int32, int64=int64, var_float=var_float, string=string, binary=binary, byte_with_max_length=byte_with_max_length, var_date=var_date, date_time=date_time, password=password, param_callback=param_callback) @@ -1223,6 +1286,66 @@ void (empty response body) [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) +# **test_error_responses_with_model** +> test_error_responses_with_model() + +test error responses with model + +### Example + +```python +import time +import os +import petstore_api +from petstore_api.rest import ApiException +from pprint import pprint + +# Defining the host is optional and defaults to http://petstore.swagger.io:80/v2 +# See configuration.py for a list of all supported configuration parameters. +configuration = petstore_api.Configuration( + host = "http://petstore.swagger.io:80/v2" +) + + +# Enter a context with an instance of the API client +with petstore_api.ApiClient(configuration) as api_client: + # Create an instance of the API class + api_instance = petstore_api.FakeApi(api_client) + + try: + # test error responses with model + api_instance.test_error_responses_with_model() + except Exception as e: + print("Exception when calling FakeApi->test_error_responses_with_model: %s\n" % e) +``` + + + +### Parameters +This endpoint does not need any parameter. + +### Return type + +void (empty response body) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/json + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +**204** | Success, but no response content | - | +**400** | | - | +**404** | | - | + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + # **test_group_parameters** > test_group_parameters(required_string_group, required_boolean_group, required_int64_group, string_group=string_group, boolean_group=boolean_group, int64_group=int64_group) diff --git a/samples/openapi3/client/petstore/python/docs/TestErrorResponsesWithModel400Response.md b/samples/openapi3/client/petstore/python/docs/TestErrorResponsesWithModel400Response.md new file mode 100644 index 00000000000..1ef43ce4cad --- /dev/null +++ b/samples/openapi3/client/petstore/python/docs/TestErrorResponsesWithModel400Response.md @@ -0,0 +1,28 @@ +# TestErrorResponsesWithModel400Response + + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**reason400** | **str** | | [optional] + +## Example + +```python +from petstore_api.models.test_error_responses_with_model400_response import TestErrorResponsesWithModel400Response + +# TODO update the JSON string below +json = "{}" +# create an instance of TestErrorResponsesWithModel400Response from a JSON string +test_error_responses_with_model400_response_instance = TestErrorResponsesWithModel400Response.from_json(json) +# print the JSON string representation of the object +print TestErrorResponsesWithModel400Response.to_json() + +# convert the object into a dict +test_error_responses_with_model400_response_dict = test_error_responses_with_model400_response_instance.to_dict() +# create an instance of TestErrorResponsesWithModel400Response from a dict +test_error_responses_with_model400_response_form_dict = test_error_responses_with_model400_response.from_dict(test_error_responses_with_model400_response_dict) +``` +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/samples/openapi3/client/petstore/python/docs/TestErrorResponsesWithModel404Response.md b/samples/openapi3/client/petstore/python/docs/TestErrorResponsesWithModel404Response.md new file mode 100644 index 00000000000..9fda9553784 --- /dev/null +++ b/samples/openapi3/client/petstore/python/docs/TestErrorResponsesWithModel404Response.md @@ -0,0 +1,28 @@ +# TestErrorResponsesWithModel404Response + + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**reason404** | **str** | | [optional] + +## Example + +```python +from petstore_api.models.test_error_responses_with_model404_response import TestErrorResponsesWithModel404Response + +# TODO update the JSON string below +json = "{}" +# create an instance of TestErrorResponsesWithModel404Response from a JSON string +test_error_responses_with_model404_response_instance = TestErrorResponsesWithModel404Response.from_json(json) +# print the JSON string representation of the object +print TestErrorResponsesWithModel404Response.to_json() + +# convert the object into a dict +test_error_responses_with_model404_response_dict = test_error_responses_with_model404_response_instance.to_dict() +# create an instance of TestErrorResponsesWithModel404Response from a dict +test_error_responses_with_model404_response_form_dict = test_error_responses_with_model404_response.from_dict(test_error_responses_with_model404_response_dict) +``` +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/samples/openapi3/client/petstore/python/petstore_api/__init__.py b/samples/openapi3/client/petstore/python/petstore_api/__init__.py index c1c56eb8115..72d39b9c55e 100755 --- a/samples/openapi3/client/petstore/python/petstore_api/__init__.py +++ b/samples/openapi3/client/petstore/python/petstore_api/__init__.py @@ -113,6 +113,8 @@ from petstore_api.models.special_character_enum import SpecialCharacterEnum from petstore_api.models.special_model_name import SpecialModelName from petstore_api.models.special_name import SpecialName from petstore_api.models.tag import Tag +from petstore_api.models.test_error_responses_with_model400_response import TestErrorResponsesWithModel400Response +from petstore_api.models.test_error_responses_with_model404_response import TestErrorResponsesWithModel404Response from petstore_api.models.test_inline_freeform_additional_properties_request import TestInlineFreeformAdditionalPropertiesRequest from petstore_api.models.tiger import Tiger from petstore_api.models.unnamed_dict_with_additional_model_list_properties import UnnamedDictWithAdditionalModelListProperties diff --git a/samples/openapi3/client/petstore/python/petstore_api/api/another_fake_api.py b/samples/openapi3/client/petstore/python/petstore_api/api/another_fake_api.py index 9e399b998f9..2ea2e1862c2 100755 --- a/samples/openapi3/client/petstore/python/petstore_api/api/another_fake_api.py +++ b/samples/openapi3/client/petstore/python/petstore_api/api/another_fake_api.py @@ -99,8 +99,7 @@ class AnotherFakeApi: ) _response_types_map: Dict[str, Optional[str]] = { - '200': "Client" - + '200': "Client", } response_data = self.api_client.call_api( *_param, @@ -167,8 +166,7 @@ class AnotherFakeApi: ) _response_types_map: Dict[str, Optional[str]] = { - '200': "Client" - + '200': "Client", } response_data = self.api_client.call_api( *_param, @@ -235,8 +233,7 @@ class AnotherFakeApi: ) _response_types_map: Dict[str, Optional[str]] = { - '200': "Client" - + '200': "Client", } response_data = self.api_client.call_api( *_param, diff --git a/samples/openapi3/client/petstore/python/petstore_api/api/default_api.py b/samples/openapi3/client/petstore/python/petstore_api/api/default_api.py index d18bd3f1235..2c54019d9ea 100755 --- a/samples/openapi3/client/petstore/python/petstore_api/api/default_api.py +++ b/samples/openapi3/client/petstore/python/petstore_api/api/default_api.py @@ -92,8 +92,6 @@ class DefaultApi: ) _response_types_map: Dict[str, Optional[str]] = { - - } response_data = self.api_client.call_api( *_param, @@ -155,8 +153,6 @@ class DefaultApi: ) _response_types_map: Dict[str, Optional[str]] = { - - } response_data = self.api_client.call_api( *_param, @@ -218,8 +214,6 @@ class DefaultApi: ) _response_types_map: Dict[str, Optional[str]] = { - - } response_data = self.api_client.call_api( *_param, diff --git a/samples/openapi3/client/petstore/python/petstore_api/api/fake_api.py b/samples/openapi3/client/petstore/python/petstore_api/api/fake_api.py index 324351cf68e..687cd8287d9 100755 --- a/samples/openapi3/client/petstore/python/petstore_api/api/fake_api.py +++ b/samples/openapi3/client/petstore/python/petstore_api/api/fake_api.py @@ -113,7 +113,7 @@ class FakeApi: ) _response_types_map: Dict[str, Optional[str]] = { - + '200': None, } response_data = self.api_client.call_api( *_param, @@ -179,7 +179,7 @@ class FakeApi: ) _response_types_map: Dict[str, Optional[str]] = { - + '200': None, } response_data = self.api_client.call_api( *_param, @@ -245,7 +245,7 @@ class FakeApi: ) _response_types_map: Dict[str, Optional[str]] = { - + '200': None, } response_data = self.api_client.call_api( *_param, @@ -375,7 +375,7 @@ class FakeApi: ) _response_types_map: Dict[str, Optional[str]] = { - + '200': None, } response_data = self.api_client.call_api( *_param, @@ -441,7 +441,7 @@ class FakeApi: ) _response_types_map: Dict[str, Optional[str]] = { - + '200': None, } response_data = self.api_client.call_api( *_param, @@ -507,7 +507,7 @@ class FakeApi: ) _response_types_map: Dict[str, Optional[str]] = { - + '200': None, } response_data = self.api_client.call_api( *_param, @@ -622,8 +622,7 @@ class FakeApi: ) _response_types_map: Dict[str, Optional[str]] = { - '200': "HealthCheckResult" - + '200': "HealthCheckResult", } response_data = self.api_client.call_api( *_param, @@ -685,8 +684,7 @@ class FakeApi: ) _response_types_map: Dict[str, Optional[str]] = { - '200': "HealthCheckResult" - + '200': "HealthCheckResult", } response_data = self.api_client.call_api( *_param, @@ -748,8 +746,7 @@ class FakeApi: ) _response_types_map: Dict[str, Optional[str]] = { - '200': "HealthCheckResult" - + '200': "HealthCheckResult", } response_data = self.api_client.call_api( *_param, @@ -877,7 +874,7 @@ class FakeApi: ) _response_types_map: Dict[str, Optional[str]] = { - + '200': None, } response_data = self.api_client.call_api( *_param, @@ -951,7 +948,7 @@ class FakeApi: ) _response_types_map: Dict[str, Optional[str]] = { - + '200': None, } response_data = self.api_client.call_api( *_param, @@ -1025,7 +1022,7 @@ class FakeApi: ) _response_types_map: Dict[str, Optional[str]] = { - + '200': None, } response_data = self.api_client.call_api( *_param, @@ -1166,8 +1163,7 @@ class FakeApi: ) _response_types_map: Dict[str, Optional[str]] = { - '200': "bool" - + '200': "bool", } response_data = self.api_client.call_api( *_param, @@ -1234,8 +1230,7 @@ class FakeApi: ) _response_types_map: Dict[str, Optional[str]] = { - '200': "bool" - + '200': "bool", } response_data = self.api_client.call_api( *_param, @@ -1302,8 +1297,7 @@ class FakeApi: ) _response_types_map: Dict[str, Optional[str]] = { - '200': "bool" - + '200': "bool", } response_data = self.api_client.call_api( *_param, @@ -1440,8 +1434,7 @@ class FakeApi: ) _response_types_map: Dict[str, Optional[str]] = { - '200': "OuterComposite" - + '200': "OuterComposite", } response_data = self.api_client.call_api( *_param, @@ -1508,8 +1501,7 @@ class FakeApi: ) _response_types_map: Dict[str, Optional[str]] = { - '200': "OuterComposite" - + '200': "OuterComposite", } response_data = self.api_client.call_api( *_param, @@ -1576,8 +1568,7 @@ class FakeApi: ) _response_types_map: Dict[str, Optional[str]] = { - '200': "OuterComposite" - + '200': "OuterComposite", } response_data = self.api_client.call_api( *_param, @@ -1714,8 +1705,7 @@ class FakeApi: ) _response_types_map: Dict[str, Optional[str]] = { - '200': "float" - + '200': "float", } response_data = self.api_client.call_api( *_param, @@ -1782,8 +1772,7 @@ class FakeApi: ) _response_types_map: Dict[str, Optional[str]] = { - '200': "float" - + '200': "float", } response_data = self.api_client.call_api( *_param, @@ -1850,8 +1839,7 @@ class FakeApi: ) _response_types_map: Dict[str, Optional[str]] = { - '200': "float" - + '200': "float", } response_data = self.api_client.call_api( *_param, @@ -1988,8 +1976,7 @@ class FakeApi: ) _response_types_map: Dict[str, Optional[str]] = { - '200': "str" - + '200': "str", } response_data = self.api_client.call_api( *_param, @@ -2056,8 +2043,7 @@ class FakeApi: ) _response_types_map: Dict[str, Optional[str]] = { - '200': "str" - + '200': "str", } response_data = self.api_client.call_api( *_param, @@ -2124,8 +2110,7 @@ class FakeApi: ) _response_types_map: Dict[str, Optional[str]] = { - '200': "str" - + '200': "str", } response_data = self.api_client.call_api( *_param, @@ -2262,8 +2247,7 @@ class FakeApi: ) _response_types_map: Dict[str, Optional[str]] = { - '200': "OuterObjectWithEnumProperty" - + '200': "OuterObjectWithEnumProperty", } response_data = self.api_client.call_api( *_param, @@ -2330,8 +2314,7 @@ class FakeApi: ) _response_types_map: Dict[str, Optional[str]] = { - '200': "OuterObjectWithEnumProperty" - + '200': "OuterObjectWithEnumProperty", } response_data = self.api_client.call_api( *_param, @@ -2398,8 +2381,7 @@ class FakeApi: ) _response_types_map: Dict[str, Optional[str]] = { - '200': "OuterObjectWithEnumProperty" - + '200': "OuterObjectWithEnumProperty", } response_data = self.api_client.call_api( *_param, @@ -2531,8 +2513,7 @@ class FakeApi: ) _response_types_map: Dict[str, Optional[str]] = { - '200': "List[List[Tag]]" - + '200': "List[List[Tag]]", } response_data = self.api_client.call_api( *_param, @@ -2594,8 +2575,7 @@ class FakeApi: ) _response_types_map: Dict[str, Optional[str]] = { - '200': "List[List[Tag]]" - + '200': "List[List[Tag]]", } response_data = self.api_client.call_api( *_param, @@ -2657,8 +2637,7 @@ class FakeApi: ) _response_types_map: Dict[str, Optional[str]] = { - '200': "List[List[Tag]]" - + '200': "List[List[Tag]]", } response_data = self.api_client.call_api( *_param, @@ -2778,7 +2757,7 @@ class FakeApi: ) _response_types_map: Dict[str, Optional[str]] = { - + '200': None, } response_data = self.api_client.call_api( *_param, @@ -2844,7 +2823,7 @@ class FakeApi: ) _response_types_map: Dict[str, Optional[str]] = { - + '200': None, } response_data = self.api_client.call_api( *_param, @@ -2910,7 +2889,7 @@ class FakeApi: ) _response_types_map: Dict[str, Optional[str]] = { - + '200': None, } response_data = self.api_client.call_api( *_param, @@ -3030,7 +3009,7 @@ class FakeApi: ) _response_types_map: Dict[str, Optional[str]] = { - + '200': None, } response_data = self.api_client.call_api( *_param, @@ -3097,7 +3076,7 @@ class FakeApi: ) _response_types_map: Dict[str, Optional[str]] = { - + '200': None, } response_data = self.api_client.call_api( *_param, @@ -3164,7 +3143,7 @@ class FakeApi: ) _response_types_map: Dict[str, Optional[str]] = { - + '200': None, } response_data = self.api_client.call_api( *_param, @@ -3300,7 +3279,7 @@ class FakeApi: ) _response_types_map: Dict[str, Optional[str]] = { - + '200': None, } response_data = self.api_client.call_api( *_param, @@ -3367,7 +3346,7 @@ class FakeApi: ) _response_types_map: Dict[str, Optional[str]] = { - + '200': None, } response_data = self.api_client.call_api( *_param, @@ -3434,7 +3413,7 @@ class FakeApi: ) _response_types_map: Dict[str, Optional[str]] = { - + '200': None, } response_data = self.api_client.call_api( *_param, @@ -3568,7 +3547,7 @@ class FakeApi: ) _response_types_map: Dict[str, Optional[str]] = { - + '200': None, } response_data = self.api_client.call_api( *_param, @@ -3638,7 +3617,7 @@ class FakeApi: ) _response_types_map: Dict[str, Optional[str]] = { - + '200': None, } response_data = self.api_client.call_api( *_param, @@ -3708,7 +3687,7 @@ class FakeApi: ) _response_types_map: Dict[str, Optional[str]] = { - + '200': None, } response_data = self.api_client.call_api( *_param, @@ -3844,8 +3823,7 @@ class FakeApi: ) _response_types_map: Dict[str, Optional[str]] = { - '200': "Client" - + '200': "Client", } response_data = self.api_client.call_api( *_param, @@ -3912,8 +3890,7 @@ class FakeApi: ) _response_types_map: Dict[str, Optional[str]] = { - '200': "Client" - + '200': "Client", } response_data = self.api_client.call_api( *_param, @@ -3980,8 +3957,7 @@ class FakeApi: ) _response_types_map: Dict[str, Optional[str]] = { - '200': "Client" - + '200': "Client", } response_data = self.api_client.call_api( *_param, @@ -4121,7 +4097,7 @@ class FakeApi: ) _response_types_map: Dict[str, Optional[str]] = { - + '200': None, } response_data = self.api_client.call_api( *_param, @@ -4191,7 +4167,7 @@ class FakeApi: ) _response_types_map: Dict[str, Optional[str]] = { - + '200': None, } response_data = self.api_client.call_api( *_param, @@ -4261,7 +4237,7 @@ class FakeApi: ) _response_types_map: Dict[str, Optional[str]] = { - + '200': None, } response_data = self.api_client.call_api( *_param, @@ -4341,6 +4317,252 @@ class FakeApi: + @validate_call + def test_empty_and_non_empty_responses( + self, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> None: + """test empty and non-empty responses + + + + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._test_empty_and_non_empty_responses_serialize( + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '204': None, + '206': "str", + } + response_data = self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ).data + + + @validate_call + def test_empty_and_non_empty_responses_with_http_info( + self, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> ApiResponse[None]: + """test empty and non-empty responses + + + + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._test_empty_and_non_empty_responses_serialize( + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '204': None, + '206': "str", + } + response_data = self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ) + + + @validate_call + def test_empty_and_non_empty_responses_without_preload_content( + self, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> RESTResponseType: + """test empty and non-empty responses + + + + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._test_empty_and_non_empty_responses_serialize( + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '204': None, + '206': "str", + } + response_data = self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + return response_data.response + + + def _test_empty_and_non_empty_responses_serialize( + self, + _request_auth, + _content_type, + _headers, + _host_index, + ) -> Tuple: + + _host = None + + _collection_formats: Dict[str, str] = { + + } + + _path_params: Dict[str, str] = {} + _query_params: List[Tuple[str, str]] = [] + _header_params: Dict[str, Optional[str]] = _headers or {} + _form_params: List[Tuple[str, str]] = [] + _files: Dict[str, str] = {} + _body_params: Optional[bytes] = None + + # process the path parameters + # process the query parameters + # process the header parameters + # process the form parameters + # process the body parameter + + + # set the HTTP header `Accept` + _header_params['Accept'] = self.api_client.select_header_accept( + [ + 'text/plain' + ] + ) + + + # authentication setting + _auth_settings: List[str] = [ + ] + + return self.api_client.param_serialize( + method='POST', + resource_path='/fake/empty_and_non_empty_responses', + path_params=_path_params, + query_params=_query_params, + header_params=_header_params, + body=_body_params, + post_params=_form_params, + files=_files, + auth_settings=_auth_settings, + collection_formats=_collection_formats, + _host=_host, + _request_auth=_request_auth + ) + + + + @validate_call def test_endpoint_parameters( self, @@ -4451,7 +4673,8 @@ class FakeApi: ) _response_types_map: Dict[str, Optional[str]] = { - + '400': None, + '404': None, } response_data = self.api_client.call_api( *_param, @@ -4574,7 +4797,8 @@ class FakeApi: ) _response_types_map: Dict[str, Optional[str]] = { - + '400': None, + '404': None, } response_data = self.api_client.call_api( *_param, @@ -4697,7 +4921,8 @@ class FakeApi: ) _response_types_map: Dict[str, Optional[str]] = { - + '400': None, + '404': None, } response_data = self.api_client.call_api( *_param, @@ -4817,6 +5042,252 @@ class FakeApi: + @validate_call + def test_error_responses_with_model( + self, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> None: + """test error responses with model + + + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._test_error_responses_with_model_serialize( + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '204': None, + '400': "TestErrorResponsesWithModel400Response", + '404': "TestErrorResponsesWithModel404Response", + } + response_data = self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ).data + + + @validate_call + def test_error_responses_with_model_with_http_info( + self, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> ApiResponse[None]: + """test error responses with model + + + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._test_error_responses_with_model_serialize( + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '204': None, + '400': "TestErrorResponsesWithModel400Response", + '404': "TestErrorResponsesWithModel404Response", + } + response_data = self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ) + + + @validate_call + def test_error_responses_with_model_without_preload_content( + self, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> RESTResponseType: + """test error responses with model + + + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._test_error_responses_with_model_serialize( + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '204': None, + '400': "TestErrorResponsesWithModel400Response", + '404': "TestErrorResponsesWithModel404Response", + } + response_data = self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + return response_data.response + + + def _test_error_responses_with_model_serialize( + self, + _request_auth, + _content_type, + _headers, + _host_index, + ) -> Tuple: + + _host = None + + _collection_formats: Dict[str, str] = { + + } + + _path_params: Dict[str, str] = {} + _query_params: List[Tuple[str, str]] = [] + _header_params: Dict[str, Optional[str]] = _headers or {} + _form_params: List[Tuple[str, str]] = [] + _files: Dict[str, str] = {} + _body_params: Optional[bytes] = None + + # process the path parameters + # process the query parameters + # process the header parameters + # process the form parameters + # process the body parameter + + + # set the HTTP header `Accept` + _header_params['Accept'] = self.api_client.select_header_accept( + [ + 'application/json' + ] + ) + + + # authentication setting + _auth_settings: List[str] = [ + ] + + return self.api_client.param_serialize( + method='POST', + resource_path='/fake/error_responses_with_model', + path_params=_path_params, + query_params=_query_params, + header_params=_header_params, + body=_body_params, + post_params=_form_params, + files=_files, + auth_settings=_auth_settings, + collection_formats=_collection_formats, + _host=_host, + _request_auth=_request_auth + ) + + + + @validate_call def test_group_parameters( self, @@ -4891,7 +5362,7 @@ class FakeApi: ) _response_types_map: Dict[str, Optional[str]] = { - + '400': None, } response_data = self.api_client.call_api( *_param, @@ -4978,7 +5449,7 @@ class FakeApi: ) _response_types_map: Dict[str, Optional[str]] = { - + '400': None, } response_data = self.api_client.call_api( *_param, @@ -5065,7 +5536,7 @@ class FakeApi: ) _response_types_map: Dict[str, Optional[str]] = { - + '400': None, } response_data = self.api_client.call_api( *_param, @@ -5207,7 +5678,7 @@ class FakeApi: ) _response_types_map: Dict[str, Optional[str]] = { - + '200': None, } response_data = self.api_client.call_api( *_param, @@ -5274,7 +5745,7 @@ class FakeApi: ) _response_types_map: Dict[str, Optional[str]] = { - + '200': None, } response_data = self.api_client.call_api( *_param, @@ -5341,7 +5812,7 @@ class FakeApi: ) _response_types_map: Dict[str, Optional[str]] = { - + '200': None, } response_data = self.api_client.call_api( *_param, @@ -5472,7 +5943,7 @@ class FakeApi: ) _response_types_map: Dict[str, Optional[str]] = { - + '200': None, } response_data = self.api_client.call_api( *_param, @@ -5539,7 +6010,7 @@ class FakeApi: ) _response_types_map: Dict[str, Optional[str]] = { - + '200': None, } response_data = self.api_client.call_api( *_param, @@ -5606,7 +6077,7 @@ class FakeApi: ) _response_types_map: Dict[str, Optional[str]] = { - + '200': None, } response_data = self.api_client.call_api( *_param, @@ -5741,7 +6212,7 @@ class FakeApi: ) _response_types_map: Dict[str, Optional[str]] = { - + '200': None, } response_data = self.api_client.call_api( *_param, @@ -5812,7 +6283,7 @@ class FakeApi: ) _response_types_map: Dict[str, Optional[str]] = { - + '200': None, } response_data = self.api_client.call_api( *_param, @@ -5883,7 +6354,7 @@ class FakeApi: ) _response_types_map: Dict[str, Optional[str]] = { - + '200': None, } response_data = self.api_client.call_api( *_param, @@ -6041,7 +6512,7 @@ class FakeApi: ) _response_types_map: Dict[str, Optional[str]] = { - + '200': None, } response_data = self.api_client.call_api( *_param, @@ -6132,7 +6603,7 @@ class FakeApi: ) _response_types_map: Dict[str, Optional[str]] = { - + '200': None, } response_data = self.api_client.call_api( *_param, @@ -6223,7 +6694,7 @@ class FakeApi: ) _response_types_map: Dict[str, Optional[str]] = { - + '200': None, } response_data = self.api_client.call_api( *_param, diff --git a/samples/openapi3/client/petstore/python/petstore_api/api/fake_classname_tags123_api.py b/samples/openapi3/client/petstore/python/petstore_api/api/fake_classname_tags123_api.py index 6c6f6fc3027..9ce463db91a 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/api/fake_classname_tags123_api.py +++ b/samples/openapi3/client/petstore/python/petstore_api/api/fake_classname_tags123_api.py @@ -99,8 +99,7 @@ class FakeClassnameTags123Api: ) _response_types_map: Dict[str, Optional[str]] = { - '200': "Client" - + '200': "Client", } response_data = self.api_client.call_api( *_param, @@ -167,8 +166,7 @@ class FakeClassnameTags123Api: ) _response_types_map: Dict[str, Optional[str]] = { - '200': "Client" - + '200': "Client", } response_data = self.api_client.call_api( *_param, @@ -235,8 +233,7 @@ class FakeClassnameTags123Api: ) _response_types_map: Dict[str, Optional[str]] = { - '200': "Client" - + '200': "Client", } response_data = self.api_client.call_api( *_param, diff --git a/samples/openapi3/client/petstore/python/petstore_api/api/pet_api.py b/samples/openapi3/client/petstore/python/petstore_api/api/pet_api.py index 548c57cf28f..caa3fb84b07 100755 --- a/samples/openapi3/client/petstore/python/petstore_api/api/pet_api.py +++ b/samples/openapi3/client/petstore/python/petstore_api/api/pet_api.py @@ -104,7 +104,8 @@ class PetApi: ) _response_types_map: Dict[str, Optional[str]] = { - + '200': None, + '405': None, } response_data = self.api_client.call_api( *_param, @@ -171,7 +172,8 @@ class PetApi: ) _response_types_map: Dict[str, Optional[str]] = { - + '200': None, + '405': None, } response_data = self.api_client.call_api( *_param, @@ -238,7 +240,8 @@ class PetApi: ) _response_types_map: Dict[str, Optional[str]] = { - + '200': None, + '405': None, } response_data = self.api_client.call_api( *_param, @@ -376,7 +379,8 @@ class PetApi: ) _response_types_map: Dict[str, Optional[str]] = { - + '200': None, + '400': None, } response_data = self.api_client.call_api( *_param, @@ -447,7 +451,8 @@ class PetApi: ) _response_types_map: Dict[str, Optional[str]] = { - + '200': None, + '400': None, } response_data = self.api_client.call_api( *_param, @@ -518,7 +523,8 @@ class PetApi: ) _response_types_map: Dict[str, Optional[str]] = { - + '200': None, + '400': None, } response_data = self.api_client.call_api( *_param, @@ -641,8 +647,7 @@ class PetApi: _response_types_map: Dict[str, Optional[str]] = { '200': "List[Pet]", - '400': None - + '400': None, } response_data = self.api_client.call_api( *_param, @@ -710,8 +715,7 @@ class PetApi: _response_types_map: Dict[str, Optional[str]] = { '200': "List[Pet]", - '400': None - + '400': None, } response_data = self.api_client.call_api( *_param, @@ -779,8 +783,7 @@ class PetApi: _response_types_map: Dict[str, Optional[str]] = { '200': "List[Pet]", - '400': None - + '400': None, } response_data = self.api_client.call_api( *_param, @@ -912,8 +915,7 @@ class PetApi: _response_types_map: Dict[str, Optional[str]] = { '200': "List[Pet]", - '400': None - + '400': None, } response_data = self.api_client.call_api( *_param, @@ -982,8 +984,7 @@ class PetApi: _response_types_map: Dict[str, Optional[str]] = { '200': "List[Pet]", - '400': None - + '400': None, } response_data = self.api_client.call_api( *_param, @@ -1052,8 +1053,7 @@ class PetApi: _response_types_map: Dict[str, Optional[str]] = { '200': "List[Pet]", - '400': None - + '400': None, } response_data = self.api_client.call_api( *_param, @@ -1185,8 +1185,7 @@ class PetApi: _response_types_map: Dict[str, Optional[str]] = { '200': "Pet", '400': None, - '404': None - + '404': None, } response_data = self.api_client.call_api( *_param, @@ -1255,8 +1254,7 @@ class PetApi: _response_types_map: Dict[str, Optional[str]] = { '200': "Pet", '400': None, - '404': None - + '404': None, } response_data = self.api_client.call_api( *_param, @@ -1325,8 +1323,7 @@ class PetApi: _response_types_map: Dict[str, Optional[str]] = { '200': "Pet", '400': None, - '404': None - + '404': None, } response_data = self.api_client.call_api( *_param, @@ -1452,7 +1449,10 @@ class PetApi: ) _response_types_map: Dict[str, Optional[str]] = { - + '200': None, + '400': None, + '404': None, + '405': None, } response_data = self.api_client.call_api( *_param, @@ -1519,7 +1519,10 @@ class PetApi: ) _response_types_map: Dict[str, Optional[str]] = { - + '200': None, + '400': None, + '404': None, + '405': None, } response_data = self.api_client.call_api( *_param, @@ -1586,7 +1589,10 @@ class PetApi: ) _response_types_map: Dict[str, Optional[str]] = { - + '200': None, + '400': None, + '404': None, + '405': None, } response_data = self.api_client.call_api( *_param, @@ -1728,7 +1734,8 @@ class PetApi: ) _response_types_map: Dict[str, Optional[str]] = { - + '200': None, + '405': None, } response_data = self.api_client.call_api( *_param, @@ -1803,7 +1810,8 @@ class PetApi: ) _response_types_map: Dict[str, Optional[str]] = { - + '200': None, + '405': None, } response_data = self.api_client.call_api( *_param, @@ -1878,7 +1886,8 @@ class PetApi: ) _response_types_map: Dict[str, Optional[str]] = { - + '200': None, + '405': None, } response_data = self.api_client.call_api( *_param, @@ -2024,8 +2033,7 @@ class PetApi: ) _response_types_map: Dict[str, Optional[str]] = { - '200': "ApiResponse" - + '200': "ApiResponse", } response_data = self.api_client.call_api( *_param, @@ -2100,8 +2108,7 @@ class PetApi: ) _response_types_map: Dict[str, Optional[str]] = { - '200': "ApiResponse" - + '200': "ApiResponse", } response_data = self.api_client.call_api( *_param, @@ -2176,8 +2183,7 @@ class PetApi: ) _response_types_map: Dict[str, Optional[str]] = { - '200': "ApiResponse" - + '200': "ApiResponse", } response_data = self.api_client.call_api( *_param, @@ -2329,8 +2335,7 @@ class PetApi: ) _response_types_map: Dict[str, Optional[str]] = { - '200': "ApiResponse" - + '200': "ApiResponse", } response_data = self.api_client.call_api( *_param, @@ -2405,8 +2410,7 @@ class PetApi: ) _response_types_map: Dict[str, Optional[str]] = { - '200': "ApiResponse" - + '200': "ApiResponse", } response_data = self.api_client.call_api( *_param, @@ -2481,8 +2485,7 @@ class PetApi: ) _response_types_map: Dict[str, Optional[str]] = { - '200': "ApiResponse" - + '200': "ApiResponse", } response_data = self.api_client.call_api( *_param, diff --git a/samples/openapi3/client/petstore/python/petstore_api/api/store_api.py b/samples/openapi3/client/petstore/python/petstore_api/api/store_api.py index 42ede9524e5..fd77a92f117 100755 --- a/samples/openapi3/client/petstore/python/petstore_api/api/store_api.py +++ b/samples/openapi3/client/petstore/python/petstore_api/api/store_api.py @@ -103,7 +103,8 @@ class StoreApi: ) _response_types_map: Dict[str, Optional[str]] = { - + '400': None, + '404': None, } response_data = self.api_client.call_api( *_param, @@ -170,7 +171,8 @@ class StoreApi: ) _response_types_map: Dict[str, Optional[str]] = { - + '400': None, + '404': None, } response_data = self.api_client.call_api( *_param, @@ -237,7 +239,8 @@ class StoreApi: ) _response_types_map: Dict[str, Optional[str]] = { - + '400': None, + '404': None, } response_data = self.api_client.call_api( *_param, @@ -351,8 +354,7 @@ class StoreApi: ) _response_types_map: Dict[str, Optional[str]] = { - '200': "Dict[str, int]" - + '200': "Dict[str, int]", } response_data = self.api_client.call_api( *_param, @@ -415,8 +417,7 @@ class StoreApi: ) _response_types_map: Dict[str, Optional[str]] = { - '200': "Dict[str, int]" - + '200': "Dict[str, int]", } response_data = self.api_client.call_api( *_param, @@ -479,8 +480,7 @@ class StoreApi: ) _response_types_map: Dict[str, Optional[str]] = { - '200': "Dict[str, int]" - + '200': "Dict[str, int]", } response_data = self.api_client.call_api( *_param, @@ -604,8 +604,7 @@ class StoreApi: _response_types_map: Dict[str, Optional[str]] = { '200': "Order", '400': None, - '404': None - + '404': None, } response_data = self.api_client.call_api( *_param, @@ -674,8 +673,7 @@ class StoreApi: _response_types_map: Dict[str, Optional[str]] = { '200': "Order", '400': None, - '404': None - + '404': None, } response_data = self.api_client.call_api( *_param, @@ -744,8 +742,7 @@ class StoreApi: _response_types_map: Dict[str, Optional[str]] = { '200': "Order", '400': None, - '404': None - + '404': None, } response_data = self.api_client.call_api( *_param, @@ -871,8 +868,7 @@ class StoreApi: _response_types_map: Dict[str, Optional[str]] = { '200': "Order", - '400': None - + '400': None, } response_data = self.api_client.call_api( *_param, @@ -940,8 +936,7 @@ class StoreApi: _response_types_map: Dict[str, Optional[str]] = { '200': "Order", - '400': None - + '400': None, } response_data = self.api_client.call_api( *_param, @@ -1009,8 +1004,7 @@ class StoreApi: _response_types_map: Dict[str, Optional[str]] = { '200': "Order", - '400': None - + '400': None, } response_data = self.api_client.call_api( *_param, diff --git a/samples/openapi3/client/petstore/python/petstore_api/api/user_api.py b/samples/openapi3/client/petstore/python/petstore_api/api/user_api.py index bc93910a547..2811f29911c 100755 --- a/samples/openapi3/client/petstore/python/petstore_api/api/user_api.py +++ b/samples/openapi3/client/petstore/python/petstore_api/api/user_api.py @@ -103,7 +103,6 @@ class UserApi: ) _response_types_map: Dict[str, Optional[str]] = { - } response_data = self.api_client.call_api( *_param, @@ -170,7 +169,6 @@ class UserApi: ) _response_types_map: Dict[str, Optional[str]] = { - } response_data = self.api_client.call_api( *_param, @@ -237,7 +235,6 @@ class UserApi: ) _response_types_map: Dict[str, Optional[str]] = { - } response_data = self.api_client.call_api( *_param, @@ -373,7 +370,6 @@ class UserApi: ) _response_types_map: Dict[str, Optional[str]] = { - } response_data = self.api_client.call_api( *_param, @@ -440,7 +436,6 @@ class UserApi: ) _response_types_map: Dict[str, Optional[str]] = { - } response_data = self.api_client.call_api( *_param, @@ -507,7 +502,6 @@ class UserApi: ) _response_types_map: Dict[str, Optional[str]] = { - } response_data = self.api_client.call_api( *_param, @@ -639,7 +633,6 @@ class UserApi: ) _response_types_map: Dict[str, Optional[str]] = { - } response_data = self.api_client.call_api( *_param, @@ -706,7 +699,6 @@ class UserApi: ) _response_types_map: Dict[str, Optional[str]] = { - } response_data = self.api_client.call_api( *_param, @@ -773,7 +765,6 @@ class UserApi: ) _response_types_map: Dict[str, Optional[str]] = { - } response_data = self.api_client.call_api( *_param, @@ -905,7 +896,8 @@ class UserApi: ) _response_types_map: Dict[str, Optional[str]] = { - + '400': None, + '404': None, } response_data = self.api_client.call_api( *_param, @@ -972,7 +964,8 @@ class UserApi: ) _response_types_map: Dict[str, Optional[str]] = { - + '400': None, + '404': None, } response_data = self.api_client.call_api( *_param, @@ -1039,7 +1032,8 @@ class UserApi: ) _response_types_map: Dict[str, Optional[str]] = { - + '400': None, + '404': None, } response_data = self.api_client.call_api( *_param, @@ -1159,8 +1153,7 @@ class UserApi: _response_types_map: Dict[str, Optional[str]] = { '200': "User", '400': None, - '404': None - + '404': None, } response_data = self.api_client.call_api( *_param, @@ -1229,8 +1222,7 @@ class UserApi: _response_types_map: Dict[str, Optional[str]] = { '200': "User", '400': None, - '404': None - + '404': None, } response_data = self.api_client.call_api( *_param, @@ -1299,8 +1291,7 @@ class UserApi: _response_types_map: Dict[str, Optional[str]] = { '200': "User", '400': None, - '404': None - + '404': None, } response_data = self.api_client.call_api( *_param, @@ -1430,8 +1421,7 @@ class UserApi: _response_types_map: Dict[str, Optional[str]] = { '200': "str", - '400': None - + '400': None, } response_data = self.api_client.call_api( *_param, @@ -1503,8 +1493,7 @@ class UserApi: _response_types_map: Dict[str, Optional[str]] = { '200': "str", - '400': None - + '400': None, } response_data = self.api_client.call_api( *_param, @@ -1576,8 +1565,7 @@ class UserApi: _response_types_map: Dict[str, Optional[str]] = { '200': "str", - '400': None - + '400': None, } response_data = self.api_client.call_api( *_param, @@ -1705,7 +1693,6 @@ class UserApi: ) _response_types_map: Dict[str, Optional[str]] = { - } response_data = self.api_client.call_api( *_param, @@ -1768,7 +1755,6 @@ class UserApi: ) _response_types_map: Dict[str, Optional[str]] = { - } response_data = self.api_client.call_api( *_param, @@ -1831,7 +1817,6 @@ class UserApi: ) _response_types_map: Dict[str, Optional[str]] = { - } response_data = self.api_client.call_api( *_param, @@ -1950,7 +1935,8 @@ class UserApi: ) _response_types_map: Dict[str, Optional[str]] = { - + '400': None, + '404': None, } response_data = self.api_client.call_api( *_param, @@ -2021,7 +2007,8 @@ class UserApi: ) _response_types_map: Dict[str, Optional[str]] = { - + '400': None, + '404': None, } response_data = self.api_client.call_api( *_param, @@ -2092,7 +2079,8 @@ class UserApi: ) _response_types_map: Dict[str, Optional[str]] = { - + '400': None, + '404': None, } response_data = self.api_client.call_api( *_param, diff --git a/samples/openapi3/client/petstore/python/petstore_api/api_client.py b/samples/openapi3/client/petstore/python/petstore_api/api_client.py index bdf72703ea2..f0b4714a03c 100755 --- a/samples/openapi3/client/petstore/python/petstore_api/api_client.py +++ b/samples/openapi3/client/petstore/python/petstore_api/api_client.py @@ -281,7 +281,7 @@ class ApiClient: def response_deserialize( self, - response_data=None, + response_data: rest.RESTResponse = None, response_types_map=None ) -> ApiResponse: """Deserializes response into an object. @@ -296,39 +296,29 @@ class ApiClient: # if not found, look for '1XX', '2XX', etc. response_type = response_types_map.get(str(response_data.status)[0] + "XX", None) - if not 200 <= response_data.status <= 299: - if response_data.status == 400: - raise BadRequestException(http_resp=response_data) - - if response_data.status == 401: - raise UnauthorizedException(http_resp=response_data) - - if response_data.status == 403: - raise ForbiddenException(http_resp=response_data) - - if response_data.status == 404: - raise NotFoundException(http_resp=response_data) - - if 500 <= response_data.status <= 599: - raise ServiceException(http_resp=response_data) - raise ApiException(http_resp=response_data) - # deserialize response data - - if response_type == "bytearray": - return_data = response_data.data - elif response_type is None: - return_data = None - elif response_type == "file": - return_data = self.__deserialize_file(response_data) - else: - match = None - content_type = response_data.getheader('content-type') - if content_type is not None: - match = re.search(r"charset=([a-zA-Z\-\d]+)[\s;]?", content_type) - encoding = match.group(1) if match else "utf-8" - response_text = response_data.data.decode(encoding) - return_data = self.deserialize(response_text, response_type) + response_text = None + return_data = None + try: + if response_type == "bytearray": + return_data = response_data.data + elif response_type == "file": + return_data = self.__deserialize_file(response_data) + elif response_type is not None: + match = None + content_type = response_data.getheader('content-type') + if content_type is not None: + match = re.search(r"charset=([a-zA-Z\-\d]+)[\s;]?", content_type) + encoding = match.group(1) if match else "utf-8" + response_text = response_data.data.decode(encoding) + return_data = self.deserialize(response_text, response_type) + finally: + if not 200 <= response_data.status <= 299: + raise ApiException.from_response( + http_resp=response_data, + body=response_text, + data=return_data, + ) return ApiResponse( status_code = response_data.status, diff --git a/samples/openapi3/client/petstore/python/petstore_api/exceptions.py b/samples/openapi3/client/petstore/python/petstore_api/exceptions.py index ab74ce953c7..363d0d9f874 100755 --- a/samples/openapi3/client/petstore/python/petstore_api/exceptions.py +++ b/samples/openapi3/client/petstore/python/petstore_api/exceptions.py @@ -11,6 +11,9 @@ Do not edit the class manually. """ # noqa: E501 +from typing import Any, Optional + +from typing_extensions import Self class OpenApiException(Exception): """The base exception class for all OpenAPIExceptions""" @@ -101,17 +104,56 @@ class ApiKeyError(OpenApiException, KeyError): class ApiException(OpenApiException): - def __init__(self, status=None, reason=None, http_resp=None) -> None: + def __init__( + self, + status=None, + reason=None, + http_resp=None, + *, + body: Optional[str] = None, + data: Optional[Any] = None, + ) -> None: + self.status = status + self.reason = reason + self.body = body + self.data = data + self.headers = None + if http_resp: - self.status = http_resp.status - self.reason = http_resp.reason - self.body = http_resp.data.decode('utf-8') + if self.status is None: + self.status = http_resp.status + if self.reason is None: + self.reason = http_resp.reason + if self.body is None: + try: + self.body = http_resp.data.decode('utf-8') + except Exception: + pass self.headers = http_resp.getheaders() - else: - self.status = status - self.reason = reason - self.body = None - self.headers = None + + @classmethod + def from_response( + cls, + *, + http_resp, + body: Optional[str], + data: Optional[Any], + ) -> Self: + if http_resp.status == 400: + raise BadRequestException(http_resp=http_resp, body=body, data=data) + + if http_resp.status == 401: + raise UnauthorizedException(http_resp=http_resp, body=body, data=data) + + if http_resp.status == 403: + raise ForbiddenException(http_resp=http_resp, body=body, data=data) + + if http_resp.status == 404: + raise NotFoundException(http_resp=http_resp, body=body, data=data) + + if 500 <= http_resp.status <= 599: + raise ServiceException(http_resp=http_resp, body=body, data=data) + raise ApiException(http_resp=http_resp, body=body, data=data) def __str__(self): """Custom error messages for exception""" @@ -121,38 +163,30 @@ class ApiException(OpenApiException): error_message += "HTTP response headers: {0}\n".format( self.headers) - if self.body: - error_message += "HTTP response body: {0}\n".format(self.body) + if self.data or self.body: + error_message += "HTTP response body: {0}\n".format(self.data or self.body) return error_message -class BadRequestException(ApiException): - def __init__(self, status=None, reason=None, http_resp=None) -> None: - super(BadRequestException, self).__init__(status, reason, http_resp) +class BadRequestException(ApiException): + pass + class NotFoundException(ApiException): - - def __init__(self, status=None, reason=None, http_resp=None) -> None: - super(NotFoundException, self).__init__(status, reason, http_resp) + pass class UnauthorizedException(ApiException): - - def __init__(self, status=None, reason=None, http_resp=None) -> None: - super(UnauthorizedException, self).__init__(status, reason, http_resp) + pass class ForbiddenException(ApiException): - - def __init__(self, status=None, reason=None, http_resp=None) -> None: - super(ForbiddenException, self).__init__(status, reason, http_resp) + pass class ServiceException(ApiException): - - def __init__(self, status=None, reason=None, http_resp=None) -> None: - super(ServiceException, self).__init__(status, reason, http_resp) + pass def render_path(path_to_item): diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/__init__.py b/samples/openapi3/client/petstore/python/petstore_api/models/__init__.py index dd9388d355d..c106409daa9 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/__init__.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/__init__.py @@ -89,6 +89,8 @@ from petstore_api.models.special_character_enum import SpecialCharacterEnum from petstore_api.models.special_model_name import SpecialModelName from petstore_api.models.special_name import SpecialName from petstore_api.models.tag import Tag +from petstore_api.models.test_error_responses_with_model400_response import TestErrorResponsesWithModel400Response +from petstore_api.models.test_error_responses_with_model404_response import TestErrorResponsesWithModel404Response from petstore_api.models.test_inline_freeform_additional_properties_request import TestInlineFreeformAdditionalPropertiesRequest from petstore_api.models.tiger import Tiger from petstore_api.models.unnamed_dict_with_additional_model_list_properties import UnnamedDictWithAdditionalModelListProperties diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/test_error_responses_with_model400_response.py b/samples/openapi3/client/petstore/python/petstore_api/models/test_error_responses_with_model400_response.py new file mode 100644 index 00000000000..10d52bd238b --- /dev/null +++ b/samples/openapi3/client/petstore/python/petstore_api/models/test_error_responses_with_model400_response.py @@ -0,0 +1,100 @@ +# coding: utf-8 + +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + + The version of the OpenAPI document: 1.0.0 + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + + +from typing import Any, ClassVar, Dict, List, Optional +from pydantic import BaseModel, StrictStr +try: + from typing import Self +except ImportError: + from typing_extensions import Self + +class TestErrorResponsesWithModel400Response(BaseModel): + """ + TestErrorResponsesWithModel400Response + """ # noqa: E501 + reason400: Optional[StrictStr] = None + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["reason400"] + + model_config = { + "populate_by_name": True, + "validate_assignment": True + } + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Self: + """Create an instance of TestErrorResponsesWithModel400Response from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + _dict = self.model_dump( + by_alias=True, + exclude={ + "additional_properties", + }, + exclude_none=True, + ) + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Dict) -> Self: + """Create an instance of TestErrorResponsesWithModel400Response from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "reason400": obj.get("reason400") + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/test_error_responses_with_model404_response.py b/samples/openapi3/client/petstore/python/petstore_api/models/test_error_responses_with_model404_response.py new file mode 100644 index 00000000000..a92febbe29b --- /dev/null +++ b/samples/openapi3/client/petstore/python/petstore_api/models/test_error_responses_with_model404_response.py @@ -0,0 +1,100 @@ +# coding: utf-8 + +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + + The version of the OpenAPI document: 1.0.0 + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + + +from typing import Any, ClassVar, Dict, List, Optional +from pydantic import BaseModel, StrictStr +try: + from typing import Self +except ImportError: + from typing_extensions import Self + +class TestErrorResponsesWithModel404Response(BaseModel): + """ + TestErrorResponsesWithModel404Response + """ # noqa: E501 + reason404: Optional[StrictStr] = None + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["reason404"] + + model_config = { + "populate_by_name": True, + "validate_assignment": True + } + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Self: + """Create an instance of TestErrorResponsesWithModel404Response from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + * Fields in `self.additional_properties` are added to the output dict. + """ + _dict = self.model_dump( + by_alias=True, + exclude={ + "additional_properties", + }, + exclude_none=True, + ) + # puts key-value pairs in additional_properties in the top level + if self.additional_properties is not None: + for _key, _value in self.additional_properties.items(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Dict) -> Self: + """Create an instance of TestErrorResponsesWithModel404Response from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "reason404": obj.get("reason404") + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/samples/openapi3/client/petstore/python/test/test_test_error_responses_with_model400_response.py b/samples/openapi3/client/petstore/python/test/test_test_error_responses_with_model400_response.py new file mode 100644 index 00000000000..35db7ba74fb --- /dev/null +++ b/samples/openapi3/client/petstore/python/test/test_test_error_responses_with_model400_response.py @@ -0,0 +1,52 @@ +# coding: utf-8 + +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + + The version of the OpenAPI document: 1.0.0 + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +import unittest +import datetime + +from petstore_api.models.test_error_responses_with_model400_response import TestErrorResponsesWithModel400Response + +class TestTestErrorResponsesWithModel400Response(unittest.TestCase): + """TestErrorResponsesWithModel400Response unit test stubs""" + + def setUp(self): + pass + + def tearDown(self): + pass + + def make_instance(self, include_optional) -> TestErrorResponsesWithModel400Response: + """Test TestErrorResponsesWithModel400Response + include_option is a boolean, when False only required + params are included, when True both required and + optional params are included """ + # uncomment below to create an instance of `TestErrorResponsesWithModel400Response` + """ + model = TestErrorResponsesWithModel400Response() + if include_optional: + return TestErrorResponsesWithModel400Response( + reason400 = '' + ) + else: + return TestErrorResponsesWithModel400Response( + ) + """ + + def testTestErrorResponsesWithModel400Response(self): + """Test TestErrorResponsesWithModel400Response""" + # inst_req_only = self.make_instance(include_optional=False) + # inst_req_and_optional = self.make_instance(include_optional=True) + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/petstore/python/test/test_test_error_responses_with_model404_response.py b/samples/openapi3/client/petstore/python/test/test_test_error_responses_with_model404_response.py new file mode 100644 index 00000000000..e9c97c0f484 --- /dev/null +++ b/samples/openapi3/client/petstore/python/test/test_test_error_responses_with_model404_response.py @@ -0,0 +1,52 @@ +# coding: utf-8 + +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + + The version of the OpenAPI document: 1.0.0 + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +import unittest +import datetime + +from petstore_api.models.test_error_responses_with_model404_response import TestErrorResponsesWithModel404Response + +class TestTestErrorResponsesWithModel404Response(unittest.TestCase): + """TestErrorResponsesWithModel404Response unit test stubs""" + + def setUp(self): + pass + + def tearDown(self): + pass + + def make_instance(self, include_optional) -> TestErrorResponsesWithModel404Response: + """Test TestErrorResponsesWithModel404Response + include_option is a boolean, when False only required + params are included, when True both required and + optional params are included """ + # uncomment below to create an instance of `TestErrorResponsesWithModel404Response` + """ + model = TestErrorResponsesWithModel404Response() + if include_optional: + return TestErrorResponsesWithModel404Response( + reason404 = '' + ) + else: + return TestErrorResponsesWithModel404Response( + ) + """ + + def testTestErrorResponsesWithModel404Response(self): + """Test TestErrorResponsesWithModel404Response""" + # inst_req_only = self.make_instance(include_optional=False) + # inst_req_and_optional = self.make_instance(include_optional=True) + +if __name__ == '__main__': + unittest.main() diff --git a/samples/openapi3/client/petstore/python/tests/test_api.py b/samples/openapi3/client/petstore/python/tests/test_api.py new file mode 100644 index 00000000000..8237969c494 --- /dev/null +++ b/samples/openapi3/client/petstore/python/tests/test_api.py @@ -0,0 +1,84 @@ +import json +import unittest +from unittest.mock import patch, Mock + +import pytest + +import petstore_api + + +class TestMultipleResponseTypes(unittest.TestCase): + def setUp(self): + self.api_client = petstore_api.ApiClient() + self.fake_api = petstore_api.FakeApi(self.api_client) + + def test_204(self): + mock_resp = Mock() + mock_resp.status = 204 + mock_resp.data = b"" + mock_resp.getheaders.return_value = {} + + with patch( + "petstore_api.api_client.ApiClient.call_api", return_value=mock_resp + ): + returned = self.fake_api.test_empty_and_non_empty_responses() + + assert returned is None + + def test_206(self): + mock_resp = Mock() + mock_resp.status = 206 + mock_resp.data = b"some text" + mock_resp.getheaders.return_value = {} + mock_resp.getheader = ( + lambda name: "text/plain" if name == "content-type" else Mock() + ) + + with patch( + "petstore_api.api_client.ApiClient.call_api", return_value=mock_resp + ): + returned = self.fake_api.test_empty_and_non_empty_responses() + + assert returned == "some text" + + +class TestErrorResponsesWithModels(unittest.TestCase): + def setUp(self): + self.api_client = petstore_api.ApiClient() + self.fake_api = petstore_api.FakeApi(self.api_client) + + def test_400(self): + mock_resp = Mock() + mock_resp.status = 400 + mock_resp.data = json.dumps({"reason400": "400 reason"}).encode("utf-8") + mock_resp.getheaders.return_value = {} + mock_resp.getheader.return_value = "" + + with patch( + "petstore_api.api_client.ApiClient.call_api", return_value=mock_resp + ): + with pytest.raises(petstore_api.exceptions.BadRequestException) as exc_info: + self.fake_api.test_error_responses_with_model() + + expected_resp = petstore_api.TestErrorResponsesWithModel400Response( + reason400="400 reason" + ) + assert exc_info.value.data == expected_resp + + def test_404(self): + mock_resp = Mock() + mock_resp.status = 404 + mock_resp.data = json.dumps({"reason404": "404 reason"}).encode("utf-8") + mock_resp.getheaders.return_value = {} + mock_resp.getheader.return_value = "" + + with patch( + "petstore_api.api_client.ApiClient.call_api", return_value=mock_resp + ): + with pytest.raises(petstore_api.exceptions.NotFoundException) as exc_info: + self.fake_api.test_error_responses_with_model() + + expected_resp = petstore_api.TestErrorResponsesWithModel404Response( + reason404="404 reason" + ) + assert exc_info.value.data == expected_resp