2019-12-16 12:07:43 +00:00
|
|
|
import { SwaggerUIBundle } from 'swagger-ui-dist';
|
2020-08-20 09:09:55 +00:00
|
|
|
import { deprecatedCreateFlash as flash } from '~/flash';
|
2019-12-16 12:07:43 +00:00
|
|
|
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',
|
|
|
|
});
|
|
|
|
})
|
2020-12-23 21:10:24 +00:00
|
|
|
.catch((error) => {
|
2019-12-16 12:07:43 +00:00
|
|
|
flash(__('Something went wrong while initializing the OpenAPI viewer'));
|
|
|
|
throw error;
|
|
|
|
});
|
|
|
|
};
|