Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
export function mountSwagger() {
SwaggerUIBundle({
deepLinking: true,
dom_id: "#swagger-ui",
// layout: "DashboardLayout",
plugins: [SwaggerUIBundle.plugins.DownloadUrl],
presets: [SwaggerUIBundle.presets.apis],
requestInterceptor: (request: Request) => {
request.headers["x-transient-key"] = getMeta("TransientKey");
return request;
},
url: formatUrl("/api/v2/open-api/v3" + window.location.search),
validatorUrl: null,
});
}
const plugins = [];
if (!this.tryItEnabled()) {
plugins.push(DisableTryItOutPlugin);
}
let contentAsJson = {};
try {
contentAsJson = JSON.parse(this.page.content);
} catch (e) {
contentAsJson = jsyaml.safeLoad(this.page.content);
}
let cfg = {
dom_id: '#swagger-container',
presets: [
SwaggerUIBundle.presets.apis,
],
layout: 'BaseLayout',
plugins: plugins,
requestInterceptor: (req) => {
if (req.loadSpec) {
req.credentials = 'include';
}
return req;
},
spec: contentAsJson,
};
if (!_.isNil(this.page.configuration)) {
if (this.page.configuration.showURL === "true") {
cfg["url"] = this.url;
cfg["spec"] = undefined;