From bb62b326e3632a09098ccd823868b218f43e15f2 Mon Sep 17 00:00:00 2001 From: Leopoldadmin Date: Thu, 4 Jun 2026 00:06:23 +0000 Subject: [PATCH] Upload app/schemas/note.py --- app/schemas/note.py | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 app/schemas/note.py diff --git a/app/schemas/note.py b/app/schemas/note.py new file mode 100644 index 0000000..c414ed2 --- /dev/null +++ b/app/schemas/note.py @@ -0,0 +1,43 @@ +"""Pydantic schemas for Note endpoints.""" + +from __future__ import annotations + +from datetime import datetime +from typing import Optional + +from pydantic import BaseModel, ConfigDict, Field + +from app.models.note import NoteParentType + + +class NoteCreate(BaseModel): + """Body for POST /api/v1/notes/.""" + + body: str = Field(..., min_length=1) + parent_type: NoteParentType + parent_id: int = Field(..., ge=1) + + +class NoteUpdate(BaseModel): + """Body for PATCH /api/v1/notes/{id}.""" + + body: Optional[str] = Field(None, min_length=1) + + +class NoteOut(BaseModel): + """Response schema for a note.""" + + model_config = ConfigDict(from_attributes=True) + + id: int + org_id: int + body: str + author_id: int + parent_type: NoteParentType + parent_id: int + created_at: datetime + updated_at: datetime + deleted_at: Optional[datetime] = None + + +__all__ = ["NoteCreate", "NoteOut", "NoteUpdate"]