[python][Feat] Deserialize error responses (#17038)

* refactor: Clean up _response_types_map formatting

It matches black's behavior of having trailing commas now.

* test: Add test to reproduce #16967

* fix: deserialize responses even if no returnType

Closes #16967

* refactor: Simplify ApiException subclasses

* refactor: Move exception subtype choice to ApiException

* feat: Deserialize error responses and add to exceptions

* test: Add for error responses with model
This commit is contained in:
Robert Schweizer 2023-11-15 17:37:04 +01:00 committed by GitHub
parent 69fcfeff38
commit e47e7041f7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
85 changed files with 4309 additions and 951 deletions

View File

@ -289,7 +289,7 @@ class ApiClient:
def response_deserialize( def response_deserialize(
self, self,
response_data=None, response_data: rest.RESTResponse = None,
response_types_map=None response_types_map=None
) -> ApiResponse: ) -> ApiResponse:
"""Deserializes response into an object. """Deserializes response into an object.
@ -304,32 +304,15 @@ class ApiClient:
# if not found, look for '1XX', '2XX', etc. # if not found, look for '1XX', '2XX', etc.
response_type = response_types_map.get(str(response_data.status)[0] + "XX", None) 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 # deserialize response data
response_text = None
return_data = None
try:
if response_type == "bytearray": if response_type == "bytearray":
return_data = response_data.data return_data = response_data.data
elif response_type is None:
return_data = None
elif response_type == "file": elif response_type == "file":
return_data = self.__deserialize_file(response_data) return_data = self.__deserialize_file(response_data)
else: elif response_type is not None:
match = None match = None
content_type = response_data.getheader('content-type') content_type = response_data.getheader('content-type')
if content_type is not None: if content_type is not None:
@ -337,6 +320,13 @@ class ApiClient:
encoding = match.group(1) if match else "utf-8" encoding = match.group(1) if match else "utf-8"
response_text = response_data.data.decode(encoding) response_text = response_data.data.decode(encoding)
return_data = self.deserialize(response_text, response_type) 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( return ApiResponse(
status_code = response_data.status, status_code = response_data.status,

View File

@ -1,6 +1,9 @@
# coding: utf-8 # coding: utf-8
{{>partial_header}} {{>partial_header}}
from typing import Any, Optional
from typing_extensions import Self
class OpenApiException(Exception): class OpenApiException(Exception):
"""The base exception class for all OpenAPIExceptions""" """The base exception class for all OpenAPIExceptions"""
@ -91,18 +94,57 @@ class ApiKeyError(OpenApiException, KeyError):
class ApiException(OpenApiException): class ApiException(OpenApiException):
def __init__(self, status=None, reason=None, http_resp=None) -> None: def __init__(
if http_resp: self,
self.status = http_resp.status status=None,
self.reason = http_resp.reason reason=None,
self.body = http_resp.data.decode('utf-8') http_resp=None,
self.headers = http_resp.getheaders() *,
else: body: Optional[str] = None,
data: Optional[Any] = None,
) -> None:
self.status = status self.status = status
self.reason = reason self.reason = reason
self.body = None self.body = body
self.data = data
self.headers = None self.headers = None
if http_resp:
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()
@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): def __str__(self):
"""Custom error messages for exception""" """Custom error messages for exception"""
error_message = "({0})\n"\ error_message = "({0})\n"\
@ -111,38 +153,30 @@ class ApiException(OpenApiException):
error_message += "HTTP response headers: {0}\n".format( error_message += "HTTP response headers: {0}\n".format(
self.headers) self.headers)
if self.body: if self.data or self.body:
error_message += "HTTP response body: {0}\n".format(self.body) error_message += "HTTP response body: {0}\n".format(self.data or self.body)
return error_message return error_message
class BadRequestException(ApiException):
def __init__(self, status=None, reason=None, http_resp=None) -> None: class BadRequestException(ApiException):
super(BadRequestException, self).__init__(status, reason, http_resp) pass
class NotFoundException(ApiException): class NotFoundException(ApiException):
pass
def __init__(self, status=None, reason=None, http_resp=None) -> None:
super(NotFoundException, self).__init__(status, reason, http_resp)
class UnauthorizedException(ApiException): class UnauthorizedException(ApiException):
pass
def __init__(self, status=None, reason=None, http_resp=None) -> None:
super(UnauthorizedException, self).__init__(status, reason, http_resp)
class ForbiddenException(ApiException): class ForbiddenException(ApiException):
pass
def __init__(self, status=None, reason=None, http_resp=None) -> None:
super(ForbiddenException, self).__init__(status, reason, http_resp)
class ServiceException(ApiException): class ServiceException(ApiException):
pass
def __init__(self, status=None, reason=None, http_resp=None) -> None:
super(ServiceException, self).__init__(status, reason, http_resp)
def render_path(path_to_item): def render_path(path_to_item):

View File

@ -44,6 +44,9 @@
) )
_response_types_map: Dict[str, Optional[str]] = { _response_types_map: Dict[str, Optional[str]] = {
{{#returnType}}{{#responses}}{{^isWildcard}}'{{code}}': {{#dataType}}"{{.}}"{{/dataType}}{{^dataType}}None{{/dataType}}{{/isWildcard}}{{^-last}},{{/-last}} {{#responses}}
{{/responses}}{{/returnType}} {{^isWildcard}}
'{{code}}': {{#dataType}}"{{.}}"{{/dataType}}{{^dataType}}None{{/dataType}},
{{/isWildcard}}
{{/responses}}
} }

View File

@ -1063,6 +1063,49 @@ paths:
schema: schema:
$ref: '#/components/schemas/User' $ref: '#/components/schemas/User'
required: true 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: /another-fake/dummy:
patch: patch:
tags: tags:

View File

@ -93,8 +93,7 @@ class AuthApi:
) )
_response_types_map: Dict[str, Optional[str]] = { _response_types_map: Dict[str, Optional[str]] = {
'200': "str" '200': "str",
} }
response_data = self.api_client.call_api( response_data = self.api_client.call_api(
*_param, *_param,
@ -157,8 +156,7 @@ class AuthApi:
) )
_response_types_map: Dict[str, Optional[str]] = { _response_types_map: Dict[str, Optional[str]] = {
'200': "str" '200': "str",
} }
response_data = self.api_client.call_api( response_data = self.api_client.call_api(
*_param, *_param,
@ -221,8 +219,7 @@ class AuthApi:
) )
_response_types_map: Dict[str, Optional[str]] = { _response_types_map: Dict[str, Optional[str]] = {
'200': "str" '200': "str",
} }
response_data = self.api_client.call_api( response_data = self.api_client.call_api(
*_param, *_param,

View File

@ -101,8 +101,7 @@ class BodyApi:
) )
_response_types_map: Dict[str, Optional[str]] = { _response_types_map: Dict[str, Optional[str]] = {
'200': "bytearray" '200': "bytearray",
} }
response_data = self.api_client.call_api( response_data = self.api_client.call_api(
*_param, *_param,
@ -165,8 +164,7 @@ class BodyApi:
) )
_response_types_map: Dict[str, Optional[str]] = { _response_types_map: Dict[str, Optional[str]] = {
'200': "bytearray" '200': "bytearray",
} }
response_data = self.api_client.call_api( response_data = self.api_client.call_api(
*_param, *_param,
@ -229,8 +227,7 @@ class BodyApi:
) )
_response_types_map: Dict[str, Optional[str]] = { _response_types_map: Dict[str, Optional[str]] = {
'200': "bytearray" '200': "bytearray",
} }
response_data = self.api_client.call_api( response_data = self.api_client.call_api(
*_param, *_param,
@ -351,8 +348,7 @@ class BodyApi:
) )
_response_types_map: Dict[str, Optional[str]] = { _response_types_map: Dict[str, Optional[str]] = {
'200': "str" '200': "str",
} }
response_data = self.api_client.call_api( response_data = self.api_client.call_api(
*_param, *_param,
@ -419,8 +415,7 @@ class BodyApi:
) )
_response_types_map: Dict[str, Optional[str]] = { _response_types_map: Dict[str, Optional[str]] = {
'200': "str" '200': "str",
} }
response_data = self.api_client.call_api( response_data = self.api_client.call_api(
*_param, *_param,
@ -487,8 +482,7 @@ class BodyApi:
) )
_response_types_map: Dict[str, Optional[str]] = { _response_types_map: Dict[str, Optional[str]] = {
'200': "str" '200': "str",
} }
response_data = self.api_client.call_api( response_data = self.api_client.call_api(
*_param, *_param,
@ -630,8 +624,7 @@ class BodyApi:
) )
_response_types_map: Dict[str, Optional[str]] = { _response_types_map: Dict[str, Optional[str]] = {
'200': "str" '200': "str",
} }
response_data = self.api_client.call_api( response_data = self.api_client.call_api(
*_param, *_param,
@ -698,8 +691,7 @@ class BodyApi:
) )
_response_types_map: Dict[str, Optional[str]] = { _response_types_map: Dict[str, Optional[str]] = {
'200': "str" '200': "str",
} }
response_data = self.api_client.call_api( response_data = self.api_client.call_api(
*_param, *_param,
@ -766,8 +758,7 @@ class BodyApi:
) )
_response_types_map: Dict[str, Optional[str]] = { _response_types_map: Dict[str, Optional[str]] = {
'200': "str" '200': "str",
} }
response_data = self.api_client.call_api( response_data = self.api_client.call_api(
*_param, *_param,
@ -905,8 +896,7 @@ class BodyApi:
) )
_response_types_map: Dict[str, Optional[str]] = { _response_types_map: Dict[str, Optional[str]] = {
'200': "Pet" '200': "Pet",
} }
response_data = self.api_client.call_api( response_data = self.api_client.call_api(
*_param, *_param,
@ -973,8 +963,7 @@ class BodyApi:
) )
_response_types_map: Dict[str, Optional[str]] = { _response_types_map: Dict[str, Optional[str]] = {
'200': "Pet" '200': "Pet",
} }
response_data = self.api_client.call_api( response_data = self.api_client.call_api(
*_param, *_param,
@ -1041,8 +1030,7 @@ class BodyApi:
) )
_response_types_map: Dict[str, Optional[str]] = { _response_types_map: Dict[str, Optional[str]] = {
'200': "Pet" '200': "Pet",
} }
response_data = self.api_client.call_api( response_data = self.api_client.call_api(
*_param, *_param,
@ -1179,8 +1167,7 @@ class BodyApi:
) )
_response_types_map: Dict[str, Optional[str]] = { _response_types_map: Dict[str, Optional[str]] = {
'200': "str" '200': "str",
} }
response_data = self.api_client.call_api( response_data = self.api_client.call_api(
*_param, *_param,
@ -1247,8 +1234,7 @@ class BodyApi:
) )
_response_types_map: Dict[str, Optional[str]] = { _response_types_map: Dict[str, Optional[str]] = {
'200': "str" '200': "str",
} }
response_data = self.api_client.call_api( response_data = self.api_client.call_api(
*_param, *_param,
@ -1315,8 +1301,7 @@ class BodyApi:
) )
_response_types_map: Dict[str, Optional[str]] = { _response_types_map: Dict[str, Optional[str]] = {
'200': "str" '200': "str",
} }
response_data = self.api_client.call_api( response_data = self.api_client.call_api(
*_param, *_param,
@ -1453,8 +1438,7 @@ class BodyApi:
) )
_response_types_map: Dict[str, Optional[str]] = { _response_types_map: Dict[str, Optional[str]] = {
'200': "Pet" '200': "Pet",
} }
response_data = self.api_client.call_api( response_data = self.api_client.call_api(
*_param, *_param,
@ -1521,8 +1505,7 @@ class BodyApi:
) )
_response_types_map: Dict[str, Optional[str]] = { _response_types_map: Dict[str, Optional[str]] = {
'200': "Pet" '200': "Pet",
} }
response_data = self.api_client.call_api( response_data = self.api_client.call_api(
*_param, *_param,
@ -1589,8 +1572,7 @@ class BodyApi:
) )
_response_types_map: Dict[str, Optional[str]] = { _response_types_map: Dict[str, Optional[str]] = {
'200': "Pet" '200': "Pet",
} }
response_data = self.api_client.call_api( response_data = self.api_client.call_api(
*_param, *_param,
@ -1727,8 +1709,7 @@ class BodyApi:
) )
_response_types_map: Dict[str, Optional[str]] = { _response_types_map: Dict[str, Optional[str]] = {
'200': "str" '200': "str",
} }
response_data = self.api_client.call_api( response_data = self.api_client.call_api(
*_param, *_param,
@ -1795,8 +1776,7 @@ class BodyApi:
) )
_response_types_map: Dict[str, Optional[str]] = { _response_types_map: Dict[str, Optional[str]] = {
'200': "str" '200': "str",
} }
response_data = self.api_client.call_api( response_data = self.api_client.call_api(
*_param, *_param,
@ -1863,8 +1843,7 @@ class BodyApi:
) )
_response_types_map: Dict[str, Optional[str]] = { _response_types_map: Dict[str, Optional[str]] = {
'200': "str" '200': "str",
} }
response_data = self.api_client.call_api( response_data = self.api_client.call_api(
*_param, *_param,
@ -2001,8 +1980,7 @@ class BodyApi:
) )
_response_types_map: Dict[str, Optional[str]] = { _response_types_map: Dict[str, Optional[str]] = {
'200': "str" '200': "str",
} }
response_data = self.api_client.call_api( response_data = self.api_client.call_api(
*_param, *_param,
@ -2069,8 +2047,7 @@ class BodyApi:
) )
_response_types_map: Dict[str, Optional[str]] = { _response_types_map: Dict[str, Optional[str]] = {
'200': "str" '200': "str",
} }
response_data = self.api_client.call_api( response_data = self.api_client.call_api(
*_param, *_param,
@ -2137,8 +2114,7 @@ class BodyApi:
) )
_response_types_map: Dict[str, Optional[str]] = { _response_types_map: Dict[str, Optional[str]] = {
'200': "str" '200': "str",
} }
response_data = self.api_client.call_api( response_data = self.api_client.call_api(
*_param, *_param,

View File

@ -109,8 +109,7 @@ class FormApi:
) )
_response_types_map: Dict[str, Optional[str]] = { _response_types_map: Dict[str, Optional[str]] = {
'200': "str" '200': "str",
} }
response_data = self.api_client.call_api( response_data = self.api_client.call_api(
*_param, *_param,
@ -185,8 +184,7 @@ class FormApi:
) )
_response_types_map: Dict[str, Optional[str]] = { _response_types_map: Dict[str, Optional[str]] = {
'200': "str" '200': "str",
} }
response_data = self.api_client.call_api( response_data = self.api_client.call_api(
*_param, *_param,
@ -261,8 +259,7 @@ class FormApi:
) )
_response_types_map: Dict[str, Optional[str]] = { _response_types_map: Dict[str, Optional[str]] = {
'200': "str" '200': "str",
} }
response_data = self.api_client.call_api( response_data = self.api_client.call_api(
*_param, *_param,
@ -425,8 +422,7 @@ class FormApi:
) )
_response_types_map: Dict[str, Optional[str]] = { _response_types_map: Dict[str, Optional[str]] = {
'200': "str" '200': "str",
} }
response_data = self.api_client.call_api( response_data = self.api_client.call_api(
*_param, *_param,
@ -513,8 +509,7 @@ class FormApi:
) )
_response_types_map: Dict[str, Optional[str]] = { _response_types_map: Dict[str, Optional[str]] = {
'200': "str" '200': "str",
} }
response_data = self.api_client.call_api( response_data = self.api_client.call_api(
*_param, *_param,
@ -601,8 +596,7 @@ class FormApi:
) )
_response_types_map: Dict[str, Optional[str]] = { _response_types_map: Dict[str, Optional[str]] = {
'200': "str" '200': "str",
} }
response_data = self.api_client.call_api( response_data = self.api_client.call_api(
*_param, *_param,

View File

@ -118,8 +118,7 @@ class HeaderApi:
) )
_response_types_map: Dict[str, Optional[str]] = { _response_types_map: Dict[str, Optional[str]] = {
'200': "str" '200': "str",
} }
response_data = self.api_client.call_api( response_data = self.api_client.call_api(
*_param, *_param,
@ -202,8 +201,7 @@ class HeaderApi:
) )
_response_types_map: Dict[str, Optional[str]] = { _response_types_map: Dict[str, Optional[str]] = {
'200': "str" '200': "str",
} }
response_data = self.api_client.call_api( response_data = self.api_client.call_api(
*_param, *_param,
@ -286,8 +284,7 @@ class HeaderApi:
) )
_response_types_map: Dict[str, Optional[str]] = { _response_types_map: Dict[str, Optional[str]] = {
'200': "str" '200': "str",
} }
response_data = self.api_client.call_api( response_data = self.api_client.call_api(
*_param, *_param,

View File

@ -112,8 +112,7 @@ class PathApi:
) )
_response_types_map: Dict[str, Optional[str]] = { _response_types_map: Dict[str, Optional[str]] = {
'200': "str" '200': "str",
} }
response_data = self.api_client.call_api( response_data = self.api_client.call_api(
*_param, *_param,
@ -192,8 +191,7 @@ class PathApi:
) )
_response_types_map: Dict[str, Optional[str]] = { _response_types_map: Dict[str, Optional[str]] = {
'200': "str" '200': "str",
} }
response_data = self.api_client.call_api( response_data = self.api_client.call_api(
*_param, *_param,
@ -272,8 +270,7 @@ class PathApi:
) )
_response_types_map: Dict[str, Optional[str]] = { _response_types_map: Dict[str, Optional[str]] = {
'200': "str" '200': "str",
} }
response_data = self.api_client.call_api( response_data = self.api_client.call_api(
*_param, *_param,

View File

@ -110,8 +110,7 @@ class QueryApi:
) )
_response_types_map: Dict[str, Optional[str]] = { _response_types_map: Dict[str, Optional[str]] = {
'200': "str" '200': "str",
} }
response_data = self.api_client.call_api( response_data = self.api_client.call_api(
*_param, *_param,
@ -182,8 +181,7 @@ class QueryApi:
) )
_response_types_map: Dict[str, Optional[str]] = { _response_types_map: Dict[str, Optional[str]] = {
'200': "str" '200': "str",
} }
response_data = self.api_client.call_api( response_data = self.api_client.call_api(
*_param, *_param,
@ -254,8 +252,7 @@ class QueryApi:
) )
_response_types_map: Dict[str, Optional[str]] = { _response_types_map: Dict[str, Optional[str]] = {
'200': "str" '200': "str",
} }
response_data = self.api_client.call_api( response_data = self.api_client.call_api(
*_param, *_param,
@ -394,8 +391,7 @@ class QueryApi:
) )
_response_types_map: Dict[str, Optional[str]] = { _response_types_map: Dict[str, Optional[str]] = {
'200': "str" '200': "str",
} }
response_data = self.api_client.call_api( response_data = self.api_client.call_api(
*_param, *_param,
@ -470,8 +466,7 @@ class QueryApi:
) )
_response_types_map: Dict[str, Optional[str]] = { _response_types_map: Dict[str, Optional[str]] = {
'200': "str" '200': "str",
} }
response_data = self.api_client.call_api( response_data = self.api_client.call_api(
*_param, *_param,
@ -546,8 +541,7 @@ class QueryApi:
) )
_response_types_map: Dict[str, Optional[str]] = { _response_types_map: Dict[str, Optional[str]] = {
'200': "str" '200': "str",
} }
response_data = self.api_client.call_api( response_data = self.api_client.call_api(
*_param, *_param,
@ -709,8 +703,7 @@ class QueryApi:
) )
_response_types_map: Dict[str, Optional[str]] = { _response_types_map: Dict[str, Optional[str]] = {
'200': "str" '200': "str",
} }
response_data = self.api_client.call_api( response_data = self.api_client.call_api(
*_param, *_param,
@ -785,8 +778,7 @@ class QueryApi:
) )
_response_types_map: Dict[str, Optional[str]] = { _response_types_map: Dict[str, Optional[str]] = {
'200': "str" '200': "str",
} }
response_data = self.api_client.call_api( response_data = self.api_client.call_api(
*_param, *_param,
@ -861,8 +853,7 @@ class QueryApi:
) )
_response_types_map: Dict[str, Optional[str]] = { _response_types_map: Dict[str, Optional[str]] = {
'200': "str" '200': "str",
} }
response_data = self.api_client.call_api( response_data = self.api_client.call_api(
*_param, *_param,
@ -998,8 +989,7 @@ class QueryApi:
) )
_response_types_map: Dict[str, Optional[str]] = { _response_types_map: Dict[str, Optional[str]] = {
'200': "str" '200': "str",
} }
response_data = self.api_client.call_api( response_data = self.api_client.call_api(
*_param, *_param,
@ -1066,8 +1056,7 @@ class QueryApi:
) )
_response_types_map: Dict[str, Optional[str]] = { _response_types_map: Dict[str, Optional[str]] = {
'200': "str" '200': "str",
} }
response_data = self.api_client.call_api( response_data = self.api_client.call_api(
*_param, *_param,
@ -1134,8 +1123,7 @@ class QueryApi:
) )
_response_types_map: Dict[str, Optional[str]] = { _response_types_map: Dict[str, Optional[str]] = {
'200': "str" '200': "str",
} }
response_data = self.api_client.call_api( response_data = self.api_client.call_api(
*_param, *_param,
@ -1261,8 +1249,7 @@ class QueryApi:
) )
_response_types_map: Dict[str, Optional[str]] = { _response_types_map: Dict[str, Optional[str]] = {
'200': "str" '200': "str",
} }
response_data = self.api_client.call_api( response_data = self.api_client.call_api(
*_param, *_param,
@ -1329,8 +1316,7 @@ class QueryApi:
) )
_response_types_map: Dict[str, Optional[str]] = { _response_types_map: Dict[str, Optional[str]] = {
'200': "str" '200': "str",
} }
response_data = self.api_client.call_api( response_data = self.api_client.call_api(
*_param, *_param,
@ -1397,8 +1383,7 @@ class QueryApi:
) )
_response_types_map: Dict[str, Optional[str]] = { _response_types_map: Dict[str, Optional[str]] = {
'200': "str" '200': "str",
} }
response_data = self.api_client.call_api( response_data = self.api_client.call_api(
*_param, *_param,
@ -1524,8 +1509,7 @@ class QueryApi:
) )
_response_types_map: Dict[str, Optional[str]] = { _response_types_map: Dict[str, Optional[str]] = {
'200': "str" '200': "str",
} }
response_data = self.api_client.call_api( response_data = self.api_client.call_api(
*_param, *_param,
@ -1592,8 +1576,7 @@ class QueryApi:
) )
_response_types_map: Dict[str, Optional[str]] = { _response_types_map: Dict[str, Optional[str]] = {
'200': "str" '200': "str",
} }
response_data = self.api_client.call_api( response_data = self.api_client.call_api(
*_param, *_param,
@ -1660,8 +1643,7 @@ class QueryApi:
) )
_response_types_map: Dict[str, Optional[str]] = { _response_types_map: Dict[str, Optional[str]] = {
'200': "str" '200': "str",
} }
response_data = self.api_client.call_api( response_data = self.api_client.call_api(
*_param, *_param,
@ -1787,8 +1769,7 @@ class QueryApi:
) )
_response_types_map: Dict[str, Optional[str]] = { _response_types_map: Dict[str, Optional[str]] = {
'200': "str" '200': "str",
} }
response_data = self.api_client.call_api( response_data = self.api_client.call_api(
*_param, *_param,
@ -1855,8 +1836,7 @@ class QueryApi:
) )
_response_types_map: Dict[str, Optional[str]] = { _response_types_map: Dict[str, Optional[str]] = {
'200': "str" '200': "str",
} }
response_data = self.api_client.call_api( response_data = self.api_client.call_api(
*_param, *_param,
@ -1923,8 +1903,7 @@ class QueryApi:
) )
_response_types_map: Dict[str, Optional[str]] = { _response_types_map: Dict[str, Optional[str]] = {
'200': "str" '200': "str",
} }
response_data = self.api_client.call_api( response_data = self.api_client.call_api(
*_param, *_param,
@ -2050,8 +2029,7 @@ class QueryApi:
) )
_response_types_map: Dict[str, Optional[str]] = { _response_types_map: Dict[str, Optional[str]] = {
'200': "str" '200': "str",
} }
response_data = self.api_client.call_api( response_data = self.api_client.call_api(
*_param, *_param,
@ -2118,8 +2096,7 @@ class QueryApi:
) )
_response_types_map: Dict[str, Optional[str]] = { _response_types_map: Dict[str, Optional[str]] = {
'200': "str" '200': "str",
} }
response_data = self.api_client.call_api( response_data = self.api_client.call_api(
*_param, *_param,
@ -2186,8 +2163,7 @@ class QueryApi:
) )
_response_types_map: Dict[str, Optional[str]] = { _response_types_map: Dict[str, Optional[str]] = {
'200': "str" '200': "str",
} }
response_data = self.api_client.call_api( response_data = self.api_client.call_api(
*_param, *_param,

View File

@ -282,7 +282,7 @@ class ApiClient:
def response_deserialize( def response_deserialize(
self, self,
response_data=None, response_data: rest.RESTResponse = None,
response_types_map=None response_types_map=None
) -> ApiResponse: ) -> ApiResponse:
"""Deserializes response into an object. """Deserializes response into an object.
@ -297,32 +297,15 @@ class ApiClient:
# if not found, look for '1XX', '2XX', etc. # if not found, look for '1XX', '2XX', etc.
response_type = response_types_map.get(str(response_data.status)[0] + "XX", None) 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 # deserialize response data
response_text = None
return_data = None
try:
if response_type == "bytearray": if response_type == "bytearray":
return_data = response_data.data return_data = response_data.data
elif response_type is None:
return_data = None
elif response_type == "file": elif response_type == "file":
return_data = self.__deserialize_file(response_data) return_data = self.__deserialize_file(response_data)
else: elif response_type is not None:
match = None match = None
content_type = response_data.getheader('content-type') content_type = response_data.getheader('content-type')
if content_type is not None: if content_type is not None:
@ -330,6 +313,13 @@ class ApiClient:
encoding = match.group(1) if match else "utf-8" encoding = match.group(1) if match else "utf-8"
response_text = response_data.data.decode(encoding) response_text = response_data.data.decode(encoding)
return_data = self.deserialize(response_text, response_type) 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( return ApiResponse(
status_code = response_data.status, status_code = response_data.status,

View File

@ -12,6 +12,9 @@
Do not edit the class manually. Do not edit the class manually.
""" # noqa: E501 """ # noqa: E501
from typing import Any, Optional
from typing_extensions import Self
class OpenApiException(Exception): class OpenApiException(Exception):
"""The base exception class for all OpenAPIExceptions""" """The base exception class for all OpenAPIExceptions"""
@ -102,18 +105,57 @@ class ApiKeyError(OpenApiException, KeyError):
class ApiException(OpenApiException): class ApiException(OpenApiException):
def __init__(self, status=None, reason=None, http_resp=None) -> None: def __init__(
if http_resp: self,
self.status = http_resp.status status=None,
self.reason = http_resp.reason reason=None,
self.body = http_resp.data.decode('utf-8') http_resp=None,
self.headers = http_resp.getheaders() *,
else: body: Optional[str] = None,
data: Optional[Any] = None,
) -> None:
self.status = status self.status = status
self.reason = reason self.reason = reason
self.body = None self.body = body
self.data = data
self.headers = None self.headers = None
if http_resp:
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()
@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): def __str__(self):
"""Custom error messages for exception""" """Custom error messages for exception"""
error_message = "({0})\n"\ error_message = "({0})\n"\
@ -122,38 +164,30 @@ class ApiException(OpenApiException):
error_message += "HTTP response headers: {0}\n".format( error_message += "HTTP response headers: {0}\n".format(
self.headers) self.headers)
if self.body: if self.data or self.body:
error_message += "HTTP response body: {0}\n".format(self.body) error_message += "HTTP response body: {0}\n".format(self.data or self.body)
return error_message return error_message
class BadRequestException(ApiException):
def __init__(self, status=None, reason=None, http_resp=None) -> None: class BadRequestException(ApiException):
super(BadRequestException, self).__init__(status, reason, http_resp) pass
class NotFoundException(ApiException): class NotFoundException(ApiException):
pass
def __init__(self, status=None, reason=None, http_resp=None) -> None:
super(NotFoundException, self).__init__(status, reason, http_resp)
class UnauthorizedException(ApiException): class UnauthorizedException(ApiException):
pass
def __init__(self, status=None, reason=None, http_resp=None) -> None:
super(UnauthorizedException, self).__init__(status, reason, http_resp)
class ForbiddenException(ApiException): class ForbiddenException(ApiException):
pass
def __init__(self, status=None, reason=None, http_resp=None) -> None:
super(ForbiddenException, self).__init__(status, reason, http_resp)
class ServiceException(ApiException): class ServiceException(ApiException):
pass
def __init__(self, status=None, reason=None, http_resp=None) -> None:
super(ServiceException, self).__init__(status, reason, http_resp)
def render_path(path_to_item): def render_path(path_to_item):

View File

@ -93,8 +93,7 @@ class AuthApi:
) )
_response_types_map: Dict[str, Optional[str]] = { _response_types_map: Dict[str, Optional[str]] = {
'200': "str" '200': "str",
} }
response_data = self.api_client.call_api( response_data = self.api_client.call_api(
*_param, *_param,
@ -157,8 +156,7 @@ class AuthApi:
) )
_response_types_map: Dict[str, Optional[str]] = { _response_types_map: Dict[str, Optional[str]] = {
'200': "str" '200': "str",
} }
response_data = self.api_client.call_api( response_data = self.api_client.call_api(
*_param, *_param,
@ -221,8 +219,7 @@ class AuthApi:
) )
_response_types_map: Dict[str, Optional[str]] = { _response_types_map: Dict[str, Optional[str]] = {
'200': "str" '200': "str",
} }
response_data = self.api_client.call_api( response_data = self.api_client.call_api(
*_param, *_param,

View File

@ -101,8 +101,7 @@ class BodyApi:
) )
_response_types_map: Dict[str, Optional[str]] = { _response_types_map: Dict[str, Optional[str]] = {
'200': "bytearray" '200': "bytearray",
} }
response_data = self.api_client.call_api( response_data = self.api_client.call_api(
*_param, *_param,
@ -165,8 +164,7 @@ class BodyApi:
) )
_response_types_map: Dict[str, Optional[str]] = { _response_types_map: Dict[str, Optional[str]] = {
'200': "bytearray" '200': "bytearray",
} }
response_data = self.api_client.call_api( response_data = self.api_client.call_api(
*_param, *_param,
@ -229,8 +227,7 @@ class BodyApi:
) )
_response_types_map: Dict[str, Optional[str]] = { _response_types_map: Dict[str, Optional[str]] = {
'200': "bytearray" '200': "bytearray",
} }
response_data = self.api_client.call_api( response_data = self.api_client.call_api(
*_param, *_param,
@ -351,8 +348,7 @@ class BodyApi:
) )
_response_types_map: Dict[str, Optional[str]] = { _response_types_map: Dict[str, Optional[str]] = {
'200': "str" '200': "str",
} }
response_data = self.api_client.call_api( response_data = self.api_client.call_api(
*_param, *_param,
@ -419,8 +415,7 @@ class BodyApi:
) )
_response_types_map: Dict[str, Optional[str]] = { _response_types_map: Dict[str, Optional[str]] = {
'200': "str" '200': "str",
} }
response_data = self.api_client.call_api( response_data = self.api_client.call_api(
*_param, *_param,
@ -487,8 +482,7 @@ class BodyApi:
) )
_response_types_map: Dict[str, Optional[str]] = { _response_types_map: Dict[str, Optional[str]] = {
'200': "str" '200': "str",
} }
response_data = self.api_client.call_api( response_data = self.api_client.call_api(
*_param, *_param,
@ -630,8 +624,7 @@ class BodyApi:
) )
_response_types_map: Dict[str, Optional[str]] = { _response_types_map: Dict[str, Optional[str]] = {
'200': "str" '200': "str",
} }
response_data = self.api_client.call_api( response_data = self.api_client.call_api(
*_param, *_param,
@ -698,8 +691,7 @@ class BodyApi:
) )
_response_types_map: Dict[str, Optional[str]] = { _response_types_map: Dict[str, Optional[str]] = {
'200': "str" '200': "str",
} }
response_data = self.api_client.call_api( response_data = self.api_client.call_api(
*_param, *_param,
@ -766,8 +758,7 @@ class BodyApi:
) )
_response_types_map: Dict[str, Optional[str]] = { _response_types_map: Dict[str, Optional[str]] = {
'200': "str" '200': "str",
} }
response_data = self.api_client.call_api( response_data = self.api_client.call_api(
*_param, *_param,
@ -905,8 +896,7 @@ class BodyApi:
) )
_response_types_map: Dict[str, Optional[str]] = { _response_types_map: Dict[str, Optional[str]] = {
'200': "Pet" '200': "Pet",
} }
response_data = self.api_client.call_api( response_data = self.api_client.call_api(
*_param, *_param,
@ -973,8 +963,7 @@ class BodyApi:
) )
_response_types_map: Dict[str, Optional[str]] = { _response_types_map: Dict[str, Optional[str]] = {
'200': "Pet" '200': "Pet",
} }
response_data = self.api_client.call_api( response_data = self.api_client.call_api(
*_param, *_param,
@ -1041,8 +1030,7 @@ class BodyApi:
) )
_response_types_map: Dict[str, Optional[str]] = { _response_types_map: Dict[str, Optional[str]] = {
'200': "Pet" '200': "Pet",
} }
response_data = self.api_client.call_api( response_data = self.api_client.call_api(
*_param, *_param,
@ -1179,8 +1167,7 @@ class BodyApi:
) )
_response_types_map: Dict[str, Optional[str]] = { _response_types_map: Dict[str, Optional[str]] = {
'200': "str" '200': "str",
} }
response_data = self.api_client.call_api( response_data = self.api_client.call_api(
*_param, *_param,
@ -1247,8 +1234,7 @@ class BodyApi:
) )
_response_types_map: Dict[str, Optional[str]] = { _response_types_map: Dict[str, Optional[str]] = {
'200': "str" '200': "str",
} }
response_data = self.api_client.call_api( response_data = self.api_client.call_api(
*_param, *_param,
@ -1315,8 +1301,7 @@ class BodyApi:
) )
_response_types_map: Dict[str, Optional[str]] = { _response_types_map: Dict[str, Optional[str]] = {
'200': "str" '200': "str",
} }
response_data = self.api_client.call_api( response_data = self.api_client.call_api(
*_param, *_param,
@ -1453,8 +1438,7 @@ class BodyApi:
) )
_response_types_map: Dict[str, Optional[str]] = { _response_types_map: Dict[str, Optional[str]] = {
'200': "Pet" '200': "Pet",
} }
response_data = self.api_client.call_api( response_data = self.api_client.call_api(
*_param, *_param,
@ -1521,8 +1505,7 @@ class BodyApi:
) )
_response_types_map: Dict[str, Optional[str]] = { _response_types_map: Dict[str, Optional[str]] = {
'200': "Pet" '200': "Pet",
} }
response_data = self.api_client.call_api( response_data = self.api_client.call_api(
*_param, *_param,
@ -1589,8 +1572,7 @@ class BodyApi:
) )
_response_types_map: Dict[str, Optional[str]] = { _response_types_map: Dict[str, Optional[str]] = {
'200': "Pet" '200': "Pet",
} }
response_data = self.api_client.call_api( response_data = self.api_client.call_api(
*_param, *_param,
@ -1727,8 +1709,7 @@ class BodyApi:
) )
_response_types_map: Dict[str, Optional[str]] = { _response_types_map: Dict[str, Optional[str]] = {
'200': "str" '200': "str",
} }
response_data = self.api_client.call_api( response_data = self.api_client.call_api(
*_param, *_param,
@ -1795,8 +1776,7 @@ class BodyApi:
) )
_response_types_map: Dict[str, Optional[str]] = { _response_types_map: Dict[str, Optional[str]] = {
'200': "str" '200': "str",
} }
response_data = self.api_client.call_api( response_data = self.api_client.call_api(
*_param, *_param,
@ -1863,8 +1843,7 @@ class BodyApi:
) )
_response_types_map: Dict[str, Optional[str]] = { _response_types_map: Dict[str, Optional[str]] = {
'200': "str" '200': "str",
} }
response_data = self.api_client.call_api( response_data = self.api_client.call_api(
*_param, *_param,
@ -2001,8 +1980,7 @@ class BodyApi:
) )
_response_types_map: Dict[str, Optional[str]] = { _response_types_map: Dict[str, Optional[str]] = {
'200': "str" '200': "str",
} }
response_data = self.api_client.call_api( response_data = self.api_client.call_api(
*_param, *_param,
@ -2069,8 +2047,7 @@ class BodyApi:
) )
_response_types_map: Dict[str, Optional[str]] = { _response_types_map: Dict[str, Optional[str]] = {
'200': "str" '200': "str",
} }
response_data = self.api_client.call_api( response_data = self.api_client.call_api(
*_param, *_param,
@ -2137,8 +2114,7 @@ class BodyApi:
) )
_response_types_map: Dict[str, Optional[str]] = { _response_types_map: Dict[str, Optional[str]] = {
'200': "str" '200': "str",
} }
response_data = self.api_client.call_api( response_data = self.api_client.call_api(
*_param, *_param,

View File

@ -109,8 +109,7 @@ class FormApi:
) )
_response_types_map: Dict[str, Optional[str]] = { _response_types_map: Dict[str, Optional[str]] = {
'200': "str" '200': "str",
} }
response_data = self.api_client.call_api( response_data = self.api_client.call_api(
*_param, *_param,
@ -185,8 +184,7 @@ class FormApi:
) )
_response_types_map: Dict[str, Optional[str]] = { _response_types_map: Dict[str, Optional[str]] = {
'200': "str" '200': "str",
} }
response_data = self.api_client.call_api( response_data = self.api_client.call_api(
*_param, *_param,
@ -261,8 +259,7 @@ class FormApi:
) )
_response_types_map: Dict[str, Optional[str]] = { _response_types_map: Dict[str, Optional[str]] = {
'200': "str" '200': "str",
} }
response_data = self.api_client.call_api( response_data = self.api_client.call_api(
*_param, *_param,
@ -425,8 +422,7 @@ class FormApi:
) )
_response_types_map: Dict[str, Optional[str]] = { _response_types_map: Dict[str, Optional[str]] = {
'200': "str" '200': "str",
} }
response_data = self.api_client.call_api( response_data = self.api_client.call_api(
*_param, *_param,
@ -513,8 +509,7 @@ class FormApi:
) )
_response_types_map: Dict[str, Optional[str]] = { _response_types_map: Dict[str, Optional[str]] = {
'200': "str" '200': "str",
} }
response_data = self.api_client.call_api( response_data = self.api_client.call_api(
*_param, *_param,
@ -601,8 +596,7 @@ class FormApi:
) )
_response_types_map: Dict[str, Optional[str]] = { _response_types_map: Dict[str, Optional[str]] = {
'200': "str" '200': "str",
} }
response_data = self.api_client.call_api( response_data = self.api_client.call_api(
*_param, *_param,

View File

@ -118,8 +118,7 @@ class HeaderApi:
) )
_response_types_map: Dict[str, Optional[str]] = { _response_types_map: Dict[str, Optional[str]] = {
'200': "str" '200': "str",
} }
response_data = self.api_client.call_api( response_data = self.api_client.call_api(
*_param, *_param,
@ -202,8 +201,7 @@ class HeaderApi:
) )
_response_types_map: Dict[str, Optional[str]] = { _response_types_map: Dict[str, Optional[str]] = {
'200': "str" '200': "str",
} }
response_data = self.api_client.call_api( response_data = self.api_client.call_api(
*_param, *_param,
@ -286,8 +284,7 @@ class HeaderApi:
) )
_response_types_map: Dict[str, Optional[str]] = { _response_types_map: Dict[str, Optional[str]] = {
'200': "str" '200': "str",
} }
response_data = self.api_client.call_api( response_data = self.api_client.call_api(
*_param, *_param,

View File

@ -112,8 +112,7 @@ class PathApi:
) )
_response_types_map: Dict[str, Optional[str]] = { _response_types_map: Dict[str, Optional[str]] = {
'200': "str" '200': "str",
} }
response_data = self.api_client.call_api( response_data = self.api_client.call_api(
*_param, *_param,
@ -192,8 +191,7 @@ class PathApi:
) )
_response_types_map: Dict[str, Optional[str]] = { _response_types_map: Dict[str, Optional[str]] = {
'200': "str" '200': "str",
} }
response_data = self.api_client.call_api( response_data = self.api_client.call_api(
*_param, *_param,
@ -272,8 +270,7 @@ class PathApi:
) )
_response_types_map: Dict[str, Optional[str]] = { _response_types_map: Dict[str, Optional[str]] = {
'200': "str" '200': "str",
} }
response_data = self.api_client.call_api( response_data = self.api_client.call_api(
*_param, *_param,

View File

@ -110,8 +110,7 @@ class QueryApi:
) )
_response_types_map: Dict[str, Optional[str]] = { _response_types_map: Dict[str, Optional[str]] = {
'200': "str" '200': "str",
} }
response_data = self.api_client.call_api( response_data = self.api_client.call_api(
*_param, *_param,
@ -182,8 +181,7 @@ class QueryApi:
) )
_response_types_map: Dict[str, Optional[str]] = { _response_types_map: Dict[str, Optional[str]] = {
'200': "str" '200': "str",
} }
response_data = self.api_client.call_api( response_data = self.api_client.call_api(
*_param, *_param,
@ -254,8 +252,7 @@ class QueryApi:
) )
_response_types_map: Dict[str, Optional[str]] = { _response_types_map: Dict[str, Optional[str]] = {
'200': "str" '200': "str",
} }
response_data = self.api_client.call_api( response_data = self.api_client.call_api(
*_param, *_param,
@ -394,8 +391,7 @@ class QueryApi:
) )
_response_types_map: Dict[str, Optional[str]] = { _response_types_map: Dict[str, Optional[str]] = {
'200': "str" '200': "str",
} }
response_data = self.api_client.call_api( response_data = self.api_client.call_api(
*_param, *_param,
@ -470,8 +466,7 @@ class QueryApi:
) )
_response_types_map: Dict[str, Optional[str]] = { _response_types_map: Dict[str, Optional[str]] = {
'200': "str" '200': "str",
} }
response_data = self.api_client.call_api( response_data = self.api_client.call_api(
*_param, *_param,
@ -546,8 +541,7 @@ class QueryApi:
) )
_response_types_map: Dict[str, Optional[str]] = { _response_types_map: Dict[str, Optional[str]] = {
'200': "str" '200': "str",
} }
response_data = self.api_client.call_api( response_data = self.api_client.call_api(
*_param, *_param,
@ -709,8 +703,7 @@ class QueryApi:
) )
_response_types_map: Dict[str, Optional[str]] = { _response_types_map: Dict[str, Optional[str]] = {
'200': "str" '200': "str",
} }
response_data = self.api_client.call_api( response_data = self.api_client.call_api(
*_param, *_param,
@ -785,8 +778,7 @@ class QueryApi:
) )
_response_types_map: Dict[str, Optional[str]] = { _response_types_map: Dict[str, Optional[str]] = {
'200': "str" '200': "str",
} }
response_data = self.api_client.call_api( response_data = self.api_client.call_api(
*_param, *_param,
@ -861,8 +853,7 @@ class QueryApi:
) )
_response_types_map: Dict[str, Optional[str]] = { _response_types_map: Dict[str, Optional[str]] = {
'200': "str" '200': "str",
} }
response_data = self.api_client.call_api( response_data = self.api_client.call_api(
*_param, *_param,
@ -998,8 +989,7 @@ class QueryApi:
) )
_response_types_map: Dict[str, Optional[str]] = { _response_types_map: Dict[str, Optional[str]] = {
'200': "str" '200': "str",
} }
response_data = self.api_client.call_api( response_data = self.api_client.call_api(
*_param, *_param,
@ -1066,8 +1056,7 @@ class QueryApi:
) )
_response_types_map: Dict[str, Optional[str]] = { _response_types_map: Dict[str, Optional[str]] = {
'200': "str" '200': "str",
} }
response_data = self.api_client.call_api( response_data = self.api_client.call_api(
*_param, *_param,
@ -1134,8 +1123,7 @@ class QueryApi:
) )
_response_types_map: Dict[str, Optional[str]] = { _response_types_map: Dict[str, Optional[str]] = {
'200': "str" '200': "str",
} }
response_data = self.api_client.call_api( response_data = self.api_client.call_api(
*_param, *_param,
@ -1261,8 +1249,7 @@ class QueryApi:
) )
_response_types_map: Dict[str, Optional[str]] = { _response_types_map: Dict[str, Optional[str]] = {
'200': "str" '200': "str",
} }
response_data = self.api_client.call_api( response_data = self.api_client.call_api(
*_param, *_param,
@ -1329,8 +1316,7 @@ class QueryApi:
) )
_response_types_map: Dict[str, Optional[str]] = { _response_types_map: Dict[str, Optional[str]] = {
'200': "str" '200': "str",
} }
response_data = self.api_client.call_api( response_data = self.api_client.call_api(
*_param, *_param,
@ -1397,8 +1383,7 @@ class QueryApi:
) )
_response_types_map: Dict[str, Optional[str]] = { _response_types_map: Dict[str, Optional[str]] = {
'200': "str" '200': "str",
} }
response_data = self.api_client.call_api( response_data = self.api_client.call_api(
*_param, *_param,
@ -1524,8 +1509,7 @@ class QueryApi:
) )
_response_types_map: Dict[str, Optional[str]] = { _response_types_map: Dict[str, Optional[str]] = {
'200': "str" '200': "str",
} }
response_data = self.api_client.call_api( response_data = self.api_client.call_api(
*_param, *_param,
@ -1592,8 +1576,7 @@ class QueryApi:
) )
_response_types_map: Dict[str, Optional[str]] = { _response_types_map: Dict[str, Optional[str]] = {
'200': "str" '200': "str",
} }
response_data = self.api_client.call_api( response_data = self.api_client.call_api(
*_param, *_param,
@ -1660,8 +1643,7 @@ class QueryApi:
) )
_response_types_map: Dict[str, Optional[str]] = { _response_types_map: Dict[str, Optional[str]] = {
'200': "str" '200': "str",
} }
response_data = self.api_client.call_api( response_data = self.api_client.call_api(
*_param, *_param,
@ -1787,8 +1769,7 @@ class QueryApi:
) )
_response_types_map: Dict[str, Optional[str]] = { _response_types_map: Dict[str, Optional[str]] = {
'200': "str" '200': "str",
} }
response_data = self.api_client.call_api( response_data = self.api_client.call_api(
*_param, *_param,
@ -1855,8 +1836,7 @@ class QueryApi:
) )
_response_types_map: Dict[str, Optional[str]] = { _response_types_map: Dict[str, Optional[str]] = {
'200': "str" '200': "str",
} }
response_data = self.api_client.call_api( response_data = self.api_client.call_api(
*_param, *_param,
@ -1923,8 +1903,7 @@ class QueryApi:
) )
_response_types_map: Dict[str, Optional[str]] = { _response_types_map: Dict[str, Optional[str]] = {
'200': "str" '200': "str",
} }
response_data = self.api_client.call_api( response_data = self.api_client.call_api(
*_param, *_param,
@ -2050,8 +2029,7 @@ class QueryApi:
) )
_response_types_map: Dict[str, Optional[str]] = { _response_types_map: Dict[str, Optional[str]] = {
'200': "str" '200': "str",
} }
response_data = self.api_client.call_api( response_data = self.api_client.call_api(
*_param, *_param,
@ -2118,8 +2096,7 @@ class QueryApi:
) )
_response_types_map: Dict[str, Optional[str]] = { _response_types_map: Dict[str, Optional[str]] = {
'200': "str" '200': "str",
} }
response_data = self.api_client.call_api( response_data = self.api_client.call_api(
*_param, *_param,
@ -2186,8 +2163,7 @@ class QueryApi:
) )
_response_types_map: Dict[str, Optional[str]] = { _response_types_map: Dict[str, Optional[str]] = {
'200': "str" '200': "str",
} }
response_data = self.api_client.call_api( response_data = self.api_client.call_api(
*_param, *_param,

View File

@ -282,7 +282,7 @@ class ApiClient:
def response_deserialize( def response_deserialize(
self, self,
response_data=None, response_data: rest.RESTResponse = None,
response_types_map=None response_types_map=None
) -> ApiResponse: ) -> ApiResponse:
"""Deserializes response into an object. """Deserializes response into an object.
@ -297,32 +297,15 @@ class ApiClient:
# if not found, look for '1XX', '2XX', etc. # if not found, look for '1XX', '2XX', etc.
response_type = response_types_map.get(str(response_data.status)[0] + "XX", None) 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 # deserialize response data
response_text = None
return_data = None
try:
if response_type == "bytearray": if response_type == "bytearray":
return_data = response_data.data return_data = response_data.data
elif response_type is None:
return_data = None
elif response_type == "file": elif response_type == "file":
return_data = self.__deserialize_file(response_data) return_data = self.__deserialize_file(response_data)
else: elif response_type is not None:
match = None match = None
content_type = response_data.getheader('content-type') content_type = response_data.getheader('content-type')
if content_type is not None: if content_type is not None:
@ -330,6 +313,13 @@ class ApiClient:
encoding = match.group(1) if match else "utf-8" encoding = match.group(1) if match else "utf-8"
response_text = response_data.data.decode(encoding) response_text = response_data.data.decode(encoding)
return_data = self.deserialize(response_text, response_type) 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( return ApiResponse(
status_code = response_data.status, status_code = response_data.status,

View File

@ -12,6 +12,9 @@
Do not edit the class manually. Do not edit the class manually.
""" # noqa: E501 """ # noqa: E501
from typing import Any, Optional
from typing_extensions import Self
class OpenApiException(Exception): class OpenApiException(Exception):
"""The base exception class for all OpenAPIExceptions""" """The base exception class for all OpenAPIExceptions"""
@ -102,18 +105,57 @@ class ApiKeyError(OpenApiException, KeyError):
class ApiException(OpenApiException): class ApiException(OpenApiException):
def __init__(self, status=None, reason=None, http_resp=None) -> None: def __init__(
if http_resp: self,
self.status = http_resp.status status=None,
self.reason = http_resp.reason reason=None,
self.body = http_resp.data.decode('utf-8') http_resp=None,
self.headers = http_resp.getheaders() *,
else: body: Optional[str] = None,
data: Optional[Any] = None,
) -> None:
self.status = status self.status = status
self.reason = reason self.reason = reason
self.body = None self.body = body
self.data = data
self.headers = None self.headers = None
if http_resp:
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()
@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): def __str__(self):
"""Custom error messages for exception""" """Custom error messages for exception"""
error_message = "({0})\n"\ error_message = "({0})\n"\
@ -122,38 +164,30 @@ class ApiException(OpenApiException):
error_message += "HTTP response headers: {0}\n".format( error_message += "HTTP response headers: {0}\n".format(
self.headers) self.headers)
if self.body: if self.data or self.body:
error_message += "HTTP response body: {0}\n".format(self.body) error_message += "HTTP response body: {0}\n".format(self.data or self.body)
return error_message return error_message
class BadRequestException(ApiException):
def __init__(self, status=None, reason=None, http_resp=None) -> None: class BadRequestException(ApiException):
super(BadRequestException, self).__init__(status, reason, http_resp) pass
class NotFoundException(ApiException): class NotFoundException(ApiException):
pass
def __init__(self, status=None, reason=None, http_resp=None) -> None:
super(NotFoundException, self).__init__(status, reason, http_resp)
class UnauthorizedException(ApiException): class UnauthorizedException(ApiException):
pass
def __init__(self, status=None, reason=None, http_resp=None) -> None:
super(UnauthorizedException, self).__init__(status, reason, http_resp)
class ForbiddenException(ApiException): class ForbiddenException(ApiException):
pass
def __init__(self, status=None, reason=None, http_resp=None) -> None:
super(ForbiddenException, self).__init__(status, reason, http_resp)
class ServiceException(ApiException): class ServiceException(ApiException):
pass
def __init__(self, status=None, reason=None, http_resp=None) -> None:
super(ServiceException, self).__init__(status, reason, http_resp)
def render_path(path_to_item): def render_path(path_to_item):

View File

@ -84,6 +84,8 @@ docs/SpecialModelName.md
docs/SpecialName.md docs/SpecialName.md
docs/StoreApi.md docs/StoreApi.md
docs/Tag.md docs/Tag.md
docs/TestErrorResponsesWithModel400Response.md
docs/TestErrorResponsesWithModel404Response.md
docs/TestInlineFreeformAdditionalPropertiesRequest.md docs/TestInlineFreeformAdditionalPropertiesRequest.md
docs/Tiger.md docs/Tiger.md
docs/UnnamedDictWithAdditionalModelListProperties.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_model_name.py
petstore_api/models/special_name.py petstore_api/models/special_name.py
petstore_api/models/tag.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/test_inline_freeform_additional_properties_request.py
petstore_api/models/tiger.py petstore_api/models/tiger.py
petstore_api/models/unnamed_dict_with_additional_model_list_properties.py petstore_api/models/unnamed_dict_with_additional_model_list_properties.py

View File

@ -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_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 \&quot;client\&quot; model *FakeApi* | [**test_client_model**](docs/FakeApi.md#test_client_model) | **PATCH** /fake | To test \&quot;client\&quot; model
*FakeApi* | [**test_date_time_query_parameter**](docs/FakeApi.md#test_date_time_query_parameter) | **PUT** /fake/date-time-query-params | *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_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_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_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 *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) - [SpecialModelName](docs/SpecialModelName.md)
- [SpecialName](docs/SpecialName.md) - [SpecialName](docs/SpecialName.md)
- [Tag](docs/Tag.md) - [Tag](docs/Tag.md)
- [TestErrorResponsesWithModel400Response](docs/TestErrorResponsesWithModel400Response.md)
- [TestErrorResponsesWithModel404Response](docs/TestErrorResponsesWithModel404Response.md)
- [TestInlineFreeformAdditionalPropertiesRequest](docs/TestInlineFreeformAdditionalPropertiesRequest.md) - [TestInlineFreeformAdditionalPropertiesRequest](docs/TestInlineFreeformAdditionalPropertiesRequest.md)
- [Tiger](docs/Tiger.md) - [Tiger](docs/Tiger.md)
- [UnnamedDictWithAdditionalModelListProperties](docs/UnnamedDictWithAdditionalModelListProperties.md) - [UnnamedDictWithAdditionalModelListProperties](docs/UnnamedDictWithAdditionalModelListProperties.md)

View File

@ -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_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 \&quot;client\&quot; model [**test_client_model**](FakeApi.md#test_client_model) | **PATCH** /fake | To test \&quot;client\&quot; model
[**test_date_time_query_parameter**](FakeApi.md#test_date_time_query_parameter) | **PUT** /fake/date-time-query-params | [**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_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_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_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 [**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) [[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**
> 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) > 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) [[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**
> test_group_parameters(required_string_group, required_boolean_group, required_int64_group, string_group=string_group, boolean_group=boolean_group, int64_group=int64_group) > test_group_parameters(required_string_group, required_boolean_group, required_int64_group, string_group=string_group, boolean_group=boolean_group, int64_group=int64_group)

View File

@ -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)

View File

@ -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)

View File

@ -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_model_name import SpecialModelName
from petstore_api.models.special_name import SpecialName from petstore_api.models.special_name import SpecialName
from petstore_api.models.tag import Tag 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.test_inline_freeform_additional_properties_request import TestInlineFreeformAdditionalPropertiesRequest
from petstore_api.models.tiger import Tiger from petstore_api.models.tiger import Tiger
from petstore_api.models.unnamed_dict_with_additional_model_list_properties import UnnamedDictWithAdditionalModelListProperties from petstore_api.models.unnamed_dict_with_additional_model_list_properties import UnnamedDictWithAdditionalModelListProperties

View File

@ -99,8 +99,7 @@ class AnotherFakeApi:
) )
_response_types_map: Dict[str, Optional[str]] = { _response_types_map: Dict[str, Optional[str]] = {
'200': "Client" '200': "Client",
} }
response_data = await self.api_client.call_api( response_data = await self.api_client.call_api(
*_param, *_param,
@ -167,8 +166,7 @@ class AnotherFakeApi:
) )
_response_types_map: Dict[str, Optional[str]] = { _response_types_map: Dict[str, Optional[str]] = {
'200': "Client" '200': "Client",
} }
response_data = await self.api_client.call_api( response_data = await self.api_client.call_api(
*_param, *_param,
@ -235,8 +233,7 @@ class AnotherFakeApi:
) )
_response_types_map: Dict[str, Optional[str]] = { _response_types_map: Dict[str, Optional[str]] = {
'200': "Client" '200': "Client",
} }
response_data = await self.api_client.call_api( response_data = await self.api_client.call_api(
*_param, *_param,

View File

@ -92,8 +92,6 @@ class DefaultApi:
) )
_response_types_map: Dict[str, Optional[str]] = { _response_types_map: Dict[str, Optional[str]] = {
} }
response_data = await self.api_client.call_api( response_data = await self.api_client.call_api(
*_param, *_param,
@ -155,8 +153,6 @@ class DefaultApi:
) )
_response_types_map: Dict[str, Optional[str]] = { _response_types_map: Dict[str, Optional[str]] = {
} }
response_data = await self.api_client.call_api( response_data = await self.api_client.call_api(
*_param, *_param,
@ -218,8 +214,6 @@ class DefaultApi:
) )
_response_types_map: Dict[str, Optional[str]] = { _response_types_map: Dict[str, Optional[str]] = {
} }
response_data = await self.api_client.call_api( response_data = await self.api_client.call_api(
*_param, *_param,

View File

@ -99,8 +99,7 @@ class FakeClassnameTags123Api:
) )
_response_types_map: Dict[str, Optional[str]] = { _response_types_map: Dict[str, Optional[str]] = {
'200': "Client" '200': "Client",
} }
response_data = await self.api_client.call_api( response_data = await self.api_client.call_api(
*_param, *_param,
@ -167,8 +166,7 @@ class FakeClassnameTags123Api:
) )
_response_types_map: Dict[str, Optional[str]] = { _response_types_map: Dict[str, Optional[str]] = {
'200': "Client" '200': "Client",
} }
response_data = await self.api_client.call_api( response_data = await self.api_client.call_api(
*_param, *_param,
@ -235,8 +233,7 @@ class FakeClassnameTags123Api:
) )
_response_types_map: Dict[str, Optional[str]] = { _response_types_map: Dict[str, Optional[str]] = {
'200': "Client" '200': "Client",
} }
response_data = await self.api_client.call_api( response_data = await self.api_client.call_api(
*_param, *_param,

View File

@ -104,7 +104,8 @@ class PetApi:
) )
_response_types_map: Dict[str, Optional[str]] = { _response_types_map: Dict[str, Optional[str]] = {
'200': None,
'405': None,
} }
response_data = await self.api_client.call_api( response_data = await self.api_client.call_api(
*_param, *_param,
@ -171,7 +172,8 @@ class PetApi:
) )
_response_types_map: Dict[str, Optional[str]] = { _response_types_map: Dict[str, Optional[str]] = {
'200': None,
'405': None,
} }
response_data = await self.api_client.call_api( response_data = await self.api_client.call_api(
*_param, *_param,
@ -238,7 +240,8 @@ class PetApi:
) )
_response_types_map: Dict[str, Optional[str]] = { _response_types_map: Dict[str, Optional[str]] = {
'200': None,
'405': None,
} }
response_data = await self.api_client.call_api( response_data = await self.api_client.call_api(
*_param, *_param,
@ -376,7 +379,8 @@ class PetApi:
) )
_response_types_map: Dict[str, Optional[str]] = { _response_types_map: Dict[str, Optional[str]] = {
'200': None,
'400': None,
} }
response_data = await self.api_client.call_api( response_data = await self.api_client.call_api(
*_param, *_param,
@ -447,7 +451,8 @@ class PetApi:
) )
_response_types_map: Dict[str, Optional[str]] = { _response_types_map: Dict[str, Optional[str]] = {
'200': None,
'400': None,
} }
response_data = await self.api_client.call_api( response_data = await self.api_client.call_api(
*_param, *_param,
@ -518,7 +523,8 @@ class PetApi:
) )
_response_types_map: Dict[str, Optional[str]] = { _response_types_map: Dict[str, Optional[str]] = {
'200': None,
'400': None,
} }
response_data = await self.api_client.call_api( response_data = await self.api_client.call_api(
*_param, *_param,
@ -641,8 +647,7 @@ class PetApi:
_response_types_map: Dict[str, Optional[str]] = { _response_types_map: Dict[str, Optional[str]] = {
'200': "List[Pet]", '200': "List[Pet]",
'400': None '400': None,
} }
response_data = await self.api_client.call_api( response_data = await self.api_client.call_api(
*_param, *_param,
@ -710,8 +715,7 @@ class PetApi:
_response_types_map: Dict[str, Optional[str]] = { _response_types_map: Dict[str, Optional[str]] = {
'200': "List[Pet]", '200': "List[Pet]",
'400': None '400': None,
} }
response_data = await self.api_client.call_api( response_data = await self.api_client.call_api(
*_param, *_param,
@ -779,8 +783,7 @@ class PetApi:
_response_types_map: Dict[str, Optional[str]] = { _response_types_map: Dict[str, Optional[str]] = {
'200': "List[Pet]", '200': "List[Pet]",
'400': None '400': None,
} }
response_data = await self.api_client.call_api( response_data = await self.api_client.call_api(
*_param, *_param,
@ -912,8 +915,7 @@ class PetApi:
_response_types_map: Dict[str, Optional[str]] = { _response_types_map: Dict[str, Optional[str]] = {
'200': "List[Pet]", '200': "List[Pet]",
'400': None '400': None,
} }
response_data = await self.api_client.call_api( response_data = await self.api_client.call_api(
*_param, *_param,
@ -982,8 +984,7 @@ class PetApi:
_response_types_map: Dict[str, Optional[str]] = { _response_types_map: Dict[str, Optional[str]] = {
'200': "List[Pet]", '200': "List[Pet]",
'400': None '400': None,
} }
response_data = await self.api_client.call_api( response_data = await self.api_client.call_api(
*_param, *_param,
@ -1052,8 +1053,7 @@ class PetApi:
_response_types_map: Dict[str, Optional[str]] = { _response_types_map: Dict[str, Optional[str]] = {
'200': "List[Pet]", '200': "List[Pet]",
'400': None '400': None,
} }
response_data = await self.api_client.call_api( response_data = await self.api_client.call_api(
*_param, *_param,
@ -1185,8 +1185,7 @@ class PetApi:
_response_types_map: Dict[str, Optional[str]] = { _response_types_map: Dict[str, Optional[str]] = {
'200': "Pet", '200': "Pet",
'400': None, '400': None,
'404': None '404': None,
} }
response_data = await self.api_client.call_api( response_data = await self.api_client.call_api(
*_param, *_param,
@ -1255,8 +1254,7 @@ class PetApi:
_response_types_map: Dict[str, Optional[str]] = { _response_types_map: Dict[str, Optional[str]] = {
'200': "Pet", '200': "Pet",
'400': None, '400': None,
'404': None '404': None,
} }
response_data = await self.api_client.call_api( response_data = await self.api_client.call_api(
*_param, *_param,
@ -1325,8 +1323,7 @@ class PetApi:
_response_types_map: Dict[str, Optional[str]] = { _response_types_map: Dict[str, Optional[str]] = {
'200': "Pet", '200': "Pet",
'400': None, '400': None,
'404': None '404': None,
} }
response_data = await self.api_client.call_api( response_data = await self.api_client.call_api(
*_param, *_param,
@ -1452,7 +1449,10 @@ class PetApi:
) )
_response_types_map: Dict[str, Optional[str]] = { _response_types_map: Dict[str, Optional[str]] = {
'200': None,
'400': None,
'404': None,
'405': None,
} }
response_data = await self.api_client.call_api( response_data = await self.api_client.call_api(
*_param, *_param,
@ -1519,7 +1519,10 @@ class PetApi:
) )
_response_types_map: Dict[str, Optional[str]] = { _response_types_map: Dict[str, Optional[str]] = {
'200': None,
'400': None,
'404': None,
'405': None,
} }
response_data = await self.api_client.call_api( response_data = await self.api_client.call_api(
*_param, *_param,
@ -1586,7 +1589,10 @@ class PetApi:
) )
_response_types_map: Dict[str, Optional[str]] = { _response_types_map: Dict[str, Optional[str]] = {
'200': None,
'400': None,
'404': None,
'405': None,
} }
response_data = await self.api_client.call_api( response_data = await self.api_client.call_api(
*_param, *_param,
@ -1728,7 +1734,8 @@ class PetApi:
) )
_response_types_map: Dict[str, Optional[str]] = { _response_types_map: Dict[str, Optional[str]] = {
'200': None,
'405': None,
} }
response_data = await self.api_client.call_api( response_data = await self.api_client.call_api(
*_param, *_param,
@ -1803,7 +1810,8 @@ class PetApi:
) )
_response_types_map: Dict[str, Optional[str]] = { _response_types_map: Dict[str, Optional[str]] = {
'200': None,
'405': None,
} }
response_data = await self.api_client.call_api( response_data = await self.api_client.call_api(
*_param, *_param,
@ -1878,7 +1886,8 @@ class PetApi:
) )
_response_types_map: Dict[str, Optional[str]] = { _response_types_map: Dict[str, Optional[str]] = {
'200': None,
'405': None,
} }
response_data = await self.api_client.call_api( response_data = await self.api_client.call_api(
*_param, *_param,
@ -2024,8 +2033,7 @@ class PetApi:
) )
_response_types_map: Dict[str, Optional[str]] = { _response_types_map: Dict[str, Optional[str]] = {
'200': "ApiResponse" '200': "ApiResponse",
} }
response_data = await self.api_client.call_api( response_data = await self.api_client.call_api(
*_param, *_param,
@ -2100,8 +2108,7 @@ class PetApi:
) )
_response_types_map: Dict[str, Optional[str]] = { _response_types_map: Dict[str, Optional[str]] = {
'200': "ApiResponse" '200': "ApiResponse",
} }
response_data = await self.api_client.call_api( response_data = await self.api_client.call_api(
*_param, *_param,
@ -2176,8 +2183,7 @@ class PetApi:
) )
_response_types_map: Dict[str, Optional[str]] = { _response_types_map: Dict[str, Optional[str]] = {
'200': "ApiResponse" '200': "ApiResponse",
} }
response_data = await self.api_client.call_api( response_data = await self.api_client.call_api(
*_param, *_param,
@ -2329,8 +2335,7 @@ class PetApi:
) )
_response_types_map: Dict[str, Optional[str]] = { _response_types_map: Dict[str, Optional[str]] = {
'200': "ApiResponse" '200': "ApiResponse",
} }
response_data = await self.api_client.call_api( response_data = await self.api_client.call_api(
*_param, *_param,
@ -2405,8 +2410,7 @@ class PetApi:
) )
_response_types_map: Dict[str, Optional[str]] = { _response_types_map: Dict[str, Optional[str]] = {
'200': "ApiResponse" '200': "ApiResponse",
} }
response_data = await self.api_client.call_api( response_data = await self.api_client.call_api(
*_param, *_param,
@ -2481,8 +2485,7 @@ class PetApi:
) )
_response_types_map: Dict[str, Optional[str]] = { _response_types_map: Dict[str, Optional[str]] = {
'200': "ApiResponse" '200': "ApiResponse",
} }
response_data = await self.api_client.call_api( response_data = await self.api_client.call_api(
*_param, *_param,

View File

@ -103,7 +103,8 @@ class StoreApi:
) )
_response_types_map: Dict[str, Optional[str]] = { _response_types_map: Dict[str, Optional[str]] = {
'400': None,
'404': None,
} }
response_data = await self.api_client.call_api( response_data = await self.api_client.call_api(
*_param, *_param,
@ -170,7 +171,8 @@ class StoreApi:
) )
_response_types_map: Dict[str, Optional[str]] = { _response_types_map: Dict[str, Optional[str]] = {
'400': None,
'404': None,
} }
response_data = await self.api_client.call_api( response_data = await self.api_client.call_api(
*_param, *_param,
@ -237,7 +239,8 @@ class StoreApi:
) )
_response_types_map: Dict[str, Optional[str]] = { _response_types_map: Dict[str, Optional[str]] = {
'400': None,
'404': None,
} }
response_data = await self.api_client.call_api( response_data = await self.api_client.call_api(
*_param, *_param,
@ -351,8 +354,7 @@ class StoreApi:
) )
_response_types_map: Dict[str, Optional[str]] = { _response_types_map: Dict[str, Optional[str]] = {
'200': "Dict[str, int]" '200': "Dict[str, int]",
} }
response_data = await self.api_client.call_api( response_data = await self.api_client.call_api(
*_param, *_param,
@ -415,8 +417,7 @@ class StoreApi:
) )
_response_types_map: Dict[str, Optional[str]] = { _response_types_map: Dict[str, Optional[str]] = {
'200': "Dict[str, int]" '200': "Dict[str, int]",
} }
response_data = await self.api_client.call_api( response_data = await self.api_client.call_api(
*_param, *_param,
@ -479,8 +480,7 @@ class StoreApi:
) )
_response_types_map: Dict[str, Optional[str]] = { _response_types_map: Dict[str, Optional[str]] = {
'200': "Dict[str, int]" '200': "Dict[str, int]",
} }
response_data = await self.api_client.call_api( response_data = await self.api_client.call_api(
*_param, *_param,
@ -604,8 +604,7 @@ class StoreApi:
_response_types_map: Dict[str, Optional[str]] = { _response_types_map: Dict[str, Optional[str]] = {
'200': "Order", '200': "Order",
'400': None, '400': None,
'404': None '404': None,
} }
response_data = await self.api_client.call_api( response_data = await self.api_client.call_api(
*_param, *_param,
@ -674,8 +673,7 @@ class StoreApi:
_response_types_map: Dict[str, Optional[str]] = { _response_types_map: Dict[str, Optional[str]] = {
'200': "Order", '200': "Order",
'400': None, '400': None,
'404': None '404': None,
} }
response_data = await self.api_client.call_api( response_data = await self.api_client.call_api(
*_param, *_param,
@ -744,8 +742,7 @@ class StoreApi:
_response_types_map: Dict[str, Optional[str]] = { _response_types_map: Dict[str, Optional[str]] = {
'200': "Order", '200': "Order",
'400': None, '400': None,
'404': None '404': None,
} }
response_data = await self.api_client.call_api( response_data = await self.api_client.call_api(
*_param, *_param,
@ -871,8 +868,7 @@ class StoreApi:
_response_types_map: Dict[str, Optional[str]] = { _response_types_map: Dict[str, Optional[str]] = {
'200': "Order", '200': "Order",
'400': None '400': None,
} }
response_data = await self.api_client.call_api( response_data = await self.api_client.call_api(
*_param, *_param,
@ -940,8 +936,7 @@ class StoreApi:
_response_types_map: Dict[str, Optional[str]] = { _response_types_map: Dict[str, Optional[str]] = {
'200': "Order", '200': "Order",
'400': None '400': None,
} }
response_data = await self.api_client.call_api( response_data = await self.api_client.call_api(
*_param, *_param,
@ -1009,8 +1004,7 @@ class StoreApi:
_response_types_map: Dict[str, Optional[str]] = { _response_types_map: Dict[str, Optional[str]] = {
'200': "Order", '200': "Order",
'400': None '400': None,
} }
response_data = await self.api_client.call_api( response_data = await self.api_client.call_api(
*_param, *_param,

View File

@ -103,7 +103,6 @@ class UserApi:
) )
_response_types_map: Dict[str, Optional[str]] = { _response_types_map: Dict[str, Optional[str]] = {
} }
response_data = await self.api_client.call_api( response_data = await self.api_client.call_api(
*_param, *_param,
@ -170,7 +169,6 @@ class UserApi:
) )
_response_types_map: Dict[str, Optional[str]] = { _response_types_map: Dict[str, Optional[str]] = {
} }
response_data = await self.api_client.call_api( response_data = await self.api_client.call_api(
*_param, *_param,
@ -237,7 +235,6 @@ class UserApi:
) )
_response_types_map: Dict[str, Optional[str]] = { _response_types_map: Dict[str, Optional[str]] = {
} }
response_data = await self.api_client.call_api( response_data = await self.api_client.call_api(
*_param, *_param,
@ -373,7 +370,6 @@ class UserApi:
) )
_response_types_map: Dict[str, Optional[str]] = { _response_types_map: Dict[str, Optional[str]] = {
} }
response_data = await self.api_client.call_api( response_data = await self.api_client.call_api(
*_param, *_param,
@ -440,7 +436,6 @@ class UserApi:
) )
_response_types_map: Dict[str, Optional[str]] = { _response_types_map: Dict[str, Optional[str]] = {
} }
response_data = await self.api_client.call_api( response_data = await self.api_client.call_api(
*_param, *_param,
@ -507,7 +502,6 @@ class UserApi:
) )
_response_types_map: Dict[str, Optional[str]] = { _response_types_map: Dict[str, Optional[str]] = {
} }
response_data = await self.api_client.call_api( response_data = await self.api_client.call_api(
*_param, *_param,
@ -639,7 +633,6 @@ class UserApi:
) )
_response_types_map: Dict[str, Optional[str]] = { _response_types_map: Dict[str, Optional[str]] = {
} }
response_data = await self.api_client.call_api( response_data = await self.api_client.call_api(
*_param, *_param,
@ -706,7 +699,6 @@ class UserApi:
) )
_response_types_map: Dict[str, Optional[str]] = { _response_types_map: Dict[str, Optional[str]] = {
} }
response_data = await self.api_client.call_api( response_data = await self.api_client.call_api(
*_param, *_param,
@ -773,7 +765,6 @@ class UserApi:
) )
_response_types_map: Dict[str, Optional[str]] = { _response_types_map: Dict[str, Optional[str]] = {
} }
response_data = await self.api_client.call_api( response_data = await self.api_client.call_api(
*_param, *_param,
@ -905,7 +896,8 @@ class UserApi:
) )
_response_types_map: Dict[str, Optional[str]] = { _response_types_map: Dict[str, Optional[str]] = {
'400': None,
'404': None,
} }
response_data = await self.api_client.call_api( response_data = await self.api_client.call_api(
*_param, *_param,
@ -972,7 +964,8 @@ class UserApi:
) )
_response_types_map: Dict[str, Optional[str]] = { _response_types_map: Dict[str, Optional[str]] = {
'400': None,
'404': None,
} }
response_data = await self.api_client.call_api( response_data = await self.api_client.call_api(
*_param, *_param,
@ -1039,7 +1032,8 @@ class UserApi:
) )
_response_types_map: Dict[str, Optional[str]] = { _response_types_map: Dict[str, Optional[str]] = {
'400': None,
'404': None,
} }
response_data = await self.api_client.call_api( response_data = await self.api_client.call_api(
*_param, *_param,
@ -1159,8 +1153,7 @@ class UserApi:
_response_types_map: Dict[str, Optional[str]] = { _response_types_map: Dict[str, Optional[str]] = {
'200': "User", '200': "User",
'400': None, '400': None,
'404': None '404': None,
} }
response_data = await self.api_client.call_api( response_data = await self.api_client.call_api(
*_param, *_param,
@ -1229,8 +1222,7 @@ class UserApi:
_response_types_map: Dict[str, Optional[str]] = { _response_types_map: Dict[str, Optional[str]] = {
'200': "User", '200': "User",
'400': None, '400': None,
'404': None '404': None,
} }
response_data = await self.api_client.call_api( response_data = await self.api_client.call_api(
*_param, *_param,
@ -1299,8 +1291,7 @@ class UserApi:
_response_types_map: Dict[str, Optional[str]] = { _response_types_map: Dict[str, Optional[str]] = {
'200': "User", '200': "User",
'400': None, '400': None,
'404': None '404': None,
} }
response_data = await self.api_client.call_api( response_data = await self.api_client.call_api(
*_param, *_param,
@ -1430,8 +1421,7 @@ class UserApi:
_response_types_map: Dict[str, Optional[str]] = { _response_types_map: Dict[str, Optional[str]] = {
'200': "str", '200': "str",
'400': None '400': None,
} }
response_data = await self.api_client.call_api( response_data = await self.api_client.call_api(
*_param, *_param,
@ -1503,8 +1493,7 @@ class UserApi:
_response_types_map: Dict[str, Optional[str]] = { _response_types_map: Dict[str, Optional[str]] = {
'200': "str", '200': "str",
'400': None '400': None,
} }
response_data = await self.api_client.call_api( response_data = await self.api_client.call_api(
*_param, *_param,
@ -1576,8 +1565,7 @@ class UserApi:
_response_types_map: Dict[str, Optional[str]] = { _response_types_map: Dict[str, Optional[str]] = {
'200': "str", '200': "str",
'400': None '400': None,
} }
response_data = await self.api_client.call_api( response_data = await self.api_client.call_api(
*_param, *_param,
@ -1705,7 +1693,6 @@ class UserApi:
) )
_response_types_map: Dict[str, Optional[str]] = { _response_types_map: Dict[str, Optional[str]] = {
} }
response_data = await self.api_client.call_api( response_data = await self.api_client.call_api(
*_param, *_param,
@ -1768,7 +1755,6 @@ class UserApi:
) )
_response_types_map: Dict[str, Optional[str]] = { _response_types_map: Dict[str, Optional[str]] = {
} }
response_data = await self.api_client.call_api( response_data = await self.api_client.call_api(
*_param, *_param,
@ -1831,7 +1817,6 @@ class UserApi:
) )
_response_types_map: Dict[str, Optional[str]] = { _response_types_map: Dict[str, Optional[str]] = {
} }
response_data = await self.api_client.call_api( response_data = await self.api_client.call_api(
*_param, *_param,
@ -1950,7 +1935,8 @@ class UserApi:
) )
_response_types_map: Dict[str, Optional[str]] = { _response_types_map: Dict[str, Optional[str]] = {
'400': None,
'404': None,
} }
response_data = await self.api_client.call_api( response_data = await self.api_client.call_api(
*_param, *_param,
@ -2021,7 +2007,8 @@ class UserApi:
) )
_response_types_map: Dict[str, Optional[str]] = { _response_types_map: Dict[str, Optional[str]] = {
'400': None,
'404': None,
} }
response_data = await self.api_client.call_api( response_data = await self.api_client.call_api(
*_param, *_param,
@ -2092,7 +2079,8 @@ class UserApi:
) )
_response_types_map: Dict[str, Optional[str]] = { _response_types_map: Dict[str, Optional[str]] = {
'400': None,
'404': None,
} }
response_data = await self.api_client.call_api( response_data = await self.api_client.call_api(
*_param, *_param,

View File

@ -284,7 +284,7 @@ class ApiClient:
def response_deserialize( def response_deserialize(
self, self,
response_data=None, response_data: rest.RESTResponse = None,
response_types_map=None response_types_map=None
) -> ApiResponse: ) -> ApiResponse:
"""Deserializes response into an object. """Deserializes response into an object.
@ -299,32 +299,15 @@ class ApiClient:
# if not found, look for '1XX', '2XX', etc. # if not found, look for '1XX', '2XX', etc.
response_type = response_types_map.get(str(response_data.status)[0] + "XX", None) 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 # deserialize response data
response_text = None
return_data = None
try:
if response_type == "bytearray": if response_type == "bytearray":
return_data = response_data.data return_data = response_data.data
elif response_type is None:
return_data = None
elif response_type == "file": elif response_type == "file":
return_data = self.__deserialize_file(response_data) return_data = self.__deserialize_file(response_data)
else: elif response_type is not None:
match = None match = None
content_type = response_data.getheader('content-type') content_type = response_data.getheader('content-type')
if content_type is not None: if content_type is not None:
@ -332,6 +315,13 @@ class ApiClient:
encoding = match.group(1) if match else "utf-8" encoding = match.group(1) if match else "utf-8"
response_text = response_data.data.decode(encoding) response_text = response_data.data.decode(encoding)
return_data = self.deserialize(response_text, response_type) 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( return ApiResponse(
status_code = response_data.status, status_code = response_data.status,

View File

@ -11,6 +11,9 @@
Do not edit the class manually. Do not edit the class manually.
""" # noqa: E501 """ # noqa: E501
from typing import Any, Optional
from typing_extensions import Self
class OpenApiException(Exception): class OpenApiException(Exception):
"""The base exception class for all OpenAPIExceptions""" """The base exception class for all OpenAPIExceptions"""
@ -101,18 +104,57 @@ class ApiKeyError(OpenApiException, KeyError):
class ApiException(OpenApiException): class ApiException(OpenApiException):
def __init__(self, status=None, reason=None, http_resp=None) -> None: def __init__(
if http_resp: self,
self.status = http_resp.status status=None,
self.reason = http_resp.reason reason=None,
self.body = http_resp.data.decode('utf-8') http_resp=None,
self.headers = http_resp.getheaders() *,
else: body: Optional[str] = None,
data: Optional[Any] = None,
) -> None:
self.status = status self.status = status
self.reason = reason self.reason = reason
self.body = None self.body = body
self.data = data
self.headers = None self.headers = None
if http_resp:
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()
@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): def __str__(self):
"""Custom error messages for exception""" """Custom error messages for exception"""
error_message = "({0})\n"\ error_message = "({0})\n"\
@ -121,38 +163,30 @@ class ApiException(OpenApiException):
error_message += "HTTP response headers: {0}\n".format( error_message += "HTTP response headers: {0}\n".format(
self.headers) self.headers)
if self.body: if self.data or self.body:
error_message += "HTTP response body: {0}\n".format(self.body) error_message += "HTTP response body: {0}\n".format(self.data or self.body)
return error_message return error_message
class BadRequestException(ApiException):
def __init__(self, status=None, reason=None, http_resp=None) -> None: class BadRequestException(ApiException):
super(BadRequestException, self).__init__(status, reason, http_resp) pass
class NotFoundException(ApiException): class NotFoundException(ApiException):
pass
def __init__(self, status=None, reason=None, http_resp=None) -> None:
super(NotFoundException, self).__init__(status, reason, http_resp)
class UnauthorizedException(ApiException): class UnauthorizedException(ApiException):
pass
def __init__(self, status=None, reason=None, http_resp=None) -> None:
super(UnauthorizedException, self).__init__(status, reason, http_resp)
class ForbiddenException(ApiException): class ForbiddenException(ApiException):
pass
def __init__(self, status=None, reason=None, http_resp=None) -> None:
super(ForbiddenException, self).__init__(status, reason, http_resp)
class ServiceException(ApiException): class ServiceException(ApiException):
pass
def __init__(self, status=None, reason=None, http_resp=None) -> None:
super(ServiceException, self).__init__(status, reason, http_resp)
def render_path(path_to_item): def render_path(path_to_item):

View File

@ -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_model_name import SpecialModelName
from petstore_api.models.special_name import SpecialName from petstore_api.models.special_name import SpecialName
from petstore_api.models.tag import Tag 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.test_inline_freeform_additional_properties_request import TestInlineFreeformAdditionalPropertiesRequest
from petstore_api.models.tiger import Tiger from petstore_api.models.tiger import Tiger
from petstore_api.models.unnamed_dict_with_additional_model_list_properties import UnnamedDictWithAdditionalModelListProperties from petstore_api.models.unnamed_dict_with_additional_model_list_properties import UnnamedDictWithAdditionalModelListProperties

View File

@ -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

View File

@ -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

View File

@ -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()

View File

@ -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()

View File

@ -84,6 +84,8 @@ docs/SpecialModelName.md
docs/SpecialName.md docs/SpecialName.md
docs/StoreApi.md docs/StoreApi.md
docs/Tag.md docs/Tag.md
docs/TestErrorResponsesWithModel400Response.md
docs/TestErrorResponsesWithModel404Response.md
docs/TestInlineFreeformAdditionalPropertiesRequest.md docs/TestInlineFreeformAdditionalPropertiesRequest.md
docs/Tiger.md docs/Tiger.md
docs/UnnamedDictWithAdditionalModelListProperties.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_model_name.py
petstore_api/models/special_name.py petstore_api/models/special_name.py
petstore_api/models/tag.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/test_inline_freeform_additional_properties_request.py
petstore_api/models/tiger.py petstore_api/models/tiger.py
petstore_api/models/unnamed_dict_with_additional_model_list_properties.py petstore_api/models/unnamed_dict_with_additional_model_list_properties.py

View File

@ -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_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 \&quot;client\&quot; model *FakeApi* | [**test_client_model**](docs/FakeApi.md#test_client_model) | **PATCH** /fake | To test \&quot;client\&quot; model
*FakeApi* | [**test_date_time_query_parameter**](docs/FakeApi.md#test_date_time_query_parameter) | **PUT** /fake/date-time-query-params | *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_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_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_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 *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) - [SpecialModelName](docs/SpecialModelName.md)
- [SpecialName](docs/SpecialName.md) - [SpecialName](docs/SpecialName.md)
- [Tag](docs/Tag.md) - [Tag](docs/Tag.md)
- [TestErrorResponsesWithModel400Response](docs/TestErrorResponsesWithModel400Response.md)
- [TestErrorResponsesWithModel404Response](docs/TestErrorResponsesWithModel404Response.md)
- [TestInlineFreeformAdditionalPropertiesRequest](docs/TestInlineFreeformAdditionalPropertiesRequest.md) - [TestInlineFreeformAdditionalPropertiesRequest](docs/TestInlineFreeformAdditionalPropertiesRequest.md)
- [Tiger](docs/Tiger.md) - [Tiger](docs/Tiger.md)
- [UnnamedDictWithAdditionalModelListProperties](docs/UnnamedDictWithAdditionalModelListProperties.md) - [UnnamedDictWithAdditionalModelListProperties](docs/UnnamedDictWithAdditionalModelListProperties.md)

View File

@ -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_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 \&quot;client\&quot; model [**test_client_model**](FakeApi.md#test_client_model) | **PATCH** /fake | To test \&quot;client\&quot; model
[**test_date_time_query_parameter**](FakeApi.md#test_date_time_query_parameter) | **PUT** /fake/date-time-query-params | [**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_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_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_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 [**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) [[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**
> 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) > 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) [[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**
> test_group_parameters(required_string_group, required_boolean_group, required_int64_group, string_group=string_group, boolean_group=boolean_group, int64_group=int64_group) > test_group_parameters(required_string_group, required_boolean_group, required_int64_group, string_group=string_group, boolean_group=boolean_group, int64_group=int64_group)

View File

@ -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)

View File

@ -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)

View File

@ -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_model_name import SpecialModelName
from petstore_api.models.special_name import SpecialName from petstore_api.models.special_name import SpecialName
from petstore_api.models.tag import Tag 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.test_inline_freeform_additional_properties_request import TestInlineFreeformAdditionalPropertiesRequest
from petstore_api.models.tiger import Tiger from petstore_api.models.tiger import Tiger
from petstore_api.models.unnamed_dict_with_additional_model_list_properties import UnnamedDictWithAdditionalModelListProperties from petstore_api.models.unnamed_dict_with_additional_model_list_properties import UnnamedDictWithAdditionalModelListProperties

View File

@ -2078,6 +2078,120 @@ class FakeApi:
collection_formats=_collection_formats, collection_formats=_collection_formats,
_request_auth=_params.get('_request_auth')) _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 @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 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 """Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 # noqa: E501
@ -2315,6 +2429,118 @@ class FakeApi:
collection_formats=_collection_formats, collection_formats=_collection_formats,
_request_auth=_params.get('_request_auth')) _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 @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 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 """Fake endpoint to test group parameters (optional) # noqa: E501

View File

@ -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_model_name import SpecialModelName
from petstore_api.models.special_name import SpecialName from petstore_api.models.special_name import SpecialName
from petstore_api.models.tag import Tag 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.test_inline_freeform_additional_properties_request import TestInlineFreeformAdditionalPropertiesRequest
from petstore_api.models.tiger import Tiger from petstore_api.models.tiger import Tiger
from petstore_api.models.unnamed_dict_with_additional_model_list_properties import UnnamedDictWithAdditionalModelListProperties from petstore_api.models.unnamed_dict_with_additional_model_list_properties import UnnamedDictWithAdditionalModelListProperties

View File

@ -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

View File

@ -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

View File

@ -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()

View File

@ -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()

View File

@ -84,6 +84,8 @@ docs/SpecialModelName.md
docs/SpecialName.md docs/SpecialName.md
docs/StoreApi.md docs/StoreApi.md
docs/Tag.md docs/Tag.md
docs/TestErrorResponsesWithModel400Response.md
docs/TestErrorResponsesWithModel404Response.md
docs/TestInlineFreeformAdditionalPropertiesRequest.md docs/TestInlineFreeformAdditionalPropertiesRequest.md
docs/Tiger.md docs/Tiger.md
docs/UnnamedDictWithAdditionalModelListProperties.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_model_name.py
petstore_api/models/special_name.py petstore_api/models/special_name.py
petstore_api/models/tag.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/test_inline_freeform_additional_properties_request.py
petstore_api/models/tiger.py petstore_api/models/tiger.py
petstore_api/models/unnamed_dict_with_additional_model_list_properties.py petstore_api/models/unnamed_dict_with_additional_model_list_properties.py

View File

@ -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_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 \&quot;client\&quot; model *FakeApi* | [**test_client_model**](docs/FakeApi.md#test_client_model) | **PATCH** /fake | To test \&quot;client\&quot; model
*FakeApi* | [**test_date_time_query_parameter**](docs/FakeApi.md#test_date_time_query_parameter) | **PUT** /fake/date-time-query-params | *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_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_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_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 *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) - [SpecialModelName](docs/SpecialModelName.md)
- [SpecialName](docs/SpecialName.md) - [SpecialName](docs/SpecialName.md)
- [Tag](docs/Tag.md) - [Tag](docs/Tag.md)
- [TestErrorResponsesWithModel400Response](docs/TestErrorResponsesWithModel400Response.md)
- [TestErrorResponsesWithModel404Response](docs/TestErrorResponsesWithModel404Response.md)
- [TestInlineFreeformAdditionalPropertiesRequest](docs/TestInlineFreeformAdditionalPropertiesRequest.md) - [TestInlineFreeformAdditionalPropertiesRequest](docs/TestInlineFreeformAdditionalPropertiesRequest.md)
- [Tiger](docs/Tiger.md) - [Tiger](docs/Tiger.md)
- [UnnamedDictWithAdditionalModelListProperties](docs/UnnamedDictWithAdditionalModelListProperties.md) - [UnnamedDictWithAdditionalModelListProperties](docs/UnnamedDictWithAdditionalModelListProperties.md)

View File

@ -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_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 \&quot;client\&quot; model [**test_client_model**](FakeApi.md#test_client_model) | **PATCH** /fake | To test \&quot;client\&quot; model
[**test_date_time_query_parameter**](FakeApi.md#test_date_time_query_parameter) | **PUT** /fake/date-time-query-params | [**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_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_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_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 [**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) [[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**
> 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) > 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) [[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**
> test_group_parameters(required_string_group, required_boolean_group, required_int64_group, string_group=string_group, boolean_group=boolean_group, int64_group=int64_group) > test_group_parameters(required_string_group, required_boolean_group, required_int64_group, string_group=string_group, boolean_group=boolean_group, int64_group=int64_group)

View File

@ -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)

View File

@ -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)

View File

@ -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_model_name import SpecialModelName
from petstore_api.models.special_name import SpecialName from petstore_api.models.special_name import SpecialName
from petstore_api.models.tag import Tag 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.test_inline_freeform_additional_properties_request import TestInlineFreeformAdditionalPropertiesRequest
from petstore_api.models.tiger import Tiger from petstore_api.models.tiger import Tiger
from petstore_api.models.unnamed_dict_with_additional_model_list_properties import UnnamedDictWithAdditionalModelListProperties from petstore_api.models.unnamed_dict_with_additional_model_list_properties import UnnamedDictWithAdditionalModelListProperties

View File

@ -2333,6 +2333,136 @@ class FakeApi:
collection_formats=_collection_formats, collection_formats=_collection_formats,
_request_auth=_params.get('_request_auth')) _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 @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 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 """Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 # noqa: E501
@ -2586,6 +2716,134 @@ class FakeApi:
collection_formats=_collection_formats, collection_formats=_collection_formats,
_request_auth=_params.get('_request_auth')) _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 @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 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 """Fake endpoint to test group parameters (optional) # noqa: E501

View File

@ -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_model_name import SpecialModelName
from petstore_api.models.special_name import SpecialName from petstore_api.models.special_name import SpecialName
from petstore_api.models.tag import Tag 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.test_inline_freeform_additional_properties_request import TestInlineFreeformAdditionalPropertiesRequest
from petstore_api.models.tiger import Tiger from petstore_api.models.tiger import Tiger
from petstore_api.models.unnamed_dict_with_additional_model_list_properties import UnnamedDictWithAdditionalModelListProperties from petstore_api.models.unnamed_dict_with_additional_model_list_properties import UnnamedDictWithAdditionalModelListProperties

View File

@ -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

View File

@ -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

View File

@ -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()

View File

@ -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()

View File

@ -84,6 +84,8 @@ docs/SpecialModelName.md
docs/SpecialName.md docs/SpecialName.md
docs/StoreApi.md docs/StoreApi.md
docs/Tag.md docs/Tag.md
docs/TestErrorResponsesWithModel400Response.md
docs/TestErrorResponsesWithModel404Response.md
docs/TestInlineFreeformAdditionalPropertiesRequest.md docs/TestInlineFreeformAdditionalPropertiesRequest.md
docs/Tiger.md docs/Tiger.md
docs/UnnamedDictWithAdditionalModelListProperties.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_model_name.py
petstore_api/models/special_name.py petstore_api/models/special_name.py
petstore_api/models/tag.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/test_inline_freeform_additional_properties_request.py
petstore_api/models/tiger.py petstore_api/models/tiger.py
petstore_api/models/unnamed_dict_with_additional_model_list_properties.py petstore_api/models/unnamed_dict_with_additional_model_list_properties.py

View File

@ -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_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 \&quot;client\&quot; model *FakeApi* | [**test_client_model**](docs/FakeApi.md#test_client_model) | **PATCH** /fake | To test \&quot;client\&quot; model
*FakeApi* | [**test_date_time_query_parameter**](docs/FakeApi.md#test_date_time_query_parameter) | **PUT** /fake/date-time-query-params | *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_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_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_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 *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) - [SpecialModelName](docs/SpecialModelName.md)
- [SpecialName](docs/SpecialName.md) - [SpecialName](docs/SpecialName.md)
- [Tag](docs/Tag.md) - [Tag](docs/Tag.md)
- [TestErrorResponsesWithModel400Response](docs/TestErrorResponsesWithModel400Response.md)
- [TestErrorResponsesWithModel404Response](docs/TestErrorResponsesWithModel404Response.md)
- [TestInlineFreeformAdditionalPropertiesRequest](docs/TestInlineFreeformAdditionalPropertiesRequest.md) - [TestInlineFreeformAdditionalPropertiesRequest](docs/TestInlineFreeformAdditionalPropertiesRequest.md)
- [Tiger](docs/Tiger.md) - [Tiger](docs/Tiger.md)
- [UnnamedDictWithAdditionalModelListProperties](docs/UnnamedDictWithAdditionalModelListProperties.md) - [UnnamedDictWithAdditionalModelListProperties](docs/UnnamedDictWithAdditionalModelListProperties.md)

View File

@ -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_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 \&quot;client\&quot; model [**test_client_model**](FakeApi.md#test_client_model) | **PATCH** /fake | To test \&quot;client\&quot; model
[**test_date_time_query_parameter**](FakeApi.md#test_date_time_query_parameter) | **PUT** /fake/date-time-query-params | [**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_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_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_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 [**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) [[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**
> 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) > 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) [[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**
> test_group_parameters(required_string_group, required_boolean_group, required_int64_group, string_group=string_group, boolean_group=boolean_group, int64_group=int64_group) > test_group_parameters(required_string_group, required_boolean_group, required_int64_group, string_group=string_group, boolean_group=boolean_group, int64_group=int64_group)

View File

@ -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)

View File

@ -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)

View File

@ -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_model_name import SpecialModelName
from petstore_api.models.special_name import SpecialName from petstore_api.models.special_name import SpecialName
from petstore_api.models.tag import Tag 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.test_inline_freeform_additional_properties_request import TestInlineFreeformAdditionalPropertiesRequest
from petstore_api.models.tiger import Tiger from petstore_api.models.tiger import Tiger
from petstore_api.models.unnamed_dict_with_additional_model_list_properties import UnnamedDictWithAdditionalModelListProperties from petstore_api.models.unnamed_dict_with_additional_model_list_properties import UnnamedDictWithAdditionalModelListProperties

View File

@ -99,8 +99,7 @@ class AnotherFakeApi:
) )
_response_types_map: Dict[str, Optional[str]] = { _response_types_map: Dict[str, Optional[str]] = {
'200': "Client" '200': "Client",
} }
response_data = self.api_client.call_api( response_data = self.api_client.call_api(
*_param, *_param,
@ -167,8 +166,7 @@ class AnotherFakeApi:
) )
_response_types_map: Dict[str, Optional[str]] = { _response_types_map: Dict[str, Optional[str]] = {
'200': "Client" '200': "Client",
} }
response_data = self.api_client.call_api( response_data = self.api_client.call_api(
*_param, *_param,
@ -235,8 +233,7 @@ class AnotherFakeApi:
) )
_response_types_map: Dict[str, Optional[str]] = { _response_types_map: Dict[str, Optional[str]] = {
'200': "Client" '200': "Client",
} }
response_data = self.api_client.call_api( response_data = self.api_client.call_api(
*_param, *_param,

View File

@ -92,8 +92,6 @@ class DefaultApi:
) )
_response_types_map: Dict[str, Optional[str]] = { _response_types_map: Dict[str, Optional[str]] = {
} }
response_data = self.api_client.call_api( response_data = self.api_client.call_api(
*_param, *_param,
@ -155,8 +153,6 @@ class DefaultApi:
) )
_response_types_map: Dict[str, Optional[str]] = { _response_types_map: Dict[str, Optional[str]] = {
} }
response_data = self.api_client.call_api( response_data = self.api_client.call_api(
*_param, *_param,
@ -218,8 +214,6 @@ class DefaultApi:
) )
_response_types_map: Dict[str, Optional[str]] = { _response_types_map: Dict[str, Optional[str]] = {
} }
response_data = self.api_client.call_api( response_data = self.api_client.call_api(
*_param, *_param,

View File

@ -99,8 +99,7 @@ class FakeClassnameTags123Api:
) )
_response_types_map: Dict[str, Optional[str]] = { _response_types_map: Dict[str, Optional[str]] = {
'200': "Client" '200': "Client",
} }
response_data = self.api_client.call_api( response_data = self.api_client.call_api(
*_param, *_param,
@ -167,8 +166,7 @@ class FakeClassnameTags123Api:
) )
_response_types_map: Dict[str, Optional[str]] = { _response_types_map: Dict[str, Optional[str]] = {
'200': "Client" '200': "Client",
} }
response_data = self.api_client.call_api( response_data = self.api_client.call_api(
*_param, *_param,
@ -235,8 +233,7 @@ class FakeClassnameTags123Api:
) )
_response_types_map: Dict[str, Optional[str]] = { _response_types_map: Dict[str, Optional[str]] = {
'200': "Client" '200': "Client",
} }
response_data = self.api_client.call_api( response_data = self.api_client.call_api(
*_param, *_param,

View File

@ -104,7 +104,8 @@ class PetApi:
) )
_response_types_map: Dict[str, Optional[str]] = { _response_types_map: Dict[str, Optional[str]] = {
'200': None,
'405': None,
} }
response_data = self.api_client.call_api( response_data = self.api_client.call_api(
*_param, *_param,
@ -171,7 +172,8 @@ class PetApi:
) )
_response_types_map: Dict[str, Optional[str]] = { _response_types_map: Dict[str, Optional[str]] = {
'200': None,
'405': None,
} }
response_data = self.api_client.call_api( response_data = self.api_client.call_api(
*_param, *_param,
@ -238,7 +240,8 @@ class PetApi:
) )
_response_types_map: Dict[str, Optional[str]] = { _response_types_map: Dict[str, Optional[str]] = {
'200': None,
'405': None,
} }
response_data = self.api_client.call_api( response_data = self.api_client.call_api(
*_param, *_param,
@ -376,7 +379,8 @@ class PetApi:
) )
_response_types_map: Dict[str, Optional[str]] = { _response_types_map: Dict[str, Optional[str]] = {
'200': None,
'400': None,
} }
response_data = self.api_client.call_api( response_data = self.api_client.call_api(
*_param, *_param,
@ -447,7 +451,8 @@ class PetApi:
) )
_response_types_map: Dict[str, Optional[str]] = { _response_types_map: Dict[str, Optional[str]] = {
'200': None,
'400': None,
} }
response_data = self.api_client.call_api( response_data = self.api_client.call_api(
*_param, *_param,
@ -518,7 +523,8 @@ class PetApi:
) )
_response_types_map: Dict[str, Optional[str]] = { _response_types_map: Dict[str, Optional[str]] = {
'200': None,
'400': None,
} }
response_data = self.api_client.call_api( response_data = self.api_client.call_api(
*_param, *_param,
@ -641,8 +647,7 @@ class PetApi:
_response_types_map: Dict[str, Optional[str]] = { _response_types_map: Dict[str, Optional[str]] = {
'200': "List[Pet]", '200': "List[Pet]",
'400': None '400': None,
} }
response_data = self.api_client.call_api( response_data = self.api_client.call_api(
*_param, *_param,
@ -710,8 +715,7 @@ class PetApi:
_response_types_map: Dict[str, Optional[str]] = { _response_types_map: Dict[str, Optional[str]] = {
'200': "List[Pet]", '200': "List[Pet]",
'400': None '400': None,
} }
response_data = self.api_client.call_api( response_data = self.api_client.call_api(
*_param, *_param,
@ -779,8 +783,7 @@ class PetApi:
_response_types_map: Dict[str, Optional[str]] = { _response_types_map: Dict[str, Optional[str]] = {
'200': "List[Pet]", '200': "List[Pet]",
'400': None '400': None,
} }
response_data = self.api_client.call_api( response_data = self.api_client.call_api(
*_param, *_param,
@ -912,8 +915,7 @@ class PetApi:
_response_types_map: Dict[str, Optional[str]] = { _response_types_map: Dict[str, Optional[str]] = {
'200': "List[Pet]", '200': "List[Pet]",
'400': None '400': None,
} }
response_data = self.api_client.call_api( response_data = self.api_client.call_api(
*_param, *_param,
@ -982,8 +984,7 @@ class PetApi:
_response_types_map: Dict[str, Optional[str]] = { _response_types_map: Dict[str, Optional[str]] = {
'200': "List[Pet]", '200': "List[Pet]",
'400': None '400': None,
} }
response_data = self.api_client.call_api( response_data = self.api_client.call_api(
*_param, *_param,
@ -1052,8 +1053,7 @@ class PetApi:
_response_types_map: Dict[str, Optional[str]] = { _response_types_map: Dict[str, Optional[str]] = {
'200': "List[Pet]", '200': "List[Pet]",
'400': None '400': None,
} }
response_data = self.api_client.call_api( response_data = self.api_client.call_api(
*_param, *_param,
@ -1185,8 +1185,7 @@ class PetApi:
_response_types_map: Dict[str, Optional[str]] = { _response_types_map: Dict[str, Optional[str]] = {
'200': "Pet", '200': "Pet",
'400': None, '400': None,
'404': None '404': None,
} }
response_data = self.api_client.call_api( response_data = self.api_client.call_api(
*_param, *_param,
@ -1255,8 +1254,7 @@ class PetApi:
_response_types_map: Dict[str, Optional[str]] = { _response_types_map: Dict[str, Optional[str]] = {
'200': "Pet", '200': "Pet",
'400': None, '400': None,
'404': None '404': None,
} }
response_data = self.api_client.call_api( response_data = self.api_client.call_api(
*_param, *_param,
@ -1325,8 +1323,7 @@ class PetApi:
_response_types_map: Dict[str, Optional[str]] = { _response_types_map: Dict[str, Optional[str]] = {
'200': "Pet", '200': "Pet",
'400': None, '400': None,
'404': None '404': None,
} }
response_data = self.api_client.call_api( response_data = self.api_client.call_api(
*_param, *_param,
@ -1452,7 +1449,10 @@ class PetApi:
) )
_response_types_map: Dict[str, Optional[str]] = { _response_types_map: Dict[str, Optional[str]] = {
'200': None,
'400': None,
'404': None,
'405': None,
} }
response_data = self.api_client.call_api( response_data = self.api_client.call_api(
*_param, *_param,
@ -1519,7 +1519,10 @@ class PetApi:
) )
_response_types_map: Dict[str, Optional[str]] = { _response_types_map: Dict[str, Optional[str]] = {
'200': None,
'400': None,
'404': None,
'405': None,
} }
response_data = self.api_client.call_api( response_data = self.api_client.call_api(
*_param, *_param,
@ -1586,7 +1589,10 @@ class PetApi:
) )
_response_types_map: Dict[str, Optional[str]] = { _response_types_map: Dict[str, Optional[str]] = {
'200': None,
'400': None,
'404': None,
'405': None,
} }
response_data = self.api_client.call_api( response_data = self.api_client.call_api(
*_param, *_param,
@ -1728,7 +1734,8 @@ class PetApi:
) )
_response_types_map: Dict[str, Optional[str]] = { _response_types_map: Dict[str, Optional[str]] = {
'200': None,
'405': None,
} }
response_data = self.api_client.call_api( response_data = self.api_client.call_api(
*_param, *_param,
@ -1803,7 +1810,8 @@ class PetApi:
) )
_response_types_map: Dict[str, Optional[str]] = { _response_types_map: Dict[str, Optional[str]] = {
'200': None,
'405': None,
} }
response_data = self.api_client.call_api( response_data = self.api_client.call_api(
*_param, *_param,
@ -1878,7 +1886,8 @@ class PetApi:
) )
_response_types_map: Dict[str, Optional[str]] = { _response_types_map: Dict[str, Optional[str]] = {
'200': None,
'405': None,
} }
response_data = self.api_client.call_api( response_data = self.api_client.call_api(
*_param, *_param,
@ -2024,8 +2033,7 @@ class PetApi:
) )
_response_types_map: Dict[str, Optional[str]] = { _response_types_map: Dict[str, Optional[str]] = {
'200': "ApiResponse" '200': "ApiResponse",
} }
response_data = self.api_client.call_api( response_data = self.api_client.call_api(
*_param, *_param,
@ -2100,8 +2108,7 @@ class PetApi:
) )
_response_types_map: Dict[str, Optional[str]] = { _response_types_map: Dict[str, Optional[str]] = {
'200': "ApiResponse" '200': "ApiResponse",
} }
response_data = self.api_client.call_api( response_data = self.api_client.call_api(
*_param, *_param,
@ -2176,8 +2183,7 @@ class PetApi:
) )
_response_types_map: Dict[str, Optional[str]] = { _response_types_map: Dict[str, Optional[str]] = {
'200': "ApiResponse" '200': "ApiResponse",
} }
response_data = self.api_client.call_api( response_data = self.api_client.call_api(
*_param, *_param,
@ -2329,8 +2335,7 @@ class PetApi:
) )
_response_types_map: Dict[str, Optional[str]] = { _response_types_map: Dict[str, Optional[str]] = {
'200': "ApiResponse" '200': "ApiResponse",
} }
response_data = self.api_client.call_api( response_data = self.api_client.call_api(
*_param, *_param,
@ -2405,8 +2410,7 @@ class PetApi:
) )
_response_types_map: Dict[str, Optional[str]] = { _response_types_map: Dict[str, Optional[str]] = {
'200': "ApiResponse" '200': "ApiResponse",
} }
response_data = self.api_client.call_api( response_data = self.api_client.call_api(
*_param, *_param,
@ -2481,8 +2485,7 @@ class PetApi:
) )
_response_types_map: Dict[str, Optional[str]] = { _response_types_map: Dict[str, Optional[str]] = {
'200': "ApiResponse" '200': "ApiResponse",
} }
response_data = self.api_client.call_api( response_data = self.api_client.call_api(
*_param, *_param,

View File

@ -103,7 +103,8 @@ class StoreApi:
) )
_response_types_map: Dict[str, Optional[str]] = { _response_types_map: Dict[str, Optional[str]] = {
'400': None,
'404': None,
} }
response_data = self.api_client.call_api( response_data = self.api_client.call_api(
*_param, *_param,
@ -170,7 +171,8 @@ class StoreApi:
) )
_response_types_map: Dict[str, Optional[str]] = { _response_types_map: Dict[str, Optional[str]] = {
'400': None,
'404': None,
} }
response_data = self.api_client.call_api( response_data = self.api_client.call_api(
*_param, *_param,
@ -237,7 +239,8 @@ class StoreApi:
) )
_response_types_map: Dict[str, Optional[str]] = { _response_types_map: Dict[str, Optional[str]] = {
'400': None,
'404': None,
} }
response_data = self.api_client.call_api( response_data = self.api_client.call_api(
*_param, *_param,
@ -351,8 +354,7 @@ class StoreApi:
) )
_response_types_map: Dict[str, Optional[str]] = { _response_types_map: Dict[str, Optional[str]] = {
'200': "Dict[str, int]" '200': "Dict[str, int]",
} }
response_data = self.api_client.call_api( response_data = self.api_client.call_api(
*_param, *_param,
@ -415,8 +417,7 @@ class StoreApi:
) )
_response_types_map: Dict[str, Optional[str]] = { _response_types_map: Dict[str, Optional[str]] = {
'200': "Dict[str, int]" '200': "Dict[str, int]",
} }
response_data = self.api_client.call_api( response_data = self.api_client.call_api(
*_param, *_param,
@ -479,8 +480,7 @@ class StoreApi:
) )
_response_types_map: Dict[str, Optional[str]] = { _response_types_map: Dict[str, Optional[str]] = {
'200': "Dict[str, int]" '200': "Dict[str, int]",
} }
response_data = self.api_client.call_api( response_data = self.api_client.call_api(
*_param, *_param,
@ -604,8 +604,7 @@ class StoreApi:
_response_types_map: Dict[str, Optional[str]] = { _response_types_map: Dict[str, Optional[str]] = {
'200': "Order", '200': "Order",
'400': None, '400': None,
'404': None '404': None,
} }
response_data = self.api_client.call_api( response_data = self.api_client.call_api(
*_param, *_param,
@ -674,8 +673,7 @@ class StoreApi:
_response_types_map: Dict[str, Optional[str]] = { _response_types_map: Dict[str, Optional[str]] = {
'200': "Order", '200': "Order",
'400': None, '400': None,
'404': None '404': None,
} }
response_data = self.api_client.call_api( response_data = self.api_client.call_api(
*_param, *_param,
@ -744,8 +742,7 @@ class StoreApi:
_response_types_map: Dict[str, Optional[str]] = { _response_types_map: Dict[str, Optional[str]] = {
'200': "Order", '200': "Order",
'400': None, '400': None,
'404': None '404': None,
} }
response_data = self.api_client.call_api( response_data = self.api_client.call_api(
*_param, *_param,
@ -871,8 +868,7 @@ class StoreApi:
_response_types_map: Dict[str, Optional[str]] = { _response_types_map: Dict[str, Optional[str]] = {
'200': "Order", '200': "Order",
'400': None '400': None,
} }
response_data = self.api_client.call_api( response_data = self.api_client.call_api(
*_param, *_param,
@ -940,8 +936,7 @@ class StoreApi:
_response_types_map: Dict[str, Optional[str]] = { _response_types_map: Dict[str, Optional[str]] = {
'200': "Order", '200': "Order",
'400': None '400': None,
} }
response_data = self.api_client.call_api( response_data = self.api_client.call_api(
*_param, *_param,
@ -1009,8 +1004,7 @@ class StoreApi:
_response_types_map: Dict[str, Optional[str]] = { _response_types_map: Dict[str, Optional[str]] = {
'200': "Order", '200': "Order",
'400': None '400': None,
} }
response_data = self.api_client.call_api( response_data = self.api_client.call_api(
*_param, *_param,

View File

@ -103,7 +103,6 @@ class UserApi:
) )
_response_types_map: Dict[str, Optional[str]] = { _response_types_map: Dict[str, Optional[str]] = {
} }
response_data = self.api_client.call_api( response_data = self.api_client.call_api(
*_param, *_param,
@ -170,7 +169,6 @@ class UserApi:
) )
_response_types_map: Dict[str, Optional[str]] = { _response_types_map: Dict[str, Optional[str]] = {
} }
response_data = self.api_client.call_api( response_data = self.api_client.call_api(
*_param, *_param,
@ -237,7 +235,6 @@ class UserApi:
) )
_response_types_map: Dict[str, Optional[str]] = { _response_types_map: Dict[str, Optional[str]] = {
} }
response_data = self.api_client.call_api( response_data = self.api_client.call_api(
*_param, *_param,
@ -373,7 +370,6 @@ class UserApi:
) )
_response_types_map: Dict[str, Optional[str]] = { _response_types_map: Dict[str, Optional[str]] = {
} }
response_data = self.api_client.call_api( response_data = self.api_client.call_api(
*_param, *_param,
@ -440,7 +436,6 @@ class UserApi:
) )
_response_types_map: Dict[str, Optional[str]] = { _response_types_map: Dict[str, Optional[str]] = {
} }
response_data = self.api_client.call_api( response_data = self.api_client.call_api(
*_param, *_param,
@ -507,7 +502,6 @@ class UserApi:
) )
_response_types_map: Dict[str, Optional[str]] = { _response_types_map: Dict[str, Optional[str]] = {
} }
response_data = self.api_client.call_api( response_data = self.api_client.call_api(
*_param, *_param,
@ -639,7 +633,6 @@ class UserApi:
) )
_response_types_map: Dict[str, Optional[str]] = { _response_types_map: Dict[str, Optional[str]] = {
} }
response_data = self.api_client.call_api( response_data = self.api_client.call_api(
*_param, *_param,
@ -706,7 +699,6 @@ class UserApi:
) )
_response_types_map: Dict[str, Optional[str]] = { _response_types_map: Dict[str, Optional[str]] = {
} }
response_data = self.api_client.call_api( response_data = self.api_client.call_api(
*_param, *_param,
@ -773,7 +765,6 @@ class UserApi:
) )
_response_types_map: Dict[str, Optional[str]] = { _response_types_map: Dict[str, Optional[str]] = {
} }
response_data = self.api_client.call_api( response_data = self.api_client.call_api(
*_param, *_param,
@ -905,7 +896,8 @@ class UserApi:
) )
_response_types_map: Dict[str, Optional[str]] = { _response_types_map: Dict[str, Optional[str]] = {
'400': None,
'404': None,
} }
response_data = self.api_client.call_api( response_data = self.api_client.call_api(
*_param, *_param,
@ -972,7 +964,8 @@ class UserApi:
) )
_response_types_map: Dict[str, Optional[str]] = { _response_types_map: Dict[str, Optional[str]] = {
'400': None,
'404': None,
} }
response_data = self.api_client.call_api( response_data = self.api_client.call_api(
*_param, *_param,
@ -1039,7 +1032,8 @@ class UserApi:
) )
_response_types_map: Dict[str, Optional[str]] = { _response_types_map: Dict[str, Optional[str]] = {
'400': None,
'404': None,
} }
response_data = self.api_client.call_api( response_data = self.api_client.call_api(
*_param, *_param,
@ -1159,8 +1153,7 @@ class UserApi:
_response_types_map: Dict[str, Optional[str]] = { _response_types_map: Dict[str, Optional[str]] = {
'200': "User", '200': "User",
'400': None, '400': None,
'404': None '404': None,
} }
response_data = self.api_client.call_api( response_data = self.api_client.call_api(
*_param, *_param,
@ -1229,8 +1222,7 @@ class UserApi:
_response_types_map: Dict[str, Optional[str]] = { _response_types_map: Dict[str, Optional[str]] = {
'200': "User", '200': "User",
'400': None, '400': None,
'404': None '404': None,
} }
response_data = self.api_client.call_api( response_data = self.api_client.call_api(
*_param, *_param,
@ -1299,8 +1291,7 @@ class UserApi:
_response_types_map: Dict[str, Optional[str]] = { _response_types_map: Dict[str, Optional[str]] = {
'200': "User", '200': "User",
'400': None, '400': None,
'404': None '404': None,
} }
response_data = self.api_client.call_api( response_data = self.api_client.call_api(
*_param, *_param,
@ -1430,8 +1421,7 @@ class UserApi:
_response_types_map: Dict[str, Optional[str]] = { _response_types_map: Dict[str, Optional[str]] = {
'200': "str", '200': "str",
'400': None '400': None,
} }
response_data = self.api_client.call_api( response_data = self.api_client.call_api(
*_param, *_param,
@ -1503,8 +1493,7 @@ class UserApi:
_response_types_map: Dict[str, Optional[str]] = { _response_types_map: Dict[str, Optional[str]] = {
'200': "str", '200': "str",
'400': None '400': None,
} }
response_data = self.api_client.call_api( response_data = self.api_client.call_api(
*_param, *_param,
@ -1576,8 +1565,7 @@ class UserApi:
_response_types_map: Dict[str, Optional[str]] = { _response_types_map: Dict[str, Optional[str]] = {
'200': "str", '200': "str",
'400': None '400': None,
} }
response_data = self.api_client.call_api( response_data = self.api_client.call_api(
*_param, *_param,
@ -1705,7 +1693,6 @@ class UserApi:
) )
_response_types_map: Dict[str, Optional[str]] = { _response_types_map: Dict[str, Optional[str]] = {
} }
response_data = self.api_client.call_api( response_data = self.api_client.call_api(
*_param, *_param,
@ -1768,7 +1755,6 @@ class UserApi:
) )
_response_types_map: Dict[str, Optional[str]] = { _response_types_map: Dict[str, Optional[str]] = {
} }
response_data = self.api_client.call_api( response_data = self.api_client.call_api(
*_param, *_param,
@ -1831,7 +1817,6 @@ class UserApi:
) )
_response_types_map: Dict[str, Optional[str]] = { _response_types_map: Dict[str, Optional[str]] = {
} }
response_data = self.api_client.call_api( response_data = self.api_client.call_api(
*_param, *_param,
@ -1950,7 +1935,8 @@ class UserApi:
) )
_response_types_map: Dict[str, Optional[str]] = { _response_types_map: Dict[str, Optional[str]] = {
'400': None,
'404': None,
} }
response_data = self.api_client.call_api( response_data = self.api_client.call_api(
*_param, *_param,
@ -2021,7 +2007,8 @@ class UserApi:
) )
_response_types_map: Dict[str, Optional[str]] = { _response_types_map: Dict[str, Optional[str]] = {
'400': None,
'404': None,
} }
response_data = self.api_client.call_api( response_data = self.api_client.call_api(
*_param, *_param,
@ -2092,7 +2079,8 @@ class UserApi:
) )
_response_types_map: Dict[str, Optional[str]] = { _response_types_map: Dict[str, Optional[str]] = {
'400': None,
'404': None,
} }
response_data = self.api_client.call_api( response_data = self.api_client.call_api(
*_param, *_param,

View File

@ -281,7 +281,7 @@ class ApiClient:
def response_deserialize( def response_deserialize(
self, self,
response_data=None, response_data: rest.RESTResponse = None,
response_types_map=None response_types_map=None
) -> ApiResponse: ) -> ApiResponse:
"""Deserializes response into an object. """Deserializes response into an object.
@ -296,32 +296,15 @@ class ApiClient:
# if not found, look for '1XX', '2XX', etc. # if not found, look for '1XX', '2XX', etc.
response_type = response_types_map.get(str(response_data.status)[0] + "XX", None) 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 # deserialize response data
response_text = None
return_data = None
try:
if response_type == "bytearray": if response_type == "bytearray":
return_data = response_data.data return_data = response_data.data
elif response_type is None:
return_data = None
elif response_type == "file": elif response_type == "file":
return_data = self.__deserialize_file(response_data) return_data = self.__deserialize_file(response_data)
else: elif response_type is not None:
match = None match = None
content_type = response_data.getheader('content-type') content_type = response_data.getheader('content-type')
if content_type is not None: if content_type is not None:
@ -329,6 +312,13 @@ class ApiClient:
encoding = match.group(1) if match else "utf-8" encoding = match.group(1) if match else "utf-8"
response_text = response_data.data.decode(encoding) response_text = response_data.data.decode(encoding)
return_data = self.deserialize(response_text, response_type) 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( return ApiResponse(
status_code = response_data.status, status_code = response_data.status,

View File

@ -11,6 +11,9 @@
Do not edit the class manually. Do not edit the class manually.
""" # noqa: E501 """ # noqa: E501
from typing import Any, Optional
from typing_extensions import Self
class OpenApiException(Exception): class OpenApiException(Exception):
"""The base exception class for all OpenAPIExceptions""" """The base exception class for all OpenAPIExceptions"""
@ -101,18 +104,57 @@ class ApiKeyError(OpenApiException, KeyError):
class ApiException(OpenApiException): class ApiException(OpenApiException):
def __init__(self, status=None, reason=None, http_resp=None) -> None: def __init__(
if http_resp: self,
self.status = http_resp.status status=None,
self.reason = http_resp.reason reason=None,
self.body = http_resp.data.decode('utf-8') http_resp=None,
self.headers = http_resp.getheaders() *,
else: body: Optional[str] = None,
data: Optional[Any] = None,
) -> None:
self.status = status self.status = status
self.reason = reason self.reason = reason
self.body = None self.body = body
self.data = data
self.headers = None self.headers = None
if http_resp:
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()
@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): def __str__(self):
"""Custom error messages for exception""" """Custom error messages for exception"""
error_message = "({0})\n"\ error_message = "({0})\n"\
@ -121,38 +163,30 @@ class ApiException(OpenApiException):
error_message += "HTTP response headers: {0}\n".format( error_message += "HTTP response headers: {0}\n".format(
self.headers) self.headers)
if self.body: if self.data or self.body:
error_message += "HTTP response body: {0}\n".format(self.body) error_message += "HTTP response body: {0}\n".format(self.data or self.body)
return error_message return error_message
class BadRequestException(ApiException):
def __init__(self, status=None, reason=None, http_resp=None) -> None: class BadRequestException(ApiException):
super(BadRequestException, self).__init__(status, reason, http_resp) pass
class NotFoundException(ApiException): class NotFoundException(ApiException):
pass
def __init__(self, status=None, reason=None, http_resp=None) -> None:
super(NotFoundException, self).__init__(status, reason, http_resp)
class UnauthorizedException(ApiException): class UnauthorizedException(ApiException):
pass
def __init__(self, status=None, reason=None, http_resp=None) -> None:
super(UnauthorizedException, self).__init__(status, reason, http_resp)
class ForbiddenException(ApiException): class ForbiddenException(ApiException):
pass
def __init__(self, status=None, reason=None, http_resp=None) -> None:
super(ForbiddenException, self).__init__(status, reason, http_resp)
class ServiceException(ApiException): class ServiceException(ApiException):
pass
def __init__(self, status=None, reason=None, http_resp=None) -> None:
super(ServiceException, self).__init__(status, reason, http_resp)
def render_path(path_to_item): def render_path(path_to_item):

View File

@ -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_model_name import SpecialModelName
from petstore_api.models.special_name import SpecialName from petstore_api.models.special_name import SpecialName
from petstore_api.models.tag import Tag 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.test_inline_freeform_additional_properties_request import TestInlineFreeformAdditionalPropertiesRequest
from petstore_api.models.tiger import Tiger from petstore_api.models.tiger import Tiger
from petstore_api.models.unnamed_dict_with_additional_model_list_properties import UnnamedDictWithAdditionalModelListProperties from petstore_api.models.unnamed_dict_with_additional_model_list_properties import UnnamedDictWithAdditionalModelListProperties

View File

@ -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

View File

@ -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

View File

@ -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()

View File

@ -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()

View File

@ -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