Skip to content

# `schemas` module

Here's the reference for all response models and types provided by the `schemas` module.

You can import them directly from `fastapi_toolsets.schemas`:

    from fastapi_toolsets.schemas import (
        PydanticBase,
        ResponseStatus,
        ApiError,
        BaseResponse,
        Response,
        ErrorResponse,
        Pagination,
        PaginatedResponse,
    )

## `fastapi_toolsets.schemas.PydanticBase`

Bases: `BaseModel`

Base class for all Pydantic models with common configuration.

## `fastapi_toolsets.schemas.ResponseStatus`

Bases: `str`, `Enum`

Standard API response status.

## `fastapi_toolsets.schemas.ApiError`

Bases: `PydanticBase`

Structured API error definition.

Used to define standard error responses with consistent format.

Attributes:

Name | Type | Description
--- | --- | ---
`code` | `int` | HTTP status code
`msg` | `str` | Short error message
`desc` | `str` | Detailed error description
`err_code` | `str` | Application-specific error code (e.g., "AUTH-401")

## `fastapi_toolsets.schemas.BaseResponse`

Bases: `PydanticBase`

Base response structure for all API responses.

Attributes:

Name | Type | Description
--- | --- | ---
`status` | `ResponseStatus` | SUCCESS or FAIL
`message` | `str` | Human-readable message
`error_code` | `str | None` | Error code if status is FAIL, None otherwise

## `fastapi_toolsets.schemas.Response`

Bases: `BaseResponse`, `Generic[DataT]`

Generic API response with data payload.

Example

    Response[UserRead](data=user, message="User retrieved")

## `fastapi_toolsets.schemas.ErrorResponse`

Bases: `BaseResponse`

Error response with additional description field.

Used for error responses that need more context.

## `fastapi_toolsets.schemas.Pagination = OffsetPagination` `module-attribute`

## `fastapi_toolsets.schemas.PaginatedResponse`

Bases: `BaseResponse`, `Generic[DataT]`

Paginated API response for list endpoints.