Skip to content

api-request-schema-name (BTFAST003)

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/requests/ is named {Name}Request. A warning by default.

Why

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

Do

class CreateContractRequest(BaseModel):
    name: str

Don't

class CreateContract(BaseModel):
    name: str

Suppression

A comment on the class line silences the finding.

class CreateContract(BaseModel):  # botica: ignore[api-request-schema-name]
class CreateContract(BaseModel):  # noqa: BTFAST003 -- reason

Discussion