
Security News
NVD Quietly Sweeps 100K+ CVEs Into a “Deferred” Black Hole
NVD now marks all pre-2018 CVEs as "Deferred," signaling it will no longer enrich older vulnerabilities, further eroding trust in its data.
fastapi-pagination-utilities
Advanced tools
A module containing helpers for paginating responses with FastAPI
This Python package contains utilities to aid in paginating responses from FastAPI applications.
Install fastapi-pagination-utilities
using pip:
pip install fastapi-pagination-utilities
The module can then be used as fastapi_pagination
:
from fastapi import FastAPI
from fastapi_pagination import (
CURSOR_QUERY, PAGE_SIZE_QUERY, PaginationDetails, PaginatedResults
)
from pydantic import BaseModel
app = FastAPI()
class Widget(BaseModel):
name: str
@app.get(
'/widgets',
summary="List widgets",
description="List all the widgers which are available."
response_model=PaginatedResults[Widget]
)
def list_widgets(
request: Request,
cursor: Optional[str] = CURSOR_QUERY,
page_size: Optional[int] = PAGE_SIZE_QUERY):
# Get pagination.
pagination = PaginationDetails(cursor, page_size)
# list_widgets() should take a page size and offset and return a list of
# results.
results, has_more = list_widgets(pagination.offset, pagination.page_size)
return PaginatedResults(
next=(
str(request.url.include_query_params(cursor=pagination.next_cursor()))
if has_more else None
),
previous=(
str(request.url.include_query_params(cursor=pagination.previous_cursor()))
if pagination.previous_cursor() else None
),
results=results
)
This project contains a dockerized testing environment which wraps tox.
Tests can be run using the ./test.sh
command:
# Run all PyTest tests and Flake8 checks
$ ./test.sh
# Run just PyTest
$ ./test.sh -e py3
# Run a single test file within PyTest
$ ./test.sh -e py3 -- tests/test_identifiers.py
# Run a single test file within PyTest with verbose logging
$ ./test.sh -e py3 -- tests/test_identifiers.py -vvv
FAQs
A module containing helpers for paginating responses with FastAPI
We found that fastapi-pagination-utilities demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
NVD now marks all pre-2018 CVEs as "Deferred," signaling it will no longer enrich older vulnerabilities, further eroding trust in its data.
Research
Security News
Lazarus-linked threat actors expand their npm malware campaign with new RAT loaders, hex obfuscation, and over 5,600 downloads across 11 packages.
Security News
Safari 18.4 adds support for Iterator Helpers and two other TC39 JavaScript features, bringing full cross-browser coverage to key parts of the ECMAScript spec.