feature/add route parameters (#18)

* add package manager field to package json

* Remove TODO

* design rework and path basics

* update packagemanager

* remove package manager
This commit is contained in:
Malte Teichert
2024-05-24 19:31:38 +02:00
committed by GitHub
parent 55eeb50276
commit 9dad6d9b32
19 changed files with 2821 additions and 1933 deletions

View File

@@ -1,59 +1,41 @@
<script lang="ts">
import { addPath } from '$lib';
import { openApiStore, pathRegex, sortPathsAlphabetically } from '$lib';
import { pathTemplate } from '$lib/pathTemplate';
import { openApiStore, sortPathsAlphabetically } from '$lib';
import type { OpenAPIV3 } from '$lib/openAPITypes';
import PathListItem from '../atoms/PathListItem.svelte';
import PathButtons from '../atoms/PathButtons.svelte';
import { getModalStore } from '@skeletonlabs/skeleton';
let paths: OpenAPIV3.PathsObject = {};
// @ts-expect-error - working with a potentially empty object
openApiStore.subscribe((store) => (paths = store.paths));
const modalStore = getModalStore();
// match path with parameters
// add path
// const addPath = () => {
// // prompt user to enter path
// const path = prompt(
// 'Enter path. Wrap path parameters in curly braces. Example: /users/{userId}'
// );
// if (!path) return;
// // check if path is valid
// if (!pathRegex.test(path)) {
// alert('Invalid path');
// return;
// }
// // check if path already exists
// // @ts-expect-error - we are working with an initially empty object
// if ($openApiStore.paths[path]) {
// alert('Path already exists');
// return;
// }
// // create a temporary object to store paths
// // add path to paths object
// $openApiStore.paths = {
// ...$openApiStore.paths,
// [path]: pathTemplate
// };
// // sort paths alphabetically
// sortPathsAlphabetically();
// };
</script>
<div
class="container mx-auto border-token rounded-container-token bg-surface-backdrop-token px-6 py-4 min-h-20 space-y-3"
class="container mx-auto border-token rounded-container-token bg-surface-backdrop-token px-6 py-4 space-y-4"
>
{#if Object.keys($openApiStore.paths).length > 0}
<PathButtons />
<hr />
{#each Object.keys($openApiStore.paths) as pathName, index}
<PathListItem {pathName} id={index} />
{/each}
<PathButtons />
{:else}
<PathButtons justify="justify-center" sort={false} />
{/if}
{#each Object.keys(paths) as pathName, index}
<PathListItem {pathName} id={index} />
{/each}
<span class="w-full flex justify-center">
<button
type="button"
class="btn variant-filled-primary"
on:click={() => {
addPath(modalStore);
}}
>
Add Path
</button>
</span>
<span class="w-full flex justify-center">
<button
type="button"
class="btn btn-sm variant-filled-secondary"
on:click={sortPathsAlphabetically}
>
Sort paths
</button>
</span>
</div>