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