diff --git a/src/aashto/src/main/resources/swagger/index.js b/src/aashto/src/main/resources/swagger/index.js new file mode 100644 index 0000000000000000000000000000000000000000..dc24f90f0d66b86603481f9c2089d1f2346ec46a --- /dev/null +++ b/src/aashto/src/main/resources/swagger/index.js @@ -0,0 +1,42 @@ +window.onload = function() { + let contextPath = window.location.pathname; + contextPath = contextPath.endsWith('/') ? contextPath.slice(0, -1) : contextPath; + + const ui = SwaggerUIBundle({ + defaultModelsExpandDepth: 0, + deepLinking: true, + docExpansion: 'full', + dom_id: '#swagger-ui', + layout: 'BaseLayout', + plugins: [SwaggerUIBundle.plugins.DownloadUrl, updateContextPath(contextPath)], + presets: [SwaggerUIBundle.presets.apis], + tagsSorter: 'alpha', + tryItOutEnabled: true, + validatorUrl: null, + url: `./swagger`, + }); + + window.ui = ui; +}; + +function updateContextPath(contextPath) { + return { + statePlugins: { + spec: { + wrapActions: { + updateJsonSpec: (oriAction) => (...args) => { + const [spec] = args; + if (spec && spec.paths) { + const newPaths = {}; + Object.entries(spec.paths).forEach( + ([path, value]) => (newPaths[contextPath + path] = value) + ); + spec.paths = newPaths; + } + oriAction(...args); + }, + }, + }, + }, + }; +} diff --git a/src/hazard/src/main/resources/swagger/index.js b/src/hazard/src/main/resources/swagger/index.js new file mode 100644 index 0000000000000000000000000000000000000000..2a6fbfd60d9634ea5dff2ddbd01738b4e600fc60 --- /dev/null +++ b/src/hazard/src/main/resources/swagger/index.js @@ -0,0 +1,41 @@ +window.onload = function() { + let contextPath = window.location.pathname; + contextPath = contextPath.endsWith('/') ? contextPath.slice(0, -1) : contextPath; + + const ui = SwaggerUIBundle({ + defaultModelsExpandDepth: 0, + deepLinking: true, + dom_id: '#swagger-ui', + layout: 'BaseLayout', + plugins: [SwaggerUIBundle.plugins.DownloadUrl, updateContextPath(contextPath)], + presets: [SwaggerUIBundle.presets.apis], + tagsSorter: 'alpha', + tryItOutEnabled: true, + validatorUrl: null, + url: `./swagger`, + }); + + window.ui = ui; +}; + +function updateContextPath(contextPath) { + return { + statePlugins: { + spec: { + wrapActions: { + updateJsonSpec: (oriAction) => (...args) => { + const [spec] = args; + if (spec && spec.paths) { + const newPaths = {}; + Object.entries(spec.paths).forEach( + ([path, value]) => (newPaths[contextPath + path] = value) + ); + spec.paths = newPaths; + } + oriAction(...args); + }, + }, + }, + }, + }; +}