forked from treasure-data/digdag
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request treasure-data#1292 from treasure-data/swagger-api-doc
Serve REST API document as a static HTML at docs.digdag.io/api/
- Loading branch information
Showing
6 changed files
with
53 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
<!doctype html> | ||
<html> | ||
<head> | ||
<meta charset="utf-8"> | ||
<script type="module" src="https://unpkg.com/[email protected]/dist/rapidoc-min.js"></script> | ||
</head> | ||
<body> | ||
<rapi-doc | ||
id="rapidoc" | ||
spec-url="swagger.yaml" | ||
allow-try="false" | ||
allow-authentication="false" | ||
allow-spec-url-load="false" | ||
allow-spec-file-load="false" | ||
show-info="false" | ||
heading-text="Digdag REST API" | ||
header-color="#f0f2f4" | ||
regular-font="BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif" | ||
> | ||
<div slot="logo" style="height:36px;width:36px;margin-left:5px;margin-right:auto;"> | ||
<a href="https://digdag.io"><img src="../_static/logo/dig-dag-logo-tr.png" alt="Digdag logo" height="36" width="36" /></img></a> | ||
</div> | ||
</rapi-doc> | ||
|
||
<script> | ||
// Modify style here because RapiDoc doesn't highlight deprecated endpoints. | ||
// Deprecated endpoints are highlighted with "read" mode https://github.com/mrin9/RapiDoc/issues/91, | ||
// but not with default "view" mode. | ||
const markDeprecated = function() { | ||
const rapidocRoot = document.querySelector("#rapidoc").shadowRoot // Shadow DOM is not directly accessible | ||
rapidocRoot.querySelectorAll(".m-endpoint").forEach(function(endpointEl) { | ||
// Find endpoints whose description is empty (undocumented) or includes /deprecate/i (deprecated). | ||
const descText = endpointEl.querySelector(".descr").textContent | ||
if (!descText || descText.toLowerCase().includes("deprecate")) { | ||
// Mark it as deprecated by changing style | ||
endpointEl.querySelector(".method").setAttribute("style", "color:#bbb;border-color:#bbb;") | ||
endpointEl.querySelector(".path").setAttribute("style", "color:#bbb;") | ||
endpointEl.querySelector(".descr").setAttribute("style", "color:#bbb;") | ||
} | ||
}) | ||
} | ||
// Use setTimeout instead of spec-loaded event because spec-loaded is not added rapidoc | ||
// since 7.0.5 and it is not released yet. | ||
//document.getElementById("doc").addEventListener('spec-loaded', markDeprecated) | ||
setTimeout(markDeprecated, 500) | ||
</script> | ||
</body> | ||
</html> |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
REST API | ||
================================== | ||
|
||
Open API document is available at `swagger.digdag.io <https://swagger.digdag.io/>`_. | ||
Open API document is available at `docs.digdag.io/api <https://docs.digdag.io/api/>`_. | ||
|