@loopback/rest-explorer 3.0.4 → 3.2.0
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 +44 -0
- package/README.md +20 -0
- package/dist/rest-explorer.component.js.map +1 -1
- package/dist/rest-explorer.controller.d.ts +3 -2
- package/dist/rest-explorer.controller.js +12 -6
- package/dist/rest-explorer.controller.js.map +1 -1
- package/dist/rest-explorer.keys.js.map +1 -1
- package/dist/rest-explorer.types.d.ts +1 -0
- package/package.json +16 -16
- package/src/rest-explorer.controller.ts +12 -4
- package/src/rest-explorer.keys.ts +3 -3
- package/src/rest-explorer.types.ts +5 -0
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,50 @@
|
|
|
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
|
+
# [3.2.0](https://github.com/strongloop/loopback-next/compare/@loopback/rest-explorer@3.1.0...@loopback/rest-explorer@3.2.0) (2021-03-18)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Features
|
|
10
|
+
|
|
11
|
+
* update package-lock.json to v2 consistently ([dfc3fbd](https://github.com/strongloop/loopback-next/commit/dfc3fbdae0c9ca9f34c64154a471bef22d5ac6b7))
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
# [3.1.0](https://github.com/strongloop/loopback-next/compare/@loopback/rest-explorer@3.0.6...@loopback/rest-explorer@3.1.0) (2021-02-09)
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
### Bug Fixes
|
|
21
|
+
|
|
22
|
+
* prettier README ([1fc462e](https://github.com/strongloop/loopback-next/commit/1fc462e8065b6ef420d3be51273d18e4c59d986b))
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
### Features
|
|
26
|
+
|
|
27
|
+
* **cli:** add graphql example ([6e53690](https://github.com/strongloop/loopback-next/commit/6e536904cd495a6d9d2d34bf9d184a2fa56c7bb2))
|
|
28
|
+
* add explorer indexTemplatePath customization ([070e0c9](https://github.com/strongloop/loopback-next/commit/070e0c9901a338204503006f6e8de749b39f8651))
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
## [3.0.6](https://github.com/strongloop/loopback-next/compare/@loopback/rest-explorer@3.0.5...@loopback/rest-explorer@3.0.6) (2021-01-21)
|
|
35
|
+
|
|
36
|
+
**Note:** Version bump only for package @loopback/rest-explorer
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
## [3.0.5](https://github.com/strongloop/loopback-next/compare/@loopback/rest-explorer@3.0.4...@loopback/rest-explorer@3.0.5) (2020-12-07)
|
|
43
|
+
|
|
44
|
+
**Note:** Version bump only for package @loopback/rest-explorer
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
|
|
6
50
|
## [3.0.4](https://github.com/strongloop/loopback-next/compare/@loopback/rest-explorer@3.0.3...@loopback/rest-explorer@3.0.4) (2020-11-18)
|
|
7
51
|
|
|
8
52
|
**Note:** Version bump only for package @loopback/rest-explorer
|
package/README.md
CHANGED
|
@@ -172,6 +172,26 @@ When the application runs, the explorer template will load the
|
|
|
172
172
|
Here is a repository that contains popular Swagger-UI themes:
|
|
173
173
|
https://github.com/ostranme/swagger-ui-themes.
|
|
174
174
|
|
|
175
|
+
### Overriding the Swagger UI index.html
|
|
176
|
+
|
|
177
|
+
For more flexibility, the `indexTemplatePath` property can be used to allow full
|
|
178
|
+
customization of
|
|
179
|
+
[Swagger UI configuration options](https://swagger.io/docs/open-source-tools/swagger-ui/usage/configuration/).
|
|
180
|
+
|
|
181
|
+
`indexTemplatePath` should be an absolute path to a .html.ejs template.
|
|
182
|
+
|
|
183
|
+
To get started,
|
|
184
|
+
[download the default index.html.ejs](https://github.com/strongloop/loopback-next/blob/master/packages/rest-explorer/templates/index.html.ejs),
|
|
185
|
+
add /explorer/index.html.ejs to your project, and update the configuration:
|
|
186
|
+
|
|
187
|
+
```ts
|
|
188
|
+
this.configure(RestExplorerBindings.COMPONENT).to({
|
|
189
|
+
// For example, create a directory "explorer" at the same level
|
|
190
|
+
// as "src" and "node_modules" in your applciation structure
|
|
191
|
+
indexTemplatePath: path.resolve(__dirname, '../explorer/index.html.ejs'),
|
|
192
|
+
});
|
|
193
|
+
```
|
|
194
|
+
|
|
175
195
|
## Contributions
|
|
176
196
|
|
|
177
197
|
- [Guidelines](https://github.com/strongloop/loopback-next/blob/master/docs/CONTRIBUTING.md)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rest-explorer.component.js","sourceRoot":"","sources":["../src/rest-explorer.component.ts"],"names":[],"mappings":";AAAA,sDAAsD;AACtD,uCAAuC;AACvC,+CAA+C;AAC/C,gEAAgE;;;;AAEhE,yCAOwB;AACxB,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,
|
|
1
|
+
{"version":3,"file":"rest-explorer.component.js","sourceRoot":"","sources":["../src/rest-explorer.component.ts"],"names":[],"mappings":";AAAA,sDAAsD;AACtD,uCAAuC;AACvC,+CAA+C;AAC/C,gEAAgE;;;;AAEhE,yCAOwB;AACxB,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,GAA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';
|
|
1
|
+
import { OpenApiSpecForm, RequestContext, RestServer, RestServerConfig } from '@loopback/rest';
|
|
2
2
|
import { RestExplorerConfig } from './rest-explorer.types';
|
|
3
3
|
export declare class ExplorerController {
|
|
4
4
|
private serverBasePath;
|
|
@@ -9,7 +9,8 @@ export declare class ExplorerController {
|
|
|
9
9
|
private openApiSpecUrl;
|
|
10
10
|
private useSelfHostedSpec;
|
|
11
11
|
private swaggerThemeFile;
|
|
12
|
-
|
|
12
|
+
private indexTemplatePath;
|
|
13
|
+
constructor(restConfig: RestServerConfig | undefined, explorerConfig: RestExplorerConfig | undefined, serverBasePath: string, restServer: RestServer, requestContext: RequestContext);
|
|
13
14
|
indexRedirect(): void;
|
|
14
15
|
index(): void;
|
|
15
16
|
spec(): Promise<import("@loopback/rest").OpenAPIObject>;
|
|
@@ -12,19 +12,20 @@ const ejs_1 = tslib_1.__importDefault(require("ejs"));
|
|
|
12
12
|
const fs_1 = tslib_1.__importDefault(require("fs"));
|
|
13
13
|
const path_1 = tslib_1.__importDefault(require("path"));
|
|
14
14
|
const rest_explorer_keys_1 = require("./rest-explorer.keys");
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
const template = fs_1.default.readFileSync(indexHtml, 'utf-8');
|
|
18
|
-
const templateFn = ejs_1.default.compile(template);
|
|
15
|
+
let prevIndexTemplatePath;
|
|
16
|
+
let templateFn;
|
|
19
17
|
let ExplorerController = class ExplorerController {
|
|
20
18
|
constructor(restConfig = {}, explorerConfig = {}, serverBasePath, restServer, requestContext) {
|
|
21
|
-
var _a;
|
|
19
|
+
var _a, _b;
|
|
22
20
|
this.serverBasePath = serverBasePath;
|
|
23
21
|
this.restServer = restServer;
|
|
24
22
|
this.requestContext = requestContext;
|
|
25
23
|
this.useSelfHostedSpec = explorerConfig.useSelfHostedSpec !== false;
|
|
26
24
|
this.openApiSpecUrl = this.getOpenApiSpecUrl(restConfig);
|
|
27
|
-
this.swaggerThemeFile =
|
|
25
|
+
this.swaggerThemeFile =
|
|
26
|
+
(_a = explorerConfig.swaggerThemeFile) !== null && _a !== void 0 ? _a : './swagger-ui.css';
|
|
27
|
+
this.indexTemplatePath =
|
|
28
|
+
(_b = explorerConfig.indexTemplatePath) !== null && _b !== void 0 ? _b : path_1.default.resolve(__dirname, '../templates/index.html.ejs');
|
|
28
29
|
}
|
|
29
30
|
indexRedirect() {
|
|
30
31
|
const { request, response } = this.requestContext;
|
|
@@ -59,6 +60,11 @@ let ExplorerController = class ExplorerController {
|
|
|
59
60
|
openApiSpecUrl,
|
|
60
61
|
swaggerThemeFile,
|
|
61
62
|
};
|
|
63
|
+
if (prevIndexTemplatePath !== this.indexTemplatePath) {
|
|
64
|
+
const template = fs_1.default.readFileSync(this.indexTemplatePath, 'utf-8');
|
|
65
|
+
templateFn = ejs_1.default.compile(template);
|
|
66
|
+
prevIndexTemplatePath = this.indexTemplatePath;
|
|
67
|
+
}
|
|
62
68
|
const homePage = templateFn(data);
|
|
63
69
|
this.requestContext.response
|
|
64
70
|
.status(200)
|
|
@@ -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;;;;AAEhE,yCAA8C;AAC9C,yCAMwB;AACxB,sDAAsB;AACtB,oDAAoB;AACpB,wDAAwB;AACxB,6DAA0D;AAG1D,
|
|
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,yCAA8C;AAC9C,yCAMwB;AACxB,sDAAsB;AACtB,oDAAoB;AACpB,wDAAwB;AACxB,6DAA0D;AAG1D,IAAI,qBAA6B,CAAC;AAClC,IAAI,UAAgC,CAAC;AAErC,IAAa,kBAAkB,GAA/B,MAAa,kBAAkB;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,uCAAuC;AACvC,+CAA+C;AAC/C,gEAAgE;;;AAEhE,yCAA0D;AAI1D;;GAEG;AACH,IAAiB,oBAAoB,CAgBpC;AAhBD,WAAiB,oBAAoB;IACnC;;OAEG;IACU,8BAAS,GAAG,iBAAU,CAAC,MAAM,CACxC,kCAAkC,CACnC,CAAC;IACF;;;;;OAKG;IACU,2BAAM,GAAuC,iBAAU,CAAC,iBAAiB,
|
|
1
|
+
{"version":3,"file":"rest-explorer.keys.js","sourceRoot":"","sources":["../src/rest-explorer.keys.ts"],"names":[],"mappings":";AAAA,sDAAsD;AACtD,uCAAuC;AACvC,+CAA+C;AAC/C,gEAAgE;;;AAEhE,yCAA0D;AAI1D;;GAEG;AACH,IAAiB,oBAAoB,CAgBpC;AAhBD,WAAiB,oBAAoB;IACnC;;OAEG;IACU,8BAAS,GAAG,iBAAU,CAAC,MAAM,CACxC,kCAAkC,CACnC,CAAC;IACF;;;;;OAKG;IACU,2BAAM,GAAuC,iBAAU,CAAC,iBAAiB,CACpF,qBAAA,SAAS,CACV,CAAC;AACJ,CAAC,EAhBgB,oBAAoB,GAApB,4BAAoB,KAApB,4BAAoB,QAgBpC"}
|
package/package.json
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@loopback/rest-explorer",
|
|
3
|
-
"version": "3.0
|
|
3
|
+
"version": "3.2.0",
|
|
4
4
|
"description": "LoopBack's API Explorer",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
7
7
|
"engines": {
|
|
8
|
-
"node": "^10.16 || 12 || 14"
|
|
8
|
+
"node": "^10.16 || 12 || 14 || 15"
|
|
9
9
|
},
|
|
10
10
|
"scripts": {
|
|
11
11
|
"build": "lb-tsc",
|
|
@@ -21,23 +21,23 @@
|
|
|
21
21
|
"access": "public"
|
|
22
22
|
},
|
|
23
23
|
"peerDependencies": {
|
|
24
|
-
"@loopback/core": "^2.
|
|
25
|
-
"@loopback/rest": "^9.
|
|
24
|
+
"@loopback/core": "^2.15.0",
|
|
25
|
+
"@loopback/rest": "^9.2.0"
|
|
26
26
|
},
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"ejs": "^3.1.
|
|
29
|
-
"swagger-ui-dist": "3.
|
|
30
|
-
"tslib": "^2.0
|
|
28
|
+
"ejs": "^3.1.6",
|
|
29
|
+
"swagger-ui-dist": "3.45.0",
|
|
30
|
+
"tslib": "^2.1.0"
|
|
31
31
|
},
|
|
32
32
|
"devDependencies": {
|
|
33
|
-
"@loopback/build": "^6.
|
|
34
|
-
"@loopback/core": "^2.
|
|
35
|
-
"@loopback/eslint-config": "^10.0
|
|
36
|
-
"@loopback/rest": "^9.
|
|
37
|
-
"@loopback/testlab": "^3.
|
|
38
|
-
"@types/ejs": "^3.0.
|
|
39
|
-
"@types/express": "^4.17.
|
|
40
|
-
"@types/node": "^10.17.
|
|
33
|
+
"@loopback/build": "^6.3.0",
|
|
34
|
+
"@loopback/core": "^2.15.0",
|
|
35
|
+
"@loopback/eslint-config": "^10.1.0",
|
|
36
|
+
"@loopback/rest": "^9.2.0",
|
|
37
|
+
"@loopback/testlab": "^3.3.0",
|
|
38
|
+
"@types/ejs": "^3.0.6",
|
|
39
|
+
"@types/express": "^4.17.11",
|
|
40
|
+
"@types/node": "^10.17.55",
|
|
41
41
|
"express": "^4.17.1"
|
|
42
42
|
},
|
|
43
43
|
"keywords": [
|
|
@@ -57,5 +57,5 @@
|
|
|
57
57
|
"url": "https://github.com/strongloop/loopback-next.git",
|
|
58
58
|
"directory": "packages/rest-explorer"
|
|
59
59
|
},
|
|
60
|
-
"gitHead": "
|
|
60
|
+
"gitHead": "85a45b8a0d6c1216c11256cb511ec6cfbfb4c226"
|
|
61
61
|
}
|
|
@@ -17,10 +17,8 @@ import path from 'path';
|
|
|
17
17
|
import {RestExplorerBindings} from './rest-explorer.keys';
|
|
18
18
|
import {RestExplorerConfig} from './rest-explorer.types';
|
|
19
19
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
const template = fs.readFileSync(indexHtml, 'utf-8');
|
|
23
|
-
const templateFn = ejs.compile(template);
|
|
20
|
+
let prevIndexTemplatePath: string;
|
|
21
|
+
let templateFn: ejs.TemplateFunction;
|
|
24
22
|
|
|
25
23
|
export class ExplorerController {
|
|
26
24
|
static readonly OPENAPI_RELATIVE_URL = 'openapi.json';
|
|
@@ -32,6 +30,7 @@ export class ExplorerController {
|
|
|
32
30
|
private openApiSpecUrl: string;
|
|
33
31
|
private useSelfHostedSpec: boolean;
|
|
34
32
|
private swaggerThemeFile: string;
|
|
33
|
+
private indexTemplatePath: string;
|
|
35
34
|
|
|
36
35
|
constructor(
|
|
37
36
|
@inject(RestBindings.CONFIG, {optional: true})
|
|
@@ -46,6 +45,9 @@ export class ExplorerController {
|
|
|
46
45
|
this.openApiSpecUrl = this.getOpenApiSpecUrl(restConfig);
|
|
47
46
|
this.swaggerThemeFile =
|
|
48
47
|
explorerConfig.swaggerThemeFile ?? './swagger-ui.css';
|
|
48
|
+
this.indexTemplatePath =
|
|
49
|
+
explorerConfig.indexTemplatePath ??
|
|
50
|
+
path.resolve(__dirname, '../templates/index.html.ejs');
|
|
49
51
|
}
|
|
50
52
|
|
|
51
53
|
indexRedirect() {
|
|
@@ -87,6 +89,12 @@ export class ExplorerController {
|
|
|
87
89
|
swaggerThemeFile,
|
|
88
90
|
};
|
|
89
91
|
|
|
92
|
+
if (prevIndexTemplatePath !== this.indexTemplatePath) {
|
|
93
|
+
const template = fs.readFileSync(this.indexTemplatePath, 'utf-8');
|
|
94
|
+
templateFn = ejs.compile(template);
|
|
95
|
+
prevIndexTemplatePath = this.indexTemplatePath;
|
|
96
|
+
}
|
|
97
|
+
|
|
90
98
|
const homePage = templateFn(data);
|
|
91
99
|
this.requestContext.response
|
|
92
100
|
.status(200)
|
|
@@ -23,7 +23,7 @@ export namespace RestExplorerBindings {
|
|
|
23
23
|
* We recommend `ctx.configure(RestExplorerBindings.COMPONENT)` to be used
|
|
24
24
|
* instead of `ctx.bind(RestExplorerBindings.CONFIG)`.
|
|
25
25
|
*/
|
|
26
|
-
export const CONFIG: BindingAddress<RestExplorerConfig> = BindingKey.buildKeyForConfig<
|
|
27
|
-
|
|
28
|
-
|
|
26
|
+
export const CONFIG: BindingAddress<RestExplorerConfig> = BindingKey.buildKeyForConfig<RestExplorerConfig>(
|
|
27
|
+
COMPONENT,
|
|
28
|
+
);
|
|
29
29
|
}
|