2018-04-18 10:39:03 +00:00
|
|
|
from openapi_core.schema.exceptions import OpenAPIMappingError
|
|
|
|
|
2018-09-06 14:50:16 +00:00
|
|
|
import attr
|
|
|
|
|
2018-04-18 10:39:03 +00:00
|
|
|
|
|
|
|
class OpenAPIParameterError(OpenAPIMappingError):
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
2018-09-06 14:50:16 +00:00
|
|
|
@attr.s
|
2018-04-18 10:39:03 +00:00
|
|
|
class MissingParameter(OpenAPIParameterError):
|
2018-09-06 14:50:16 +00:00
|
|
|
name = attr.ib()
|
|
|
|
|
|
|
|
def __str__(self):
|
|
|
|
return "Missing parameter (without default value): {0}".format(self.name)
|
2018-04-18 10:39:03 +00:00
|
|
|
|
|
|
|
|
2018-09-06 14:50:16 +00:00
|
|
|
@attr.s
|
2018-04-18 10:39:03 +00:00
|
|
|
class MissingRequiredParameter(OpenAPIParameterError):
|
2018-09-06 14:50:16 +00:00
|
|
|
name = attr.ib()
|
|
|
|
|
|
|
|
def __str__(self):
|
|
|
|
return "Missing required parameter: {0}".format(self.name)
|
2018-04-18 10:39:03 +00:00
|
|
|
|
|
|
|
|
2018-09-06 14:50:16 +00:00
|
|
|
@attr.s
|
2018-04-18 10:39:03 +00:00
|
|
|
class EmptyParameterValue(OpenAPIParameterError):
|
2018-09-06 14:50:16 +00:00
|
|
|
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
|
|
|
|
|
|
|
|
2018-09-06 14:50:16 +00:00
|
|
|
@attr.s
|
2018-04-18 10:39:03 +00:00
|
|
|
class InvalidParameterValue(OpenAPIParameterError):
|
2018-09-06 14:50:16 +00:00
|
|
|
name = attr.ib()
|
|
|
|
original_exception = attr.ib()
|
|
|
|
|
|
|
|
def __str__(self):
|
|
|
|
return "Invalid parameter value for `{0}`: {1}".format(sef.name, self.original_exception)
|