mirror of
https://github.com/correl/openapi-core.git
synced 2024-11-25 11:09:53 +00:00
6bdd1a6756
Main motivation behind this change is to be able to catch exceptions as per raise_for_errors() helpers, but to inspect state of exceptions instead of just getting a rendered string. This allows rendering exceptions into JSON, for example.
72 lines
1.7 KiB
Python
72 lines
1.7 KiB
Python
from openapi_core.schema.exceptions import OpenAPIMappingError
|
|
|
|
import attr
|
|
|
|
|
|
class OpenAPISchemaError(OpenAPIMappingError):
|
|
pass
|
|
|
|
|
|
@attr.s
|
|
class NoValidSchema(OpenAPISchemaError):
|
|
value = attr.ib()
|
|
|
|
def __str__(self):
|
|
return "No valid schema found for value: {0}".format(self.value)
|
|
|
|
|
|
@attr.s
|
|
class UndefinedItemsSchema(OpenAPISchemaError):
|
|
type = attr.ib()
|
|
|
|
def __str__(self):
|
|
return "Null value for schema type {0}".format(self.type)
|
|
|
|
|
|
@attr.s
|
|
class InvalidSchemaValue(OpenAPISchemaError):
|
|
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)
|
|
|
|
|
|
@attr.s
|
|
class UndefinedSchemaProperty(OpenAPISchemaError):
|
|
extra_props = attr.ib()
|
|
|
|
def __str__(self):
|
|
return "Extra unexpected properties found in schema: {0}".format(self.extra_props)
|
|
|
|
|
|
@attr.s
|
|
class MissingSchemaProperty(OpenAPISchemaError):
|
|
property_name = attr.ib()
|
|
|
|
def __str__(self):
|
|
return "Missing schema property: {0}".format(self.property_name)
|
|
|
|
|
|
@attr.s
|
|
class NoOneOfSchema(OpenAPISchemaError):
|
|
type = attr.ib()
|
|
|
|
def __str__(self):
|
|
return "Exactly one valid schema type {0} should be valid, None found.".format(self.type)
|
|
|
|
|
|
@attr.s
|
|
class MultipleOneOfSchema(OpenAPISchemaError):
|
|
type = attr.ib()
|
|
|
|
def __str__(self):
|
|
return "Exactly one schema type {0} should be valid, more than one found".format(self.type)
|