fix: openapi schema
This commit is contained in:
@@ -15,6 +15,20 @@ import { Title } from "~/types/title";
|
||||
import { getUser } from "./getUser";
|
||||
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({
|
||||
tags: ["aniplay", "auth"],
|
||||
summary:
|
||||
@@ -23,18 +37,19 @@ const route = createRoute({
|
||||
method: "get",
|
||||
path: "/",
|
||||
request: {
|
||||
query: z.object({
|
||||
token: z.string(),
|
||||
deviceId: z.string(),
|
||||
// "x-anilist-token": z.string(),
|
||||
// "x-aniplay-device-id": z.string(),
|
||||
headers: z.object({
|
||||
"x-anilist-token": z.string(),
|
||||
"x-aniplay-device-id": z.string(),
|
||||
}),
|
||||
},
|
||||
responses: {
|
||||
200: {
|
||||
content: {
|
||||
"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",
|
||||
@@ -77,7 +92,7 @@ app.openapi(route, async (c) => {
|
||||
await associateDeviceIdWithUsername(
|
||||
env(c, "workerd"),
|
||||
deviceId!,
|
||||
user.name,
|
||||
user.name!,
|
||||
);
|
||||
|
||||
return streamSSE(
|
||||
|
||||
Reference in New Issue
Block a user