I want to be able to provide my team with a Swagger UI for my FastAPI application to explore the results of each endpoint.
I want to keep the syntax-highlighting on, and want the UI to default to a limit value of 100 (this is part of the function being called)
I don't want calls to the GET endpoint to default to 100 objects when making the call without providing any limit value (in code)
For example:
@router.get("/some_endpoint", response_model=List[SomeSchema])def read_some_endpoint( name: str, limit: Optional[int] = Query(100, description="Limit the number of results to return"), db: Session = Depends(get_db),):""" Query database """ query = db.query(SomeModel).filter(SomeModel.name == name) if limit: query = query.limit(limit) results = query.all() return results
This sets the default in the Swagger UI (desired), but when I make a call through the requests package, I only get 100 rows (undesired).
My use-case seems reasonable, so I'm wondering if there's a way to do this.
Basically when "Try It Out" is pressed, have the limit parameter populated in the Swagger UI and let me set the function default to Query(None, description="...")