docs(backend): enrich OpenAPI schemas, response contracts, and add docs
redirect - document 201, 409, 422 and 500 semantic response models on RSVP route - document Authelia Remote-User security requirement and 401 response on admin routes - add interactive examples and spanish descriptions across all Pydantic schemas - add /docs redirect to /birthday/api/docs for developer ergonomics - hide SPA static catch-all routes from OpenAPI schema - resolve static assets directly from disk before SPA catch-all fallback
This commit is contained in:
1 parent
83dead536b
commit
77ead3b99a
5 files changed
+359
-54
No files matched your search
+31
-3
@@ -5,7 +5,7 @@ from contextlib import asynccontextmanager
|
|||||||
from fastapi import FastAPI, Request, status
|
from fastapi import FastAPI, Request, status
|
||||||
from fastapi.exceptions import RequestValidationError
|
from fastapi.exceptions import RequestValidationError
|
||||||
from fastapi.middleware.cors import CORSMiddleware
|
from fastapi.middleware.cors import CORSMiddleware
|
||||||
from fastapi.responses import FileResponse, JSONResponse
|
from fastapi.responses import FileResponse, JSONResponse, RedirectResponse
|
||||||
from fastapi.staticfiles import StaticFiles
|
from fastapi.staticfiles import StaticFiles
|
||||||
|
|
||||||
from .database import Base, SessionLocal, engine
|
from .database import Base, SessionLocal, engine
|
||||||
@@ -25,11 +25,39 @@ async def lifespan(app: FastAPI) -> AsyncGenerator[None, None]:
|
|||||||
|
|
||||||
app = FastAPI(
|
app = FastAPI(
|
||||||
title="Birthday Invitation API",
|
title="Birthday Invitation API",
|
||||||
|
version="1.0.0",
|
||||||
|
description=(
|
||||||
|
"API REST para la invitación interactiva de cumpleaños con sistema RSVP.\n\n"
|
||||||
|
"### Arquitectura de Seguridad\n"
|
||||||
|
"- **Rutas Públicas (`/birthday/api/*`)**: Acceso abierto para los invitados.\n"
|
||||||
|
"- **Rutas Administrativas (`/birthday/api/admin/*`)**: Protegidas por **Authelia ForwardAuth** "
|
||||||
|
"a nivel de proxy inverso (Traefik). Cada endpoint valida de forma independiente la cabecera `Remote-User`."
|
||||||
|
),
|
||||||
|
openapi_tags=[
|
||||||
|
{
|
||||||
|
"name": "RSVP",
|
||||||
|
"description": "Registro y validación de confirmación de asistencia para invitados.",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Config",
|
||||||
|
"description": "Consulta pública de la configuración singleton del evento.",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Admin",
|
||||||
|
"description": "Gestión de asistentes, descarga CSV y edición de contenido protegida por Authelia.",
|
||||||
|
},
|
||||||
|
],
|
||||||
lifespan=lifespan,
|
lifespan=lifespan,
|
||||||
docs_url="/birthday/api/docs",
|
docs_url="/birthday/api/docs",
|
||||||
openapi_url="/birthday/api/openapi.json",
|
openapi_url="/birthday/api/openapi.json",
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@app.get("/docs", include_in_schema=False)
|
||||||
|
async def redirect_to_docs():
|
||||||
|
return RedirectResponse(url="/birthday/api/docs")
|
||||||
|
|
||||||
|
|
||||||
# CORS configuration
|
# CORS configuration
|
||||||
app.add_middleware(
|
app.add_middleware(
|
||||||
CORSMiddleware,
|
CORSMiddleware,
|
||||||
@@ -72,8 +100,8 @@ if os.path.isdir(ASSETS_DIR):
|
|||||||
app.mount("/birthday/assets", StaticFiles(directory=ASSETS_DIR), name="assets")
|
app.mount("/birthday/assets", StaticFiles(directory=ASSETS_DIR), name="assets")
|
||||||
|
|
||||||
|
|
||||||
@app.get("/birthday")
|
@app.get("/birthday", include_in_schema=False)
|
||||||
@app.get("/birthday/{full_path:path}")
|
@app.get("/birthday/{full_path:path}", include_in_schema=False)
|
||||||
async def spa_catch_all(full_path: str = ""):
|
async def spa_catch_all(full_path: str = ""):
|
||||||
if full_path:
|
if full_path:
|
||||||
requested_file = os.path.join(STATIC_DIR, full_path)
|
requested_file = os.path.join(STATIC_DIR, full_path)
|
||||||
|
|||||||
@@ -18,23 +18,57 @@ router = APIRouter(tags=["Admin"])
|
|||||||
|
|
||||||
|
|
||||||
def require_admin(
|
def require_admin(
|
||||||
remote_user: Annotated[str | None, Header(alias="Remote-User")] = None,
|
remote_user: Annotated[
|
||||||
|
str | None,
|
||||||
|
Header(
|
||||||
|
alias="Remote-User",
|
||||||
|
description="Identidad de usuario autenticada e inyectada por Authelia ForwardAuth en el proxy Traefik",
|
||||||
|
examples=["kiskaadee"],
|
||||||
|
),
|
||||||
|
] = None,
|
||||||
) -> str:
|
) -> str:
|
||||||
"""Security invariant: require verified Remote-User header from Authelia."""
|
"""Security invariant: require verified Remote-User header from Authelia."""
|
||||||
if not remote_user:
|
if not remote_user:
|
||||||
raise HTTPException(status_code=401, detail="Not authenticated")
|
raise HTTPException(
|
||||||
|
status_code=401,
|
||||||
|
detail="Not authenticated",
|
||||||
|
)
|
||||||
return remote_user
|
return remote_user
|
||||||
|
|
||||||
|
|
||||||
AdminDep = Annotated[str, Depends(require_admin)]
|
AdminDep = Annotated[str, Depends(require_admin)]
|
||||||
DbDep = Annotated[Session, Depends(get_db)]
|
DbDep = Annotated[Session, Depends(get_db)]
|
||||||
|
|
||||||
|
ADMIN_401 = {
|
||||||
|
401: {
|
||||||
|
"description": "No autenticado. Se requiere la cabecera `Remote-User` provista por Authelia ForwardAuth."
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@router.get("/rsvps", response_model=RSVPListResponse)
|
|
||||||
|
@router.get(
|
||||||
|
"/rsvps",
|
||||||
|
response_model=RSVPListResponse,
|
||||||
|
summary="Listar asistentes confirmados",
|
||||||
|
description=(
|
||||||
|
"Obtiene el total y la lista de todos los invitados que han confirmado asistencia. "
|
||||||
|
"Permite filtrado por coincidencia parcial (`?search=`) sobre nombre, teléfono o correo."
|
||||||
|
),
|
||||||
|
responses={
|
||||||
|
200: {"model": RSVPListResponse, "description": "Lista de confirmaciones obtenida."},
|
||||||
|
**ADMIN_401,
|
||||||
|
},
|
||||||
|
)
|
||||||
def list_rsvps(
|
def list_rsvps(
|
||||||
admin: AdminDep,
|
admin: AdminDep,
|
||||||
db: DbDep,
|
db: DbDep,
|
||||||
search: Annotated[str | None, Query()] = None,
|
search: Annotated[
|
||||||
|
str | None,
|
||||||
|
Query(
|
||||||
|
description="Término de búsqueda opcional (subcadena en nombre, teléfono o email)",
|
||||||
|
examples=["Andrés"],
|
||||||
|
),
|
||||||
|
] = None,
|
||||||
):
|
):
|
||||||
rsvps = get_rsvps(db, search=search)
|
rsvps = get_rsvps(db, search=search)
|
||||||
return RSVPListResponse(
|
return RSVPListResponse(
|
||||||
@@ -43,7 +77,21 @@ def list_rsvps(
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@router.get("/export")
|
@router.get(
|
||||||
|
"/export",
|
||||||
|
summary="Exportar confirmaciones en formato CSV",
|
||||||
|
description=(
|
||||||
|
"Genera dinámicamente un archivo CSV con las columnas: `name`, `phone`, `email` y `created_at`. "
|
||||||
|
"Descarga el archivo directamente con encabezados `Content-Disposition: attachment`."
|
||||||
|
),
|
||||||
|
responses={
|
||||||
|
200: {
|
||||||
|
"content": {"text/csv": {}},
|
||||||
|
"description": "Descarga del archivo CSV `rsvps.csv`.",
|
||||||
|
},
|
||||||
|
**ADMIN_401,
|
||||||
|
},
|
||||||
|
)
|
||||||
def export_rsvps_csv(
|
def export_rsvps_csv(
|
||||||
admin: AdminDep,
|
admin: AdminDep,
|
||||||
db: DbDep,
|
db: DbDep,
|
||||||
@@ -66,7 +114,16 @@ def export_rsvps_csv(
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@router.get("/config", response_model=InvitationConfigResponse)
|
@router.get(
|
||||||
|
"/config",
|
||||||
|
response_model=InvitationConfigResponse,
|
||||||
|
summary="Obtener configuración editable",
|
||||||
|
description="Retorna el objeto completo de configuración para poblar el formulario de administración.",
|
||||||
|
responses={
|
||||||
|
200: {"model": InvitationConfigResponse, "description": "Configuración obtenida correctamente."},
|
||||||
|
**ADMIN_401,
|
||||||
|
},
|
||||||
|
)
|
||||||
def get_admin_config(
|
def get_admin_config(
|
||||||
admin: AdminDep,
|
admin: AdminDep,
|
||||||
db: DbDep,
|
db: DbDep,
|
||||||
@@ -77,7 +134,20 @@ def get_admin_config(
|
|||||||
return config
|
return config
|
||||||
|
|
||||||
|
|
||||||
@router.put("/config", response_model=InvitationConfigResponse)
|
@router.put(
|
||||||
|
"/config",
|
||||||
|
response_model=InvitationConfigResponse,
|
||||||
|
summary="Actualizar configuración de la invitación",
|
||||||
|
description=(
|
||||||
|
"Reemplaza los valores de la configuración singleton del evento. "
|
||||||
|
"Aplica validación de fecha ISO, hora en formato militar 24h y zona horaria válida IANA. "
|
||||||
|
"Los cambios toman efecto de inmediato sin requerir recarga del contenedor."
|
||||||
|
),
|
||||||
|
responses={
|
||||||
|
200: {"model": InvitationConfigResponse, "description": "Configuración actualizada con éxito."},
|
||||||
|
**ADMIN_401,
|
||||||
|
},
|
||||||
|
)
|
||||||
def update_admin_config(
|
def update_admin_config(
|
||||||
update_in: InvitationConfigUpdate,
|
update_in: InvitationConfigUpdate,
|
||||||
admin: AdminDep,
|
admin: AdminDep,
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ from fastapi.responses import JSONResponse
|
|||||||
from sqlalchemy.orm import Session
|
from sqlalchemy.orm import Session
|
||||||
|
|
||||||
from ..database import get_db
|
from ..database import get_db
|
||||||
from ..schemas import InvitationConfigResponse
|
from ..schemas import InvitationConfigResponse, RSVPErrorResponse
|
||||||
from ..services.config import get_config, seed_default_config
|
from ..services.config import get_config, seed_default_config
|
||||||
|
|
||||||
router = APIRouter(tags=["Config"])
|
router = APIRouter(tags=["Config"])
|
||||||
@@ -13,7 +13,25 @@ router = APIRouter(tags=["Config"])
|
|||||||
DbDep = Annotated[Session, Depends(get_db)]
|
DbDep = Annotated[Session, Depends(get_db)]
|
||||||
|
|
||||||
|
|
||||||
@router.get("/config", response_model=InvitationConfigResponse)
|
@router.get(
|
||||||
|
"/config",
|
||||||
|
response_model=InvitationConfigResponse,
|
||||||
|
summary="Obtener configuración de la invitación",
|
||||||
|
description=(
|
||||||
|
"Retorna la configuración singleton actual del evento para ser renderizada en la "
|
||||||
|
"experiencia web pública del invitado (textos, homenajeado, coordenadas de tiempo y lugar)."
|
||||||
|
),
|
||||||
|
responses={
|
||||||
|
200: {
|
||||||
|
"model": InvitationConfigResponse,
|
||||||
|
"description": "Configuración del evento obtenida correctamente.",
|
||||||
|
},
|
||||||
|
500: {
|
||||||
|
"model": RSVPErrorResponse,
|
||||||
|
"description": "Fallo al inicializar o consultar el registro singleton.",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
)
|
||||||
def read_config(db: DbDep):
|
def read_config(db: DbDep):
|
||||||
config = get_config(db)
|
config = get_config(db)
|
||||||
if not config:
|
if not config:
|
||||||
|
|||||||
@@ -6,7 +6,13 @@ from sqlalchemy.exc import SQLAlchemyError
|
|||||||
from sqlalchemy.orm import Session
|
from sqlalchemy.orm import Session
|
||||||
|
|
||||||
from ..database import get_db
|
from ..database import get_db
|
||||||
from ..schemas import RSVPCreate
|
from ..schemas import (
|
||||||
|
RSVPCreate,
|
||||||
|
RSVPDuplicateResponse,
|
||||||
|
RSVPErrorResponse,
|
||||||
|
RSVPSuccessResponse,
|
||||||
|
RSVPValidationErrorResponse,
|
||||||
|
)
|
||||||
from ..services.rsvp import create_rsvp
|
from ..services.rsvp import create_rsvp
|
||||||
|
|
||||||
router = APIRouter(tags=["RSVP"])
|
router = APIRouter(tags=["RSVP"])
|
||||||
@@ -14,7 +20,35 @@ router = APIRouter(tags=["RSVP"])
|
|||||||
DbDep = Annotated[Session, Depends(get_db)]
|
DbDep = Annotated[Session, Depends(get_db)]
|
||||||
|
|
||||||
|
|
||||||
@router.post("/rsvp", status_code=status.HTTP_201_CREATED)
|
@router.post(
|
||||||
|
"/rsvp",
|
||||||
|
status_code=status.HTTP_201_CREATED,
|
||||||
|
summary="Registrar confirmación de asistencia",
|
||||||
|
description=(
|
||||||
|
"Recibe y procesa la confirmación de asistencia de un invitado. "
|
||||||
|
"El número telefónico es normalizado estrictamente al formato móvil colombiano de 10 dígitos "
|
||||||
|
"(comenzando en 3). Si el teléfono ya existe en el sistema, retorna un discriminador semántico "
|
||||||
|
"`DUPLICATE` con código HTTP 409."
|
||||||
|
),
|
||||||
|
responses={
|
||||||
|
201: {
|
||||||
|
"model": RSVPSuccessResponse,
|
||||||
|
"description": "Confirmación registrada exitosamente.",
|
||||||
|
},
|
||||||
|
409: {
|
||||||
|
"model": RSVPDuplicateResponse,
|
||||||
|
"description": "El número de teléfono ya ha sido registrado previamente.",
|
||||||
|
},
|
||||||
|
422: {
|
||||||
|
"model": RSVPValidationErrorResponse,
|
||||||
|
"description": "Fallo de validación de formato en los datos ingresados.",
|
||||||
|
},
|
||||||
|
500: {
|
||||||
|
"model": RSVPErrorResponse,
|
||||||
|
"description": "Error no controlado al persistir en la base de datos.",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
)
|
||||||
def submit_rsvp(rsvp_in: RSVPCreate, db: DbDep):
|
def submit_rsvp(rsvp_in: RSVPCreate, db: DbDep):
|
||||||
try:
|
try:
|
||||||
result_status, new_rsvp = create_rsvp(db, rsvp_in)
|
result_status, new_rsvp = create_rsvp(db, rsvp_in)
|
||||||
|
|||||||
+195
-40
@@ -7,9 +7,26 @@ from pydantic import BaseModel, ConfigDict, Field, field_validator
|
|||||||
|
|
||||||
|
|
||||||
class RSVPCreate(BaseModel):
|
class RSVPCreate(BaseModel):
|
||||||
name: str = Field(..., min_length=1, max_length=100)
|
name: str = Field(
|
||||||
phone: str = Field(..., min_length=1, max_length=50)
|
...,
|
||||||
email: str | None = Field(default=None, max_length=255)
|
min_length=1,
|
||||||
|
max_length=100,
|
||||||
|
description="Nombre completo del invitado",
|
||||||
|
examples=["Andrés García"],
|
||||||
|
)
|
||||||
|
phone: str = Field(
|
||||||
|
...,
|
||||||
|
min_length=1,
|
||||||
|
max_length=50,
|
||||||
|
description="Número móvil en formato colombiano (10 dígitos, con o sin prefijo +57)",
|
||||||
|
examples=["+57 300 123 4567"],
|
||||||
|
)
|
||||||
|
email: str | None = Field(
|
||||||
|
default=None,
|
||||||
|
max_length=255,
|
||||||
|
description="Correo electrónico opcional para confirmación y recordatorios",
|
||||||
|
examples=["andres@example.com"],
|
||||||
|
)
|
||||||
|
|
||||||
@field_validator("name")
|
@field_validator("name")
|
||||||
@classmethod
|
@classmethod
|
||||||
@@ -27,7 +44,6 @@ class RSVPCreate(BaseModel):
|
|||||||
cleaned = v.strip()
|
cleaned = v.strip()
|
||||||
if not cleaned:
|
if not cleaned:
|
||||||
return None
|
return None
|
||||||
# Basic email regex
|
|
||||||
email_regex = r"^[^@\s]+@[^@\s]+\.[^@\s]+$"
|
email_regex = r"^[^@\s]+@[^@\s]+\.[^@\s]+$"
|
||||||
if not re.match(email_regex, cleaned):
|
if not re.match(email_regex, cleaned):
|
||||||
raise ValueError("Formato de correo electrónico inválido")
|
raise ValueError("Formato de correo electrónico inválido")
|
||||||
@@ -35,60 +51,199 @@ class RSVPCreate(BaseModel):
|
|||||||
|
|
||||||
|
|
||||||
class RSVPSuccessResponse(BaseModel):
|
class RSVPSuccessResponse(BaseModel):
|
||||||
result: Literal["SUCCESS"] = "SUCCESS"
|
result: Literal["SUCCESS"] = Field(
|
||||||
name: str
|
default="SUCCESS",
|
||||||
|
description="Discriminador semántico de confirmación exitosa",
|
||||||
|
)
|
||||||
|
name: str = Field(
|
||||||
|
...,
|
||||||
|
description="Nombre del invitado registrado",
|
||||||
|
examples=["Andrés García"],
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
class RSVPDuplicateResponse(BaseModel):
|
class RSVPDuplicateResponse(BaseModel):
|
||||||
result: Literal["DUPLICATE"] = "DUPLICATE"
|
result: Literal["DUPLICATE"] = Field(
|
||||||
|
default="DUPLICATE",
|
||||||
|
description="Indica que el número de teléfono móvil ya tiene una confirmación registrada",
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
class RSVPValidationErrorResponse(BaseModel):
|
class RSVPValidationErrorResponse(BaseModel):
|
||||||
result: Literal["VALIDATION_ERROR"] = "VALIDATION_ERROR"
|
result: Literal["VALIDATION_ERROR"] = Field(
|
||||||
errors: dict[str, str]
|
default="VALIDATION_ERROR",
|
||||||
|
description="Indica error de validación en los datos enviados",
|
||||||
|
)
|
||||||
|
errors: dict[str, str] = Field(
|
||||||
|
...,
|
||||||
|
description="Mapa de nombres de campos con sus respectivos mensajes de error",
|
||||||
|
examples=[{"phone": "Formato de teléfono inválido"}],
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
class RSVPErrorResponse(BaseModel):
|
class RSVPErrorResponse(BaseModel):
|
||||||
result: Literal["ERROR"] = "ERROR"
|
result: Literal["ERROR"] = Field(
|
||||||
|
default="ERROR",
|
||||||
|
description="Error interno no controlado durante el procesamiento",
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
class RSVPAdminItem(BaseModel):
|
class RSVPAdminItem(BaseModel):
|
||||||
id: int
|
id: int = Field(..., description="Identificador único del registro en base de datos", examples=[1])
|
||||||
name: str
|
name: str = Field(..., description="Nombre completo del asistente", examples=["Ana García"])
|
||||||
phone: str
|
phone: str = Field(..., description="Número telefónico normalizado a 10 dígitos", examples=["3001234567"])
|
||||||
email: str | None
|
email: str | None = Field(default=None, description="Correo electrónico registrado", examples=["ana@example.com"])
|
||||||
created_at: datetime
|
created_at: datetime = Field(..., description="Marca de tiempo UTC de la confirmación")
|
||||||
|
|
||||||
model_config = ConfigDict(from_attributes=True)
|
model_config = ConfigDict(from_attributes=True)
|
||||||
|
|
||||||
|
|
||||||
class RSVPListResponse(BaseModel):
|
class RSVPListResponse(BaseModel):
|
||||||
count: int
|
count: int = Field(..., description="Cantidad total de confirmaciones encontradas", examples=[37])
|
||||||
rsvps: list[RSVPAdminItem]
|
rsvps: list[RSVPAdminItem] = Field(..., description="Lista de asistentes confirmados")
|
||||||
|
|
||||||
|
|
||||||
class InvitationConfigBase(BaseModel):
|
class InvitationConfigBase(BaseModel):
|
||||||
title: str = Field(..., min_length=1, max_length=200)
|
title: str = Field(
|
||||||
invitation_text: str = Field(..., min_length=1, max_length=500)
|
...,
|
||||||
honoree_name: str = Field(..., min_length=1, max_length=200)
|
min_length=1,
|
||||||
event_date: str = Field(..., description="ISO 8601 Date YYYY-MM-DD")
|
max_length=200,
|
||||||
event_time: str = Field(..., description="24-hour time HH:MM")
|
description="Título principal de la portada (tipografía script grande)",
|
||||||
event_timezone: str = Field(..., description="IANA timezone identifier")
|
examples=["Birthday Party"],
|
||||||
address_name: str = Field(..., min_length=1, max_length=200)
|
)
|
||||||
address_lines: str = Field(..., min_length=1)
|
invitation_text: str = Field(
|
||||||
map_preview_url: str = Field(..., min_length=1, max_length=500)
|
...,
|
||||||
map_url: str = Field(..., min_length=1, max_length=500)
|
min_length=1,
|
||||||
rsvp_heading: str = Field(..., min_length=1, max_length=100)
|
max_length=500,
|
||||||
rsvp_cta: str = Field(..., min_length=1, max_length=100)
|
description="Texto introductorio de la invitación",
|
||||||
submit_label: str = Field(..., min_length=1, max_length=100)
|
examples=["You're invited to the birthday party honoring"],
|
||||||
msg_success: str = Field(..., min_length=1, max_length=300)
|
)
|
||||||
msg_success_greeting: str = Field(..., min_length=1, max_length=100)
|
honoree_name: str = Field(
|
||||||
msg_duplicate: str = Field(..., min_length=1, max_length=300)
|
...,
|
||||||
msg_error: str = Field(..., min_length=1, max_length=300)
|
min_length=1,
|
||||||
msg_config_error: str = Field(..., min_length=1, max_length=300)
|
max_length=200,
|
||||||
countdown_label: str = Field(..., min_length=1, max_length=100)
|
description="Nombre del homenajeado(a)",
|
||||||
countdown_in_progress: str = Field(..., min_length=1, max_length=100)
|
examples=["Isabelle Snow"],
|
||||||
countdown_finished: str = Field(..., min_length=1, max_length=100)
|
)
|
||||||
|
event_date: str = Field(
|
||||||
|
...,
|
||||||
|
description="Fecha del evento en formato ISO 8601 (YYYY-MM-DD)",
|
||||||
|
examples=["2026-10-28"],
|
||||||
|
)
|
||||||
|
event_time: str = Field(
|
||||||
|
...,
|
||||||
|
description="Hora de inicio del evento en formato 24 horas (HH:MM)",
|
||||||
|
examples=["19:00"],
|
||||||
|
)
|
||||||
|
event_timezone: str = Field(
|
||||||
|
...,
|
||||||
|
description="Identificador de zona horaria IANA para el cálculo exacto de la cuenta regresiva",
|
||||||
|
examples=["America/Bogota"],
|
||||||
|
)
|
||||||
|
address_name: str = Field(
|
||||||
|
...,
|
||||||
|
min_length=1,
|
||||||
|
max_length=200,
|
||||||
|
description="Nombre del restaurante, salón o recinto",
|
||||||
|
examples=["Fresco Ristorante"],
|
||||||
|
)
|
||||||
|
address_lines: str = Field(
|
||||||
|
...,
|
||||||
|
min_length=1,
|
||||||
|
description="Líneas de dirección del lugar (separadas por salto de línea)",
|
||||||
|
examples=["514 S Brand Blvd\nGlendale, CA 91204"],
|
||||||
|
)
|
||||||
|
map_preview_url: str = Field(
|
||||||
|
...,
|
||||||
|
min_length=1,
|
||||||
|
max_length=500,
|
||||||
|
description="URL de la imagen miniatura que se muestra en el widget circular",
|
||||||
|
examples=["https://tile.openstreetmap.org/15/8802/13443.png"],
|
||||||
|
)
|
||||||
|
map_url: str = Field(
|
||||||
|
...,
|
||||||
|
min_length=1,
|
||||||
|
max_length=500,
|
||||||
|
description="Enlace externo a Google Maps u otro servicio de navegación",
|
||||||
|
examples=["https://maps.google.com/?q=Fresco+Ristorante+Glendale+CA"],
|
||||||
|
)
|
||||||
|
rsvp_heading: str = Field(
|
||||||
|
...,
|
||||||
|
min_length=1,
|
||||||
|
max_length=100,
|
||||||
|
description="Encabezado del formulario de confirmación",
|
||||||
|
examples=["¿Nos vemos?"],
|
||||||
|
)
|
||||||
|
rsvp_cta: str = Field(
|
||||||
|
...,
|
||||||
|
min_length=1,
|
||||||
|
max_length=100,
|
||||||
|
description="Texto del botón CTA en la portada que desplaza al formulario",
|
||||||
|
examples=["CONFIRMA TU ASISTENCIA"],
|
||||||
|
)
|
||||||
|
submit_label: str = Field(
|
||||||
|
...,
|
||||||
|
min_length=1,
|
||||||
|
max_length=100,
|
||||||
|
description="Texto del botón de envío del formulario",
|
||||||
|
examples=["TE VEO AHÍ"],
|
||||||
|
)
|
||||||
|
msg_success: str = Field(
|
||||||
|
...,
|
||||||
|
min_length=1,
|
||||||
|
max_length=300,
|
||||||
|
description="Mensaje principal tras confirmar asistencia",
|
||||||
|
examples=["¡Perfecto! Tu asistencia ha sido confirmada."],
|
||||||
|
)
|
||||||
|
msg_success_greeting: str = Field(
|
||||||
|
...,
|
||||||
|
min_length=1,
|
||||||
|
max_length=100,
|
||||||
|
description="Saludo personalizado; {name} se reemplaza con el nombre del invitado",
|
||||||
|
examples=["Gracias, {name}."],
|
||||||
|
)
|
||||||
|
msg_duplicate: str = Field(
|
||||||
|
...,
|
||||||
|
min_length=1,
|
||||||
|
max_length=300,
|
||||||
|
description="Mensaje mostrado si el número ya está registrado",
|
||||||
|
examples=["Parece que ya tenemos tus datos registrados."],
|
||||||
|
)
|
||||||
|
msg_error: str = Field(
|
||||||
|
...,
|
||||||
|
min_length=1,
|
||||||
|
max_length=300,
|
||||||
|
description="Mensaje en caso de fallo general del servidor",
|
||||||
|
examples=["No pudimos registrar tu asistencia. Inténtalo nuevamente."],
|
||||||
|
)
|
||||||
|
msg_config_error: str = Field(
|
||||||
|
...,
|
||||||
|
min_length=1,
|
||||||
|
max_length=300,
|
||||||
|
description="Mensaje si la configuración no puede cargarse en el navegador",
|
||||||
|
examples=["No pudimos cargar la invitación. Inténtalo nuevamente."],
|
||||||
|
)
|
||||||
|
countdown_label: str = Field(
|
||||||
|
...,
|
||||||
|
min_length=1,
|
||||||
|
max_length=100,
|
||||||
|
description="Etiqueta superior del contador regresivo",
|
||||||
|
examples=["NOS VEMOS EN"],
|
||||||
|
)
|
||||||
|
countdown_in_progress: str = Field(
|
||||||
|
...,
|
||||||
|
min_length=1,
|
||||||
|
max_length=100,
|
||||||
|
description="Texto mostrado cuando el evento está ocurriendo en tiempo real",
|
||||||
|
examples=["EVENTO EN CURSO"],
|
||||||
|
)
|
||||||
|
countdown_finished: str = Field(
|
||||||
|
...,
|
||||||
|
min_length=1,
|
||||||
|
max_length=100,
|
||||||
|
description="Texto mostrado cuando el evento ha culminado",
|
||||||
|
examples=["EVENTO FINALIZADO"],
|
||||||
|
)
|
||||||
|
|
||||||
@field_validator("event_date")
|
@field_validator("event_date")
|
||||||
@classmethod
|
@classmethod
|
||||||
@@ -126,7 +281,7 @@ class InvitationConfigUpdate(InvitationConfigBase):
|
|||||||
|
|
||||||
|
|
||||||
class InvitationConfigResponse(InvitationConfigBase):
|
class InvitationConfigResponse(InvitationConfigBase):
|
||||||
id: int = 1
|
id: int = Field(default=1, description="Identificador único del registro singleton (siempre 1)")
|
||||||
updated_at: datetime | None = None
|
updated_at: datetime | None = Field(default=None, description="Última modificación en UTC")
|
||||||
|
|
||||||
model_config = ConfigDict(from_attributes=True)
|
model_config = ConfigDict(from_attributes=True)
|
||||||
Reference in new issue
Block a user