diff options
author | 2020-12-17 12:53:14 +0300 | |
---|---|---|
committer | 2020-12-17 12:55:59 +0300 | |
commit | 2552ca6aa43d148b12d19dd6c511fa14864cede4 (patch) | |
tree | b0e485760dec7c82f3165bfce0651f1f70534b07 /backend/validation.py | |
parent | Adds Webhook Sending Functionality (diff) | |
parent | Merge pull request #37 from python-discord/docs/api-spec (diff) |
Merge branch 'main' into discord-webhook
Signed-off-by: Hassan Abouelela <[email protected]>
# Conflicts:
# backend/routes/forms/submit.py
Diffstat (limited to 'backend/validation.py')
-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}`" + ) + ) |