mirror of
https://github.com/LukeHagar/OpenAPI.gg.git
synced 2025-12-07 12:37:46 +00:00
component reworkings
This commit is contained in:
@@ -4,20 +4,15 @@
|
|||||||
import { stringify } from 'yaml';
|
import { stringify } from 'yaml';
|
||||||
|
|
||||||
$: fileName = filenamify($openApiStore?.info?.title) || 'openapi';
|
$: fileName = filenamify($openApiStore?.info?.title) || 'openapi';
|
||||||
</script>
|
|
||||||
|
|
||||||
<label class="flex flex-col text-xs">
|
// TODO: Refactor this to use the new storage instead of localstorage
|
||||||
<span>Download</span>
|
const saveYAML = () => {
|
||||||
<button
|
|
||||||
class="btn btn-sm grow variant-ghost-tertiary mb-1"
|
|
||||||
on:click={() => {
|
|
||||||
const openApiStorage = localStorage.getItem(`${localStoragePrefix}openApi`);
|
const openApiStorage = localStorage.getItem(`${localStoragePrefix}openApi`);
|
||||||
if (!openApiStorage) return;
|
if (!openApiStorage) return;
|
||||||
const openApi = JSON.parse(openApiStorage);
|
const openApi = JSON.parse(openApiStorage);
|
||||||
const blob = new Blob(
|
const blob = new Blob([stringify(openApi, null, { indent: 2, aliasDuplicateObjects: false })], {
|
||||||
[stringify(openApi, null, { indent: 2, aliasDuplicateObjects: false })],
|
type: 'application/yaml'
|
||||||
{ type: 'application/yaml' }
|
});
|
||||||
);
|
|
||||||
const url = URL.createObjectURL(blob);
|
const url = URL.createObjectURL(blob);
|
||||||
const a = document.createElement('a');
|
const a = document.createElement('a');
|
||||||
a.href = url;
|
a.href = url;
|
||||||
@@ -25,27 +20,10 @@
|
|||||||
document.body.appendChild(a);
|
document.body.appendChild(a);
|
||||||
a.click();
|
a.click();
|
||||||
window.URL.revokeObjectURL(url);
|
window.URL.revokeObjectURL(url);
|
||||||
}}
|
};
|
||||||
>
|
|
||||||
<svg
|
// TODO: Refactor this to use the new storage instead of localstorage
|
||||||
xmlns="http://www.w3.org/2000/svg"
|
const saveJSON = () => {
|
||||||
fill="none"
|
|
||||||
viewBox="0 0 24 24"
|
|
||||||
stroke-width="1.5"
|
|
||||||
stroke="currentColor"
|
|
||||||
class="size-6"
|
|
||||||
>
|
|
||||||
<path
|
|
||||||
stroke-linecap="round"
|
|
||||||
stroke-linejoin="round"
|
|
||||||
d="M19.5 14.25v-2.625a3.375 3.375 0 0 0-3.375-3.375h-1.5A1.125 1.125 0 0 1 13.5 7.125v-1.5a3.375 3.375 0 0 0-3.375-3.375H8.25m.75 12 3 3m0 0 3-3m-3 3v-6m-1.5-9H5.625c-.621 0-1.125.504-1.125 1.125v17.25c0 .621.504 1.125 1.125 1.125h12.75c.621 0 1.125-.504 1.125-1.125V11.25a9 9 0 0 0-9-9Z"
|
|
||||||
/>
|
|
||||||
</svg>
|
|
||||||
YAML
|
|
||||||
</button>
|
|
||||||
<button
|
|
||||||
class="btn btn-sm grow variant-ghost-tertiary"
|
|
||||||
on:click={() => {
|
|
||||||
const openApiStorage = localStorage.getItem(`${localStoragePrefix}openApi`);
|
const openApiStorage = localStorage.getItem(`${localStoragePrefix}openApi`);
|
||||||
if (!openApiStorage) return;
|
if (!openApiStorage) return;
|
||||||
const openApi = JSON.parse(openApiStorage);
|
const openApi = JSON.parse(openApiStorage);
|
||||||
@@ -59,8 +37,18 @@
|
|||||||
document.body.appendChild(a);
|
document.body.appendChild(a);
|
||||||
a.click();
|
a.click();
|
||||||
window.URL.revokeObjectURL(url);
|
window.URL.revokeObjectURL(url);
|
||||||
}}
|
};
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<div class="grid grid-cols-1 text-xs gap-2">
|
||||||
|
<span class="text-center font-bold text-sm">Download</span>
|
||||||
|
<button
|
||||||
|
type="button"
|
||||||
|
on:click={saveYAML}
|
||||||
|
class="btn btn-sm rounded-lg w-full variant-ghost-tertiary gap-1"
|
||||||
|
aria-label="Download a YAML representation of the OpenAPI document."
|
||||||
>
|
>
|
||||||
|
YAML
|
||||||
<svg
|
<svg
|
||||||
xmlns="http://www.w3.org/2000/svg"
|
xmlns="http://www.w3.org/2000/svg"
|
||||||
fill="none"
|
fill="none"
|
||||||
@@ -75,6 +63,27 @@
|
|||||||
d="M19.5 14.25v-2.625a3.375 3.375 0 0 0-3.375-3.375h-1.5A1.125 1.125 0 0 1 13.5 7.125v-1.5a3.375 3.375 0 0 0-3.375-3.375H8.25m.75 12 3 3m0 0 3-3m-3 3v-6m-1.5-9H5.625c-.621 0-1.125.504-1.125 1.125v17.25c0 .621.504 1.125 1.125 1.125h12.75c.621 0 1.125-.504 1.125-1.125V11.25a9 9 0 0 0-9-9Z"
|
d="M19.5 14.25v-2.625a3.375 3.375 0 0 0-3.375-3.375h-1.5A1.125 1.125 0 0 1 13.5 7.125v-1.5a3.375 3.375 0 0 0-3.375-3.375H8.25m.75 12 3 3m0 0 3-3m-3 3v-6m-1.5-9H5.625c-.621 0-1.125.504-1.125 1.125v17.25c0 .621.504 1.125 1.125 1.125h12.75c.621 0 1.125-.504 1.125-1.125V11.25a9 9 0 0 0-9-9Z"
|
||||||
/>
|
/>
|
||||||
</svg>
|
</svg>
|
||||||
JSON
|
|
||||||
</button>
|
</button>
|
||||||
</label>
|
<button
|
||||||
|
type="button"
|
||||||
|
on:click={saveJSON}
|
||||||
|
class="btn btn-sm rounded-lg w-full variant-ghost-tertiary gap-1"
|
||||||
|
aria-label="Download a JSON representation of the OpenAPI document."
|
||||||
|
>
|
||||||
|
JSON
|
||||||
|
<svg
|
||||||
|
xmlns="http://www.w3.org/2000/svg"
|
||||||
|
fill="none"
|
||||||
|
viewBox="0 0 24 24"
|
||||||
|
stroke-width="1.5"
|
||||||
|
stroke="currentColor"
|
||||||
|
class="size-6"
|
||||||
|
>
|
||||||
|
<path
|
||||||
|
stroke-linecap="round"
|
||||||
|
stroke-linejoin="round"
|
||||||
|
d="M19.5 14.25v-2.625a3.375 3.375 0 0 0-3.375-3.375h-1.5A1.125 1.125 0 0 1 13.5 7.125v-1.5a3.375 3.375 0 0 0-3.375-3.375H8.25m.75 12 3 3m0 0 3-3m-3 3v-6m-1.5-9H5.625c-.621 0-1.125.504-1.125 1.125v17.25c0 .621.504 1.125 1.125 1.125h12.75c.621 0 1.125-.504 1.125-1.125V11.25a9 9 0 0 0-9-9Z"
|
||||||
|
/>
|
||||||
|
</svg>
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
|||||||
@@ -69,6 +69,38 @@
|
|||||||
<div
|
<div
|
||||||
class="mx-auto border-token rounded-container-token bg-surface-backdrop-token px-6 py-4 space-y-4"
|
class="mx-auto border-token rounded-container-token bg-surface-backdrop-token px-6 py-4 space-y-4"
|
||||||
>
|
>
|
||||||
|
{#if Object.keys(paths).length === 0}
|
||||||
|
<p class="text-center">Wow such empty.</p>
|
||||||
|
<p class="text-center">Please consider adding a path to your API.</p>
|
||||||
|
<!-- This is very important. Do not remove :) -->
|
||||||
|
<pre class="flex justify-center text-xs">
|
||||||
|
⠀⠀⠀⡟⠋⠈⠙⣦⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣠⠤⢤⡀⠀⠀
|
||||||
|
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⡇⠀⠀⠀⠈⢇⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⡠⠞⠀⠀⢠⡜⣦⠀
|
||||||
|
*wow*⠀⠀⠀⠀⠀⠀⠀⡃⠀⠀⠀⠀⠈⢷⡄⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⡠⠊⣠⠀⠀⠀⠀⢻⡘⡇
|
||||||
|
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢠⠃⠀⠀⠀⠀⠀⠀⠙⢶⣀⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⡠⠚⢀⡼⠃⠀⠀⠀⠀⠸⣇⢳
|
||||||
|
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣾⠀⣀⠖⠀⠀⠀⠀⠉⠀⠀⠈⠉⠛⠛⡛⢛⠛⢳⡶⠖⠋⠀⢠⡞⠀⠀⠀⠐⠆⠀⠀⣿⢸
|
||||||
|
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣼⠇⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠻⣦⣀⣴⡟⠀⠀⢶⣶⣾⡿⠀⠀⣿⢸ *such empty*
|
||||||
|
⠀⠀⠀⠀⠀⠀⠀⠀⢀⣤⠞⠁⠀⠀⠀⠀⠀⠀⠀⠀⡠⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠈⠻⣏⠀⠀⠀⣶⣿⣿⡇⠀⠀⢏⡞
|
||||||
|
⠀⠀⠀⠀⠀⠀⢀⡴⠛⠀⠀⠀⠀⠀⠀⠀⠀⢀⢀⡾⠁⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠘⢦⣤⣾⣿⣿⠋⠀⠀⡀⣾⠁
|
||||||
|
⠀⠀⠀⠀⠀⣠⠟⠁⠀⠀⠀⣀⠀⠀⠀⠀⢀⡟⠈⢀⣤⠂⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠉⠙⣏⡁⠀⠐⠚⠃⣿⠀
|
||||||
|
⠀⠀⠀⠀⣴⠋⠀⠀⠀⡴⣿⣿⡟⣷⠀⠀⠊⠀⠴⠛⠁⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠙⠀⠀⠀⠀⢹⡆
|
||||||
|
⠀⠀⠀⣴⠃⠀⠀⠀⠀⣇⣿⣿⣿⠃⠀⠀⠀⠀⠀⠀⠀⠀⢀⣤⡶⢶⣶⣄⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⡇
|
||||||
|
*very sadge*⠀⠀⣸⠃⠀⠀⠀⢠⠀⠊⠛⠉⠁⠀⠀⠀⠀⠀⠀⠀⢲⣾⣿⡏⣾⣿⣿⣿⣿⠖⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢧
|
||||||
|
⠀⢠⡇⠀⠀⠀⠀⠈⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠈⠈⠛⠿⣽⣿⡿⠏⠁⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⡜
|
||||||
|
⢀⡿⠀⠀⠀⠀⢀⣤⣶⣟⣶⣦⣄⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⡇
|
||||||
|
⢸⠇⠀⠀⠀⠀⣿⣿⣿⣿⣿⣿⣿⣿⣧⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⡇
|
||||||
|
⣼⠀⢀⡀⠀⠀⢷⣿⣿⣿⣿⣿⣿⡿⠁⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢠⡇
|
||||||
|
⡇⠀⠈⠀⠀⠀⣬⠻⣿⣿⣿⡿⠙⠀⠀⢀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣼⠁
|
||||||
|
⢹⡀⠀⠀⠀⠈⣿⣶⣿⣿⣝⡛⢳⠭⠍⠉⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢰⠃⠀
|
||||||
|
⠸⡇⠀⠀⠀⠀⠙⣿⣿⣿⣿⣿⣿⣷⣦⣀⣀⣀⣤⣤⣴⡶⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣰⠇⠀⠀
|
||||||
|
⠀⢿⡄⠀⠀⠀⠀⠀⠙⣇⠉⠉⠙⠛⠻⠟⠛⠛⠉⠙⠉⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⡰⠋⠀⠀⠀
|
||||||
|
⠀⠈⢧⠀⠀⠀⠀⠀⠀⠈⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣠⠞⠁⠀⠀⠀⠀
|
||||||
|
⠀⠀⠘⢷⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣠⠞⠁⠀⠀⠀⠀⠀⠀
|
||||||
|
⠀⠀⠀⠀⠱⢆⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣀⡴⠋⠁⠀⠀⠀⠀⠀⠀⠀⠀
|
||||||
|
⠀⠀⠀⠀⠀⠀⠛⢦⣀⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣀⣠⠴⠟⠁ *many space*
|
||||||
|
⠀⠀⠀⠀⠀⠀⠀⠀⠈⠛⠲⠤⣤⣤⣤⣄⠀⠀⠀⠀⠀⠀⠀⢠⣤⣤⠤⠴⠒⠛⠋⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
|
||||||
|
</pre>
|
||||||
|
{/if}
|
||||||
{#each Object.keys(paths) as pathName, index}
|
{#each Object.keys(paths) as pathName, index}
|
||||||
<PathListItem {pathName} id={index} />
|
<PathListItem {pathName} id={index} />
|
||||||
{/each}
|
{/each}
|
||||||
|
|||||||
@@ -30,6 +30,7 @@ export const blankSpec: OpenAPIV3_1.Document = {
|
|||||||
},
|
},
|
||||||
servers: [],
|
servers: [],
|
||||||
paths: {},
|
paths: {},
|
||||||
|
webhooks: {},
|
||||||
components: {},
|
components: {},
|
||||||
security: [],
|
security: [],
|
||||||
tags: [],
|
tags: [],
|
||||||
|
|||||||
@@ -10,7 +10,12 @@
|
|||||||
$: console.log($apiSpecs);
|
$: console.log($apiSpecs);
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<AppRail width="w-28" aspectRatio="aspect-[3/2]" background="variant-ghost-surface" border="ring-0">
|
<AppRail
|
||||||
|
width="w-28"
|
||||||
|
aspectRatio="aspect-[20/14]"
|
||||||
|
background="variant-ghost-surface"
|
||||||
|
border="ring-0"
|
||||||
|
>
|
||||||
<svelte:fragment slot="lead">
|
<svelte:fragment slot="lead">
|
||||||
<div>
|
<div>
|
||||||
<AppRailAnchor href="/">
|
<AppRailAnchor href="/">
|
||||||
@@ -76,7 +81,7 @@
|
|||||||
d="M15.75 5.25a3 3 0 0 1 3 3m3 0a6 6 0 0 1-7.029 5.912c-.563-.097-1.159.026-1.563.43L10.5 17.25H8.25v2.25H6v2.25H2.25v-2.818c0-.597.237-1.17.659-1.591l6.499-6.499c.404-.404.527-1 .43-1.563A6 6 0 1 1 21.75 8.25Z"
|
d="M15.75 5.25a3 3 0 0 1 3 3m3 0a6 6 0 0 1-7.029 5.912c-.563-.097-1.159.026-1.563.43L10.5 17.25H8.25v2.25H6v2.25H2.25v-2.818c0-.597.237-1.17.659-1.591l6.499-6.499c.404-.404.527-1 .43-1.563A6 6 0 1 1 21.75 8.25Z"
|
||||||
/>
|
/>
|
||||||
</svg>
|
</svg>
|
||||||
Authentication
|
Security
|
||||||
</AppRailAnchor>
|
</AppRailAnchor>
|
||||||
<AppRailAnchor href="/paths" selected={$page.url.pathname === '/paths'}>
|
<AppRailAnchor href="/paths" selected={$page.url.pathname === '/paths'}>
|
||||||
<svg
|
<svg
|
||||||
@@ -95,6 +100,40 @@
|
|||||||
</svg>
|
</svg>
|
||||||
Paths
|
Paths
|
||||||
</AppRailAnchor>
|
</AppRailAnchor>
|
||||||
|
<AppRailAnchor href="/webhooks" selected={$page.url.pathname === '/webhooks'}>
|
||||||
|
<svg
|
||||||
|
xmlns="http://www.w3.org/2000/svg"
|
||||||
|
fill="none"
|
||||||
|
viewBox="0 0 24 24"
|
||||||
|
stroke-width="1.5"
|
||||||
|
stroke="currentColor"
|
||||||
|
class="size-6 mx-auto"
|
||||||
|
>
|
||||||
|
<path
|
||||||
|
stroke-linecap="round"
|
||||||
|
stroke-linejoin="round"
|
||||||
|
d="M12 21a9.004 9.004 0 0 0 8.716-6.747M12 21a9.004 9.004 0 0 1-8.716-6.747M12 21c2.485 0 4.5-4.03 4.5-9S14.485 3 12 3m0 18c-2.485 0-4.5-4.03-4.5-9S9.515 3 12 3m0 0a8.997 8.997 0 0 1 7.843 4.582M12 3a8.997 8.997 0 0 0-7.843 4.582m15.686 0A11.953 11.953 0 0 1 12 10.5c-2.998 0-5.74-1.1-7.843-2.918m15.686 0A8.959 8.959 0 0 1 21 12c0 .778-.099 1.533-.284 2.253m0 0A17.919 17.919 0 0 1 12 16.5c-3.162 0-6.133-.815-8.716-2.247m0 0A9.015 9.015 0 0 1 3 12c0-1.605.42-3.113 1.157-4.418"
|
||||||
|
/>
|
||||||
|
</svg>
|
||||||
|
Webhooks
|
||||||
|
</AppRailAnchor>
|
||||||
|
<AppRailAnchor href="/components" selected={$page.url.pathname === '/components'}>
|
||||||
|
<svg
|
||||||
|
xmlns="http://www.w3.org/2000/svg"
|
||||||
|
fill="none"
|
||||||
|
viewBox="0 0 24 24"
|
||||||
|
stroke-width="1.5"
|
||||||
|
stroke="currentColor"
|
||||||
|
class="size-6 mx-auto"
|
||||||
|
>
|
||||||
|
<path
|
||||||
|
stroke-linecap="round"
|
||||||
|
stroke-linejoin="round"
|
||||||
|
d="m20.25 7.5-.625 10.632a2.25 2.25 0 0 1-2.247 2.118H6.622a2.25 2.25 0 0 1-2.247-2.118L3.75 7.5M10 11.25h4M3.375 7.5h17.25c.621 0 1.125-.504 1.125-1.125v-1.5c0-.621-.504-1.125-1.125-1.125H3.375c-.621 0-1.125.504-1.125 1.125v1.5c0 .621.504 1.125 1.125 1.125Z"
|
||||||
|
/>
|
||||||
|
</svg>
|
||||||
|
Components
|
||||||
|
</AppRailAnchor>
|
||||||
<AppRailAnchor href="/stats" selected={$page.url.pathname === '/stats'}>
|
<AppRailAnchor href="/stats" selected={$page.url.pathname === '/stats'}>
|
||||||
<svg
|
<svg
|
||||||
xmlns="http://www.w3.org/2000/svg"
|
xmlns="http://www.w3.org/2000/svg"
|
||||||
|
|||||||
7
src/routes/components/+page.svelte
Normal file
7
src/routes/components/+page.svelte
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
<script lang="ts">
|
||||||
|
import type { PageData } from './$types';
|
||||||
|
|
||||||
|
export let data: PageData;
|
||||||
|
</script>
|
||||||
|
|
||||||
|
components/+page.svelte
|
||||||
@@ -3,3 +3,5 @@
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<Info />
|
<Info />
|
||||||
|
|
||||||
|
<!-- TODO: Tags and External Documentation -->
|
||||||
|
|||||||
7
src/routes/webhooks/+page.svelte
Normal file
7
src/routes/webhooks/+page.svelte
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
<script lang="ts">
|
||||||
|
import type { PageData } from './$types';
|
||||||
|
|
||||||
|
export let data: PageData;
|
||||||
|
</script>
|
||||||
|
|
||||||
|
webhooks/+page.svelte
|
||||||
Reference in New Issue
Block a user