Skip to content

OpenAPI: schemas defined via guard() are missing from generated spec #1490

@omer-os

Description

@omer-os

What version of Elysia is running?

├── @elysiajs/jwt@1.4.0 ├── @elysiajs/openapi@1.4.11 ├── @prisma/client@6.17.1 ├── bun-types@1.3.0 ├── elysia@1.4.12 └── prismabox@1.1.25

What platform is your computer?

Linux 6.14.0-33-generic x86_64 x86_64

What environment are you using

Using Bun 1.3.0

Are you using dynamic mode?

no

What steps can reproduce the bug?

Minimal app:

import { Elysia, t } from "elysia";
import { openapi } from "@elysiajs/openapi";

export const app = new Elysia()
  .guard(
    {
      body: t.Object({
        username: t.String(),
        password: t.String(),
      }),
    },
    (app) =>
      app
        .post("/sign-up", ({ body }) => body)
        .post("/sign-in", ({ body }) => body),
  )
  .get("/", "hi")
  .use(
    openapi({
      path: "/docs",
      documentation: {
        info: { title: "Elysia API Documentation", version: "1.0.0" },
      },
    }),
  )
  .listen(3000);

Start server then check the /docs

What is the expected behavior?

/docs includes requestBody schemas for /sign-up and /sign-in inherited from the guard() block

What do you see instead?

docs shows the paths but no requestBody or component schema for those routes

Additional information

Code and types and everything work at runtime and vscode Ide. i can see types and everything.

Have you try removing the node_modules and bun.lockb and try again yet?

yes

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions