summaryrefslogtreecommitdiffstats
path: root/openapi
diff options
context:
space:
mode:
authorBenjamin Tissoires <benjamin.tissoires@gmail.com>2020-06-12 07:22:36 +0200
committerBenjamin Tissoires <benjamin.tissoires@gmail.com>2020-06-17 05:15:39 +0200
commit431d884e8371dfbce6d151493044ffcd2a92d10d (patch)
treeec1e5892113950a30675788e947fb5a00b0ec991 /openapi
parent983714cd7298746dd7437b91cc9464b23b9a1bfd (diff)
downloadwekan-431d884e8371dfbce6d151493044ffcd2a92d10d.tar.gz
wekan-431d884e8371dfbce6d151493044ffcd2a92d10d.tar.bz2
wekan-431d884e8371dfbce6d151493044ffcd2a92d10d.zip
openapi: fix jsdoc/operation matching
The script was considering that the operation associated to a jsdoc was declared on the line just after the end of the jsdoc. Turns out that adding new lines makes the code clearer, but the python script was then ignoring some jsdocs. Change the behaviour to consider that the jsdoc associated with an operation is the last one declared after the end of the previous operation. Fixes #3169
Diffstat (limited to 'openapi')
-rw-r--r--openapi/generate_openapi.py12
1 files changed, 10 insertions, 2 deletions
diff --git a/openapi/generate_openapi.py b/openapi/generate_openapi.py
index 54526416..b843feff 100644
--- a/openapi/generate_openapi.py
+++ b/openapi/generate_openapi.py
@@ -814,13 +814,21 @@ def parse_schemas(schemas_dir):
for d in data]
entry_points.extend(schema_entry_points)
+ end_of_previous_operation = -1
+
# try to match JSDoc to the operations
for entry_point in schema_entry_points:
operation = entry_point.method # POST/GET/PUT/DELETE
+
+ # find all jsdocs that end before the current operation,
+ # the last item in the list is the one we need
jsdoc = [j for j in jsdocs
- if j.loc.end.line + 1 == operation.loc.start.line]
+ if j.loc.end.line + 1 <= operation.loc.start.line and
+ j.loc.start.line > end_of_previous_operation]
if bool(jsdoc):
- entry_point.doc = jsdoc[0]
+ entry_point.doc = jsdoc[-1]
+
+ end_of_previous_operation = operation.loc.end.line
except TypeError:
logger.warning(context.txt_for(statement))
logger.error('{}:{}-{} can not parse {}'.format(path,