middleware icon indicating copy to clipboard operation
middleware copied to clipboard

[@hono/swagger-ui] examples url generated by swagger are incorrect

Open Alex-us opened this issue 1 year ago • 3 comments

Which middleware has the bug?

@hono/swagger-ui

What version of the middleware?

0.5.1

What version of Hono are you using?

4.7.6

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

Bun

What steps can reproduce the bug?

Create openAPI spec with server:

const V1_PATH =${BASE_ROUTES.ROOT}${BASE_ROUTES.V1}; const url = ${process.env.API_URL || ''}${V1_PATH}`;

export const openAPIV1Spec = { documentation: { info: { ... }, servers: [ { url, description: ${process.env.NODE_ENV || 'development'} Server, }, ], } } ` Localy when I start bun server on my machne it is working just fine and example urls are correct. But when I deploy it on railway, it is duplicated paths for some reason

Image

Please let me know if you need additional info

What is the expected behavior?

No response

What do you see instead?

No response

Additional information

No response

Alex-us avatar Apr 12 '25 19:04 Alex-us

@Alex-us

What is the expected behavior? And this issue depends on the deployment environments (Railway), so it may be difficult to handle as our issue.

yusukebe avatar Apr 13 '25 02:04 yusukebe

@yusukebe the question is how swaggerUI generates this url? In local it takes url from server and addng a path: ${server.url}${endpoint_path} But on deployment env it looks like it takes url ${server.url}${v1_path}${endpoint_path}

If I set server.ur into '/' it start working just fine generatng "https://lix-backend-stage.up.railway.app/api/v1/public/account/reset-password" but stop working on lokal, since url become '/public/accout/reset-password'

So I guess problem somewhere inside swaggerUI and how it builds url

Alex-us avatar Apr 13 '25 08:04 Alex-us

@Alex-us

the question is how swaggerUI generates this url?

It depends on your OpenAPI document.

yusukebe avatar Apr 17 '25 22:04 yusukebe