Replies: 2 comments
-
|
@Subaku Did you find a solution/workaround for this? My use case:
If the user sets |
Beta Was this translation helpful? Give feedback.
0 replies
-
|
I am able to solve this by getting the query param value from the raw request. Example: from fastapi import FastAPI, Request
from pydantic.validators import BOOL_FALSE
app = FastAPI()
@app.get("/")
def read_root(request: Request, x_enable: bool = False):
if not x_enable:
if request.query_params.get("x_enable", "").lower() in BOOL_FALSE:
# We know that x_enable was set to false by the user
...
else:
# x_enable is False because it's the default
... |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Hello,
I've got a use case that sometimes comes up. When filtering my DB querying for "null" from the client on a particular field is a valid thing to do. This of course translates to
None. Problem is most of the time query parameters of optional for me. How might I determine whichNoneI'm dealing with? I.e. did the client explicitly provide the parameter or was it missing andNonewas set as the default.From similar issues I'm thinking that maybe some kind of middleware to determine if I actually passed a value or not might be in order but wanted to see if I'm missing something elegant.
Thanks!
Beta Was this translation helpful? Give feedback.
All reactions