Skip to content

Commit

Permalink
fix api definition paths
Browse files Browse the repository at this point in the history
  • Loading branch information
nc-andreashaller committed Oct 16, 2024
1 parent d21f939 commit 7fb24fb
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions blocks/swaggerui/swaggerui.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import ComponentBase from '../../scripts/component-base.js';

const prefixPath = '/api-definitions';

export default class SwaggerUI extends ComponentBase {

async loadEnvironments() {
const response = await fetch('/apis/environments.json');
const response = await fetch(`${prefixPath}/environments.json`);
return response.json();
}

Expand All @@ -21,7 +23,7 @@ export default class SwaggerUI extends ComponentBase {
});

environmentsElement.addEventListener('change', async () => {
const response = await fetch(`/apis/${environmentsElement.value}/index.json`);
const response = await fetch(`${prefixPath}/${environmentsElement.value}/index.json`);
const apis = await response.json();
definitionsElement.innerHTML = '';
wrapperElement.innerHTML = '';
Expand All @@ -35,7 +37,7 @@ export default class SwaggerUI extends ComponentBase {
const file = definitionsElement.value;
wrapperElement.innerHTML = '';
window.SwaggerUIBundle({
url: `/apis/${environmentsElement.value}/${file}`,
url: `${prefixPath}/${environmentsElement.value}/${file}`,
domNode: wrapperElement,
presets: [window.SwaggerUIBundle.presets.apis, window.SwaggerUIStandalonePreset],
layout: 'StandaloneLayout',
Expand Down

0 comments on commit 7fb24fb

Please sign in to comment.