please help me. In the function I set the optional parameter param as a boolean value, but the docs (swagger) do not display the data type for param. How to fix it? I'm using python 3.12.1
from fastapi import FastAPI
from datetime import date
app=FastAPI()
@app.get ("/sales")
def sales(
date_from: date,
date_to: date,
param: bool | None = None,
):
return date_from, date_to, param

on version python 3.9 everything is fine
set the optional parameter "param" as a boolean value, but the docs do not display the data type
Well, it's not a bool, is it?
You decided to make it a bool | None instead.
(Sometimes pronounced Optional[bool], same thing.)
Let's fix that:
param: bool = False,
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With