Skip to content

Sorting logic in paginate and additional_data #1176

Answered by uriyyo
Mithmi asked this question in Q&A
Discussion options

You must be logged in to vote

I guess it's Swagger UI issue.

Here is simple application:

from typing import TypeVar, Generic, Optional, Dict

from fastapi import FastAPI, Query
from pydantic import BaseModel
from typing import Any

from fastapi_pagination import Page as BasePage, add_pagination, paginate

T = TypeVar("T")
F = TypeVar("F")


class Page(BasePage[T], Generic[T, F]):
    filters: Optional[F] = None


class DocumentsFilter(BaseModel):
    year: Dict[int, int]


app = FastAPI()
add_pagination(app)


@app.get("/documents")
async def route(
        reverse: bool = Query(False),
) -> Page[Any, DocumentsFilter]:
    data = [
        (2020, 2414),
        (2021, 2814),
        (2022, 2661),
        (2023, 2068),…

Replies: 1 comment 3 replies

Comment options

You must be logged in to vote
3 replies
@Mithmi
Comment options

@uriyyo
Comment options

Answer selected by Mithmi
@Mithmi
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants