diff options
-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}`" + ) + ) |