How to use the swagger-ui-dist/swagger-ui-es-bundle.js function in swagger-ui-dist

To help you get started, we’ve selected a few swagger-ui-dist examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github go-gitea / gitea / web_src / js / standalone / swagger.js View on Github external
window.addEventListener('load', async () => {
  const url = document.getElementById('swagger-ui').dataset.source;
  const res = await fetch(url);
  const spec = await res.json();

  // Make the page's protocol be at the top of the schemes list
  const proto = window.location.protocol.slice(0, -1);
  spec.schemes.sort((a, b) => {
    if (a === proto) return -1;
    if (b === proto) return 1;
    return 0;
  });

  const ui = SwaggerUI({
    spec,
    dom_id: '#swagger-ui',
    deepLinking: true,
    docExpansion: 'none',
    defaultModelRendering: 'model', // don't show examples by default, because they may be incomplete
    presets: [
      SwaggerUI.presets.apis
    ],
    plugins: [
      SwaggerUI.plugins.DownloadUrl
    ]
  });

  window.ui = ui;
});

swagger-ui-dist

[![NPM version](https://badge.fury.io/js/swagger-ui-dist.svg)](http://badge.fury.io/js/swagger-ui-dist)

Apache-2.0
Latest version published 5 months ago

Package Health Score

87 / 100
Full package analysis

Similar packages