[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
85 changed files with 4309 additions and 951 deletions

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