api-schema-in-route-module (BTFAST002)¶
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 route module holds routes. A Pydantic schema (BaseModel) defined in a module under
api/**/routers/ or api/**/routes/ is reported: put it in the schemas/requests/ or
schemas/responses/ package of api. A warning by default.
Why¶
A schema inside a route file cannot be reused by another route or by a client, and the
request/response split that the schemas packages express is lost.
Do¶
Don't¶
Suppression¶
A comment on the class line silences the finding.