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

24 lines
652 B
JavaScript
Raw Normal View History

2020-01-01 13:55:28 +05:30
import { SwaggerUIBundle } from 'swagger-ui-dist';
2021-09-30 23:02:18 +05:30
import createFlash 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',
2022-04-01 21:47:47 +05:30
deepLinking: true,
2022-07-16 23:28:13 +05:30
displayOperationId: true,
2020-01-01 13:55:28 +05:30
});
})
2021-03-08 18:12:59 +05:30
.catch((error) => {
2021-09-30 23:02:18 +05:30
createFlash({
message: __('Something went wrong while initializing the OpenAPI viewer'),
});
2020-01-01 13:55:28 +05:30
throw error;
});
};