Redundant wrapper in schema created by cli?

In a Cloudflare worker project created from cli, I get a hono server created, and the response to TaskFetch endpoint is described with this openApi schema:
responses: {
"200": {
description: "Returns a single task if found",
content: {
"application/json": {
schema: z.object({
series: z.object({
success: Bool(),
result: z.object({
task: Task,
}),
}),
}),
},
},
},
"404": {
description: "Task not found",
content: {
"application/json": {
schema: z.object({
series: z.object({
success: Bool(),
error: Str(),
}),
}),
},
},
},
}
responses: {
"200": {
description: "Returns a single task if found",
content: {
"application/json": {
schema: z.object({
series: z.object({
success: Bool(),
result: z.object({
task: Task,
}),
}),
}),
},
},
},
"404": {
description: "Task not found",
content: {
"application/json": {
schema: z.object({
series: z.object({
success: Bool(),
error: Str(),
}),
}),
},
},
},
}
The endpoint returns this:
return {
success: true,
task: {
name: "my task",
slug: taskSlug,
description: "this needs to be done",
completed: false,
due_date: new Date().toISOString().slice(0, 10),
},
};
return {
success: true,
task: {
name: "my task",
slug: taskSlug,
description: "this needs to be done",
completed: false,
due_date: new Date().toISOString().slice(0, 10),
},
};
I'm trying to understand what does series in the schema means, because I don't see it in the response. In the TaskList endpoint there's also an additional wrapper:
schema: z.object({
series: z.object({
success: Bool(),
result: z.object({
tasks: Task.array(),
}),
}),
})
schema: z.object({
series: z.object({
success: Bool(),
result: z.object({
tasks: Task.array(),
}),
}),
})
both series and result do not appear to be part of the response.:
return {
success: true,
tasks: [
{
name: "Clean my room",
slug: "clean-room",
description: null,
completed: false,
due_date: "2025-01-05",
},
{
name: "Build something awesome with Cloudflare Workers",
slug: "cloudflare-workers",
description: "Lorem Ipsum",
completed: true,
due_date: "2022-12-24",
},
],
};
return {
success: true,
tasks: [
{
name: "Clean my room",
slug: "clean-room",
description: null,
completed: false,
due_date: "2025-01-05",
},
{
name: "Build something awesome with Cloudflare Workers",
slug: "cloudflare-workers",
description: "Lorem Ipsum",
completed: true,
due_date: "2022-12-24",
},
],
};
0 Replies
No replies yetBe the first to reply to this messageJoin
Want results from more Discord servers?
Add your server