debian-mirror-gitlab/app/assets/javascripts/blob/openapi/index.js

20 lines
580 B
JavaScript
Raw Normal View History

2020-01-01 13:55:28 +05:30
import { SwaggerUIBundle } from 'swagger-ui-dist';
2020-10-24 23:57:45 +05:30
import { deprecatedCreateFlash as flash } from '~/flash';
2020-01-01 13:55:28 +05:30
import { __ } from '~/locale';
export default () => {
const el = document.getElementById('js-openapi-viewer');
Promise.all([import(/* webpackChunkName: 'openapi' */ 'swagger-ui-dist/swagger-ui.css')])
.then(() => {
SwaggerUIBundle({
url: el.dataset.endpoint,
dom_id: '#js-openapi-viewer',
});
})
2021-03-08 18:12:59 +05:30
.catch((error) => {
2020-01-01 13:55:28 +05:30
flash(__('Something went wrong while initializing the OpenAPI viewer'));
throw error;
});
};