Skip to content

Elysia OpenAPI doens't work with zod union #283

@Vicentesan

Description

@Vicentesan

Based on the following code, Swagger does not return the response object on the /openapi page:

Image
import { Elysia } from 'elysia'
import { openapi } from '@elysiajs/openapi'
import { z } from 'zod'

const app = new Elysia()
  .use(openapi({ mapJsonSchema: { zod: z.toJSONSchema } }))
  .get('/hey', c => c.status(200, 'hey'), {
    response: {
      200: z.union([z.literal('hey'), z.undefined()]),
    },
  });

app.listen(3000);

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions