webui/src/routes/api/+page.svelte

65 lines
1.8 KiB
Svelte
Raw Normal View History

2023-11-17 00:05:35 +00:00
<script lang="ts">
import { _ } from 'svelte-i18n';
import { Col, Container, Row, Button } from 'sveltestrap';
2023-11-17 00:05:35 +00:00
import { onMount } from 'svelte';
//import * as swaggerJson from '../../../static/swagger.json';
2023-11-17 18:10:46 +00:00
// import SwaggerUI from 'swagger-ui';
import 'swagger-ui/dist/swagger-ui.css';
2023-11-17 00:05:35 +00:00
let swaggerLoaded:boolean = false;
2023-11-17 00:05:35 +00:00
onMount(async () => {
2023-11-17 18:10:46 +00:00
// @ts-ignore
loadSwagger();
2023-11-17 00:05:35 +00:00
});
const loadSwagger = () => {
if (!SwaggerUIBundle)
return;
swaggerLoaded = true;
window.ui = SwaggerUIBundle({
url: '/swagger.json',
dom_id: '#swagger-ui-container',
presets: [
// @ts-ignore
SwaggerUIBundle.presets.apis,
// @ts-ignore
SwaggerUIStandalonePreset
],
// layout: "StandaloneLayout",
});
}
2023-11-17 00:05:35 +00:00
</script>
<svelte:head>
2023-11-17 18:10:46 +00:00
<title>API playground</title>
<script
src="https://cdnjs.cloudflare.com/ajax/libs/swagger-ui/5.10.0/swagger-ui-bundle.min.js"
integrity="sha512-Ckle4LZv9LhAfEdohBdUi+QCu0e7HkXHTeSPXfbDzbCsR87QNTUBylkBEPsBNn4Ph83yK1hJ6f2uH4QMtB0hTA=="
crossorigin="anonymous"
referrerpolicy="no-referrer"
></script>
<script
src="https://cdnjs.cloudflare.com/ajax/libs/swagger-ui/5.10.0/swagger-ui-standalone-preset.min.js"
integrity="sha512-qwGi7EG31HcylzamsmacHLZJrfUGRuuHEaCMcOojuNpMu+paR554VjaCZ9LdUVTrmF8xC03YVqTzuKx0SDdruA=="
crossorigin="anonymous"
referrerpolicy="no-referrer"
></script>
<link
rel="stylesheet"
href="https://cdnjs.cloudflare.com/ajax/libs/swagger-ui/5.10.0/swagger-ui.min.css"
integrity="sha512-Ck+X9SARG7WscOTG4a8Qod5Zgd1MZlz4VtyyucjMJ3PnZy2lUl7q/v/0055yIfGM/v+f+216ME0/dv0qqtm6+g=="
crossorigin="anonymous"
referrerpolicy="no-referrer"
/>
2023-11-17 00:05:35 +00:00
</svelte:head>
<Container fluid class="bg-light">
<section class:invisible={swaggerLoaded}><Button on:click="{loadSwagger}">Load</Button></section>
2023-11-17 18:10:46 +00:00
<div id="swagger-ui-container" />
2023-11-17 00:05:35 +00:00
</Container>