Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
// License text available at https://opensource.org/licenses/MIT

import {Client} from '@loopback/testlab';
import {setupExpressApplication} from './test-helper';
import {ExpressServer} from '../../server';
import {setupExpressApplication} from './test-helper';

describe('ExpressApplication', () => {
let server: ExpressServer;
Expand Down Expand Up @@ -53,7 +53,7 @@ describe('ExpressApplication', () => {
.get('/api/explorer/')
.expect(200)
.expect('content-type', /html/)
.expect(/url\: '\/api\/openapi\.json'\,/)
.expect(/url\: '\/openapi\.json'\,/)
.expect(/<title>LoopBack API Explorer/);
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ describe('REST Explorer mounted as an express router', () => {
.get('/api/explorer/')
.expect(200)
.expect('content-type', /html/)
.expect(/url\: '\/api\/openapi\.json'\,/);
.expect(/url\: '\/openapi\.json'\,/);
});

it('redirects from "/api/explorer" to "/api/explorer/"', async () => {
Expand Down
14 changes: 9 additions & 5 deletions packages/rest-explorer/src/rest-explorer.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@

import {inject} from '@loopback/context';
import {
RestBindings,
RestServerConfig,
OpenApiSpecForm,
Request,
Response,
RestBindings,
RestServerConfig,
} from '@loopback/rest';
import * as ejs from 'ejs';
import * as fs from 'fs';
Expand Down Expand Up @@ -39,9 +39,13 @@ export class ExplorerController {

index() {
let openApiSpecUrl = this.openApiSpecUrl;
if (this.request.baseUrl && this.request.baseUrl !== '/') {
openApiSpecUrl = this.request.baseUrl + openApiSpecUrl;
}

// NOTE(bajtos) OpenAPI routes do not honor basePath setting (yet)
// See https://github.com/strongloop/loopback-next/pull/2554
// if (this.request.baseUrl && this.request.baseUrl !== '/') {
// openApiSpecUrl = this.request.baseUrl + openApiSpecUrl;
// }

const data = {
openApiSpecUrl,
};
Expand Down