Skip to content

Commit 5d6df60

Browse files
committed
doc(backend): add documentation with pydantic
1 parent b2a596f commit 5d6df60

File tree

1 file changed

+6
-19
lines changed

1 file changed

+6
-19
lines changed

backend/src/schemas/sample.py

+6-19
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,24 @@
11
import datetime
2-
from pydantic import BaseModel
2+
from pydantic import BaseModel, Field
33
from .page import Page
44
from src.utilities.metaclass import Partial
55

66
class SampleBase(BaseModel):
77
"Base class for all Sample schemas, for internal use only"
8-
9-
name: str
10-
"Name / Label"
11-
12-
date: datetime.datetime
13-
"Date collected"
14-
15-
type: str
16-
"Type of experiment"
8+
name: str = Field(default=None, title="Name / Label", max_length=300)
9+
date: datetime.datetime = Field(default=None, title="Date collected")
10+
type: str = Field(default=None, title="Type of experiment", max_length=300)
1711

1812

1913
class Sample(SampleBase):
2014
"Sample existing in the database"
21-
22-
id: int
23-
"Unique identifier"
24-
25-
file_name: str | None
15+
id: int = Field(title="Unique identifier")
16+
file_name: str | None = Field(default=None, title="Stored filename (with extension), A null value means no file is currently attached to the sample.")
2617
"""
27-
Stored filename (with extension).
28-
29-
A null value means no file is currently attached to the sample.
3018
Evolution:
3119
we might have a file table in the future to hide the real name and store the user's file name, and extension
3220
"""
3321

34-
3522
SampleCreate = SampleBase # Simple alias
3623
"Minimal data to create a new Sample"
3724

0 commit comments

Comments
 (0)