Skip to content

api-response-schema-name (BTFAST004)

Added in 0.10.0 · Preview · Off by default (warning)

Family: fastapi · Standard: CES-17 · Languages: python

This rule is unstable and in preview. It runs only with preview = true, and only when it is selected.

Directive

A Pydantic model under api/**/schemas/responses/ is named {Name}Response. A warning by default.

Why

The suffix says at the call site which side of the boundary a model is on, and keeps a table class from being returned by mistake.

Do

class ContractResponse(BaseModel):
    id: str

Don't

class Contract(BaseModel):
    id: str

Suppression

A comment on the class line silences the finding.

class Contract(BaseModel):  # botica: ignore[api-response-schema-name]
class Contract(BaseModel):  # noqa: BTFAST004 -- reason

Discussion