Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: don't use relative paths #127

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

recanman
Copy link

@recanman recanman commented Jun 17, 2024

When setting a custom path for documentation (e.g /api/docs), Scalar requests the OpenAPI specification using the wrong path (as it is relative).

@marclave marclave self-requested a review June 18, 2024 20:46
@marclave
Copy link
Collaborator

@recanman recanman changed the title feat: allow configuring the path of the openapi json spec (copy of #11) fix: don't use relative paths Jun 21, 2024
@recanman
Copy link
Author

Must've been asleep when making this PR, #11 was vastly outdated and I was attempting to fix a previous issue I had with this package.

I've been using this patch for getting custom paths to work:

diff --git a/node_modules/@elysiajs/swagger/dist/index.js b/node_modules/@elysiajs/swagger/dist/index.js
index 3863b14..7519681 100644
--- a/node_modules/@elysiajs/swagger/dist/index.js
+++ b/node_modules/@elysiajs/swagger/dist/index.js
@@ -31,7 +31,7 @@ export const swagger = ({ provider = 'scalar', scalarVersion = 'latest', scalarC
         version: '0.0.0',
         ...documentation.info
     };
-    const relativePath = path.startsWith('/') ? path.slice(1) : path;
+    const relativePath = path;
     app.get(path, () => {
         const combinedSwaggerOptions = {
             url: `${relativePath}/json`,

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants