Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

💄 Switch from Swagger UI to RapiDoc #1081

Merged
merged 3 commits into from
Sep 27, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,3 +0,0 @@
[submodule "swagger-ui"]
path = swagger-ui
url = https://github.com/matrix-org/swagger-ui.git
10 changes: 0 additions & 10 deletions content/swagger.css

This file was deleted.

30 changes: 30 additions & 0 deletions rapidoc/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<!doctype html> <!-- Important: must specify -->
<html>
<head>
<meta charset="utf-8"> <!-- Important: rapi-doc uses utf8 charecters -->
<script type="module" src="./rapidoc-9.1.1.min.js"></script>
</head>
<body>
<rapi-doc
spec-url = "json/api-docs.json"
show-header="false"
render-style="focused"

theme="light"
nav-bg-color="#f4f4f4"
nav-accent-color="#0098d4"
nav-text-color="#000000"
nav-hover-text-color="#ffffff"
nav-hover-bg-color="#000000"
nav-active-text-color="#0098d4"
nav-active-bg-color="#000000"
primary-color="#000000"
>
<div slot="nav-logo" style="display: flex; align-items: center; justify-content: center;">
<a href="/docs/develop">
<img src="/images/matrix-logo.svg">
</a>
</div>
</rapi-doc>
</body>
</html>
5 changes: 5 additions & 0 deletions rapidoc/rapidoc-9.1.1.min.js

Large diffs are not rendered by default.

80 changes: 0 additions & 80 deletions scripts/swagger-ui.patch

This file was deleted.

12 changes: 5 additions & 7 deletions scripts/update_docs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
# At present this includes:
# * the spec intro and appendices
# * the guides and howtos
# * the swagger UI for the API
# * 'Unstable' versions of the spec docs
# * the RapiDoc UI for the API
#
# Note that the historical versions of the CS spec and swagger, and the spec
# index, are generated manually within matrix-doc and then *committed to git*.
Expand All @@ -30,11 +30,10 @@ fi
# otherwise, assume the latest build was fetched by Github Actions.
tar -xzf assets.tar.gz

# copy the swagger UI into place
# Set up foundations for RapiDoc API playground
rm -fr unstyled_docs/api/client-server
mkdir -p unstyled_docs/api/client-server/json
cp -r swagger-ui/dist/* unstyled_docs/api/client-server/
(cd unstyled_docs && patch -p0) <scripts/swagger-ui.patch
ln -s ../../../spec/client_server/latest.json unstyled_docs/api/client-server/json/api-docs.json

# and the unstable spec docs, but not:
# * the spec index (because we want to keep the git version, which points to a specific c-s version), or
Expand All @@ -44,12 +43,11 @@ rm -f assets/spec/index.html
rm -f assets/spec/appendices.html
cp -ar assets/spec unstyled_docs

# add a link to the stable swagger doc
ln -s ../../../spec/client_server/latest.json unstyled_docs/api/client-server/json/api-docs.json

# copy the unstyled docs and add the jekyll styling
rm -rf content/docs
cp -r unstyled_docs content/docs
find "content/docs" -name '*.html' -type f |
xargs "./scripts/add-matrix-org-stylings.pl" "./jekyll/_includes"

# Set up RapiDoc itself at the end so it doesn’t get styled
cp -r rapidoc/* content/docs/api/client-server/
1 change: 0 additions & 1 deletion swagger-ui
Submodule swagger-ui deleted from 64dc30
2 changes: 1 addition & 1 deletion unstyled_docs/spec/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -1108,7 +1108,7 @@ <h1><a class="toc-backref" href="#id6">1&nbsp;&nbsp;&nbsp;Matrix APIs</a></h1>
and <a class="reference external" href="#architecture">overall architecture</a>.</p>
<p>The <a class="reference external" href="appendices.html">Appendices</a> contain supplemental information not specific to
one of the above APIs.</p>
<p>The <a class="reference external" href="https://matrix.org/docs/api/client-server/">Matrix Client-Server API Swagger Viewer</a>
<p>The <a class="reference external" href="https://matrix.org/docs/api/client-server/">Matrix Client-Server OpenAPI Viewer</a>
is useful for browsing the Client-Server API.</p>
<p><a class="anchor" id="matrix-versions"></a></p>
<div class="section" id="matrix-versions">
Expand Down