-
-
Notifications
You must be signed in to change notification settings - Fork 82
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added requests validation based on swagger schema.
- Loading branch information
Showing
13 changed files
with
1,157 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
from .builders import * # noqa | ||
from .decorators import * # noqa | ||
from .validation import * # noqa |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,27 @@ | ||
class swagger_path(object): | ||
from functools import partial | ||
from inspect import isfunction, isclass | ||
|
||
__all__ = ( | ||
'swagger_path', | ||
'swagger_validation', | ||
) | ||
|
||
|
||
class swagger_path: | ||
|
||
def __init__(self, swagger_file): | ||
self.swagger_file = swagger_file | ||
|
||
def __call__(self, f): | ||
f.swagger_file = self.swagger_file | ||
return f | ||
|
||
|
||
def swagger_validation(func=None, *, validation=True): | ||
|
||
if func is None or not (isfunction(func) or isclass(func)): | ||
validation = func | ||
return partial(swagger_validation, validation=validation) | ||
|
||
func.validation = validation | ||
return func |
Oops, something went wrong.