Skip to content

Commit 0604145

Browse files
authored
Merge pull request #165 from p1c2u/feature/validation-datatypes
Validation datatypes
2 parents f12b6d8 + 48ee8f9 commit 0604145

File tree

14 files changed

+321
-301
lines changed

14 files changed

+321
-301
lines changed

openapi_core/validation/models.py renamed to openapi_core/validation/datatypes.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
"""OpenAPI core validation models module"""
1+
"""OpenAPI core validation datatypes module"""
2+
import attr
23

34

5+
@attr.s
46
class BaseValidationResult(object):
5-
6-
def __init__(self, errors):
7-
self.errors = errors
7+
errors = attr.ib(factory=list)
88

99
def raise_for_errors(self):
1010
for error in self.errors:
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
"""OpenAPI core validation request datatypes module"""
2+
import attr
3+
4+
from openapi_core.validation.datatypes import BaseValidationResult
5+
6+
7+
@attr.s
8+
class RequestParameters(object):
9+
path = attr.ib(factory=dict)
10+
query = attr.ib(factory=dict)
11+
header = attr.ib(factory=dict)
12+
cookie = attr.ib(factory=dict)
13+
14+
def __getitem__(self, location):
15+
return getattr(self, location)
16+
17+
18+
@attr.s
19+
class RequestValidationResult(BaseValidationResult):
20+
body = attr.ib(default=None)
21+
parameters = attr.ib(factory=RequestParameters)

openapi_core/validation/request/models.py

Lines changed: 0 additions & 41 deletions
This file was deleted.

openapi_core/validation/request/validators.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
from openapi_core.schema.exceptions import OpenAPIMappingError
66
from openapi_core.schema.parameters.exceptions import MissingParameter
7-
from openapi_core.validation.request.models import (
7+
from openapi_core.validation.request.datatypes import (
88
RequestParameters, RequestValidationResult,
99
)
1010
from openapi_core.validation.util import get_operation_pattern
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
"""OpenAPI core validation response datatypes module"""
2+
import attr
3+
4+
from openapi_core.validation.datatypes import BaseValidationResult
5+
6+
7+
@attr.s
8+
class ResponseValidationResult(BaseValidationResult):
9+
data = attr.ib(default=None)
10+
headers = attr.ib(factory=dict)

openapi_core/validation/response/models.py

Lines changed: 0 additions & 10 deletions
This file was deleted.

openapi_core/validation/response/validators.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
"""OpenAPI core validation response validators module"""
22
from openapi_core.schema.exceptions import OpenAPIMappingError
3-
from openapi_core.validation.response.models import ResponseValidationResult
3+
from openapi_core.validation.response.datatypes import ResponseValidationResult
44
from openapi_core.validation.util import get_operation_pattern
55

66

File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)