2019-10-25 23:34:42 +00:00
|
|
|
"""OpenAPI core exceptions module"""
|
2021-04-27 21:16:30 +00:00
|
|
|
import attr
|
2019-10-25 23:34:42 +00:00
|
|
|
|
|
|
|
|
|
|
|
class OpenAPIError(Exception):
|
|
|
|
pass
|
2021-04-27 21:16:30 +00:00
|
|
|
|
|
|
|
|
|
|
|
class OpenAPIParameterError(OpenAPIError):
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
|
|
|
class MissingParameterError(OpenAPIParameterError):
|
|
|
|
"""Missing parameter error"""
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
|
|
|
@attr.s(hash=True)
|
|
|
|
class MissingParameter(MissingParameterError):
|
|
|
|
name = attr.ib()
|
|
|
|
|
|
|
|
def __str__(self):
|
|
|
|
return "Missing parameter (without default value): {0}".format(
|
|
|
|
self.name)
|
|
|
|
|
|
|
|
|
|
|
|
@attr.s(hash=True)
|
|
|
|
class MissingRequiredParameter(MissingParameterError):
|
|
|
|
name = attr.ib()
|
|
|
|
|
|
|
|
def __str__(self):
|
|
|
|
return "Missing required parameter: {0}".format(self.name)
|
|
|
|
|
|
|
|
|
|
|
|
class OpenAPIRequestBodyError(OpenAPIError):
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
|
|
|
@attr.s(hash=True)
|
|
|
|
class MissingRequestBody(OpenAPIRequestBodyError):
|
|
|
|
request = attr.ib()
|
|
|
|
|
|
|
|
def __str__(self):
|
|
|
|
return "Missing required request body"
|
|
|
|
|
|
|
|
|
|
|
|
class OpenAPIResponseError(OpenAPIError):
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
|
|
|
@attr.s(hash=True)
|
|
|
|
class MissingResponseContent(OpenAPIResponseError):
|
|
|
|
response = attr.ib()
|
|
|
|
|
|
|
|
def __str__(self):
|
|
|
|
return "Missing response content"
|