From 93547ea0abd51d0214337657acad8241986bf583 Mon Sep 17 00:00:00 2001 From: JacobLinCool Date: Sun, 25 Jun 2023 02:07:43 +0800 Subject: [PATCH] feat: add operation id for submit --- package.json | 3 +-- pnpm-lock.yaml | 8 ++++---- src/api/auth/shared.ts | 4 ++-- src/api/problem/shared.ts | 4 ++-- src/api/submission/POST.ts | 5 +++-- src/api/submission/shared.ts | 4 ++-- src/routes/api/+server.ts | 2 +- 7 files changed, 15 insertions(+), 15 deletions(-) diff --git a/package.json b/package.json index 6d2aa35..853625c 100644 --- a/package.json +++ b/package.json @@ -1,5 +1,4 @@ { - "private": true, "name": "@wasm-oj/wonderland", "version": "0.0.1", "type": "module", @@ -67,7 +66,7 @@ "svelte-check": "^3.4.3", "svelte-i18n": "^3.6.0", "svelte-markdown": "^0.2.3", - "sveltekit-api": "^0.2.11", + "sveltekit-api": "^0.2.12", "sveltekit-jwt": "^0.2.0", "sveltekit-superforms": "^1.0.0-rc.4", "tailwindcss": "^3.3.2", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 68ab742..704e2fb 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -125,8 +125,8 @@ devDependencies: specifier: ^0.2.3 version: 0.2.3(svelte@3.59.1) sveltekit-api: - specifier: ^0.2.11 - version: 0.2.11(@sveltejs/kit@1.20.2)(svelte@3.59.1) + specifier: ^0.2.12 + version: 0.2.12(@sveltejs/kit@1.20.2)(svelte@3.59.1) sveltekit-jwt: specifier: ^0.2.0 version: 0.2.0(svelte@3.59.1) @@ -6551,10 +6551,10 @@ packages: engines: { node: ">= 8" } dev: true - /sveltekit-api@0.2.11(@sveltejs/kit@1.20.2)(svelte@3.59.1): + /sveltekit-api@0.2.12(@sveltejs/kit@1.20.2)(svelte@3.59.1): resolution: { - integrity: sha512-pG1HTFm1lxgt/P8uhSU9CnfmFAslt5ope2Z/8PEalDuyEb4tfK0zI18oBMXoXhpos9CBHlVWSBGChAinsW+ICA==, + integrity: sha512-78UAo9s156NWleTXfK2sh+wQVdfkuospY4fiDZ7WCli993c2PaeoksI7wkQ+notYVikFQ3lwLc68dgvMIUo7ug==, } peerDependencies: "@sveltejs/kit": ^1.0.0 diff --git a/src/api/auth/shared.ts b/src/api/auth/shared.ts index 8938eb6..44697ba 100644 --- a/src/api/auth/shared.ts +++ b/src/api/auth/shared.ts @@ -1,6 +1,6 @@ -import type { RouteConfig } from "sveltekit-api"; +import type { RouteModifier } from "sveltekit-api"; -export const Modifier = (r: RouteConfig) => { +export const Modifier: RouteModifier = (r) => { r.tags = ["Auth"]; return r; }; diff --git a/src/api/problem/shared.ts b/src/api/problem/shared.ts index dac99c3..789c98d 100644 --- a/src/api/problem/shared.ts +++ b/src/api/problem/shared.ts @@ -1,6 +1,6 @@ -import type { RouteConfig } from "sveltekit-api"; +import type { RouteModifier } from "sveltekit-api"; -export const Modifier = (r: RouteConfig) => { +export const Modifier: RouteModifier = (r) => { r.tags = ["Problem"]; return r; }; diff --git a/src/api/submission/POST.ts b/src/api/submission/POST.ts index ea7a6e5..7aea633 100644 --- a/src/api/submission/POST.ts +++ b/src/api/submission/POST.ts @@ -1,7 +1,7 @@ import { submit } from "$lib/server/submission"; import { sha256 } from "$lib/utils"; import { z } from "sveltekit-api"; -import type { RouteConfig } from "sveltekit-api"; +import type { RouteModifier } from "sveltekit-api"; import { error } from "@sveltejs/kit"; import type { RequestEvent } from "@sveltejs/kit"; import { Modifier as _Modifier } from "./shared"; @@ -25,9 +25,10 @@ export const Error = { 401: error(401, "Unauthorized"), }; -export const Modifier = (r: RouteConfig) => { +export const Modifier: RouteModifier = (r) => { _Modifier(r); r.security = [{ bearerAuth: [] }]; + r.operationId = "submit"; return r; }; diff --git a/src/api/submission/shared.ts b/src/api/submission/shared.ts index df04668..9adbdbe 100644 --- a/src/api/submission/shared.ts +++ b/src/api/submission/shared.ts @@ -1,6 +1,6 @@ -import type { RouteConfig } from "sveltekit-api"; +import type { RouteModifier } from "sveltekit-api"; -export const Modifier = (r: RouteConfig) => { +export const Modifier: RouteModifier = (r) => { r.tags = ["Submission"]; return r; }; diff --git a/src/routes/api/+server.ts b/src/routes/api/+server.ts index 07016ff..035847b 100644 --- a/src/routes/api/+server.ts +++ b/src/routes/api/+server.ts @@ -4,5 +4,5 @@ import type { RequestHandler } from "./$types"; export const GET = (async ({ url }) => { const doc = new URL(url); doc.pathname = "/api/openapi.json"; - throw redirect(301, `https://api-spec.pages.dev/x?url=${doc.toString()}`); + throw redirect(301, `https://api-spec.pages.dev/rapidoc?url=${doc.toString()}`); }) satisfies RequestHandler;