Skip to content

bug: OpenAPI spec (JSON) not served on nested paths.Β #301

@staciax

Description

@staciax

Works fine on a simple path like /a β€” JSON spec loads, endpoints and schemas show up.

But when I try a nested path like /a/b, the docs page loads, but the spec fails to load. Console shows it trying /a/a/b/json instead of /a/b/json, so nothing shows in the UI.

Looks like the plugin is calculating the spec URL wrong for nested routes.

src/index.ts

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

new Elysia()
    .use(openapi({
        path: '/a/b'
    }))
    .get('/', () => 'hi', { response: t.String({ description: 'sample description' }) })
    .listen(8080);

version

  "dependencies": {
    "@elysiajs/openapi": "~1.4.11",
    "elysia": "~1.4.16"
  }

console

standalone.js:34920 @scalar/[email protected] standalone.js:34618 [CLIENT]: Client element changed. Unmounting client... 
standalone.js:34618 [CLIENT]: Client element changed. Mounting client...
standalone.js:34771 GET http://localhost:8080/a/a/b/json 404 (Not Found)
Image

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