diff options
Diffstat (limited to 'docs/guides/onap-developer/how-to-use-docs')
5 files changed, 163 insertions, 2 deletions
diff --git a/docs/guides/onap-developer/how-to-use-docs/api-swagger-guide.rst b/docs/guides/onap-developer/how-to-use-docs/api-swagger-guide.rst new file mode 100644 index 000000000..9d3a7f6fc --- /dev/null +++ b/docs/guides/onap-developer/how-to-use-docs/api-swagger-guide.rst @@ -0,0 +1,84 @@ +.. This work is licensed under a Creative Commons Attribution 4.0 +.. International License. http://creativecommons.org/licenses/by/4.0 +.. Copyright 2019 Orange. All rights reserved. + +.. _api-swagger-guide: + +API documentation +================= + +Swagger +------- + +The API should be described using OpenAPI specifications and available as a +`JSON file <https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.0.md>`_ + +A Swagger editor is available here `<http://editor.swagger.io/>`_ to generate +such JSON files. + +As a result, you should get one JSON file per API. For example the project +**my** has 2 API: **myAPI1** and **myAPI2**. + +- myAPI1.json +- myAPI2.json + +Global API table +---------------- +It is recommended to list the following API available with an access to the +Swagger JSON files to help the developers/users to play with JSON. + +We propose the following table: + +.. csv-table:: + :header: "API name", "Swagger JSON" + :widths: 10,5 + + "myAPI1", ":download:`link <myAPI1.json>`" + "myAPI12", ":download:`link <myAPI2.json>`" + +.. note:: + During documentation merge/publish at RTD, any file referenced in an RST file with + ':download:' and relative path to a contributing project repository is copied, uniquely + named, and published with the generated HTML pages. + +The code is available here: + +.. code:: rst + + .. csv-table:: + :header: "API name", "Swagger JSON" + :widths: 10,5 + + "myAPI1", ":download:`link <myAPI1.json>`" + "myAPI2", ":download:`link <myAPI2.json>`" + +.. note:: + The syntax of <myAPI1.json> is to be taken literally. Keep '<' and '>'. + +.. note:: + Note the āvā in swaggerv2doc! + If your JSON file has multiple endpoints, this directive does not preserve the order. + +API Swagger +----------- +For each API, the ``swaggerv2doc`` directive must be used as follows: + +.. code:: rst + + myAPI1 + ...... + .. swaggerv2doc:: myAPI1.json + + myAPI2 + ...... + .. swaggerv2doc:: myAPI2.json + +It will produce the following output: + +myAPI1 +...... +.. swaggerv2doc:: myAPI1.json + +myAPI2 +...... +.. swaggerv2doc:: myAPI2.json diff --git a/docs/guides/onap-developer/how-to-use-docs/include-documentation.rst b/docs/guides/onap-developer/how-to-use-docs/include-documentation.rst index 35c833cf9..896c23170 100644 --- a/docs/guides/onap-developer/how-to-use-docs/include-documentation.rst +++ b/docs/guides/onap-developer/how-to-use-docs/include-documentation.rst @@ -492,11 +492,13 @@ Build documentation using tox local environment & then open using any browser. firefox docs/_build/html/index.html .. note:: Make sure to run `tox -elocal` and not just `tox`. + This updates all submodule repositories that are integrated + by the doc project. There are additional tox environment options for checking External URLs and Spelling. Use the tox environment options below and then -look at the output with the Linux `more` or similar command for -scanning for output that applies to the files you are validating. +look at the output with the Linux `more` or similar command +scan for output that applies to the files you are validating. .. code-block:: bash diff --git a/docs/guides/onap-developer/how-to-use-docs/index.rst b/docs/guides/onap-developer/how-to-use-docs/index.rst index a2cdd6e6b..90c657501 100644 --- a/docs/guides/onap-developer/how-to-use-docs/index.rst +++ b/docs/guides/onap-developer/how-to-use-docs/index.rst @@ -10,6 +10,7 @@ Creating Documentation documentation-guide style-guide include-documentation + api-swagger-guide converting-formats addendum diff --git a/docs/guides/onap-developer/how-to-use-docs/myAPI1.json b/docs/guides/onap-developer/how-to-use-docs/myAPI1.json new file mode 100644 index 000000000..b611ad81c --- /dev/null +++ b/docs/guides/onap-developer/how-to-use-docs/myAPI1.json @@ -0,0 +1,37 @@ +{ + "swagger" : "2.0", + "info" : { + "description" : "my API 1", + "version" : "1.0.0", + "title" : "API example", + "contact" : { + "email" : "onap@orange.com" + }, + "license" : { + "name" : "Apache 2.0", + "url" : "http://www.apache.org/licenses/LICENSE-2.0.html" + } + }, + "host" : "serverRoot", + "basePath" : "/healthCheck", + "schemes" : [ "https" ], + "produces": [ + "application/json;charset=utf-8" + ], + "paths" : { + "/healthCheck" : { + "get" : { + "summary" : "Displays healhcheck for my favorite component", + "description" : "Displays healthcheck for my favorite component", + "responses": { + "200": { + "description": "Service OK" + }, + "503" : { + "description" : "Service Unavailable" + } + } + } + } + } +} diff --git a/docs/guides/onap-developer/how-to-use-docs/myAPI2.json b/docs/guides/onap-developer/how-to-use-docs/myAPI2.json new file mode 100644 index 000000000..473d351b2 --- /dev/null +++ b/docs/guides/onap-developer/how-to-use-docs/myAPI2.json @@ -0,0 +1,37 @@ +{ + "swagger" : "2.0", + "info" : { + "description" : "my API 2", + "version" : "1.0.0", + "title" : "API example", + "contact" : { + "email" : "onap@orange.com" + }, + "license" : { + "name" : "Apache 2.0", + "url" : "http://www.apache.org/licenses/LICENSE-2.0.html" + } + }, + "host" : "serverRoot", + "basePath" : "/status", + "schemes" : [ "https" ], + "produces": [ + "application/json;charset=utf-8" + ], + "paths" : { + "/status" : { + "get" : { + "summary" : "Displays status for my favorite component", + "description" : "Displays status for my favorite component", + "responses": { + "200": { + "description": "Service OK" + }, + "503" : { + "description" : "Service Unavailable" + } + } + } + } + } +} |