You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Using an Optional or Union type with the @ValidateParameters decorator works for validation purposes, but it causes a 500 error when accessing the /docs route.
It looks like it may be this function that is causing the issue.
def get_arg_type_hint(fdocs, arg_name): """ Extract the type hint for a specific argument. """ arg_type = fdocs["argspec"].annotations[arg_name] if hasattr(arg_type, "__args__"): return ( f"{arg_type.__name__}[{', '.join([a.__name__ for a in arg_type.__args__])}]" ) return arg_type.__name__
Specifically the arg_type.__name__ seems to not exist for Optional and Union types.
Apologies again for the delay, finally got a chance to look at this today and am having issues reproducing the issue on Python 3.12: pip freeze output:
Using an Optional or Union type with the @ValidateParameters decorator works for validation purposes, but it causes a 500 error when accessing the /docs route.
It looks like it may be this function that is causing the issue.
def get_arg_type_hint(fdocs, arg_name): """ Extract the type hint for a specific argument. """ arg_type = fdocs["argspec"].annotations[arg_name] if hasattr(arg_type, "__args__"): return ( f"{arg_type.__name__}[{', '.join([a.__name__ for a in arg_type.__args__])}]" ) return arg_type.__name__
Specifically the
arg_type.__name__
seems to not exist for Optional and Union types.It looks like there is a note about Optional parameters in 2.3.0 (https://github.com/Ge0rg3/flask-parameter-validation/releases/tag/v2.3.0), but I think this may just be for validation.
The text was updated successfully, but these errors were encountered: