feat(api): Add OpenAPI visualizer
Some checks failed
CodeQL Scan / Analyze (javascript-typescript) (push) Failing after 53s
Build Docker Images / lint (push) Failing after 10s
Build Docker Images / check (push) Failing after 10s
Build Docker Images / tests (push) Failing after 6s
Build Docker Images / build (server, Dockerfile, ${{ github.repository_owner }}/server) (push) Has been skipped
Build Docker Images / build (worker, Worker.Dockerfile, ${{ github.repository_owner }}/worker) (push) Has been skipped
Deploy Docs to GitHub Pages / build (push) Failing after 5s
Mirror to Codeberg / Mirror (push) Failing after 0s
Deploy Docs to GitHub Pages / Deploy (push) Has been skipped
Nix Build / check (push) Failing after 5s

This commit is contained in:
Jesse Wierzbinski 2025-03-24 15:25:40 +01:00
parent 65e2e19ff1
commit c674a1309c
No known key found for this signature in database
32 changed files with 772 additions and 732 deletions

View file

@ -1,65 +1,67 @@
import { z } from "@hono/zod-openapi";
export const Application = z.object({
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()
.openapi({
description: "The website associated with your application.",
example: "https://app.example",
externalDocs: {
url: "https://docs.joinmastodon.org/entities/Application/#website",
},
}),
scopes: z
.array(z.string())
.default(["read"])
.openapi({
export const Application = z
.object({
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()
.openapi({
description: "The website associated with your application.",
example: "https://app.example",
externalDocs: {
url: "https://docs.joinmastodon.org/entities/Application/#website",
},
}),
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()
.or(z.literal("urn:ietf:wg:oauth:2.0:oob"))
.openapi({
description: "URL or 'urn:ietf:wg:oauth:2.0:oob'",
}),
)
.openapi({
description:
"The registered redirection URI(s) for your application.",
externalDocs: {
url: "https://docs.joinmastodon.org/entities/Application/#redirect_uris",
},
}),
redirect_uri: z.string().openapi({
deprecated: true,
description:
"The scopes for your application. This is the registered scopes string split on whitespace.",
example: ["read", "write", "push"],
"The registered redirection URI(s) for your application. May contain \\n characters when multiple redirect URIs are registered.",
externalDocs: {
url: "https://docs.joinmastodon.org/entities/Application/#scopes",
url: "https://docs.joinmastodon.org/entities/Application/#redirect_uri",
},
}),
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'",
}),
)
.openapi({
description:
"The registered redirection URI(s) for your application.",
externalDocs: {
url: "https://docs.joinmastodon.org/entities/Application/#redirect_uris",
},
}),
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: {
url: "https://docs.joinmastodon.org/entities/Application/#redirect_uri",
},
}),
});
})
.openapi("Application");
export const CredentialApplication = Application.extend({
client_id: z.string().openapi({
@ -81,4 +83,4 @@ export const CredentialApplication = Application.extend({
url: "https://docs.joinmastodon.org/entities/CredentialApplication/#client_secret_expires_at",
},
}),
});
}).openapi("CredentialApplication");