pydantic-models-py
Installation
SKILL.md
Iron Law
NEVER USE A SINGLE PYDANTIC MODEL FOR BOTH CREATE AND RESPONSE — separate contracts prevent leaking internal fields, block over-posting, and make API evolution safe
Pydantic v2 Models
Create Pydantic models following the multi-model pattern for clean, safe API contracts.
Multi-Model Pattern
| Model | Purpose | Required Fields |
|---|---|---|
Base |
Common fields shared across all variants | Shared, validated fields |
Create |
POST request body — fields the client supplies | Required fields only |
Update |
PATCH request body — partial update | All optional (use None default) |
Response |
API response — all fields the client sees | Includes id, timestamps |
InDB |
Internal/repository layer — DO NOT expose directly | DB-only fields (e.g., hashed passwords) |