diff options
author | 2020-12-16 23:26:05 +0000 | |
---|---|---|
committer | 2020-12-16 23:26:05 +0000 | |
commit | 9932f04d9b4a9a003d756cd37f06c7a029cb12b9 (patch) | |
tree | 87d2e475ce2e647a8af2900166e28df767060af6 /backend | |
parent | Add Spectree package (diff) |
Add validation utilities
Diffstat (limited to 'backend')
-rw-r--r-- | backend/validation.py | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/backend/validation.py b/backend/validation.py new file mode 100644 index 0000000..e696683 --- /dev/null +++ b/backend/validation.py @@ -0,0 +1,30 @@ +"""Utilities for providing API payload validation.""" + +from typing import Optional +from pydantic.fields import Field +from pydantic.main import BaseModel +from spectree import SpecTree + +api = SpecTree( + "starlette", + TITLE="Python Discord Forms", + PATH="docs" +) + + +class ErrorMessage(BaseModel): + error: str = Field(description="The details on the error") + + +class OkayResponse(BaseModel): + status: str = "ok" + + +class AuthorizationHeaders(BaseModel): + authorization: Optional[str] = Field( + title="Authorization", + description=( + "The Authorization JWT token received from the " + "authorize route in the format `JWT {token}`" + ) + ) |