docs: initialize redoc via JS API

Preparation for the next commit in which we'll make the script tag async
(in order to use await to fetch the new versions.json file).

Signed-off-by: Martin Fischer <martin@push-f.com>
This commit is contained in:
Martin Fischer
2025-10-14 08:15:46 +02:00
parent 858150288f
commit fa5d6cc103

View File

@@ -18,6 +18,8 @@
</style> </style>
</head> </head>
<body> <body>
<script src="https://cdn.jsdelivr.net/npm/redoc@next/bundles/redoc.standalone.js"> </script>
<div id="redoc-container"></div>
<script> <script>
// get version from query (default to latest) // get version from query (default to latest)
var queryString = window.location.search; var queryString = window.location.search;
@@ -27,13 +29,10 @@
version = query.get("version"); version = query.get("version");
} }
var redoc = document.createElement("redoc"); Redoc.init("https://storage.googleapis.com/libpod-master-releases/swagger-" + version + ".yaml", {
redoc.setAttribute("sort-props-alphabetically",""); sortPropsAlphabetically: true,
redoc.setAttribute("sort-operations-alphabetically",""); sortOperationsAlphabetically: true,
redoc.setAttribute("spec-url","https://storage.googleapis.com/libpod-master-releases/swagger-" + version + ".yaml"); }, document.getElementById("redoc-container"));
document.body.appendChild(redoc);
</script> </script>
<script src="https://cdn.jsdelivr.net/npm/redoc@next/bundles/redoc.standalone.js"> </script>
</body> </body>
</html> </html>