Skip to content

Swagger UI "urls" config shows "No API definition provided." #1480

@frasergr

Description

@frasergr

Which middleware has the bug?

@hono/swagger-ui

What version of the middleware?

0.5.2

What version of Hono are you using?

4.9.8

What runtime/platform is your app running on? (with version if possible)

Node v20.19.2

What steps can reproduce the bug?

When using @hono/swagger-ui with the urls array, the UI renders but shows "No API definition provided." and does not auto-load a spec. Single url works as expected.

Environment

  • Node: v20.19.2 (also tested with Bun 1.2.21)
  • npm: 11.4.2
  • hono: 4.9.8
  • @hono/swagger-ui: 0.5.2
  • @hono/zod-openapi: 1.1.3

Steps

  1. Create routes with @hono/zod-openapi serving /v1/users/openapi.json and /v1/widgets/openapi.json.
  2. Mount Swagger UI with only "urls":
app.get('/docs', swaggerUI({
  urls: [
    { url: '/v1/users/openapi.json', name: 'Users API' },
    { url: '/v1/widgets/openapi.json', name: 'Widgets API' },
  ],
}))
  1. Navigate to /docs. UI shows "No API definition provided."

Repro

https://github.com/frasergr/hono-swagger-ui-issue-example

What is the expected behavior?

With urls provided, the first entry should auto-load and there should be a way to select other entries.

What do you see instead?

/docs UI shows "No API definition provided."

Additional information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions