fix(backend): FastAPI docs broken due to missing schema for NullableUUID (#739)

Just updates `NullableUUID` to extend from `UUID`. This lets FastAPI infer the correct field schema and resolves the /docs and /redocs endpoint failing to render

Signed-off-by: Braden Mars <bradenmars@bradenmars.me>
This commit is contained in:
Braden Mars 2023-07-23 04:14:42 -05:00 committed by GitHub
parent 97fd239980
commit 914689957d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -28,13 +28,14 @@ from utils.constants import (
chat_router = APIRouter() chat_router = APIRouter()
class NullableUUID: class NullableUUID(UUID):
@classmethod @classmethod
def __get_validators__(cls): def __get_validators__(cls):
yield cls.validate yield cls.validate
@classmethod @classmethod
def validate(cls, v): def validate(cls, v) -> UUID | None:
if v == "": if v == "":
return None return None
try: try: