Commit graph

12 commits

Author SHA1 Message Date
Benjamin Tissoires
2c1f40357d Fix openapi docs generation
esprima-python is now safe to use
(https://github.com/Kronuz/esprima-python/pull/12)

And there was a new ArrowFunctionExpression used in db666eec65
that broke the python script
2021-03-26 18:41:34 +01:00
Lauri Ojansivu
0bb3b67075 Fixed generating API docs and Wekan Custom Fields REST API.
Thanks to xet7 !
2021-03-07 17:57:24 +02:00
Benjamin Tissoires
e1ffe943c8 openapi: also consider Object type as valid
Not sure if this will end up in a correct openapi file, but the docs
are correctly generated, so... meh.
2020-06-17 05:40:38 +02:00
Benjamin Tissoires
431d884e83 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
2020-06-17 05:15:39 +02:00
Benjamin Tissoires
3f059ec1e0 generate_openapi: fix enums when they are declared as const
Fixes: #2781
2019-11-05 12:58:06 +01:00
Benjamin Tissoires
8cb3974eff generate_openapi: print a more useful error
...when we can not parse a SchemaProperty
2019-11-05 12:54:58 +01:00
Benjamin Tissoires
7d62d0920c generate_openapi: add a little bit more verbosity when we get an Error 2019-11-05 12:01:04 +01:00
Benjamin Tissoires
b787854289 generate_openapi.py: use the logging module
Instead of dealing with custom writes to stderr, it's always better
to rely on standard libraries.
2019-11-05 11:06:40 +01:00
Benjamin Tissoires
1eea102f26 openAPI: also handle export statement in the scripts
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.
2019-05-14 10:10:21 +02:00
Lauri Ojansivu
2969161afb - More whitelabeling.
Thanks to xet7 !
2019-03-21 20:27:21 +02:00
Benjamin Tissoires
8be7eec2ca openapi: make the code python 3.5 compatible
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.
2019-01-18 17:03:12 +01:00
Benjamin Tissoires
49d3eb5a3f Add OpenAPI description of the REST API
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.
2019-01-18 17:01:11 +01:00