Skip to content

Commit 44d7803

Browse files
dfuqqjanbuchar
authored andcommitted
fix: specEndpoint correct handling
this commit fixes hardcoded /api path on UI Plugins, allowing to fully provide custom route
1 parent 469fbf4 commit 44d7803

4 files changed

Lines changed: 4 additions & 4 deletions

File tree

src/rapidocPlugin.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ const rapidoc =
3838
</head>
3939
<body>
4040
<script src="https://cdn.jsdelivr.net/npm/rapidoc@9.3.8/dist/rapidoc-min.js" type="module"></script>
41-
<rapi-doc spec-url="${req.protocol}//${req.headers.get('host')}/api${specEndpoint}"></rapi-doc>
41+
<rapi-doc spec-url="${req.protocol}//${req.headers.get('host')}${specEndpoint}"></rapi-doc>
4242
</body>
4343
</html>`,
4444
{ headers: { 'content-type': 'text/html' } },

src/redocPlugin.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ const redoc =
4343
</style>
4444
</head>
4545
<body>
46-
<redoc spec-url="${req.protocol}//${req.headers.get('host')}/api${specEndpoint}"></redoc>
46+
<redoc spec-url="${req.protocol}//${req.headers.get('host')}${specEndpoint}"></redoc>
4747
<script src="https://cdn.jsdelivr.net/npm/redoc@2.4.0/bundles/redoc.standalone.js"></script>
4848
</body>
4949
</html>`,

src/scalarPlugin.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ const scalar =
2323
method: 'get',
2424
path: docsUrl,
2525
handler: async req => {
26-
const fullSpecUrl = `${req.protocol}//${req.headers.get('host')}/api${specEndpoint}`
26+
const fullSpecUrl = `${req.protocol}//${req.headers.get('host')}${specEndpoint}`
2727

2828
const html = `
2929
<!DOCTYPE html>

src/swaggerUIPlugin.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ const swaggerUI =
4242
<script>
4343
window.onload = () => {
4444
window.ui = SwaggerUIBundle({
45-
url: '${req.protocol}//${req.headers.get('host')}/api${specEndpoint}',
45+
url: '${req.protocol}//${req.headers.get('host')}${specEndpoint}',
4646
dom_id: '#swagger-ui',
4747
});
4848
};

0 commit comments

Comments
 (0)