Skip to content

defineRouteMeta is ignored in nitro v3 (OpenAPI meta missing) #3899

Closed

Description

@medz

Describe the bug

In nitro commit fb6b85d (installed via https://pkg.pr.new/nitrojs/nitro@fb6b85d), route metadata defined via defineRouteMeta() is not reflected in OpenAPI output. When building with Vite, OpenAPI generation appears to be broken entirely (no openapi.json is generated). Non‑Vite builds still generate the file.

Reproduction

  1. Create a Nitro app with OpenAPI enabled:
export default defineConfig({
  experimental: { openAPI: true },
  openAPI: { route: '/_docs/openapi.json' }
});
  1. Add a route that defines OpenAPI meta:
import { defineRouteMeta } from 'nitro';
import { defineHandler } from 'nitro/h3';

defineRouteMeta({
  openAPI: {
    tags: ['Test'],
    summary: 'Test',
    responses: { 200: { description: 'OK' } }
  }
});

export default defineHandler(() => 'ok');
  1. Build with Vite and check /_docs/openapi.json.

Expected

The OpenAPI spec is generated at /_docs/openapi.json and includes route metadata (tags/summary/responses) plus any $global components defined via defineRouteMeta.

Actual

When using Vite to build, no openapi.json is generated at all. (Non‑Vite builds still generate it.)

Environment

  • Nitro: https://pkg.pr.new/nitrojs/nitro@fb6b85d (3.0.1-alpha.1)
  • Bun: 1.3.3 (macOS arm64)
  • Preset: cloudflare-module
  • Build: Vite (vite build)

Activity

  1. added
    vite
    on Dec 26, 2025
  2. medz commented on Jan 22, 2026

    @medz
    ContributorAuthor

    This feature was restored in version v3.0.1-alpha.2 (verified, it now functions correctly).

    Therefore, I will close this issue. ❤️

    I made a mistake in my verification. Rolldown works fine, but vite is still missing. 😂

  3. reopened this on Jan 22, 2026
  4. kyjus25 commented on Feb 26, 2026

    @kyjus25
    Contributor

    Same here with 3.0.1-alpha.2

    Swagger/Scalar working with Vite + Rolldown (8.0.0-beta.13) here, but defineRouteMeta is ignored :(

  5. krthr commented on Mar 13, 2026

    @krthr

    Same here with 3.0.260311-beta

    defineRouteMeta is ignored

  6. juane1000 commented on Apr 12, 2026

    @juane1000

    Same here. Completely ignored.

  7. kyjus25 commented on May 6, 2026

    @kyjus25
    Contributor

    Ignored in 3.0.260429-beta

  8. kyjus25 commented on Jun 5, 2026

    @kyjus25
    Contributor

    Ignored in 3.0.260603-beta

  9. changed the title [-]defineRouteMeta is ignored in nitro@fb6b85d (OpenAPI meta missing)[/-] [+]defineRouteMeta is ignored in nitro v3 (OpenAPI meta missing)[/+] on Jun 5, 2026
  10. medz commented on Jun 5, 2026

    @medz
    ContributorAuthor

    Ignored in 3.0.260603-beta

    Thank you for your continued attention to this issue. I've now reverted to writing my own Vite plugin and using Zod's registries to generate the openapi.json file. I really hope Nitro can fix this soon, and I recall there was a proposal for a dynamic value marriage proposal; it would be fantastic if Nitro could work with Zod to develop OpenAPI.

  11. kyjus25 commented on Jun 5, 2026

    @kyjus25
    Contributor

    Thank you for your continued attention to this issue

    Happy to help! I am waiting on it as well.

    I've opened a PR to fix the issue, easy fix in the Rollup/Rolldown plugin. Every other plugin intercepting import specifiers (virtual, raw) already uses order: "pre" for the same reason.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    vite

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions