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 OpenAPISchemaError(OpenAPIMappingError):
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
2018-09-06 14:50:16 +00:00
|
|
|
@attr.s
|
2018-08-05 12:40:34 +00:00
|
|
|
class NoValidSchema(OpenAPISchemaError):
|
2018-09-06 14:50:16 +00:00
|
|
|
value = attr.ib()
|
|
|
|
|
|
|
|
def __str__(self):
|
|
|
|
return "No valid schema found for value: {0}".format(self.value)
|
2018-08-05 12:40:34 +00:00
|
|
|
|
|
|
|
|
2018-09-06 14:50:16 +00:00
|
|
|
@attr.s
|
2018-08-05 12:40:34 +00:00
|
|
|
class UndefinedItemsSchema(OpenAPISchemaError):
|
2018-09-06 14:50:16 +00:00
|
|
|
type = attr.ib()
|
|
|
|
|
|
|
|
def __str__(self):
|
|
|
|
return "Null value for schema type {0}".format(self.type)
|
2018-08-05 12:40:34 +00:00
|
|
|
|
|
|
|
|
2018-09-06 14:50:16 +00:00
|
|
|
@attr.s
|
2018-04-18 10:39:03 +00:00
|
|
|
class InvalidSchemaValue(OpenAPISchemaError):
|
2018-09-06 14:50:16 +00:00
|
|
|
msg = attr.ib()
|
|
|
|
value = attr.ib()
|
|
|
|
type = attr.ib()
|
|
|
|
|
|
|
|
def __str__(self):
|
|
|
|
return self.msg.format(value=self.value, type=self.type)
|
|
|
|
|
|
|
|
@attr.s
|
|
|
|
class InvalidCustomFormatSchemaValue(InvalidSchemaValue):
|
|
|
|
original_exception = attr.ib()
|
|
|
|
|
|
|
|
def __str__(self):
|
|
|
|
return self.msg.format(value=self.value, type=self.type, exception=self.original_exception)
|
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 UndefinedSchemaProperty(OpenAPISchemaError):
|
2018-09-06 14:50:16 +00:00
|
|
|
extra_props = attr.ib()
|
|
|
|
|
|
|
|
def __str__(self):
|
|
|
|
return "Extra unexpected properties found in schema: {0}".format(self.extra_props)
|
2018-04-18 10:39:03 +00:00
|
|
|
|
2018-09-12 16:43:31 +00:00
|
|
|
@attr.s
|
|
|
|
class InvalidSchemaProperty(OpenAPISchemaError):
|
|
|
|
property_name = attr.ib()
|
|
|
|
original_exception = attr.ib()
|
|
|
|
|
|
|
|
def __str__(self):
|
|
|
|
return "Invalid schema property {0}: {1}".format(self.property_name, self.original_exception)
|
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 MissingSchemaProperty(OpenAPISchemaError):
|
2018-09-06 14:50:16 +00:00
|
|
|
property_name = attr.ib()
|
|
|
|
|
|
|
|
def __str__(self):
|
|
|
|
return "Missing schema property: {0}".format(self.property_name)
|
2018-05-25 15:32:09 +00:00
|
|
|
|
|
|
|
|
2018-09-06 14:50:16 +00:00
|
|
|
@attr.s
|
2018-05-25 15:32:09 +00:00
|
|
|
class NoOneOfSchema(OpenAPISchemaError):
|
2018-09-06 14:50:16 +00:00
|
|
|
type = attr.ib()
|
|
|
|
|
|
|
|
def __str__(self):
|
|
|
|
return "Exactly one valid schema type {0} should be valid, None found.".format(self.type)
|
2018-05-25 15:32:09 +00:00
|
|
|
|
|
|
|
|
2018-09-06 14:50:16 +00:00
|
|
|
@attr.s
|
2018-05-25 15:32:09 +00:00
|
|
|
class MultipleOneOfSchema(OpenAPISchemaError):
|
2018-09-06 14:50:16 +00:00
|
|
|
type = attr.ib()
|
|
|
|
|
|
|
|
def __str__(self):
|
|
|
|
return "Exactly one schema type {0} should be valid, more than one found".format(self.type)
|
2019-05-23 11:48:45 +00:00
|
|
|
|
|
|
|
|
|
|
|
class UnmarshallerError(Exception):
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
|
|
|
@attr.s
|
|
|
|
class UnmarshallerStrictTypeError(UnmarshallerError):
|
|
|
|
value = attr.ib()
|
|
|
|
types = attr.ib()
|
|
|
|
|
|
|
|
def __str__(self):
|
|
|
|
return "Value {value} is not one of types {types}".format(
|
|
|
|
self.value, self.types)
|