-
-
Notifications
You must be signed in to change notification settings - Fork 444
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Custom pagination for multiple response types? #940
Comments
Hi @SonQBChau yeah.. the pagination router does not support multiple codes (for now I guess) what you can do at this moment - define response as just list and throw http error with message: @router.get("/books", response=List[BookSchema]). # <-----
def list_books(request, filters: BookFilterSchema = Query(...)):
...
if error:
raise HttpError(400, 'Invalid filters') # <-----
return books |
Thank you for the reply. The implemented filter has conditional requirements; for instance, |
I will keep this open - maybe we simply find first 200 response for paginator (if it is marked as collection) |
I have a current use case, in which the return schema will vary depending on authorization level. We can use the HTTP response codes to reflect this, but then the pagination needs to work for 2xx response codes. |
How can I implement custom pagination for multiple response types? I've successfully applied custom pagination with
response=List[MySchema]
, but encountered issues with a structure likeresponse={200:List[MySchema], 400: Dict[str,str]}
. Here's what I've attempted so far:The text was updated successfully, but these errors were encountered: