refactor: ⬆️ Upgrade to Zod v4 and hono-openapi 0.5.0

This commit is contained in:
Jesse Wierzbinski 2025-07-07 03:42:35 +02:00
parent add2429606
commit 24d4150da4
No known key found for this signature in database
209 changed files with 1331 additions and 1622 deletions

View file

@ -1,4 +1,4 @@
import { z } from "zod";
import { z } from "zod/v4";
export const Application = z
.object({
@ -7,7 +7,7 @@ export const Application = z
.trim()
.min(1)
.max(200)
.openapi({
.meta({
description: "The name of your application.",
example: "Test Application",
externalDocs: {
@ -17,7 +17,7 @@ export const Application = z
website: z
.string()
.nullable()
.openapi({
.meta({
description: "The website associated with your application.",
example: "https://app.example",
externalDocs: {
@ -27,7 +27,7 @@ export const Application = z
scopes: z
.array(z.string())
.default(["read"])
.openapi({
.meta({
description:
"The scopes for your application. This is the registered scopes string split on whitespace.",
example: ["read", "write", "push"],
@ -37,22 +37,18 @@ export const Application = z
}),
redirect_uris: z
.array(
z
.string()
.url()
.or(z.literal("urn:ietf:wg:oauth:2.0:oob"))
.openapi({
description: "URL or 'urn:ietf:wg:oauth:2.0:oob'",
}),
z.url().or(z.literal("urn:ietf:wg:oauth:2.0:oob")).meta({
description: "URL or 'urn:ietf:wg:oauth:2.0:oob'",
}),
)
.openapi({
.meta({
description:
"The registered redirection URI(s) for your application.",
externalDocs: {
url: "https://docs.joinmastodon.org/entities/Application/#redirect_uris",
},
}),
redirect_uri: z.string().openapi({
redirect_uri: z.string().meta({
deprecated: true,
description:
"The registered redirection URI(s) for your application. May contain \\n characters when multiple redirect URIs are registered.",
@ -61,30 +57,30 @@ export const Application = z
},
}),
})
.openapi({
ref: "Application",
.meta({
id: "Application",
});
export const CredentialApplication = Application.extend({
client_id: z.string().openapi({
client_id: z.string().meta({
description: "Client ID key, to be used for obtaining OAuth tokens",
externalDocs: {
url: "https://docs.joinmastodon.org/entities/CredentialApplication/#client_id",
},
}),
client_secret: z.string().openapi({
client_secret: z.string().meta({
description: "Client secret key, to be used for obtaining OAuth tokens",
externalDocs: {
url: "https://docs.joinmastodon.org/entities/CredentialApplication/#client_secret",
},
}),
client_secret_expires_at: z.string().openapi({
client_secret_expires_at: z.string().meta({
description:
"When the client secret key will expire at, presently this always returns 0 indicating that OAuth Clients do not expire",
externalDocs: {
url: "https://docs.joinmastodon.org/entities/CredentialApplication/#client_secret_expires_at",
},
}),
}).openapi({
ref: "CredentialApplication",
}).meta({
id: "CredentialApplication",
});