summaryrefslogtreecommitdiff
path: root/app/assets/javascripts/blob
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2019-12-16 12:07:43 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2019-12-16 12:07:43 +0000
commitd10a462fedbd7794a83abdba9b4526600f71de5b (patch)
tree4dbd21cb89013d9e07b05bac5101cd13585a8be5 /app/assets/javascripts/blob
parent13867d66e92c2fd8962a126db4fbdc32891343c9 (diff)
downloadgitlab-ce-d10a462fedbd7794a83abdba9b4526600f71de5b.tar.gz
Add latest changes from gitlab-org/gitlab@masterogolowinski-master-patch-80898
Diffstat (limited to 'app/assets/javascripts/blob')
-rw-r--r--app/assets/javascripts/blob/openapi/index.js19
-rw-r--r--app/assets/javascripts/blob/openapi_viewer.js3
-rw-r--r--app/assets/javascripts/blob/viewer/index.js3
3 files changed, 25 insertions, 0 deletions
diff --git a/app/assets/javascripts/blob/openapi/index.js b/app/assets/javascripts/blob/openapi/index.js
new file mode 100644
index 00000000000..a6f28de799f
--- /dev/null
+++ b/app/assets/javascripts/blob/openapi/index.js
@@ -0,0 +1,19 @@
+import { SwaggerUIBundle } from 'swagger-ui-dist';
+import flash from '~/flash';
+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;
+ });
+};
diff --git a/app/assets/javascripts/blob/openapi_viewer.js b/app/assets/javascripts/blob/openapi_viewer.js
new file mode 100644
index 00000000000..0cacc33571f
--- /dev/null
+++ b/app/assets/javascripts/blob/openapi_viewer.js
@@ -0,0 +1,3 @@
+import renderOpenApi from './openapi';
+
+export default renderOpenApi;
diff --git a/app/assets/javascripts/blob/viewer/index.js b/app/assets/javascripts/blob/viewer/index.js
index 07e4dde41d9..742404da46c 100644
--- a/app/assets/javascripts/blob/viewer/index.js
+++ b/app/assets/javascripts/blob/viewer/index.js
@@ -39,6 +39,9 @@ export default class BlobViewer {
case 'notebook':
initViewer(import(/* webpackChunkName: 'notebook_viewer' */ '../notebook_viewer'));
break;
+ case 'openapi':
+ initViewer(import(/* webpackChunkName: 'openapi_viewer' */ '../openapi_viewer'));
+ break;
case 'pdf':
initViewer(import(/* webpackChunkName: 'pdf_viewer' */ '../pdf_viewer'));
break;