Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[zod-openapi] streamSSE from hono/streaming together with @hono/zod-openapi have type issues #735

Open
sebastianwessel opened this issue Sep 9, 2024 · 1 comment

Comments

@sebastianwessel
Copy link

Think it is related to this: #374

Issue:

The return type of streamSSE does not match and typsescript is complaining

Example:

const chatRoute = createRoute({
  method: 'post',
  path: '/{projectId}/chat',
  security: [{ Bearer: [] }],
  description: 'Send a message to the project chat and receive a response via SSE',
  request: {
    params: z.object({
      projectId: z.string().describe('The ID of the project'),
    }),
    body: {
      content: {
        'application/json': {
          schema: z.object({
            message: z.string().describe('The message to send'),
            conversationId: z
              .string()
              .optional()
              .describe('The ID of the conversation, if continuing an existing one'),
          }),
        },
      },
    },
  },
  responses: {
    200: {
      description: 'Successful response with SSE stream',
      content: {
        'text/event-stream': {
          schema: z.object({
            event: z.enum(['start', 'token', 'end', 'error']),
            data: z.string(),
          }),
        },
      },
    },
    ...errorResponse,
  },
})

app.openapi(chatRoute, async (c) => {
  return streamSSE(c, async (stream) => {
   [...]
  })
})
@yusukebe
Copy link
Member

This related to honojs/hono#3309

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants