Upload app/schemas/note.py
This commit is contained in:
@@ -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"]
|
||||
Reference in New Issue
Block a user