Skip to content

Commit

Permalink
Docs: Include REST API reference content from swagger.json (#14607)
Browse files Browse the repository at this point in the history
  • Loading branch information
oraNod authored Nov 11, 2023
1 parent d8a28b3 commit 0057c8d
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 5 deletions.
3 changes: 2 additions & 1 deletion docs/docsite/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from datetime import datetime
from importlib import import_module

#sys.path.insert(0, os.path.abspath('./rst/rest_api/_swagger'))
sys.path.insert(0, os.path.abspath('./rst/rest_api/_swagger'))

project = u'Ansible AWX'
copyright = u'2023, Red Hat'
Expand Down Expand Up @@ -35,6 +35,7 @@
'sphinx.ext.coverage',
'sphinx.ext.ifconfig',
'sphinx_ansible_theme',
'swagger',
]

html_theme = 'sphinx_ansible_theme'
Expand Down
13 changes: 13 additions & 0 deletions docs/docsite/rst/rest_api/_swagger/download-json.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import requests

url = "https://awx-public-ci-files.s3.amazonaws.com/community-docs/swagger.json"
swagger_json = "./docs/docsite/rst/rest_api/_swagger/swagger.json"

response = requests.get(url)

if response.status_code == 200:
with open(swagger_json, 'wb') as file:
file.write(response.content)
print(f"JSON file downloaded to {swagger_json}")
else:
print(f"Request failed with status code: {response.status_code}")
4 changes: 1 addition & 3 deletions docs/docsite/rst/rest_api/api_ref.rst
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
:orphan:

.. _api_reference:

AWX API Reference Guide
Expand Down Expand Up @@ -48,7 +46,7 @@ The API Reference Manual provides in-depth documentation for the AWX REST API, i
<script>
window.onload = function() {
$('head').append('<link rel="stylesheet" href="../_static/swagger-ui.css" type="text/css"></link>');
$('head').append('<link rel="stylesheet" href="../_static/tower.css" type="text/css"></link>');
$('head').append('<link rel="stylesheet" href="../_static/awx-rest-api.css" type="text/css"></link>');
$('#swagger-ui').on('click', function(e) {
// By default, swagger-ui has a show/hide toggle for headers, and
// there's no way to turn it off; this code intercepts the click event
Expand Down
2 changes: 1 addition & 1 deletion docs/docsite/rst/rest_api/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ You can also find lots of AWX discussion and get answers to questions at `forum.
access_resources
read_only_fields
authentication
.. api_ref
api_ref

.. intro
.. auth_token
Expand Down
1 change: 1 addition & 0 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,5 @@ deps =
-r{toxinidir}/docs/docsite/requirements.in
-c{toxinidir}/docs/docsite/requirements.txt
commands =
python {toxinidir}/docs/docsite/rst/rest_api/_swagger/download-json.py
sphinx-build -T -E -W -n --keep-going {tty:--color} -j auto -c docs/docsite -d docs/docsite/build/doctrees -b html docs/docsite/rst docs/docsite/build/html

0 comments on commit 0057c8d

Please sign in to comment.