FastAPI turns annotated path, query, header, and body parameters into runtime validation and OpenAPI documentation. A strong contract also filters responses, makes errors predictable, distinguishes omitted fields from null, and prevents clients from writing server-owned properties. The generated schema must be reviewed as a public artifact.
For partial updates, None can mean “clear the value” while omission can mean “do not change it.” Use command.model_fields_set to distinguish them when null is allowed. Never accept server-owned fields such as tenant, creator, audit timestamps, or permission state from the body.
response_model validates and filters outgoing data. A database row may include password hashes, internal notes, deleted flags, provider payloads, or cost details. Public view schemas explicitly allow what crosses the boundary.
Create a stable problem shape:
Do not reveal whether a cross-tenant identifier exists; authorization policy may intentionally return 404.
Save the normalized OpenAPI document as a reviewed artifact or compare it in CI with an API-diff tool. Classify removals, required-field additions, type changes, and enum narrowing as potentially breaking.
Model and tool schemas are contracts too. Version them independently, forbid unrecognized fields, and log schema version with every AI run. OpenAPI describes HTTP availability; a curated tool registry describes what a model may propose.
Add separate internal and public ticket views. Seed an internal ai_provider_payload and prove an HTTP response never includes it. Add an OpenAPI assertion for the maximum list limit.
Acceptance criteria: tests fail if the private field leaks or the maximum exceeds 100.