Skip to content
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
8 changes: 4 additions & 4 deletions aiscript-runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -190,10 +190,10 @@ async fn run_server(
if config.apidoc.enabled {
match config.apidoc.doc_type {
config::ApiDocType::Swagger => {
// router = router.route(
// &config.apidoc.path,
// get(move || async { Html(include_str!("openapi/swagger.html")) }),
// );
router = router.route(
&config.apidoc.path,
get(move || async { Html(include_str!("openapi/swagger.html")) }),
);
}
config::ApiDocType::Redoc => {
router = router.route(
Expand Down
56 changes: 56 additions & 0 deletions aiscript-runtime/src/openapi/swagger.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Swagger UI</title>
<link rel="stylesheet" type="text/css" href="https://unpkg.com/swagger-ui-dist@5.9.0/swagger-ui.css" />
<link rel="icon" type="image/png" href="https://unpkg.com/swagger-ui-dist@5.9.0/favicon-32x32.png" sizes="32x32" />
<link rel="icon" type="image/png" href="https://unpkg.com/swagger-ui-dist@5.9.0/favicon-16x16.png" sizes="16x16" />
<style>
html {
box-sizing: border-box;
overflow: -moz-scrollbars-vertical;
overflow-y: scroll;
}

*,
*:before,
*:after {
box-sizing: inherit;
}

body {
margin: 0;
background: #fafafa;
}
</style>
</head>

<body>
<div id="swagger-ui"></div>

<script src="https://unpkg.com/swagger-ui-dist@5.9.0/swagger-ui-bundle.js"></script>
<script src="https://unpkg.com/swagger-ui-dist@5.9.0/swagger-ui-standalone-preset.js"></script>
<script>
window.onload = function() {
// get the base part of the URL
const baseUrl = window.location.protocol + '//' + window.location.host;

// initialize Swagger UI
window.ui = SwaggerUIBundle({
url: baseUrl + "/openapi.json", // OpenAPI specification JSON
dom_id: '#swagger-ui',
deepLinking: true,
presets: [
SwaggerUIBundle.presets.apis,
SwaggerUIStandalonePreset
],
plugins: [
SwaggerUIBundle.plugins.DownloadUrl
],
layout: "StandaloneLayout"
});
};
</script>
</body>
</html>
Loading