Skip to content
Snippets Groups Projects
Commit 62663312 authored by Clayton, Brandon Scott's avatar Clayton, Brandon Scott
Browse files

add swagger javascript per application

parent be0909a2
No related branches found
No related tags found
2 merge requests!124Production Release | nshmp-ws-static,!123Resolves - Remove GITLAB_TOKEN Requirement and AASHTO-2023 web service -- add CSV response
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);
},
},
},
},
};
}
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);
},
},
},
},
};
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment