mirror of
https://codeberg.org/forgejo/forgejo
synced 2024-11-24 02:36:10 +01:00
9eb22ddc19
- Tell webpack to chunk the swagger-ui dependency, so it can be re-used for the forgejo-swagger.js and swagger.js files (these two files are two seperate javascript files in the output). - This saves off 400KB when Forgejo is built with the `bindata` build tag.
24 lines
712 B
JavaScript
24 lines
712 B
JavaScript
window.addEventListener('load', async () => {
|
|
const [{default: SwaggerUI}] = await Promise.all([
|
|
import(/* webpackChunkName: "swagger-ui" */'swagger-ui-dist/swagger-ui-es-bundle.js'),
|
|
import(/* webpackChunkName: "swagger-ui" */'swagger-ui-dist/swagger-ui.css'),
|
|
]);
|
|
const url = document.getElementById('swagger-ui').getAttribute('data-source');
|
|
|
|
const ui = SwaggerUI({
|
|
url,
|
|
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;
|
|
});
|