mirror of
https://github.com/correl/openapi-core.git
synced 2024-11-25 11:09:53 +00:00
attr errors hashable fix
This commit is contained in:
parent
78ede74825
commit
c9b2d8c4f8
15 changed files with 50 additions and 46 deletions
|
@ -1,13 +1,13 @@
|
|||
from openapi_core.schema.exceptions import OpenAPIMappingError
|
||||
|
||||
import attr
|
||||
|
||||
from openapi_core.schema.exceptions import OpenAPIMappingError
|
||||
|
||||
|
||||
class OpenAPIContentError(OpenAPIMappingError):
|
||||
pass
|
||||
|
||||
|
||||
@attr.s
|
||||
@attr.s(hash=True)
|
||||
class MimeTypeNotFound(OpenAPIContentError):
|
||||
mimetype = attr.ib()
|
||||
availableMimetypes = attr.ib()
|
||||
|
|
|
@ -18,4 +18,4 @@ class Content(dict):
|
|||
if fnmatch.fnmatch(mimetype, key):
|
||||
return value
|
||||
|
||||
raise MimeTypeNotFound(mimetype, self.keys())
|
||||
raise MimeTypeNotFound(mimetype, list(self.keys()))
|
||||
|
|
|
@ -1,19 +1,21 @@
|
|||
from openapi_core.schema.exceptions import OpenAPIMappingError
|
||||
|
||||
import attr
|
||||
|
||||
from openapi_core.schema.exceptions import OpenAPIMappingError
|
||||
|
||||
|
||||
class OpenAPIMediaTypeError(OpenAPIMappingError):
|
||||
pass
|
||||
|
||||
@attr.s
|
||||
|
||||
@attr.s(hash=True)
|
||||
class InvalidMediaTypeValue(OpenAPIMediaTypeError):
|
||||
original_exception = attr.ib()
|
||||
|
||||
def __str__(self):
|
||||
return "Mimetype invalid: {0}".format(self.original_exception)
|
||||
|
||||
@attr.s
|
||||
|
||||
@attr.s(hash=True)
|
||||
class InvalidContentType(OpenAPIMediaTypeError):
|
||||
mimetype = attr.ib()
|
||||
|
||||
|
|
|
@ -1,13 +1,13 @@
|
|||
from openapi_core.schema.exceptions import OpenAPIMappingError
|
||||
|
||||
import attr
|
||||
|
||||
from openapi_core.schema.exceptions import OpenAPIMappingError
|
||||
|
||||
|
||||
class OpenAPIOperationError(OpenAPIMappingError):
|
||||
pass
|
||||
|
||||
|
||||
@attr.s
|
||||
@attr.s(hash=True)
|
||||
class InvalidOperation(OpenAPIOperationError):
|
||||
path_pattern = attr.ib()
|
||||
http_method = attr.ib()
|
||||
|
|
|
@ -1,13 +1,13 @@
|
|||
from openapi_core.schema.exceptions import OpenAPIMappingError
|
||||
|
||||
import attr
|
||||
|
||||
from openapi_core.schema.exceptions import OpenAPIMappingError
|
||||
|
||||
|
||||
class OpenAPIParameterError(OpenAPIMappingError):
|
||||
pass
|
||||
|
||||
|
||||
@attr.s
|
||||
@attr.s(hash=True)
|
||||
class MissingParameter(OpenAPIParameterError):
|
||||
name = attr.ib()
|
||||
|
||||
|
@ -15,7 +15,7 @@ class MissingParameter(OpenAPIParameterError):
|
|||
return "Missing parameter (without default value): {0}".format(self.name)
|
||||
|
||||
|
||||
@attr.s
|
||||
@attr.s(hash=True)
|
||||
class MissingRequiredParameter(OpenAPIParameterError):
|
||||
name = attr.ib()
|
||||
|
||||
|
@ -23,7 +23,7 @@ class MissingRequiredParameter(OpenAPIParameterError):
|
|||
return "Missing required parameter: {0}".format(self.name)
|
||||
|
||||
|
||||
@attr.s
|
||||
@attr.s(hash=True)
|
||||
class EmptyParameterValue(OpenAPIParameterError):
|
||||
name = attr.ib()
|
||||
|
||||
|
@ -31,7 +31,7 @@ class EmptyParameterValue(OpenAPIParameterError):
|
|||
return "Value of parameter cannot be empty: {0}".format(self.name)
|
||||
|
||||
|
||||
@attr.s
|
||||
@attr.s(hash=True)
|
||||
class InvalidParameterValue(OpenAPIParameterError):
|
||||
name = attr.ib()
|
||||
original_exception = attr.ib()
|
||||
|
|
|
@ -1,13 +1,13 @@
|
|||
from openapi_core.schema.exceptions import OpenAPIMappingError
|
||||
|
||||
import attr
|
||||
|
||||
from openapi_core.schema.exceptions import OpenAPIMappingError
|
||||
|
||||
|
||||
class OpenAPIRequestBodyError(OpenAPIMappingError):
|
||||
pass
|
||||
|
||||
|
||||
@attr.s
|
||||
@attr.s(hash=True)
|
||||
class MissingRequestBody(OpenAPIRequestBodyError):
|
||||
request = attr.ib()
|
||||
|
||||
|
|
|
@ -1,13 +1,13 @@
|
|||
from openapi_core.schema.exceptions import OpenAPIMappingError
|
||||
|
||||
import attr
|
||||
|
||||
from openapi_core.schema.exceptions import OpenAPIMappingError
|
||||
|
||||
|
||||
class OpenAPIResponseError(OpenAPIMappingError):
|
||||
pass
|
||||
|
||||
|
||||
@attr.s
|
||||
@attr.s(hash=True)
|
||||
class InvalidResponse(OpenAPIResponseError):
|
||||
http_status = attr.ib()
|
||||
responses = attr.ib()
|
||||
|
@ -16,7 +16,7 @@ class InvalidResponse(OpenAPIResponseError):
|
|||
return "Unknown response http status: {0}".format(str(self.http_status))
|
||||
|
||||
|
||||
@attr.s
|
||||
@attr.s(hash=True)
|
||||
class MissingResponseContent(OpenAPIResponseError):
|
||||
response = attr.ib()
|
||||
|
||||
|
|
|
@ -1,13 +1,13 @@
|
|||
from openapi_core.schema.exceptions import OpenAPIMappingError
|
||||
|
||||
import attr
|
||||
|
||||
from openapi_core.schema.exceptions import OpenAPIMappingError
|
||||
|
||||
|
||||
class OpenAPISchemaError(OpenAPIMappingError):
|
||||
pass
|
||||
|
||||
|
||||
@attr.s
|
||||
@attr.s(hash=True)
|
||||
class NoValidSchema(OpenAPISchemaError):
|
||||
value = attr.ib()
|
||||
|
||||
|
@ -15,7 +15,7 @@ class NoValidSchema(OpenAPISchemaError):
|
|||
return "No valid schema found for value: {0}".format(self.value)
|
||||
|
||||
|
||||
@attr.s
|
||||
@attr.s(hash=True)
|
||||
class UndefinedItemsSchema(OpenAPISchemaError):
|
||||
type = attr.ib()
|
||||
|
||||
|
@ -23,7 +23,7 @@ class UndefinedItemsSchema(OpenAPISchemaError):
|
|||
return "Null value for schema type {0}".format(self.type)
|
||||
|
||||
|
||||
@attr.s
|
||||
@attr.s(hash=True)
|
||||
class InvalidSchemaValue(OpenAPISchemaError):
|
||||
msg = attr.ib()
|
||||
value = attr.ib()
|
||||
|
@ -32,7 +32,8 @@ class InvalidSchemaValue(OpenAPISchemaError):
|
|||
def __str__(self):
|
||||
return self.msg.format(value=self.value, type=self.type)
|
||||
|
||||
@attr.s
|
||||
|
||||
@attr.s(hash=True)
|
||||
class InvalidCustomFormatSchemaValue(InvalidSchemaValue):
|
||||
original_exception = attr.ib()
|
||||
|
||||
|
@ -40,14 +41,15 @@ class InvalidCustomFormatSchemaValue(InvalidSchemaValue):
|
|||
return self.msg.format(value=self.value, type=self.type, exception=self.original_exception)
|
||||
|
||||
|
||||
@attr.s
|
||||
@attr.s(hash=True)
|
||||
class UndefinedSchemaProperty(OpenAPISchemaError):
|
||||
extra_props = attr.ib()
|
||||
|
||||
def __str__(self):
|
||||
return "Extra unexpected properties found in schema: {0}".format(self.extra_props)
|
||||
|
||||
@attr.s
|
||||
|
||||
@attr.s(hash=True)
|
||||
class InvalidSchemaProperty(OpenAPISchemaError):
|
||||
property_name = attr.ib()
|
||||
original_exception = attr.ib()
|
||||
|
@ -55,7 +57,8 @@ class InvalidSchemaProperty(OpenAPISchemaError):
|
|||
def __str__(self):
|
||||
return "Invalid schema property {0}: {1}".format(self.property_name, self.original_exception)
|
||||
|
||||
@attr.s
|
||||
|
||||
@attr.s(hash=True)
|
||||
class MissingSchemaProperty(OpenAPISchemaError):
|
||||
property_name = attr.ib()
|
||||
|
||||
|
@ -63,7 +66,7 @@ class MissingSchemaProperty(OpenAPISchemaError):
|
|||
return "Missing schema property: {0}".format(self.property_name)
|
||||
|
||||
|
||||
@attr.s
|
||||
@attr.s(hash=True)
|
||||
class NoOneOfSchema(OpenAPISchemaError):
|
||||
type = attr.ib()
|
||||
|
||||
|
@ -71,7 +74,7 @@ class NoOneOfSchema(OpenAPISchemaError):
|
|||
return "Exactly one valid schema type {0} should be valid, None found.".format(self.type)
|
||||
|
||||
|
||||
@attr.s
|
||||
@attr.s(hash=True)
|
||||
class MultipleOneOfSchema(OpenAPISchemaError):
|
||||
type = attr.ib()
|
||||
|
||||
|
@ -79,11 +82,10 @@ class MultipleOneOfSchema(OpenAPISchemaError):
|
|||
return "Exactly one schema type {0} should be valid, more than one found".format(self.type)
|
||||
|
||||
|
||||
class UnmarshallerError(Exception):
|
||||
class UnmarshallerError(OpenAPIMappingError):
|
||||
pass
|
||||
|
||||
|
||||
@attr.s
|
||||
class UnmarshallerStrictTypeError(UnmarshallerError):
|
||||
value = attr.ib()
|
||||
types = attr.ib()
|
||||
|
|
|
@ -1,13 +1,13 @@
|
|||
from openapi_core.schema.exceptions import OpenAPIMappingError
|
||||
|
||||
import attr
|
||||
|
||||
from openapi_core.schema.exceptions import OpenAPIMappingError
|
||||
|
||||
|
||||
class OpenAPIServerError(OpenAPIMappingError):
|
||||
pass
|
||||
|
||||
|
||||
@attr.s
|
||||
@attr.s(hash=True)
|
||||
class InvalidServer(OpenAPIServerError):
|
||||
full_url_pattern = attr.ib()
|
||||
|
||||
|
|
|
@ -40,5 +40,5 @@ class TestLinks(object):
|
|||
@pytest.mark.parametrize("request_body", request_body_list)
|
||||
def test_iteritems(self, link_factory, request_body, server):
|
||||
link = link_factory(request_body, server)
|
||||
for par_name in link.parameters.keys():
|
||||
for par_name in link.parameters:
|
||||
assert link[par_name] == link.parameters[par_name]
|
||||
|
|
|
@ -15,7 +15,7 @@ class TestSchemas(object):
|
|||
return Operation('get', '/path', {}, parameters=parameters)
|
||||
|
||||
def test_iteritems(self, operation):
|
||||
for name in operation.parameters.keys():
|
||||
for name in operation.parameters:
|
||||
assert operation[name] == operation.parameters[name]
|
||||
|
||||
|
||||
|
|
|
@ -16,6 +16,6 @@ class TestPaths(object):
|
|||
|
||||
@property
|
||||
def test_iteritems(self, path):
|
||||
for http_method in path.operations.keys():
|
||||
for http_method in path.operations:
|
||||
assert path[http_method] ==\
|
||||
path.operations[http_method]
|
||||
|
|
|
@ -16,6 +16,6 @@ class TestRequestBodies(object):
|
|||
|
||||
@property
|
||||
def test_iteritems(self, request_body):
|
||||
for mimetype in request_body.content.keys():
|
||||
for mimetype in request_body.content:
|
||||
assert request_body[mimetype] ==\
|
||||
request_body.content[mimetype]
|
||||
|
|
|
@ -27,7 +27,7 @@ class TestSchemaIteritems(object):
|
|||
|
||||
@property
|
||||
def test_valid(self, schema):
|
||||
for name in schema.properties.keys():
|
||||
for name in schema.properties:
|
||||
assert schema[name] == schema.properties[name]
|
||||
|
||||
|
||||
|
|
|
@ -32,7 +32,7 @@ class TestSpecs(object):
|
|||
return Spec(servers, paths)
|
||||
|
||||
def test_iteritems(self, spec):
|
||||
for path_name in spec.paths.keys():
|
||||
for path_name in spec.paths:
|
||||
assert spec[path_name] ==\
|
||||
spec.paths[path_name]
|
||||
|
||||
|
|
Loading…
Reference in a new issue