Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/OM-HASE/openapi-generator
Browse files Browse the repository at this point in the history
…into OM-HASE-master
  • Loading branch information
wing328 committed Dec 30, 2024
2 parents 45aeae3 + da0cb28 commit 89b6a96
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,13 @@ class ApiException(OpenApiException):
if http_resp.status == 404:
raise NotFoundException(http_resp=http_resp, body=body, data=data)

# Added new conditions for 409 and 422
if http_resp.status == 409:
raise ConflictException(http_resp=http_resp, body=body, data=data)

if http_resp.status == 422:
raise UnprocessableEntityException(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)
Expand Down Expand Up @@ -178,6 +185,16 @@ class ServiceException(ApiException):
pass


class ConflictException(ApiException):
"""Exception for HTTP 409 Conflict."""
pass


class UnprocessableEntityException(ApiException):
"""Exception for HTTP 422 Unprocessable Entity."""
pass


def render_path(path_to_item):
"""Returns a string representation of a path"""
result = ""
Expand Down
16 changes: 16 additions & 0 deletions samples/openapi3/client/petstore/python/petstore_api/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,14 @@ def from_response(
if http_resp.status == 404:
raise NotFoundException(http_resp=http_resp, body=body, data=data)

# Added new exception classes for 409 and 422

if http_resp.status == 409:
raise ConflictException(http_resp=http_resp, body=body, data=data)

if http_resp.status == 422:
raise UnprocessableEntityException(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)
Expand Down Expand Up @@ -183,6 +191,14 @@ class UnauthorizedException(ApiException):
class ForbiddenException(ApiException):
pass

class ConflictException(ApiException):
"""Exception raised for HTTP 409 Conflict errors."""
pass


class UnprocessableEntityException(ApiException):
"""Exception raised for HTTP 422 Unprocessable Entity errors."""
pass

class ServiceException(ApiException):
pass
Expand Down

0 comments on commit 89b6a96

Please sign in to comment.