Skip to content
This repository has been archived by the owner on Sep 26, 2024. It is now read-only.

Commit

Permalink
validate support tag
Browse files Browse the repository at this point in the history
  • Loading branch information
ponytailer committed Sep 29, 2021
1 parent 049cc31 commit f44caa1
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions schema_validator/validation.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,9 +124,10 @@ def validate(
query_string: Optional[PydanticModel] = None,
body: Optional[PydanticModel] = None,
source: DataSource = DataSource.JSON,
validate_path: bool = False,
validate_path_args: bool = False,
responses: Union[PydanticModel, Dict[int, PydanticModel], None] = None,
headers: Optional[PydanticModel] = None
headers: Optional[PydanticModel] = None,
tags: Optional[Iterable[str]] = None
) -> Callable:
"""
params:
Expand Down Expand Up @@ -173,7 +174,8 @@ def create_todo():
@app.put("/")
@validate(
body=Todo,
responses={200: TodoResponse, 400: TodoResponse}
responses={200: TodoResponse, 400: TodoResponse},
tags=["SOME-TAG"]
)
def update_todo():
... # Do something with data, e.g. save to the DB
Expand All @@ -185,8 +187,11 @@ class View(MethodView):
def get(self):
return {}
"""
if validate_path:

# TODO
if validate_path_args:
pass
# TODO
if headers is not None:
pass

Expand All @@ -207,6 +212,8 @@ def decorator(func: Callable) -> Callable[..., Response]:
setattr(func, SCHEMA_REQUEST_ATTRIBUTE, (body, source))
if responses:
setattr(func, SCHEMA_RESPONSE_ATTRIBUTE, responses)
if tags:
setattr(func, SCHEMA_TAG_ATTRIBUTE, list(set(tags)))

@wraps(func)
def wrapper(*args: Any, **kwargs: Any) -> Any:
Expand Down

0 comments on commit f44caa1

Please sign in to comment.