@midwayjs/swagger 3.13.9 → 3.13.10-beta.2
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/dist/config/config.default.js +3 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +5 -1
- package/dist/interfaces/index.d.ts +7 -1
- package/dist/swaggerMiddleware.d.ts +1 -2
- package/dist/swaggerMiddleware.js +39 -79
- package/dist/ui/render.d.ts +18 -0
- package/dist/ui/render.js +79 -0
- package/dist/ui.d.ts +10 -0
- package/dist/ui.js +57 -0
- package/index.html +32 -0
- package/package.json +4 -4
- package/LICENSE +0 -21
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.swagger = void 0;
|
|
4
|
+
const render_1 = require("../ui/render");
|
|
4
5
|
exports.swagger = {
|
|
5
6
|
title: 'My Project',
|
|
6
7
|
description: 'This is a swagger-ui for midwayjs project',
|
|
7
8
|
version: '1.0.0',
|
|
8
9
|
swaggerPath: '/swagger-ui',
|
|
10
|
+
swaggerUIRender: render_1.renderSwaggerUIRemote,
|
|
11
|
+
swaggerUIRenderOptions: {},
|
|
9
12
|
};
|
|
10
13
|
//# sourceMappingURL=config.default.js.map
|
package/dist/index.d.ts
CHANGED
|
@@ -3,4 +3,5 @@ export * from './interfaces';
|
|
|
3
3
|
export { SwaggerConfiguration as Configuration } from './configuration';
|
|
4
4
|
export { SwaggerExplorer } from './swaggerExplorer';
|
|
5
5
|
export { SwaggerMiddleware } from './swaggerMiddleware';
|
|
6
|
+
export { renderSwaggerUIRemote, renderSwaggerUIDist, renderJSON, } from './ui/render';
|
|
6
7
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.js
CHANGED
|
@@ -14,7 +14,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
exports.SwaggerMiddleware = exports.SwaggerExplorer = exports.Configuration = void 0;
|
|
17
|
+
exports.renderJSON = exports.renderSwaggerUIDist = exports.renderSwaggerUIRemote = exports.SwaggerMiddleware = exports.SwaggerExplorer = exports.Configuration = void 0;
|
|
18
18
|
__exportStar(require("./decorators"), exports);
|
|
19
19
|
__exportStar(require("./interfaces"), exports);
|
|
20
20
|
var configuration_1 = require("./configuration");
|
|
@@ -23,4 +23,8 @@ var swaggerExplorer_1 = require("./swaggerExplorer");
|
|
|
23
23
|
Object.defineProperty(exports, "SwaggerExplorer", { enumerable: true, get: function () { return swaggerExplorer_1.SwaggerExplorer; } });
|
|
24
24
|
var swaggerMiddleware_1 = require("./swaggerMiddleware");
|
|
25
25
|
Object.defineProperty(exports, "SwaggerMiddleware", { enumerable: true, get: function () { return swaggerMiddleware_1.SwaggerMiddleware; } });
|
|
26
|
+
var render_1 = require("./ui/render");
|
|
27
|
+
Object.defineProperty(exports, "renderSwaggerUIRemote", { enumerable: true, get: function () { return render_1.renderSwaggerUIRemote; } });
|
|
28
|
+
Object.defineProperty(exports, "renderSwaggerUIDist", { enumerable: true, get: function () { return render_1.renderSwaggerUIDist; } });
|
|
29
|
+
Object.defineProperty(exports, "renderJSON", { enumerable: true, get: function () { return render_1.renderJSON; } });
|
|
26
30
|
//# sourceMappingURL=index.js.map
|
|
@@ -2,7 +2,8 @@
|
|
|
2
2
|
* inspired by https://github.com/metadevpro/openapi3-ts
|
|
3
3
|
* @see https://github.com/OAI/OpenAPI-Specification/blob/3.0.0-rc0/versions/3.0.md
|
|
4
4
|
*/
|
|
5
|
-
import
|
|
5
|
+
import { RouterOption } from '@midwayjs/core';
|
|
6
|
+
import { SwaggerExplorer } from '../swaggerExplorer';
|
|
6
7
|
export interface OpenAPIObject {
|
|
7
8
|
openapi: string;
|
|
8
9
|
info: InfoObject;
|
|
@@ -363,5 +364,10 @@ export interface SwaggerOptions {
|
|
|
363
364
|
*/
|
|
364
365
|
operationIdFactory?: (controllerKey: string, webRouter: RouterOption) => string;
|
|
365
366
|
};
|
|
367
|
+
swaggerUIRender?: (config: SwaggerOptions, swaggerExplorer: SwaggerExplorer, swaggerRenderOptions?: any) => (pathname: string) => Promise<{
|
|
368
|
+
ext: string;
|
|
369
|
+
content: any;
|
|
370
|
+
}>;
|
|
371
|
+
swaggerUIRenderOptions?: Record<string, any>;
|
|
366
372
|
}
|
|
367
373
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
import { IMiddleware, IMidwayApplication, IMidwayContext, NextFunction, MidwayEnvironmentService } from '@midwayjs/core';
|
|
2
2
|
export declare class SwaggerMiddleware implements IMiddleware<IMidwayContext, NextFunction, unknown> {
|
|
3
3
|
private swaggerConfig;
|
|
4
|
-
private
|
|
4
|
+
private swaggerRender;
|
|
5
5
|
private swaggerExplorer;
|
|
6
6
|
environmentService: MidwayEnvironmentService;
|
|
7
7
|
init(): Promise<void>;
|
|
8
8
|
resolve(app: IMidwayApplication): (req: any, res: any, next: NextFunction) => Promise<any>;
|
|
9
|
-
replaceInfo(content: string): string;
|
|
10
9
|
static getName(): string;
|
|
11
10
|
}
|
|
12
11
|
//# sourceMappingURL=swaggerMiddleware.d.ts.map
|
|
@@ -11,106 +11,66 @@ var __metadata = (this && this.__metadata) || function (k, v) {
|
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
exports.SwaggerMiddleware = void 0;
|
|
13
13
|
const core_1 = require("@midwayjs/core");
|
|
14
|
-
const fs_1 = require("fs");
|
|
15
|
-
const path_1 = require("path");
|
|
16
14
|
const swaggerExplorer_1 = require("./swaggerExplorer");
|
|
17
15
|
let SwaggerMiddleware = class SwaggerMiddleware {
|
|
18
16
|
async init() {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
this.swaggerUiAssetPath = getAbsoluteFSPath();
|
|
22
|
-
}
|
|
23
|
-
else {
|
|
24
|
-
throw new core_1.MidwayCommonError('swagger-ui-dist is not installed');
|
|
17
|
+
if (typeof this.swaggerConfig.swaggerUIRender !== 'function') {
|
|
18
|
+
throw new core_1.MidwayInvalidConfigPropertyError('swagger.swaggerRender');
|
|
25
19
|
}
|
|
20
|
+
this.swaggerRender = this.swaggerConfig.swaggerUIRender(this.swaggerConfig, this.swaggerExplorer);
|
|
26
21
|
}
|
|
27
22
|
resolve(app) {
|
|
28
23
|
if (app.getFrameworkType() === core_1.MidwayFrameworkType.WEB_EXPRESS) {
|
|
29
24
|
return async (req, res, next) => {
|
|
30
25
|
const pathname = req.path;
|
|
31
|
-
|
|
32
|
-
|
|
26
|
+
const renderResult = await this.swaggerRender(pathname);
|
|
27
|
+
if (renderResult) {
|
|
28
|
+
const { ext, content } = renderResult;
|
|
29
|
+
if (ext === '.js') {
|
|
30
|
+
res.type('application/javascript');
|
|
31
|
+
}
|
|
32
|
+
else if (ext === '.map') {
|
|
33
|
+
res.type('application/json');
|
|
34
|
+
}
|
|
35
|
+
else if (ext === '.css') {
|
|
36
|
+
res.type('text/css');
|
|
37
|
+
}
|
|
38
|
+
else if (ext === '.png') {
|
|
39
|
+
res.type('image/png');
|
|
40
|
+
}
|
|
41
|
+
res.send(content);
|
|
42
|
+
}
|
|
43
|
+
else {
|
|
33
44
|
return next();
|
|
34
45
|
}
|
|
35
|
-
const arr = pathname.split('/');
|
|
36
|
-
let lastName = arr.pop();
|
|
37
|
-
if (lastName === 'index.json') {
|
|
38
|
-
res.send(this.swaggerExplorer.getData());
|
|
39
|
-
return;
|
|
40
|
-
}
|
|
41
|
-
if (!lastName) {
|
|
42
|
-
lastName = 'index.html';
|
|
43
|
-
}
|
|
44
|
-
let content = (0, fs_1.readFileSync)((0, path_1.join)(this.swaggerUiAssetPath, lastName));
|
|
45
|
-
if (lastName === 'index.html' ||
|
|
46
|
-
lastName === 'swagger-initializer.js') {
|
|
47
|
-
content = content.toString('utf8');
|
|
48
|
-
content = this.replaceInfo(content);
|
|
49
|
-
}
|
|
50
|
-
const ext = (0, path_1.extname)(lastName);
|
|
51
|
-
if (ext === '.js') {
|
|
52
|
-
res.type('application/javascript');
|
|
53
|
-
}
|
|
54
|
-
else if (ext === '.map') {
|
|
55
|
-
res.type('application/json');
|
|
56
|
-
}
|
|
57
|
-
else if (ext === '.css') {
|
|
58
|
-
res.type('text/css');
|
|
59
|
-
}
|
|
60
|
-
else if (ext === '.png') {
|
|
61
|
-
res.type('image/png');
|
|
62
|
-
}
|
|
63
|
-
res.send(content);
|
|
64
46
|
};
|
|
65
47
|
}
|
|
66
48
|
else {
|
|
67
49
|
return async (ctx, next) => {
|
|
68
50
|
const pathname = ctx.path;
|
|
69
|
-
|
|
70
|
-
|
|
51
|
+
const renderResult = await this.swaggerRender(pathname);
|
|
52
|
+
if (renderResult) {
|
|
53
|
+
const { ext, content } = renderResult;
|
|
54
|
+
if (ext === '.js') {
|
|
55
|
+
ctx.set('Content-Type', 'application/javascript');
|
|
56
|
+
}
|
|
57
|
+
else if (ext === '.map') {
|
|
58
|
+
ctx.set('Content-Type', 'application/json');
|
|
59
|
+
}
|
|
60
|
+
else if (ext === '.css') {
|
|
61
|
+
ctx.set('Content-Type', 'text/css');
|
|
62
|
+
}
|
|
63
|
+
else if (ext === '.png') {
|
|
64
|
+
ctx.set('Content-Type', 'image/png');
|
|
65
|
+
}
|
|
66
|
+
ctx.body = content;
|
|
67
|
+
}
|
|
68
|
+
else {
|
|
71
69
|
return next();
|
|
72
70
|
}
|
|
73
|
-
const arr = pathname.split('/');
|
|
74
|
-
let lastName = arr.pop();
|
|
75
|
-
if (lastName === 'index.json') {
|
|
76
|
-
ctx.body = this.swaggerExplorer.getData();
|
|
77
|
-
return;
|
|
78
|
-
}
|
|
79
|
-
if (!lastName) {
|
|
80
|
-
lastName = 'index.html';
|
|
81
|
-
}
|
|
82
|
-
let content = (0, fs_1.readFileSync)((0, path_1.join)(this.swaggerUiAssetPath, lastName));
|
|
83
|
-
if (lastName === 'index.html' ||
|
|
84
|
-
lastName === 'swagger-initializer.js') {
|
|
85
|
-
content = content.toString('utf8');
|
|
86
|
-
content = this.replaceInfo(content);
|
|
87
|
-
}
|
|
88
|
-
const ext = (0, path_1.extname)(lastName);
|
|
89
|
-
if (ext === '.js') {
|
|
90
|
-
ctx.set('Content-Type', 'application/javascript');
|
|
91
|
-
}
|
|
92
|
-
else if (ext === '.map') {
|
|
93
|
-
ctx.set('Content-Type', 'application/json');
|
|
94
|
-
}
|
|
95
|
-
else if (ext === '.css') {
|
|
96
|
-
ctx.set('Content-Type', 'text/css');
|
|
97
|
-
}
|
|
98
|
-
else if (ext === '.png') {
|
|
99
|
-
ctx.set('Content-Type', 'image/png');
|
|
100
|
-
}
|
|
101
|
-
ctx.body = content;
|
|
102
71
|
};
|
|
103
72
|
}
|
|
104
73
|
}
|
|
105
|
-
replaceInfo(content) {
|
|
106
|
-
let str = `location.href.replace('${this.swaggerConfig.swaggerPath}/index.html', '${this.swaggerConfig.swaggerPath}/index.json'),\n validatorUrl: null,`;
|
|
107
|
-
if (this.swaggerConfig.displayOptions) {
|
|
108
|
-
Object.keys(this.swaggerConfig.displayOptions).forEach(key => {
|
|
109
|
-
str += `\n${key}: ${this.swaggerConfig.displayOptions[key]},`;
|
|
110
|
-
});
|
|
111
|
-
}
|
|
112
|
-
return content.replace('"https://petstore.swagger.io/v2/swagger.json",', str);
|
|
113
|
-
}
|
|
114
74
|
static getName() {
|
|
115
75
|
return 'swagger';
|
|
116
76
|
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { SwaggerOptions } from '../interfaces';
|
|
2
|
+
import { SwaggerExplorer } from '../swaggerExplorer';
|
|
3
|
+
export declare function renderSwaggerUIDist(swaggerConfig: SwaggerOptions, swaggerExplorer: SwaggerExplorer): (pathname: string) => Promise<{
|
|
4
|
+
ext: string;
|
|
5
|
+
content: any;
|
|
6
|
+
}>;
|
|
7
|
+
export declare function renderJSON(swaggerConfig: SwaggerOptions, swaggerExplorer: SwaggerExplorer): (pathname: string) => Promise<{
|
|
8
|
+
ext: string;
|
|
9
|
+
content: Omit<import("../interfaces").OpenAPIObject, "paths">;
|
|
10
|
+
}>;
|
|
11
|
+
export declare function renderSwaggerUIRemote(swaggerConfig: SwaggerOptions, swaggerExplorer: SwaggerExplorer, swaggerRenderOptions: any): (pathname: string) => Promise<{
|
|
12
|
+
ext: string;
|
|
13
|
+
content: Omit<import("../interfaces").OpenAPIObject, "paths">;
|
|
14
|
+
} | {
|
|
15
|
+
ext: string;
|
|
16
|
+
content: string;
|
|
17
|
+
}>;
|
|
18
|
+
//# sourceMappingURL=render.d.ts.map
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.renderSwaggerUIRemote = exports.renderJSON = exports.renderSwaggerUIDist = void 0;
|
|
4
|
+
const core_1 = require("@midwayjs/core");
|
|
5
|
+
const fs_1 = require("fs");
|
|
6
|
+
const path_1 = require("path");
|
|
7
|
+
function renderSwaggerUIDist(swaggerConfig, swaggerExplorer) {
|
|
8
|
+
const { getAbsoluteFSPath } = (0, core_1.safeRequire)('swagger-ui-dist');
|
|
9
|
+
if (!getAbsoluteFSPath) {
|
|
10
|
+
throw new core_1.MidwayCommonError('swagger-ui-dist is not installed');
|
|
11
|
+
}
|
|
12
|
+
function replaceInfo(content) {
|
|
13
|
+
let str = `location.href.replace('${swaggerConfig.swaggerPath}/index.html', '${swaggerConfig.swaggerPath}/index.json'),\n validatorUrl: null,`;
|
|
14
|
+
if (swaggerConfig.displayOptions) {
|
|
15
|
+
Object.keys(swaggerConfig.displayOptions).forEach(key => {
|
|
16
|
+
str += `\n${key}: ${swaggerConfig.displayOptions[key]},`;
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
return content.replace('"https://petstore.swagger.io/v2/swagger.json",', str);
|
|
20
|
+
}
|
|
21
|
+
const swaggerUiAssetPath = getAbsoluteFSPath();
|
|
22
|
+
return async (pathname) => {
|
|
23
|
+
if (!swaggerUiAssetPath ||
|
|
24
|
+
pathname.indexOf(swaggerConfig.swaggerPath) === -1) {
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
27
|
+
const arr = pathname.split('/');
|
|
28
|
+
let lastName = arr.pop();
|
|
29
|
+
if (lastName === 'index.json') {
|
|
30
|
+
return { ext: 'json', content: swaggerExplorer.getData() };
|
|
31
|
+
}
|
|
32
|
+
if (!lastName) {
|
|
33
|
+
lastName = 'index.html';
|
|
34
|
+
}
|
|
35
|
+
let content = (0, fs_1.readFileSync)((0, path_1.join)(swaggerUiAssetPath, lastName));
|
|
36
|
+
if (lastName === 'index.html' || lastName === 'swagger-initializer.js') {
|
|
37
|
+
content = content.toString('utf8');
|
|
38
|
+
content = replaceInfo(content);
|
|
39
|
+
}
|
|
40
|
+
const ext = (0, path_1.extname)(lastName);
|
|
41
|
+
return { ext, content };
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
exports.renderSwaggerUIDist = renderSwaggerUIDist;
|
|
45
|
+
function renderJSON(swaggerConfig, swaggerExplorer) {
|
|
46
|
+
return async (pathname) => {
|
|
47
|
+
if (pathname.indexOf(swaggerConfig.swaggerPath) === -1) {
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
if (pathname === 'index.json') {
|
|
51
|
+
return { ext: 'json', content: swaggerExplorer.getData() };
|
|
52
|
+
}
|
|
53
|
+
return;
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
exports.renderJSON = renderJSON;
|
|
57
|
+
function renderSwaggerUIRemote(swaggerConfig, swaggerExplorer, swaggerRenderOptions) {
|
|
58
|
+
const indexPagePath = (swaggerRenderOptions === null || swaggerRenderOptions === void 0 ? void 0 : swaggerRenderOptions.indexPagePath) || (0, path_1.join)(__dirname, '../../index.html');
|
|
59
|
+
return async (pathname) => {
|
|
60
|
+
if (pathname.indexOf(swaggerConfig.swaggerPath) === -1) {
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
63
|
+
const arr = pathname.split('/');
|
|
64
|
+
let lastName = arr.pop();
|
|
65
|
+
if (lastName === 'index.json') {
|
|
66
|
+
return { ext: 'json', content: swaggerExplorer.getData() };
|
|
67
|
+
}
|
|
68
|
+
if (!lastName) {
|
|
69
|
+
lastName = 'index.html';
|
|
70
|
+
}
|
|
71
|
+
if (lastName === 'index.html') {
|
|
72
|
+
const content = (0, fs_1.readFileSync)(indexPagePath, 'utf8');
|
|
73
|
+
return { ext: 'html', content };
|
|
74
|
+
}
|
|
75
|
+
return;
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
exports.renderSwaggerUIRemote = renderSwaggerUIRemote;
|
|
79
|
+
//# sourceMappingURL=render.js.map
|
package/dist/ui.d.ts
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { SwaggerOptions } from './interfaces';
|
|
2
|
+
export declare function renderSwaggerUI(swaggerConfig: SwaggerOptions): (pathname: string) => Promise<{
|
|
3
|
+
ext: string;
|
|
4
|
+
content: any;
|
|
5
|
+
}>;
|
|
6
|
+
export declare function renderJSON(swaggerConfig: SwaggerOptions): (pathname: string) => Promise<{
|
|
7
|
+
ext: string;
|
|
8
|
+
content: any;
|
|
9
|
+
}>;
|
|
10
|
+
//# sourceMappingURL=ui.d.ts.map
|
package/dist/ui.js
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.renderJSON = exports.renderSwaggerUI = void 0;
|
|
4
|
+
const core_1 = require("@midwayjs/core");
|
|
5
|
+
const fs_1 = require("fs");
|
|
6
|
+
const path_1 = require("path");
|
|
7
|
+
function renderSwaggerUI(swaggerConfig) {
|
|
8
|
+
const { getAbsoluteFSPath } = (0, core_1.safeRequire)('swagger-ui-dist');
|
|
9
|
+
if (!getAbsoluteFSPath) {
|
|
10
|
+
throw new core_1.MidwayCommonError('swagger-ui-dist is not installed');
|
|
11
|
+
}
|
|
12
|
+
function replaceInfo(content) {
|
|
13
|
+
let str = `location.href.replace('${this.swaggerConfig.swaggerPath}/index.html', '${this.swaggerConfig.swaggerPath}/index.json'),\n validatorUrl: null,`;
|
|
14
|
+
if (this.swaggerConfig.displayOptions) {
|
|
15
|
+
Object.keys(this.swaggerConfig.displayOptions).forEach(key => {
|
|
16
|
+
str += `\n${key}: ${this.swaggerConfig.displayOptions[key]},`;
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
return content.replace('"https://petstore.swagger.io/v2/swagger.json",', str);
|
|
20
|
+
}
|
|
21
|
+
const swaggerUiAssetPath = getAbsoluteFSPath();
|
|
22
|
+
return async (pathname) => {
|
|
23
|
+
if (!swaggerUiAssetPath ||
|
|
24
|
+
pathname.indexOf(swaggerConfig.swaggerPath) === -1) {
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
27
|
+
const arr = pathname.split('/');
|
|
28
|
+
let lastName = arr.pop();
|
|
29
|
+
if (lastName === 'index.json') {
|
|
30
|
+
return { ext: 'json', content: this.swaggerExplorer.getData() };
|
|
31
|
+
}
|
|
32
|
+
if (!lastName) {
|
|
33
|
+
lastName = 'index.html';
|
|
34
|
+
}
|
|
35
|
+
let content = (0, fs_1.readFileSync)((0, path_1.join)(swaggerUiAssetPath, lastName));
|
|
36
|
+
if (lastName === 'index.html' || lastName === 'swagger-initializer.js') {
|
|
37
|
+
content = content.toString('utf8');
|
|
38
|
+
content = replaceInfo(content);
|
|
39
|
+
}
|
|
40
|
+
const ext = (0, path_1.extname)(lastName);
|
|
41
|
+
return { ext, content };
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
exports.renderSwaggerUI = renderSwaggerUI;
|
|
45
|
+
function renderJSON(swaggerConfig) {
|
|
46
|
+
return async (pathname) => {
|
|
47
|
+
if (pathname.indexOf(swaggerConfig.swaggerPath) === -1) {
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
if (pathname === 'index.json') {
|
|
51
|
+
return { ext: 'json', content: this.swaggerExplorer.getData() };
|
|
52
|
+
}
|
|
53
|
+
return;
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
exports.renderJSON = renderJSON;
|
|
57
|
+
//# sourceMappingURL=ui.js.map
|
package/index.html
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html lang="en">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="utf-8" />
|
|
5
|
+
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
|
6
|
+
<meta
|
|
7
|
+
name="description"
|
|
8
|
+
content="SwaggerUI"
|
|
9
|
+
/>
|
|
10
|
+
<title>SwaggerUI</title>
|
|
11
|
+
<link rel="stylesheet" href="https://unpkg.com/swagger-ui-dist@5.10.5/swagger-ui.css" />
|
|
12
|
+
</head>
|
|
13
|
+
<body>
|
|
14
|
+
<div id="swagger-ui"></div>
|
|
15
|
+
<script src="https://unpkg.com/swagger-ui-dist@5.10.5/swagger-ui-bundle.js" crossorigin></script>
|
|
16
|
+
<script src="https://unpkg.com/swagger-ui-dist@5.10.5/swagger-ui-standalone-preset.js" crossorigin></script>
|
|
17
|
+
<script>
|
|
18
|
+
window.onload = () => {
|
|
19
|
+
window.ui = SwaggerUIBundle({
|
|
20
|
+
url: '/swagger-ui/index.json',
|
|
21
|
+
dom_id: '#swagger-ui',
|
|
22
|
+
presets: [
|
|
23
|
+
SwaggerUIBundle.presets.apis,
|
|
24
|
+
SwaggerUIStandalonePreset
|
|
25
|
+
],
|
|
26
|
+
layout: 'StandaloneLayout',
|
|
27
|
+
persistAuthorization: true,
|
|
28
|
+
});
|
|
29
|
+
};
|
|
30
|
+
</script>
|
|
31
|
+
</body>
|
|
32
|
+
</html>
|
package/package.json
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@midwayjs/swagger",
|
|
3
|
-
"version": "3.13.
|
|
3
|
+
"version": "3.13.10-beta.2",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"typings": "index.d.ts",
|
|
6
6
|
"files": [
|
|
7
7
|
"dist/**/*.js",
|
|
8
8
|
"dist/**/*.d.ts",
|
|
9
|
-
"index.d.ts"
|
|
9
|
+
"index.d.ts",
|
|
10
|
+
"index.html"
|
|
10
11
|
],
|
|
11
12
|
"devDependencies": {
|
|
12
13
|
"@midwayjs/core": "^3.13.7",
|
|
@@ -26,6 +27,5 @@
|
|
|
26
27
|
"repository": {
|
|
27
28
|
"type": "git",
|
|
28
29
|
"url": "https://github.com/midwayjs/midway.git"
|
|
29
|
-
}
|
|
30
|
-
"gitHead": "00750219506f4e3ad0e1dbb167d295610005b328"
|
|
30
|
+
}
|
|
31
31
|
}
|
package/LICENSE
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2013 - Now midwayjs
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|