1const INDEX_STYLE: &str = include_str!("index.css");
2const SWAGGER_UI_TEMPLATE: &str = r#"
3<!-- HTML for static distribution bundle build -->
4<!DOCTYPE html>
5<html lang="en">
6 <head>
7 <meta charset="UTF-8">
8 <title>Swagger UI</title>
9 <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/swagger-ui/5.10.3/swagger-ui.min.css" integrity="sha512-GjxduL6utVm4zShr/F1ulzFRBq08BMVm6vBKBsdIRajay+5JQCCo8nTB+RuUT6WrSeRh3TOJ7JbQNRXznpYlhg==" crossorigin="anonymous" referrerpolicy="no-referrer" />
10 <style charset="UTF-8">{:index_style}</style>
11
12 </head>
13
14 <body>
15 <div id="swagger-ui"></div>
16
17 <script src="https://cdnjs.cloudflare.com/ajax/libs/swagger-ui/5.10.3/swagger-ui-bundle.min.js" integrity="sha512-sQ0p2uQ26Rl59qkMJt+ltkoBuJG2qFfkiA79QXhdxfr2JAIKZ8X+H8SWhMLIaNsFJPNNyJnN4RllWMrVczPIgw==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>
18 <script src="https://cdnjs.cloudflare.com/ajax/libs/swagger-ui/5.10.3/swagger-ui-standalone-preset.min.js" integrity="sha512-qwGi7EG31HcylzamsmacHLZJrfUGRuuHEaCMcOojuNpMu+paR554VjaCZ9LdUVTrmF8xC03YVqTzuKx0SDdruA==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>
19 <script>
20 window.onload = function() {
21 window.ui = SwaggerUIBundle({
22 url: "{:spec_url}",
23 dom_id: '#swagger-ui',
24 deepLinking: true,
25 presets: [
26 SwaggerUIBundle.presets.apis,
27 SwaggerUIStandalonePreset
28 ],
29 plugins: [
30 SwaggerUIBundle.plugins.DownloadUrl
31 ],
32 layout: "StandaloneLayout"
33 });
34 };
35 </script>
36 </body>
37</html>
38"#;
39
40pub fn swagger_ui(spec_url: &'static str) -> String {
42 SWAGGER_UI_TEMPLATE
43 .replace("{:index_style}", INDEX_STYLE)
44 .replace("{:spec_url}", spec_url)
45}