Introduced by commit f8ef2e33de ("cards.js Added a control to check
error if card is not updated"), a blank return was added at line 3914.
The generate_openapi script assumed a return statement always has an
argument, and this was crashing.
Fixes#5320
This gives an error in the resulting file, which makes it not OpenAPI
compatible (not yaml actually).
Fixes#4917
Signed-off-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
39f8a138d7 added a try/except around esprima to catch any hard error
from the parsing, but the returned value was not checked.
We now have the file models/exportExcel.js which gives us an unexpected
symbol on line 3 (not sure why it is not happy), but that fails the
generation of the doc entirely.
Fixes#3884
Signed-off-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
there is a 2 levels schemas in profile.notifications.
The code previously assumed we could only have one level, and so was not
producing the correct UsersProfileNotifications.
Fix that by being more generic in the way we retrieve the nested
subschemas.
Previously I was assuming all variables were declared in the same file.
Turns out that imports exists too, and we need to recurse one more time
in those imports./
Also "clean" up a bit the function to do the parsing in 2 steps:
- first find out the actual matching node in js
- then convert it based on its type
rinse wash repeat.
Signed-off-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
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
The files are actually modules, not plain scripts, and thus we are allowed
to use `export`. Without `parseModule`, the script would silently fail
when parsing `export.js` and the export function will not be present.
It is common to use Ubuntu 16.04 to build snaps. For example,
the official docker container to build snaps is using this old
distribution.
However, Ubuntu 16.04 ships Python 3.5.X which is not compatible
with the f-strings in generate_openapi.py. This is sad, because
we need to use the `.format()` syntax to make it compatible.
The API is generated by a custom script that parses the models directory.
Once the API is generated, tools like https://editor.swagger.io/ or
Python bravado can parse the file and generate a language friendly API.
Note that the tool generate an OpenAPI 2.0 version because bravado
doesn't handle OpenAPI 3.0.
The script also parses the JSDoc with a custom parser to allow
customization of the description of the fields.