From 904f442f5a6f394c8ec0ed5ddf2a90bb96475ee4 Mon Sep 17 00:00:00 2001 From: Jack Michaud Date: Sat, 31 Dec 2022 18:56:23 -0500 Subject: [PATCH] fix: indicate that user is optional --- oasst-shared/oasst_shared/schemas/protocol.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/oasst-shared/oasst_shared/schemas/protocol.py b/oasst-shared/oasst_shared/schemas/protocol.py index 8a6685c2..5f05adc3 100644 --- a/oasst-shared/oasst_shared/schemas/protocol.py +++ b/oasst-shared/oasst_shared/schemas/protocol.py @@ -5,7 +5,7 @@ from typing import Literal, Optional, Union from uuid import UUID, uuid4 import pydantic -from pydantic import BaseModel +from pydantic import BaseModel, Field class TaskRequestType(str, enum.Enum): @@ -56,7 +56,9 @@ class TaskRequest(BaseModel): """The frontend asks the backend for a task.""" type: TaskRequestType = TaskRequestType.random - user: Optional[User] = None + # Must use Field(..., nullable=True) to indicate to the OpenAPI schema that + # this is optional. https://github.com/pydantic/pydantic/issues/1270 + user: Optional[User] = Field(None, nullable=True) collective: bool = False