fix: openapi schema
This commit is contained in:
@@ -15,6 +15,20 @@ import { Title } from "~/types/title";
|
|||||||
import { getUser } from "./getUser";
|
import { getUser } from "./getUser";
|
||||||
import { getWatchingTitles } from "./getWatchingTitles";
|
import { getWatchingTitles } from "./getWatchingTitles";
|
||||||
|
|
||||||
|
const UserSchema = z.object({
|
||||||
|
name: z.string(),
|
||||||
|
avatar: z.object({
|
||||||
|
medium: z.string().nullable(),
|
||||||
|
large: z.string(),
|
||||||
|
}),
|
||||||
|
statistics: z.object({
|
||||||
|
minutesWatched: z.number().openapi({ type: "integer", format: "int64" }),
|
||||||
|
episodesWatched: z.number().int(),
|
||||||
|
count: z.number().int(),
|
||||||
|
meanScore: z.number().openapi({ type: "number", format: "float" }),
|
||||||
|
}),
|
||||||
|
});
|
||||||
|
|
||||||
const route = createRoute({
|
const route = createRoute({
|
||||||
tags: ["aniplay", "auth"],
|
tags: ["aniplay", "auth"],
|
||||||
summary:
|
summary:
|
||||||
@@ -23,18 +37,19 @@ const route = createRoute({
|
|||||||
method: "get",
|
method: "get",
|
||||||
path: "/",
|
path: "/",
|
||||||
request: {
|
request: {
|
||||||
query: z.object({
|
headers: z.object({
|
||||||
token: z.string(),
|
"x-anilist-token": z.string(),
|
||||||
deviceId: z.string(),
|
"x-aniplay-device-id": z.string(),
|
||||||
// "x-anilist-token": z.string(),
|
|
||||||
// "x-aniplay-device-id": z.string(),
|
|
||||||
}),
|
}),
|
||||||
},
|
},
|
||||||
responses: {
|
responses: {
|
||||||
200: {
|
200: {
|
||||||
content: {
|
content: {
|
||||||
"text/event-stream": {
|
"text/event-stream": {
|
||||||
schema: z.object({ title: Title, episodes: EpisodesResponseSchema }),
|
schema: z.union([
|
||||||
|
z.object({ title: Title, episodes: EpisodesResponseSchema }),
|
||||||
|
UserSchema,
|
||||||
|
]),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
description: "Streams a list of titles",
|
description: "Streams a list of titles",
|
||||||
@@ -77,7 +92,7 @@ app.openapi(route, async (c) => {
|
|||||||
await associateDeviceIdWithUsername(
|
await associateDeviceIdWithUsername(
|
||||||
env(c, "workerd"),
|
env(c, "workerd"),
|
||||||
deviceId!,
|
deviceId!,
|
||||||
user.name,
|
user.name!,
|
||||||
);
|
);
|
||||||
|
|
||||||
return streamSSE(
|
return streamSSE(
|
||||||
|
|||||||
Reference in New Issue
Block a user