Skip to content

Commit bdcb842

Browse files
committed
Fix #460 - missing parse_rule method
This method was removed from the public API in werkzeug 2.2.0. Copying it into this project because the method is self-contained.
1 parent 8a536cf commit bdcb842

File tree

1 file changed

+15
-16
lines changed

1 file changed

+15
-16
lines changed

flask_restx/swagger.py

+15-16
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,21 @@
5353
r"^:raises\s+(?P<name>[\w\d_]+)\s*:\s*(?P<description>.*)$", re.MULTILINE
5454
)
5555

56+
RE_PARSE_RULE = re.compile(
57+
r"""
58+
(?P<static>[^<]*) # static rule data
59+
<
60+
(?:
61+
(?P<converter>[a-zA-Z_][a-zA-Z0-9_]*) # converter name
62+
(?:\((?P<args>.*?)\))? # converter arguments
63+
\: # variable delimiter
64+
)?
65+
(?P<variable>[a-zA-Z_][a-zA-Z0-9_]*) # variable name
66+
>
67+
""",
68+
re.VERBOSE,
69+
)
70+
5671

5772
def ref(model):
5873
"""Return a reference to model in definitions"""
@@ -72,22 +87,6 @@ def extract_path(path):
7287
return RE_URL.sub(r"{\1}", path)
7388

7489

75-
RE_PARSE_RULE = re.compile(
76-
r"""
77-
(?P<static>[^<]*) # static rule data
78-
<
79-
(?:
80-
(?P<converter>[a-zA-Z_][a-zA-Z0-9_]*) # converter name
81-
(?:\((?P<args>.*?)\))? # converter arguments
82-
\: # variable delimiter
83-
)?
84-
(?P<variable>[a-zA-Z_][a-zA-Z0-9_]*) # variable name
85-
>
86-
""",
87-
re.VERBOSE,
88-
)
89-
90-
9190
def parse_rule(rule):
9291
"""
9392
This originally lived in werkzeug.routing.parse_rule until it was removed in werkzeug 2.2.0. Copying it here to

0 commit comments

Comments
 (0)