-
-
Notifications
You must be signed in to change notification settings - Fork 8.7k
Closed
Labels
Description
Hi, if you run code along the lines of:
from fastapi import FastAPI
import uvicorn
app = FastAPI(title="Sum one",
description="Get a number, add one to it",
version="0.1.0",
)
@app.post("/compute")
def compute(input: float = 0.0000001): # problematic float default value
return {'result': input + 1}
if __name__ == "__main__":
uvicorn.run(app, host="0.0.0.0", port=8000)and then
- Open the browser at http://localhost:8000/docs and click and try out the
/computeendpoint, then click on the Execute button - Execution fails because validation of the parameter field (a small float in scientific notation) is not passed, and the libraries automatically format the small float in scientific notation:
To solve, the user needs to manually override the scientific notation of the float in order to execute correctly, as done below:
- Intended behavior would be flawless execution with a float value.
Environment
- OS: Windows (but this should reproduce on Linux as well)
- FastAPI Version: 0.61.0
Reactions are currently unavailable

