File tree 2 files changed +7
-1
lines changed
flask_parameter_validation
2 files changed +7
-1
lines changed Original file line number Diff line number Diff line change @@ -34,7 +34,7 @@ def get_function_docs(func):
34
34
"""
35
35
fn_list = ValidateParameters ().get_fn_list ()
36
36
for fsig , fdocs in fn_list .items ():
37
- if fsig . endswith (func . __name__ ) :
37
+ if hasattr (func , "__fpv_discriminated_sig__" ) and func . __fpv_discriminated_sig__ == fsig :
38
38
return {
39
39
"docstring" : format_docstring (fdocs .get ("docstring" )),
40
40
"decorators" : fdocs .get ("decorators" ),
Original file line number Diff line number Diff line change 2
2
import functools
3
3
import inspect
4
4
import re
5
+ import uuid
5
6
from inspect import signature
6
7
from flask import request , Response
7
8
from werkzeug .datastructures import ImmutableMultiDict
@@ -28,6 +29,11 @@ def __call__(self, f):
28
29
Parent flow for validating each required parameter
29
30
"""
30
31
fsig = f .__module__ + "." + f .__name__
32
+ # Add a discriminator to the function signature, store it in the properties of the function
33
+ # This is used in documentation generation to associate the info gathered from inspecting the
34
+ # function with the properties passed to the ValidateParameters decorator
35
+ f .__fpv_discriminated_sig__ = f"{ uuid .uuid4 ()} _{ fsig } "
36
+ fsig = f .__fpv_discriminated_sig__
31
37
argspec = inspect .getfullargspec (f )
32
38
source = inspect .getsource (f )
33
39
index = source .find ("def " )
You can’t perform that action at this time.
0 commit comments