openapi-core/openapi_core/schema/parameters/exceptions.py

41 lines
963 B
Python
Raw Normal View History

import attr
2019-06-18 11:39:07 +00:00
from openapi_core.schema.exceptions import OpenAPIMappingError
2018-04-18 10:39:03 +00:00
class OpenAPIParameterError(OpenAPIMappingError):
pass
2019-06-18 11:39:07 +00:00
@attr.s(hash=True)
2018-04-18 10:39:03 +00:00
class MissingParameter(OpenAPIParameterError):
name = attr.ib()
def __str__(self):
return "Missing parameter (without default value): {0}".format(self.name)
2018-04-18 10:39:03 +00:00
2019-06-18 11:39:07 +00:00
@attr.s(hash=True)
2018-04-18 10:39:03 +00:00
class MissingRequiredParameter(OpenAPIParameterError):
name = attr.ib()
def __str__(self):
return "Missing required parameter: {0}".format(self.name)
2018-04-18 10:39:03 +00:00
2019-06-18 11:39:07 +00:00
@attr.s(hash=True)
2018-04-18 10:39:03 +00:00
class EmptyParameterValue(OpenAPIParameterError):
name = attr.ib()
def __str__(self):
return "Value of parameter cannot be empty: {0}".format(self.name)
2018-04-18 10:39:03 +00:00
2019-06-18 11:39:07 +00:00
@attr.s(hash=True)
2018-04-18 10:39:03 +00:00
class InvalidParameterValue(OpenAPIParameterError):
name = attr.ib()
original_exception = attr.ib()
def __str__(self):
2018-09-13 12:57:59 +00:00
return "Invalid parameter value for `{0}`: {1}".format(self.name, self.original_exception)