You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have searched existing issues to ensure the bug has not already been reported
Fastify version
4.26.1
Plugin version
4.0.0
Node.js version
20.x
Operating system
macOS
Operating system version (i.e. 20.04, 11.3, 10)
14.5
Description
In swagger docs, when unfolding the api difinitions, browser location (url) will change.
At this point, if we refresh the page, we will get error Unable to render this definition
It is because we find the difinition by using the current url and attach ./json, e.g. http://127.0.0.1:3000/api/docs#/auth/post_v1_auth_login/./json
To resolve this bug, the most straightforward way is to modify the swagger-initialzer.js
(but this solution doesn't handle the corner case where the user's url contains #)
Prerequisites
Fastify version
4.26.1
Plugin version
4.0.0
Node.js version
20.x
Operating system
macOS
Operating system version (i.e. 20.04, 11.3, 10)
14.5
Description
In swagger docs, when unfolding the api difinitions, browser location (url) will change.
At this point, if we refresh the page, we will get error
Unable to render this definition
It is because we find the difinition by using the current url and attach
./json
, e.g.http://127.0.0.1:3000/api/docs#/auth/post_v1_auth_login/./json
To resolve this bug, the most straightforward way is to modify the
swagger-initialzer.js
(but this solution doesn't handle the corner case where the user's url contains
#
)function resolveUrl(url) { var currentHref = window.location.href; > currentHref = currentHref.split('#')[0]; currentHref = currentHref.endsWith('/') ? currentHref : currentHref + '/'; var anchor = document.createElement('a'); anchor.href = currentHref + url; return anchor.href }
A better way is to make it unchanged even we refresh the page, not sure if it is a big change or not.
What do you think?
Link to code that reproduces the bug
No response
Expected Behavior
unfolding the API difinition, then refresh the browser, the docs stay the same instead of showing
Unable to render this definition
The text was updated successfully, but these errors were encountered: