redoc.html 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. {{- $file := .Get 0 -}}
  2. {{- $url := "" -}}
  3. {{- $otheroptions := .Get 1 -}}
  4. {{ if hasPrefix $file "http"}}
  5. {{- $url = $file -}}
  6. {{ else }}
  7. {{ if (fileExists (print .Page.File.Dir $file)) -}}
  8. <!-- First try as relative path -->
  9. {{- $url = (print .Page.Site.BaseURL .Page.File.Dir $file) -}}
  10. {{ else }}
  11. <!-- Then as project-relative path-->
  12. {{- $url = (print .Page.Site.BaseURL $file) -}}
  13. {{- end }}
  14. {{- end -}}
  15. <!-- CSS style overrides for Redoc API docs -->
  16. <style>
  17. #redoc input { height: 64px; }
  18. #redoc span[type="put"], span[type="get"], span[type="delete"], span[type="post"], span[type="options"], span[type="patch"], span[type="basic"], span[type="link"], span[type="head"] {
  19. border-radius: 4px;
  20. }
  21. #redoc h2 { margin-top: 0px;}
  22. </style>
  23. <!-- Back to top button start -->
  24. <style>
  25. #myBtn {
  26. display: none;
  27. position: fixed;
  28. bottom: 20px;
  29. right: 30px;
  30. z-index: 99;
  31. font-size: 18px;
  32. border: none;
  33. outline: none;
  34. background-color: #30638E;
  35. color: white;
  36. cursor: pointer;
  37. padding: 15px;
  38. border-radius: 4px;
  39. }
  40. #myBtn:hover {
  41. background-color: #555;
  42. }
  43. </style>
  44. <button onclick="topFunction()" id="myBtn" title="Go to top">Top</button>
  45. <script>
  46. //Get the button
  47. var mybutton = document.getElementById("myBtn");
  48. // When the user scrolls down 20px from the top of the document, show the button
  49. window.onscroll = function() {scrollFunction()};
  50. function scrollFunction() {
  51. if (document.body.scrollTop > 20 || document.documentElement.scrollTop > 20) {
  52. mybutton.style.display = "block";
  53. } else {
  54. mybutton.style.display = "none";
  55. }
  56. }
  57. // When the user clicks on the button, scroll to the top of the document
  58. function topFunction() {
  59. document.body.scrollTop = 0;
  60. document.documentElement.scrollTop = 0;
  61. }
  62. </script>
  63. <!-- Back to top button end -->
  64. <!--
  65. Redoc doesn't change outer page styles
  66. -->
  67. <style>
  68. body {
  69. margin: 0;
  70. padding: 0;
  71. }
  72. </style>
  73. <!--
  74. Redoc element with link to your OpenAPI definition
  75. -->
  76. <div id="redoc-container">
  77. <redoc spec-url='{{ $url }}' hide-hostname="true" suppress-warnings="true" lazy-rendering native-scrollbars scroll-y-offset=".js-navbar-scroll" {{ $otheroptions }}></redoc>
  78. </div>
  79. <!--
  80. Link to Redoc JavaScript on CDN for rendering standalone element
  81. -->
  82. <script src="https://cdn.jsdelivr.net/npm/redoc@latest/bundles/redoc.standalone.js"></script>