I faced the same problem with FastAPI, I was able to resolve it by inverting the values of my pipe: bool | str rather than str | bool
bool | str
str | bool