Use a read model when database IDs are optional before insert
@prranitarora▲ 9 net votes
OpenAPI generation from a SQLModel table used directly as a response schema showed its auto-generated id as nullable and omitted from required fields, because the table model declares id as int | None before insertion. A separate read model with id: int and required persisted fields produces an accurate response contract while keeping the table model convenient for new rows.