mirror of
https://github.com/versia-pub/server.git
synced 2026-03-13 05:49:16 +01:00
refactor(api): 🏷️ Port more misc endpoints to use new schemas
Some checks failed
Mirror to Codeberg / Mirror (push) Failing after 0s
Some checks failed
Mirror to Codeberg / Mirror (push) Failing after 0s
This commit is contained in:
parent
e3e285571e
commit
247a8fbce3
16 changed files with 462 additions and 351 deletions
|
|
@ -1,13 +1,18 @@
|
|||
import { z } from "@hono/zod-openapi";
|
||||
|
||||
export const Application = z.object({
|
||||
name: z.string().openapi({
|
||||
description: "The name of your application.",
|
||||
example: "Test Application",
|
||||
externalDocs: {
|
||||
url: "https://docs.joinmastodon.org/entities/Application/#name",
|
||||
},
|
||||
}),
|
||||
name: z
|
||||
.string()
|
||||
.trim()
|
||||
.min(1)
|
||||
.max(200)
|
||||
.openapi({
|
||||
description: "The name of your application.",
|
||||
example: "Test Application",
|
||||
externalDocs: {
|
||||
url: "https://docs.joinmastodon.org/entities/Application/#name",
|
||||
},
|
||||
}),
|
||||
website: z
|
||||
.string()
|
||||
.nullable()
|
||||
|
|
@ -18,19 +23,26 @@ export const Application = z.object({
|
|||
url: "https://docs.joinmastodon.org/entities/Application/#website",
|
||||
},
|
||||
}),
|
||||
scopes: z.array(z.string()).openapi({
|
||||
description:
|
||||
"The scopes for your application. This is the registered scopes string split on whitespace.",
|
||||
example: ["read", "write", "push"],
|
||||
externalDocs: {
|
||||
url: "https://docs.joinmastodon.org/entities/Application/#scopes",
|
||||
},
|
||||
}),
|
||||
scopes: z
|
||||
.array(z.string())
|
||||
.default(["read"])
|
||||
.openapi({
|
||||
description:
|
||||
"The scopes for your application. This is the registered scopes string split on whitespace.",
|
||||
example: ["read", "write", "push"],
|
||||
externalDocs: {
|
||||
url: "https://docs.joinmastodon.org/entities/Application/#scopes",
|
||||
},
|
||||
}),
|
||||
redirect_uris: z
|
||||
.array(
|
||||
z.string().url().openapi({
|
||||
description: "URL or 'urn:ietf:wg:oauth:2.0:oob'",
|
||||
}),
|
||||
z
|
||||
.string()
|
||||
.url()
|
||||
.or(z.literal("urn:ietf:wg:oauth:2.0:oob"))
|
||||
.openapi({
|
||||
description: "URL or 'urn:ietf:wg:oauth:2.0:oob'",
|
||||
}),
|
||||
)
|
||||
.openapi({
|
||||
description:
|
||||
|
|
@ -40,6 +52,7 @@ export const Application = z.object({
|
|||
},
|
||||
}),
|
||||
redirect_uri: z.string().openapi({
|
||||
deprecated: true,
|
||||
description:
|
||||
"The registered redirection URI(s) for your application. May contain \\n characters when multiple redirect URIs are registered.",
|
||||
externalDocs: {
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
import { emojiValidator } from "@/api.ts";
|
||||
import { z } from "@hono/zod-openapi";
|
||||
import { zBoolean } from "~/packages/config-manager/config.type";
|
||||
import { config } from "~/packages/config-manager/index.ts";
|
||||
import { Id } from "./common.ts";
|
||||
|
||||
export const CustomEmoji = z
|
||||
|
|
@ -9,13 +11,22 @@ export const CustomEmoji = z
|
|||
description: "ID of the custom emoji in the database.",
|
||||
example: "af9ccd29-c689-477f-aa27-d7d95fd8fb05",
|
||||
}),
|
||||
shortcode: z.string().openapi({
|
||||
description: "The name of the custom emoji.",
|
||||
example: "blobaww",
|
||||
externalDocs: {
|
||||
url: "https://docs.joinmastodon.org/entities/CustomEmoji/#shortcode",
|
||||
},
|
||||
}),
|
||||
shortcode: z
|
||||
.string()
|
||||
.trim()
|
||||
.min(1)
|
||||
.max(config.validation.max_emoji_shortcode_size)
|
||||
.regex(
|
||||
emojiValidator,
|
||||
"Shortcode must only contain letters (any case), numbers, dashes or underscores.",
|
||||
)
|
||||
.openapi({
|
||||
description: "The name of the custom emoji.",
|
||||
example: "blobaww",
|
||||
externalDocs: {
|
||||
url: "https://docs.joinmastodon.org/entities/CustomEmoji/#shortcode",
|
||||
},
|
||||
}),
|
||||
url: z
|
||||
.string()
|
||||
.url()
|
||||
|
|
@ -48,6 +59,8 @@ export const CustomEmoji = z
|
|||
}),
|
||||
category: z
|
||||
.string()
|
||||
.trim()
|
||||
.max(64)
|
||||
.nullable()
|
||||
.openapi({
|
||||
description: "Used for sorting custom emoji in the picker.",
|
||||
|
|
@ -64,6 +77,7 @@ export const CustomEmoji = z
|
|||
/* Versia Server API extension */
|
||||
description: z
|
||||
.string()
|
||||
.max(config.validation.max_emoji_description_size)
|
||||
.nullable()
|
||||
.openapi({
|
||||
description:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue