@loopback/rest-explorer 1.4.4 → 1.4.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +32 -0
- package/README.md +16 -0
- package/dist/rest-explorer.component.js +2 -1
- package/dist/rest-explorer.component.js.map +1 -1
- package/dist/rest-explorer.controller.js +13 -9
- package/dist/rest-explorer.controller.js.map +1 -1
- package/package.json +12 -12
- package/src/rest-explorer.component.ts +1 -1
- package/src/rest-explorer.controller.ts +6 -6
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,38 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
## [1.4.8](https://github.com/strongloop/loopback-next/compare/@loopback/rest-explorer@1.4.7...@loopback/rest-explorer@1.4.8) (2020-01-27)
|
|
7
|
+
|
|
8
|
+
**Note:** Version bump only for package @loopback/rest-explorer
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
## [1.4.7](https://github.com/strongloop/loopback-next/compare/@loopback/rest-explorer@1.4.6...@loopback/rest-explorer@1.4.7) (2020-01-07)
|
|
15
|
+
|
|
16
|
+
**Note:** Version bump only for package @loopback/rest-explorer
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
## [1.4.6](https://github.com/strongloop/loopback-next/compare/@loopback/rest-explorer@1.4.5...@loopback/rest-explorer@1.4.6) (2019-12-09)
|
|
23
|
+
|
|
24
|
+
**Note:** Version bump only for package @loopback/rest-explorer
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
## [1.4.5](https://github.com/strongloop/loopback-next/compare/@loopback/rest-explorer@1.4.4...@loopback/rest-explorer@1.4.5) (2019-11-25)
|
|
31
|
+
|
|
32
|
+
**Note:** Version bump only for package @loopback/rest-explorer
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
|
|
6
38
|
## [1.4.4](https://github.com/strongloop/loopback-next/compare/@loopback/rest-explorer@1.4.3...@loopback/rest-explorer@1.4.4) (2019-11-12)
|
|
7
39
|
|
|
8
40
|
**Note:** Version bump only for package @loopback/rest-explorer
|
package/README.md
CHANGED
|
@@ -90,6 +90,22 @@ Note also that you cannot use a url-relative path for the `servers` entry, as
|
|
|
90
90
|
the Swagger UI does not support that (yet). You may use a _host_-relative path
|
|
91
91
|
however.
|
|
92
92
|
|
|
93
|
+
### Disable Self-Hosted API Explorer
|
|
94
|
+
|
|
95
|
+
To disable the self-hosted API Explorer, remove the component from the
|
|
96
|
+
constructor of your custom Application class. Typically the component will be
|
|
97
|
+
located in `./src/application.ts` and consist of two items, for example:
|
|
98
|
+
|
|
99
|
+
```ts
|
|
100
|
+
this.bind(RestExplorerBindings.CONFIG).to({
|
|
101
|
+
path: '/openapi/ui',
|
|
102
|
+
});
|
|
103
|
+
this.component(RestExplorerComponent);
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
{% include note.html content="To completely disable API Explorer, we also need
|
|
107
|
+
to [disable the redirect to the externally hosted API Explorer](./Server.html#disable-redirect-to-api-explorer)." %}
|
|
108
|
+
|
|
93
109
|
#### Summary
|
|
94
110
|
|
|
95
111
|
For some common scenarios, here are recommended configurations to have the
|
|
@@ -28,8 +28,9 @@ const swaggerUI = require('swagger-ui-dist');
|
|
|
28
28
|
*/
|
|
29
29
|
let RestExplorerComponent = class RestExplorerComponent {
|
|
30
30
|
constructor(application, restExplorerConfig = {}) {
|
|
31
|
+
var _a;
|
|
31
32
|
this.application = application;
|
|
32
|
-
const explorerPath = restExplorerConfig.path
|
|
33
|
+
const explorerPath = (_a = restExplorerConfig.path, (_a !== null && _a !== void 0 ? _a : '/explorer'));
|
|
33
34
|
this.registerControllerRoute('get', explorerPath, 'indexRedirect');
|
|
34
35
|
this.registerControllerRoute('get', explorerPath + '/', 'index');
|
|
35
36
|
if (restExplorerConfig.useSelfHostedSpec !== false) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rest-explorer.component.js","sourceRoot":"","sources":["../src/rest-explorer.component.ts"],"names":[],"mappings":";AAAA,iDAAiD;AACjD,uCAAuC;AACvC,+CAA+C;AAC/C,gEAAgE;;;;;;;;;;;;;;AAEhE,6DAA6D;AAC7D,+CAAoE;AACpE,yCAAuD;AACvD,yCAAgF;AAChF,yEAA8D;AAC9D,6DAA0D;AAG1D,MAAM,SAAS,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAAC;AAE7C;;GAEG;AAEH,IAAa,qBAAqB,GAAlC,MAAa,qBAAqB;IAChC,YAEU,WAA4B,EAEpC,qBAAyC,EAAE
|
|
1
|
+
{"version":3,"file":"rest-explorer.component.js","sourceRoot":"","sources":["../src/rest-explorer.component.ts"],"names":[],"mappings":";AAAA,iDAAiD;AACjD,uCAAuC;AACvC,+CAA+C;AAC/C,gEAAgE;;;;;;;;;;;;;;AAEhE,6DAA6D;AAC7D,+CAAoE;AACpE,yCAAuD;AACvD,yCAAgF;AAChF,yEAA8D;AAC9D,6DAA0D;AAG1D,MAAM,SAAS,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAAC;AAE7C;;GAEG;AAEH,IAAa,qBAAqB,GAAlC,MAAa,qBAAqB;IAChC,YAEU,WAA4B,EAEpC,qBAAyC,EAAE;;QAFnC,gBAAW,GAAX,WAAW,CAAiB;QAIpC,MAAM,YAAY,SAAG,kBAAkB,CAAC,IAAI,uCAAI,WAAW,EAAA,CAAC;QAE5D,IAAI,CAAC,uBAAuB,CAAC,KAAK,EAAE,YAAY,EAAE,eAAe,CAAC,CAAC;QACnE,IAAI,CAAC,uBAAuB,CAAC,KAAK,EAAE,YAAY,GAAG,GAAG,EAAE,OAAO,CAAC,CAAC;QACjE,IAAI,kBAAkB,CAAC,iBAAiB,KAAK,KAAK,EAAE;YAClD,IAAI,CAAC,uBAAuB,CAC1B,KAAK,EACL,YAAY,GAAG,eAAe,EAC9B,MAAM,CACP,CAAC;SACH;QAED,WAAW,CAAC,MAAM,CAAC,YAAY,EAAE,SAAS,CAAC,iBAAiB,EAAE,CAAC,CAAC;QAEhE,qDAAqD;QACrD,WAAW,CAAC,UAAU,CAAC,MAAM,CAAC,WAAW,GAAG,EAAC,QAAQ,EAAE,IAAI,EAAC,CAAC;IAC/D,CAAC;IAEO,uBAAuB,CAC7B,IAAY,EACZ,IAAY,EACZ,UAAkB;QAElB,IAAI,CAAC,WAAW,CAAC,KAAK,CACpB,IAAI,EACJ,IAAI,EACJ;YACE,cAAc,EAAE,cAAc;YAC9B,SAAS,EAAE,EAAE;SACd,EACD,6CAAkB,EAClB,sCAA+B,CAAC,6CAAkB,CAAC,EACnD,UAAU,CACX,CAAC;IACJ,CAAC;CACF,CAAA;AA1CY,qBAAqB;IADjC,cAAI,CAAC,EAAC,IAAI,EAAE,EAAC,CAAC,qBAAW,CAAC,GAAG,CAAC,EAAE,yCAAoB,CAAC,SAAS,CAAC,GAAG,EAAC,EAAC,CAAC;IAGjE,WAAA,gBAAM,CAAC,mBAAY,CAAC,oBAAoB,CAAC,CAAA;IAEzC,WAAA,gBAAM,EAAE,CAAA;qCADY,sBAAe;GAH3B,qBAAqB,CA0CjC;AA1CY,sDAAqB"}
|
|
@@ -15,17 +15,20 @@ var __metadata = (this && this.__metadata) || function (k, v) {
|
|
|
15
15
|
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
16
16
|
return function (target, key) { decorator(target, key, paramIndex); }
|
|
17
17
|
};
|
|
18
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
19
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
20
|
+
};
|
|
18
21
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
19
22
|
const context_1 = require("@loopback/context");
|
|
20
23
|
const rest_1 = require("@loopback/rest");
|
|
21
|
-
const
|
|
22
|
-
const
|
|
23
|
-
const
|
|
24
|
+
const ejs_1 = __importDefault(require("ejs"));
|
|
25
|
+
const fs_1 = __importDefault(require("fs"));
|
|
26
|
+
const path_1 = __importDefault(require("path"));
|
|
24
27
|
const rest_explorer_keys_1 = require("./rest-explorer.keys");
|
|
25
28
|
// TODO(bajtos) Allow users to customize the template
|
|
26
|
-
const indexHtml =
|
|
27
|
-
const template =
|
|
28
|
-
const templateFn =
|
|
29
|
+
const indexHtml = path_1.default.resolve(__dirname, '../templates/index.html.ejs');
|
|
30
|
+
const template = fs_1.default.readFileSync(indexHtml, 'utf-8');
|
|
31
|
+
const templateFn = ejs_1.default.compile(template);
|
|
29
32
|
let ExplorerController = class ExplorerController {
|
|
30
33
|
constructor(restConfig = {}, explorerConfig = {}, serverBasePath, restServer, requestContext) {
|
|
31
34
|
this.serverBasePath = serverBasePath;
|
|
@@ -75,13 +78,14 @@ let ExplorerController = class ExplorerController {
|
|
|
75
78
|
return this.restServer.getApiSpec(this.requestContext);
|
|
76
79
|
}
|
|
77
80
|
getOpenApiSpecUrl(restConfig) {
|
|
81
|
+
var _a, _b;
|
|
78
82
|
if (this.useSelfHostedSpec) {
|
|
79
83
|
return './' + ExplorerController.OPENAPI_RELATIVE_URL;
|
|
80
84
|
}
|
|
81
|
-
const openApiConfig = restConfig.openApiSpec
|
|
82
|
-
const endpointMapping = openApiConfig.endpointMapping
|
|
85
|
+
const openApiConfig = (_a = restConfig.openApiSpec, (_a !== null && _a !== void 0 ? _a : {}));
|
|
86
|
+
const endpointMapping = (_b = openApiConfig.endpointMapping, (_b !== null && _b !== void 0 ? _b : {}));
|
|
83
87
|
const endpoint = Object.keys(endpointMapping).find(k => isOpenApiV3Json(endpointMapping[k]));
|
|
84
|
-
return endpoint
|
|
88
|
+
return (endpoint !== null && endpoint !== void 0 ? endpoint : '/openapi.json');
|
|
85
89
|
}
|
|
86
90
|
};
|
|
87
91
|
ExplorerController.OPENAPI_RELATIVE_URL = 'openapi.json';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rest-explorer.controller.js","sourceRoot":"","sources":["../src/rest-explorer.controller.ts"],"names":[],"mappings":";AAAA,sDAAsD;AACtD,uCAAuC;AACvC,+CAA+C;AAC/C,gEAAgE
|
|
1
|
+
{"version":3,"file":"rest-explorer.controller.js","sourceRoot":"","sources":["../src/rest-explorer.controller.ts"],"names":[],"mappings":";AAAA,sDAAsD;AACtD,uCAAuC;AACvC,+CAA+C;AAC/C,gEAAgE;;;;;;;;;;;;;;;;;AAEhE,+CAAyC;AACzC,yCAMwB;AACxB,8CAAsB;AACtB,4CAAoB;AACpB,gDAAwB;AACxB,6DAA0D;AAG1D,qDAAqD;AACrD,MAAM,SAAS,GAAG,cAAI,CAAC,OAAO,CAAC,SAAS,EAAE,6BAA6B,CAAC,CAAC;AACzE,MAAM,QAAQ,GAAG,YAAE,CAAC,YAAY,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC;AACrD,MAAM,UAAU,GAAG,aAAG,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;AAEzC,IAAa,kBAAkB,GAA/B,MAAa,kBAAkB;IAU7B,YAEE,aAA+B,EAAE,EAEjC,iBAAqC,EAAE,EACC,cAAsB,EACzB,UAAsB,EAChB,cAA8B;QAFjC,mBAAc,GAAd,cAAc,CAAQ;QACzB,eAAU,GAAV,UAAU,CAAY;QAChB,mBAAc,GAAd,cAAc,CAAgB;QAEzE,IAAI,CAAC,iBAAiB,GAAG,cAAc,CAAC,iBAAiB,KAAK,KAAK,CAAC;QACpE,IAAI,CAAC,cAAc,GAAG,IAAI,CAAC,iBAAiB,CAAC,UAAU,CAAC,CAAC;IAC3D,CAAC;IAED,aAAa;QACX,MAAM,EAAC,OAAO,EAAE,QAAQ,EAAC,GAAG,IAAI,CAAC,cAAc,CAAC;QAChD,IAAI,GAAG,GAAG,OAAO,CAAC,WAAW,IAAI,OAAO,CAAC,GAAG,CAAC;QAC7C,4EAA4E;Q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M,KAAK,kBAAkB,CAAC,YAAY,CAAC,MAAM,CAC1D,CAAC;AACJ,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@loopback/rest-explorer",
|
|
3
|
-
"version": "1.4.
|
|
3
|
+
"version": "1.4.8",
|
|
4
4
|
"description": "LoopBack's API Explorer",
|
|
5
5
|
"engines": {
|
|
6
6
|
"node": ">=8.9"
|
|
@@ -16,19 +16,19 @@
|
|
|
16
16
|
"copyright.owner": "IBM Corp.",
|
|
17
17
|
"license": "MIT",
|
|
18
18
|
"dependencies": {
|
|
19
|
-
"@loopback/context": "^
|
|
20
|
-
"@loopback/core": "^1.
|
|
21
|
-
"@loopback/rest": "^1.
|
|
22
|
-
"ejs": "^
|
|
23
|
-
"swagger-ui-dist": "^3.
|
|
19
|
+
"@loopback/context": "^2.0.0",
|
|
20
|
+
"@loopback/core": "^1.12.2",
|
|
21
|
+
"@loopback/rest": "^1.26.0",
|
|
22
|
+
"ejs": "^3.0.1",
|
|
23
|
+
"swagger-ui-dist": "^3.25.0"
|
|
24
24
|
},
|
|
25
25
|
"devDependencies": {
|
|
26
|
-
"@loopback/build": "^
|
|
27
|
-
"@loopback/eslint-config": "^
|
|
28
|
-
"@loopback/testlab": "^1.
|
|
29
|
-
"@types/ejs": "^
|
|
26
|
+
"@loopback/build": "^3.1.0",
|
|
27
|
+
"@loopback/eslint-config": "^5.0.2",
|
|
28
|
+
"@loopback/testlab": "^1.10.2",
|
|
29
|
+
"@types/ejs": "^3.0.0",
|
|
30
30
|
"@types/express": "^4.17.2",
|
|
31
|
-
"@types/node": "^10.17.
|
|
31
|
+
"@types/node": "^10.17.13",
|
|
32
32
|
"express": "^4.17.1"
|
|
33
33
|
},
|
|
34
34
|
"keywords": [
|
|
@@ -53,5 +53,5 @@
|
|
|
53
53
|
"url": "https://github.com/strongloop/loopback-next.git",
|
|
54
54
|
"directory": "packages/rest-explorer"
|
|
55
55
|
},
|
|
56
|
-
"gitHead": "
|
|
56
|
+
"gitHead": "d08f135a0d1040edc61497739a8d86a866e4e29a"
|
|
57
57
|
}
|
|
@@ -24,7 +24,7 @@ export class RestExplorerComponent implements Component {
|
|
|
24
24
|
@config()
|
|
25
25
|
restExplorerConfig: RestExplorerConfig = {},
|
|
26
26
|
) {
|
|
27
|
-
const explorerPath = restExplorerConfig.path
|
|
27
|
+
const explorerPath = restExplorerConfig.path ?? '/explorer';
|
|
28
28
|
|
|
29
29
|
this.registerControllerRoute('get', explorerPath, 'indexRedirect');
|
|
30
30
|
this.registerControllerRoute('get', explorerPath + '/', 'index');
|
|
@@ -11,9 +11,9 @@ import {
|
|
|
11
11
|
RestServer,
|
|
12
12
|
RestServerConfig,
|
|
13
13
|
} from '@loopback/rest';
|
|
14
|
-
import
|
|
15
|
-
import
|
|
16
|
-
import
|
|
14
|
+
import ejs from 'ejs';
|
|
15
|
+
import fs from 'fs';
|
|
16
|
+
import path from 'path';
|
|
17
17
|
import {RestExplorerBindings} from './rest-explorer.keys';
|
|
18
18
|
import {RestExplorerConfig} from './rest-explorer.types';
|
|
19
19
|
|
|
@@ -97,12 +97,12 @@ export class ExplorerController {
|
|
|
97
97
|
if (this.useSelfHostedSpec) {
|
|
98
98
|
return './' + ExplorerController.OPENAPI_RELATIVE_URL;
|
|
99
99
|
}
|
|
100
|
-
const openApiConfig = restConfig.openApiSpec
|
|
101
|
-
const endpointMapping = openApiConfig.endpointMapping
|
|
100
|
+
const openApiConfig = restConfig.openApiSpec ?? {};
|
|
101
|
+
const endpointMapping = openApiConfig.endpointMapping ?? {};
|
|
102
102
|
const endpoint = Object.keys(endpointMapping).find(k =>
|
|
103
103
|
isOpenApiV3Json(endpointMapping[k]),
|
|
104
104
|
);
|
|
105
|
-
return endpoint
|
|
105
|
+
return endpoint ?? '/openapi.json';
|
|
106
106
|
}
|
|
107
107
|
}
|
|
108
108
|
|