gitea源码

12345678910111213141516171819202122232425262728293031
  1. import SwaggerUI from 'swagger-ui-dist/swagger-ui-es-bundle.js';
  2. import 'swagger-ui-dist/swagger-ui.css';
  3. window.addEventListener('load', async () => {
  4. const url = document.querySelector('#swagger-ui').getAttribute('data-source');
  5. const res = await fetch(url);
  6. const spec = await res.json();
  7. // Make the page's protocol be at the top of the schemes list
  8. const proto = window.location.protocol.slice(0, -1);
  9. spec.schemes.sort((a: string, b: string) => {
  10. if (a === proto) return -1;
  11. if (b === proto) return 1;
  12. return 0;
  13. });
  14. SwaggerUI({
  15. spec,
  16. dom_id: '#swagger-ui',
  17. deepLinking: true,
  18. docExpansion: 'none',
  19. defaultModelRendering: 'model', // don't show examples by default, because they may be incomplete
  20. presets: [
  21. SwaggerUI.presets.apis,
  22. ],
  23. plugins: [
  24. SwaggerUI.plugins.DownloadUrl,
  25. ],
  26. });
  27. });