Skip to content

bug: setting tags on only one API cause error on openapi page #273

@marcalexiei

Description

@marcalexiei

Description

When the only entry point in the project is assigned tags that match those specified in the exclude.tags option,
the documentation will not be generated.

Reproduction

Consider the following code

import Elysia from "elysia";
import openapi from "@elysiajs/openapi";

export const app = new Elysia()
  .use(
    openapi({
      exclude: {
        tags: ["internal"],
      },
    })
  )
  .get("/", () => "index")
  .get("/healthz", () => ({ status: "ok" }), {
    detail: {
      tags: ["internal"],
    },
  })
  .listen(3000);
  1. Run the server
  2. Open http://localhost:3000/openapi
  3. Check logs and page
Server logs

[@elysiajs/openapi] error at specPath
TypeError: undefined is not an object (evaluating 'hooks.detail.tags')
      at toOpenAPISchema (__/node_modules/@elysiajs/openapi/dist/index.mjs:2895:30)
      at openAPISchema (__/node_modules/@elysiajs/openapi/dist/index.mjs:9354:9)
      at handle (file://__/node_modules/elysia/dist/bun/index.js:6:76)
      at handle (file://__/node_modules/elysia/dist/bun/index.js:6:80)
      at map (file://__/node_modules/elysia/dist/bun/index.js:4:38)

[@elysiajs/openapi] error at specPath
TypeError: undefined is not an object (evaluating 'hooks.detail.tags')
      at toOpenAPISchema (__/node_modules/@elysiajs/openapi/dist/index.mjs:2895:30)
      at openAPISchema (__/node_modules/@elysiajs/openapi/dist/index.mjs:9354:9)
      at handle (file://__/node_modules/elysia/dist/bun/index.js:6:76)
      at handle (file://__/node_modules/elysia/dist/bun/index.js:6:80)
      at map (file://__/node_modules/elysia/dist/bun/index.js:4:38)

Screenshot

Image

Specs

  System:
    OS: macOS 26.0.1
    CPU: (8) arm64 Apple M3
    Memory: 426.36 MB / 16.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 24.9.0
    Yarn: 1.22.22 
    npm: 11.6.0 
    pnpm: 10.18.1
    bun: 1.2.23
  npmPackages:
    @elysiajs/openapi: ^1.4.11 => 1.4.11 
    elysia: latest => 1.4.9 

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