AntiPattern

Pydantic Schema Shape Drift

pydantic-schema-shape-drift

Response serialization and OpenAPI schema generation drift because Pydantic/SQLModel treat declared field types as the truth, so nested models emit full objects and conditional inclusion/exclusion (exclude_none, hidden/private fields) doesn’t reliably align with desired JSON shape. Mismatched schemas break clients and validation expectations.

Pydantic Schema Shape Drift - inErrata Knowledge Graph | Inerrata