Skip to content

Commit

Permalink
update samples
Browse files Browse the repository at this point in the history
  • Loading branch information
wing328 committed Dec 30, 2024
1 parent 89b6a96 commit 65edf7d
Show file tree
Hide file tree
Showing 4 changed files with 60 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,13 @@ def from_response(
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 @@ -189,6 +196,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
17 changes: 17 additions & 0 deletions samples/client/echo_api/python/openapi_client/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,13 @@ def from_response(
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 @@ -189,6 +196,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
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,13 @@ def from_response(
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 @@ -188,6 +195,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
Original file line number Diff line number Diff line change
Expand Up @@ -150,12 +150,11 @@ 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

# 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:
if http_resp.status == 422:
raise UnprocessableEntityException(http_resp=http_resp, body=body, data=data)

if 500 <= http_resp.status <= 599:
Expand Down Expand Up @@ -191,16 +190,18 @@ class UnauthorizedException(ApiException):
class ForbiddenException(ApiException):
pass

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

class ServiceException(ApiException):
pass


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

class ServiceException(ApiException):

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


Expand Down

0 comments on commit 65edf7d

Please sign in to comment.