@tsed/swagger 7.0.0-alpha.2 → 7.0.0-beta.1
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/lib/cjs/SwaggerModule.js +133 -0
- package/lib/cjs/SwaggerModule.js.map +1 -0
- package/lib/cjs/decorators/docs.js +18 -0
- package/lib/cjs/decorators/docs.js.map +1 -0
- package/lib/cjs/decorators/hidden.js +40 -0
- package/lib/cjs/decorators/hidden.js.map +1 -0
- package/lib/cjs/index.js +9 -0
- package/lib/cjs/index.js.map +1 -0
- package/lib/cjs/interfaces/SwaggerSettings.js +3 -0
- package/lib/cjs/interfaces/SwaggerSettings.js.map +1 -0
- package/lib/cjs/interfaces/index.js +5 -0
- package/lib/cjs/interfaces/index.js.map +1 -0
- package/lib/cjs/middlewares/cssMiddleware.js +23 -0
- package/lib/cjs/middlewares/cssMiddleware.js.map +1 -0
- package/lib/cjs/middlewares/indexMiddleware.js +24 -0
- package/lib/cjs/middlewares/indexMiddleware.js.map +1 -0
- package/lib/cjs/middlewares/jsMiddleware.js +18 -0
- package/lib/cjs/middlewares/jsMiddleware.js.map +1 -0
- package/lib/cjs/middlewares/redirectMiddleware.js +16 -0
- package/lib/cjs/middlewares/redirectMiddleware.js.map +1 -0
- package/lib/cjs/services/SwaggerService.js +103 -0
- package/lib/cjs/services/SwaggerService.js.map +1 -0
- package/lib/cjs/utils/getSpecType.js +21 -0
- package/lib/cjs/utils/getSpecType.js.map +1 -0
- package/lib/cjs/utils/includeRoute.js +20 -0
- package/lib/cjs/utils/includeRoute.js.map +1 -0
- package/lib/cjs/utils/index.js +11 -0
- package/lib/cjs/utils/index.js.map +1 -0
- package/lib/cjs/utils/mapOpenSpec.js +40 -0
- package/lib/cjs/utils/mapOpenSpec.js.map +1 -0
- package/lib/cjs/utils/mapOpenSpec2.js +35 -0
- package/lib/cjs/utils/mapOpenSpec2.js.map +1 -0
- package/lib/cjs/utils/mapOpenSpec3.js +26 -0
- package/lib/cjs/utils/mapOpenSpec3.js.map +1 -0
- package/lib/cjs/utils/mapOpenSpecInfo.js +21 -0
- package/lib/cjs/utils/mapOpenSpecInfo.js.map +1 -0
- package/lib/cjs/utils/matchPath.js +10 -0
- package/lib/cjs/utils/matchPath.js.map +1 -0
- package/lib/esm/SwaggerModule.js +130 -0
- package/lib/esm/SwaggerModule.js.map +1 -0
- package/lib/esm/decorators/docs.js +14 -0
- package/lib/esm/decorators/docs.js.map +1 -0
- package/lib/esm/decorators/hidden.js +36 -0
- package/lib/esm/decorators/hidden.js.map +1 -0
- package/lib/esm/index.js +6 -0
- package/lib/esm/index.js.map +1 -0
- package/lib/esm/interfaces/SwaggerSettings.js +2 -0
- package/lib/esm/interfaces/SwaggerSettings.js.map +1 -0
- package/lib/esm/interfaces/index.js +2 -0
- package/lib/esm/interfaces/index.js.map +1 -0
- package/lib/esm/middlewares/cssMiddleware.js +18 -0
- package/lib/esm/middlewares/cssMiddleware.js.map +1 -0
- package/lib/esm/middlewares/indexMiddleware.js +20 -0
- package/lib/esm/middlewares/indexMiddleware.js.map +1 -0
- package/lib/esm/middlewares/jsMiddleware.js +13 -0
- package/lib/esm/middlewares/jsMiddleware.js.map +1 -0
- package/lib/esm/middlewares/redirectMiddleware.js +12 -0
- package/lib/esm/middlewares/redirectMiddleware.js.map +1 -0
- package/lib/esm/services/SwaggerService.js +100 -0
- package/lib/esm/services/SwaggerService.js.map +1 -0
- package/lib/esm/utils/getSpecType.js +16 -0
- package/lib/esm/utils/getSpecType.js.map +1 -0
- package/lib/esm/utils/includeRoute.js +16 -0
- package/lib/esm/utils/includeRoute.js.map +1 -0
- package/lib/esm/utils/index.js +8 -0
- package/lib/esm/utils/index.js.map +1 -0
- package/lib/esm/utils/mapOpenSpec.js +36 -0
- package/lib/esm/utils/mapOpenSpec.js.map +1 -0
- package/lib/esm/utils/mapOpenSpec2.js +31 -0
- package/lib/esm/utils/mapOpenSpec2.js.map +1 -0
- package/lib/esm/utils/mapOpenSpec3.js +22 -0
- package/lib/esm/utils/mapOpenSpec3.js.map +1 -0
- package/lib/esm/utils/mapOpenSpecInfo.js +17 -0
- package/lib/esm/utils/mapOpenSpecInfo.js.map +1 -0
- package/lib/esm/utils/matchPath.js +5 -0
- package/lib/esm/utils/matchPath.js.map +1 -0
- package/lib/{SwaggerModule.d.ts → types/SwaggerModule.d.ts} +5 -3
- package/lib/{decorators → types/decorators}/docs.d.ts +0 -0
- package/lib/{decorators → types/decorators}/hidden.d.ts +0 -0
- package/lib/{index.d.ts → types/index.d.ts} +0 -0
- package/lib/{interfaces → types/interfaces}/SwaggerSettings.d.ts +0 -0
- package/lib/{interfaces → types/interfaces}/index.d.ts +0 -0
- package/lib/{middlewares → types/middlewares}/cssMiddleware.d.ts +0 -0
- package/lib/{middlewares → types/middlewares}/indexMiddleware.d.ts +0 -0
- package/lib/{middlewares → types/middlewares}/jsMiddleware.d.ts +0 -0
- package/lib/{middlewares → types/middlewares}/redirectMiddleware.d.ts +0 -0
- package/lib/{services → types/services}/SwaggerService.d.ts +6 -0
- package/lib/{utils → types/utils}/getSpecType.d.ts +0 -0
- package/lib/{utils → types/utils}/includeRoute.d.ts +0 -0
- package/lib/{utils → types/utils}/index.d.ts +0 -0
- package/lib/{utils → types/utils}/mapOpenSpec.d.ts +0 -0
- package/lib/{utils → types/utils}/mapOpenSpec2.d.ts +1 -0
- package/lib/{utils → types/utils}/mapOpenSpec3.d.ts +0 -0
- package/lib/{utils → types/utils}/mapOpenSpecInfo.d.ts +0 -0
- package/lib/{utils → types/utils}/matchPath.d.ts +0 -0
- package/lib/views/index.ejs +145 -0
- package/lib/views/index.html +144 -0
- package/package.json +23 -22
- package/tsconfig.compile.esm.json +24 -0
- package/lib/index.js +0 -629
- package/lib/index.js.map +0 -1
- package/lib/index.modern.js +0 -626
- package/lib/index.modern.js.map +0 -1
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { getValue, setValue } from "@tsed/core";
|
|
2
|
+
import { mergeSpec, SpecTypes } from "@tsed/schema";
|
|
3
|
+
import { getSpecType } from "./getSpecType";
|
|
4
|
+
import { mapOpenSpec2 } from "./mapOpenSpec2";
|
|
5
|
+
import { mapOpenSpec3 } from "./mapOpenSpec3";
|
|
6
|
+
/**
|
|
7
|
+
* @ignore
|
|
8
|
+
* @param spec
|
|
9
|
+
* @param fileSpec
|
|
10
|
+
* @param version
|
|
11
|
+
* @param acceptMimes
|
|
12
|
+
* @param specVersion
|
|
13
|
+
*/
|
|
14
|
+
export function mapOpenSpec(spec, { fileSpec, acceptMimes, specVersion, version }) {
|
|
15
|
+
specVersion = specVersion || getValue(spec, "openapi", getValue(spec, "swagger", "2.0"));
|
|
16
|
+
const options = {
|
|
17
|
+
specVersion,
|
|
18
|
+
acceptMimes
|
|
19
|
+
};
|
|
20
|
+
switch (getSpecType(specVersion)) {
|
|
21
|
+
case SpecTypes.OPENAPI:
|
|
22
|
+
spec = mapOpenSpec3(spec, options);
|
|
23
|
+
fileSpec = fileSpec ? mapOpenSpec3(fileSpec, options) : fileSpec;
|
|
24
|
+
break;
|
|
25
|
+
default:
|
|
26
|
+
case SpecTypes.SWAGGER:
|
|
27
|
+
spec = mapOpenSpec2(spec, options);
|
|
28
|
+
fileSpec = fileSpec ? mapOpenSpec2(fileSpec, options) : fileSpec;
|
|
29
|
+
break;
|
|
30
|
+
}
|
|
31
|
+
spec = mergeSpec(spec, fileSpec);
|
|
32
|
+
setValue(spec, "info.title", getValue(spec, "info.title", "Api documentation"));
|
|
33
|
+
setValue(spec, "info.version", getValue(spec, "info.version", version));
|
|
34
|
+
return spec;
|
|
35
|
+
}
|
|
36
|
+
//# sourceMappingURL=mapOpenSpec.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mapOpenSpec.js","sourceRoot":"","sources":["../../../src/utils/mapOpenSpec.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,QAAQ,EAAE,QAAQ,EAAC,MAAM,YAAY,CAAC;AAE9C,OAAO,EAAC,SAAS,EAAE,SAAS,EAAC,MAAM,cAAc,CAAC;AAClD,OAAO,EAAC,WAAW,EAAC,MAAM,eAAe,CAAC;AAC1C,OAAO,EAAC,YAAY,EAAC,MAAM,gBAAgB,CAAC;AAC5C,OAAO,EAAC,YAAY,EAAC,MAAM,gBAAgB,CAAC;AAE5C;;;;;;;GAOG;AACH,MAAM,UAAU,WAAW,CAAC,IAAS,EAAE,EAAC,QAAQ,EAAE,WAAW,EAAE,WAAW,EAAE,OAAO,EAAM;IACvF,WAAW,GAAG,WAAW,IAAI,QAAQ,CAAmB,IAAI,EAAE,SAAS,EAAE,QAAQ,CAAC,IAAI,EAAE,SAAS,EAAE,KAAK,CAAC,CAAC,CAAC;IAE3G,MAAM,OAAO,GAAG;QACd,WAAW;QACX,WAAW;KACZ,CAAC;IAEF,QAAQ,WAAW,CAAC,WAAW,CAAC,EAAE;QAChC,KAAK,SAAS,CAAC,OAAO;YACpB,IAAI,GAAG,YAAY,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;YACnC,QAAQ,GAAG,QAAQ,CAAC,CAAC,CAAC,YAAY,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC;YACjE,MAAM;QACR,QAAQ;QACR,KAAK,SAAS,CAAC,OAAO;YACpB,IAAI,GAAG,YAAY,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;YACnC,QAAQ,GAAG,QAAQ,CAAC,CAAC,CAAC,YAAY,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC;YACjE,MAAM;KACT;IAED,IAAI,GAAG,SAAS,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC;IAEjC,QAAQ,CAAC,IAAI,EAAE,YAAY,EAAE,QAAQ,CAAC,IAAI,EAAE,YAAY,EAAE,mBAAmB,CAAC,CAAC,CAAC;IAChF,QAAQ,CAAC,IAAI,EAAE,cAAc,EAAE,QAAQ,CAAC,IAAI,EAAE,cAAc,EAAE,OAAO,CAAC,CAAC,CAAC;IAExE,OAAO,IAAI,CAAC;AACd,CAAC","sourcesContent":["import {getValue, setValue} from \"@tsed/core\";\nimport {OpenSpec2, OpenSpec3, OpenSpecVersions} from \"@tsed/openspec\";\nimport {mergeSpec, SpecTypes} from \"@tsed/schema\";\nimport {getSpecType} from \"./getSpecType\";\nimport {mapOpenSpec2} from \"./mapOpenSpec2\";\nimport {mapOpenSpec3} from \"./mapOpenSpec3\";\n\n/**\n * @ignore\n * @param spec\n * @param fileSpec\n * @param version\n * @param acceptMimes\n * @param specVersion\n */\nexport function mapOpenSpec(spec: any, {fileSpec, acceptMimes, specVersion, version}: any): Partial<OpenSpec2 | OpenSpec3> {\n specVersion = specVersion || getValue<OpenSpecVersions>(spec, \"openapi\", getValue(spec, \"swagger\", \"2.0\"));\n\n const options = {\n specVersion,\n acceptMimes\n };\n\n switch (getSpecType(specVersion)) {\n case SpecTypes.OPENAPI:\n spec = mapOpenSpec3(spec, options);\n fileSpec = fileSpec ? mapOpenSpec3(fileSpec, options) : fileSpec;\n break;\n default:\n case SpecTypes.SWAGGER:\n spec = mapOpenSpec2(spec, options);\n fileSpec = fileSpec ? mapOpenSpec2(fileSpec, options) : fileSpec;\n break;\n }\n\n spec = mergeSpec(spec, fileSpec);\n\n setValue(spec, \"info.title\", getValue(spec, \"info.title\", \"Api documentation\"));\n setValue(spec, \"info.version\", getValue(spec, \"info.version\", version));\n\n return spec;\n}\n"]}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { getValue, uniq } from "@tsed/core";
|
|
2
|
+
import { mapOpenSpecInfo } from "./mapOpenSpecInfo";
|
|
3
|
+
/**
|
|
4
|
+
* @ignore
|
|
5
|
+
* @param spec
|
|
6
|
+
* @param version
|
|
7
|
+
* @param specVersion
|
|
8
|
+
* @param acceptMimes
|
|
9
|
+
* @deprecated
|
|
10
|
+
*/
|
|
11
|
+
export function mapOpenSpec2(spec, { version, specVersion, acceptMimes = ["application/json"] }) {
|
|
12
|
+
const { paths, security, tags, host, basePath, schemes, consumes = [], produces = ["application/json"], definitions, parameters, responses, securityDefinitions, externalDocs } = spec;
|
|
13
|
+
return {
|
|
14
|
+
swagger: specVersion,
|
|
15
|
+
consumes: uniq([...acceptMimes, ...consumes]),
|
|
16
|
+
produces: uniq([...produces]),
|
|
17
|
+
info: mapOpenSpecInfo(getValue(spec, "info", {})),
|
|
18
|
+
paths,
|
|
19
|
+
host,
|
|
20
|
+
basePath,
|
|
21
|
+
schemes,
|
|
22
|
+
definitions,
|
|
23
|
+
parameters,
|
|
24
|
+
responses,
|
|
25
|
+
security,
|
|
26
|
+
securityDefinitions,
|
|
27
|
+
tags,
|
|
28
|
+
externalDocs
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
//# sourceMappingURL=mapOpenSpec2.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mapOpenSpec2.js","sourceRoot":"","sources":["../../../src/utils/mapOpenSpec2.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,QAAQ,EAAE,IAAI,EAAC,MAAM,YAAY,CAAC;AAE1C,OAAO,EAAC,eAAe,EAAC,MAAM,mBAAmB,CAAC;AAElD;;;;;;;GAOG;AACH,MAAM,UAAU,YAAY,CAC1B,IAAwB,EACxB,EAAC,OAAO,EAAE,WAAW,EAAE,WAAW,GAAG,CAAC,kBAAkB,CAAC,EAAM;IAE/D,MAAM,EACJ,KAAK,EACL,QAAQ,EACR,IAAI,EACJ,IAAI,EACJ,QAAQ,EACR,OAAO,EACP,QAAQ,GAAG,EAAE,EACb,QAAQ,GAAG,CAAC,kBAAkB,CAAC,EAC/B,WAAW,EACX,UAAU,EACV,SAAS,EACT,mBAAmB,EACnB,YAAY,EACb,GAAG,IAAI,CAAC;IAET,OAAO;QACL,OAAO,EAAE,WAAW;QACpB,QAAQ,EAAE,IAAI,CAAC,CAAC,GAAG,WAAW,EAAE,GAAG,QAAQ,CAAC,CAAC;QAC7C,QAAQ,EAAE,IAAI,CAAS,CAAC,GAAG,QAAQ,CAAC,CAAC;QACrC,IAAI,EAAE,eAAe,CAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,CAAC,CAAC;QACjD,KAAK;QACL,IAAI;QACJ,QAAQ;QACR,OAAO;QACP,WAAW;QACX,UAAU;QACV,SAAS;QACT,QAAQ;QACR,mBAAmB;QACnB,IAAI;QACJ,YAAY;KACb,CAAC;AACJ,CAAC","sourcesContent":["import {getValue, uniq} from \"@tsed/core\";\nimport {OpenSpec2} from \"@tsed/openspec\";\nimport {mapOpenSpecInfo} from \"./mapOpenSpecInfo\";\n\n/**\n * @ignore\n * @param spec\n * @param version\n * @param specVersion\n * @param acceptMimes\n * @deprecated\n */\nexport function mapOpenSpec2(\n spec: Partial<OpenSpec2>,\n {version, specVersion, acceptMimes = [\"application/json\"]}: any\n): Partial<OpenSpec2> {\n const {\n paths,\n security,\n tags,\n host,\n basePath,\n schemes,\n consumes = [],\n produces = [\"application/json\"],\n definitions,\n parameters,\n responses,\n securityDefinitions,\n externalDocs\n } = spec;\n\n return {\n swagger: specVersion,\n consumes: uniq([...acceptMimes, ...consumes]),\n produces: uniq<string>([...produces]),\n info: mapOpenSpecInfo(getValue(spec, \"info\", {})),\n paths,\n host,\n basePath,\n schemes,\n definitions,\n parameters,\n responses,\n security,\n securityDefinitions,\n tags,\n externalDocs\n };\n}\n"]}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { getValue } from "@tsed/core";
|
|
2
|
+
import { mapOpenSpecInfo } from "./mapOpenSpecInfo";
|
|
3
|
+
/**
|
|
4
|
+
* @ignore
|
|
5
|
+
* @param spec
|
|
6
|
+
* @param version
|
|
7
|
+
* @param specVersion
|
|
8
|
+
*/
|
|
9
|
+
export function mapOpenSpec3(spec, { specVersion }) {
|
|
10
|
+
const { servers, paths, components, security, tags, externalDocs } = spec;
|
|
11
|
+
return {
|
|
12
|
+
openapi: specVersion,
|
|
13
|
+
info: mapOpenSpecInfo(getValue(spec, "info", {})),
|
|
14
|
+
servers,
|
|
15
|
+
paths,
|
|
16
|
+
components,
|
|
17
|
+
security,
|
|
18
|
+
tags,
|
|
19
|
+
externalDocs
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
//# sourceMappingURL=mapOpenSpec3.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mapOpenSpec3.js","sourceRoot":"","sources":["../../../src/utils/mapOpenSpec3.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,QAAQ,EAAC,MAAM,YAAY,CAAC;AAEpC,OAAO,EAAC,eAAe,EAAC,MAAM,mBAAmB,CAAC;AAElD;;;;;GAKG;AACH,MAAM,UAAU,YAAY,CAAC,IAAS,EAAE,EAAC,WAAW,EAAM;IACxD,MAAM,EAAC,OAAO,EAAE,KAAK,EAAE,UAAU,EAAE,QAAQ,EAAE,IAAI,EAAE,YAAY,EAAC,GAAG,IAAI,CAAC;IAExE,OAAO;QACL,OAAO,EAAE,WAAW;QACpB,IAAI,EAAE,eAAe,CAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,CAAC,CAAC;QACjD,OAAO;QACP,KAAK;QACL,UAAU;QACV,QAAQ;QACR,IAAI;QACJ,YAAY;KACb,CAAC;AACJ,CAAC","sourcesContent":["import {getValue} from \"@tsed/core\";\nimport {OpenSpec3} from \"@tsed/openspec\";\nimport {mapOpenSpecInfo} from \"./mapOpenSpecInfo\";\n\n/**\n * @ignore\n * @param spec\n * @param version\n * @param specVersion\n */\nexport function mapOpenSpec3(spec: any, {specVersion}: any): Partial<OpenSpec3> {\n const {servers, paths, components, security, tags, externalDocs} = spec;\n\n return {\n openapi: specVersion,\n info: mapOpenSpecInfo(getValue(spec, \"info\", {})),\n servers,\n paths,\n components,\n security,\n tags,\n externalDocs\n };\n}\n"]}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { cleanObject } from "@tsed/core";
|
|
2
|
+
/**
|
|
3
|
+
* @ignore
|
|
4
|
+
* @param info
|
|
5
|
+
*/
|
|
6
|
+
export function mapOpenSpecInfo(info) {
|
|
7
|
+
const { title, description, version, termsOfService, contact, license } = info;
|
|
8
|
+
return cleanObject({
|
|
9
|
+
version,
|
|
10
|
+
title,
|
|
11
|
+
description,
|
|
12
|
+
termsOfService,
|
|
13
|
+
contact,
|
|
14
|
+
license
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=mapOpenSpecInfo.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mapOpenSpecInfo.js","sourceRoot":"","sources":["../../../src/utils/mapOpenSpecInfo.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,WAAW,EAAC,MAAM,YAAY,CAAC;AAGvC;;;GAGG;AACH,MAAM,UAAU,eAAe,CAAC,IAA2B;IACzD,MAAM,EAAC,KAAK,EAAE,WAAW,EAAE,OAAO,EAAE,cAAc,EAAE,OAAO,EAAE,OAAO,EAAC,GAAG,IAAI,CAAC;IAE7E,OAAO,WAAW,CAAC;QACjB,OAAO;QACP,KAAK;QACL,WAAW;QACX,cAAc;QACd,OAAO;QACP,OAAO;KACR,CAAC,CAAC;AACL,CAAC","sourcesContent":["import {cleanObject} from \"@tsed/core\";\nimport {OpenSpecInfo} from \"@tsed/openspec\";\n\n/**\n * @ignore\n * @param info\n */\nexport function mapOpenSpecInfo(info: Partial<OpenSpecInfo>): OpenSpecInfo {\n const {title, description, version, termsOfService, contact, license} = info;\n\n return cleanObject({\n version,\n title,\n description,\n termsOfService,\n contact,\n license\n });\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"matchPath.js","sourceRoot":"","sources":["../../../src/utils/matchPath.ts"],"names":[],"mappings":"AAAA,OAAO,UAAU,MAAM,YAAY,CAAC;AAEpC,MAAM,UAAU,SAAS,CAAC,IAAY,EAAE,QAAmB;IACzD,OAAO,QAAQ,IAAI,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,UAAU,CAAC,OAAO,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;AACjF,CAAC","sourcesContent":["import micromatch from \"micromatch\";\n\nexport function matchPath(path: string, patterns?: string[]) {\n return patterns && patterns.length ? micromatch.isMatch(path, patterns) : true;\n}\n"]}
|
|
@@ -1,20 +1,22 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { OnRoutesInit, Configuration, InjectorService, OnReady, PlatformApplication } from "@tsed/common";
|
|
2
2
|
import { SwaggerSettings } from "./interfaces";
|
|
3
3
|
import { SwaggerService } from "./services/SwaggerService";
|
|
4
|
+
import { Env } from "@tsed/core";
|
|
4
5
|
/**
|
|
5
6
|
* @ignore
|
|
6
7
|
*/
|
|
7
|
-
export declare class SwaggerModule implements
|
|
8
|
+
export declare class SwaggerModule implements OnRoutesInit, OnReady {
|
|
8
9
|
injector: InjectorService;
|
|
9
10
|
app: PlatformApplication;
|
|
10
11
|
configuration: Configuration;
|
|
11
12
|
swaggerService: SwaggerService;
|
|
13
|
+
env: Env;
|
|
12
14
|
private loaded;
|
|
13
15
|
get settings(): SwaggerSettings[];
|
|
14
16
|
/**
|
|
15
17
|
*
|
|
16
18
|
*/
|
|
17
|
-
$
|
|
19
|
+
$onRoutesInit(): void;
|
|
18
20
|
$onReady(): void;
|
|
19
21
|
generateSpecFiles(): Promise<void[]>;
|
|
20
22
|
private getUrls;
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -13,7 +13,13 @@ export declare class SwaggerService {
|
|
|
13
13
|
* @returns {Spec}
|
|
14
14
|
*/
|
|
15
15
|
getOpenAPISpec(conf: SwaggerOS3Settings): OpenSpec3;
|
|
16
|
+
/**
|
|
17
|
+
* @deprecated
|
|
18
|
+
*/
|
|
16
19
|
getOpenAPISpec(conf: SwaggerOS2Settings): OpenSpec2;
|
|
20
|
+
/**
|
|
21
|
+
* @deprecated
|
|
22
|
+
*/
|
|
17
23
|
getOpenAPISpec(conf: SwaggerSettings): OpenSpec2;
|
|
18
24
|
/**
|
|
19
25
|
* Return the global api information.
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html lang="en">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="UTF-8">
|
|
5
|
+
<title>Swagger UI</title>
|
|
6
|
+
<link href="https://fonts.googleapis.com/css?family=Open+Sans:400,700|Source+Code+Pro:300,600|Titillium+Web:400,600,700"
|
|
7
|
+
rel="stylesheet">
|
|
8
|
+
<link rel="stylesheet" type="text/css" href="./swagger-ui.css">
|
|
9
|
+
<link rel="icon" type="image/png" href="./favicon-32x32.png" sizes="32x32"/>
|
|
10
|
+
<link rel="icon" type="image/png" href="./favicon-16x16.png" sizes="16x16"/>
|
|
11
|
+
<style>
|
|
12
|
+
html {
|
|
13
|
+
box-sizing: border-box;
|
|
14
|
+
overflow: -moz-scrollbars-vertical;
|
|
15
|
+
overflow-y: scroll;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
*,
|
|
19
|
+
*:before,
|
|
20
|
+
*:after {
|
|
21
|
+
box-sizing: inherit;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
body {
|
|
25
|
+
margin: 0;
|
|
26
|
+
background: #fafafa;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
<% if (!showExplorer) { %>
|
|
30
|
+
.swagger-ui .topbar .download-url-wrapper {
|
|
31
|
+
display: none
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
<% } %>
|
|
35
|
+
</style>
|
|
36
|
+
<% if (cssPath) { %>
|
|
37
|
+
<link rel="stylesheet" type="text/css" href="./main.css">
|
|
38
|
+
<% } %>
|
|
39
|
+
</head>
|
|
40
|
+
|
|
41
|
+
<body>
|
|
42
|
+
<div id="swagger-ui"></div>
|
|
43
|
+
|
|
44
|
+
<script src="./swagger-ui-bundle.js"></script>
|
|
45
|
+
<script src="./swagger-ui-standalone-preset.js"></script>
|
|
46
|
+
<script>
|
|
47
|
+
if (typeof Object.assign !== 'function') {
|
|
48
|
+
// Must be writable: true, enumerable: false, configurable: true
|
|
49
|
+
Object.defineProperty(Object, "assign", {
|
|
50
|
+
value: function assign(target, varArgs) { // .length of function is 2
|
|
51
|
+
'use strict';
|
|
52
|
+
if (target == null) { // TypeError if undefined or null
|
|
53
|
+
throw new TypeError('Cannot convert undefined or null to object');
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
var to = Object(target);
|
|
57
|
+
|
|
58
|
+
for (var index = 1; index < arguments.length; index++) {
|
|
59
|
+
var nextSource = arguments[index];
|
|
60
|
+
|
|
61
|
+
if (nextSource != null) { // Skip over if undefined or null
|
|
62
|
+
for (var nextKey in nextSource) {
|
|
63
|
+
// Avoid bugs when hasOwnProperty is shadowed
|
|
64
|
+
if (Object.prototype.hasOwnProperty.call(nextSource, nextKey)) {
|
|
65
|
+
to[nextKey] = nextSource[nextKey];
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
return to;
|
|
71
|
+
},
|
|
72
|
+
writable: true,
|
|
73
|
+
configurable: true
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
</script>
|
|
77
|
+
<script>
|
|
78
|
+
const origin = window.location.origin;
|
|
79
|
+
const initialOptions = <%- JSON.stringify(swaggerOptions) %>;
|
|
80
|
+
const currentUrl = origin + "<%- url %>";
|
|
81
|
+
const urls = <%- JSON.stringify(urls) %>
|
|
82
|
+
.map(function (o) {
|
|
83
|
+
if (!o.url.match(/^https?:/)) {
|
|
84
|
+
const url = origin + o.url;
|
|
85
|
+
return {
|
|
86
|
+
name: o.name,
|
|
87
|
+
url: url,
|
|
88
|
+
selected: url === currentUrl
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
return o;
|
|
92
|
+
})
|
|
93
|
+
.sort(function (a, b) {
|
|
94
|
+
return a.selected ? -1 : 1
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
const SwaggerUIBuilder = {
|
|
98
|
+
config: Object.assign({
|
|
99
|
+
urls: urls,
|
|
100
|
+
dom_id: '#swagger-ui',
|
|
101
|
+
deepLinking: true,
|
|
102
|
+
presets: [
|
|
103
|
+
SwaggerUIBundle.presets.apis,
|
|
104
|
+
SwaggerUIStandalonePreset
|
|
105
|
+
],
|
|
106
|
+
plugins: [
|
|
107
|
+
SwaggerUIBundle.plugins.DownloadUrl
|
|
108
|
+
],
|
|
109
|
+
layout: "StandaloneLayout",
|
|
110
|
+
oauth2RedirectUrl: currentUrl.replace('swagger.json', 'oauth2-redirect.html'),
|
|
111
|
+
validatorUrl: origin.match('0.0.0.0') || origin.match('localhost') ? null : undefined
|
|
112
|
+
}, initialOptions),
|
|
113
|
+
/**
|
|
114
|
+
*
|
|
115
|
+
*/
|
|
116
|
+
init: function () {
|
|
117
|
+
this.ui = SwaggerUIBundle(this.config);
|
|
118
|
+
|
|
119
|
+
if (this.config.oauth) {
|
|
120
|
+
this.ui.initOAuth(this.config.oauth);
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
if (this.config.authorize) {
|
|
124
|
+
this.ui.authActions.authorize(this.config.authorize);
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
window.ui = this.ui;
|
|
128
|
+
|
|
129
|
+
const event = new Event('swagger.init');
|
|
130
|
+
document.dispatchEvent(event);
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
</script>
|
|
135
|
+
<% if (jsPath) { %>
|
|
136
|
+
<script src="./main.js"></script>
|
|
137
|
+
<% } %>
|
|
138
|
+
<script>
|
|
139
|
+
window.onload = function () {
|
|
140
|
+
SwaggerUIBuilder.init();
|
|
141
|
+
}
|
|
142
|
+
</script>
|
|
143
|
+
|
|
144
|
+
</body>
|
|
145
|
+
</html>
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html lang="en">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="UTF-8">
|
|
5
|
+
<title>Swagger UI</title>
|
|
6
|
+
<link href="https://fonts.googleapis.com/css?family=Open+Sans:400,700|Source+Code+Pro:300,600|Titillium+Web:400,600,700"
|
|
7
|
+
rel="stylesheet">
|
|
8
|
+
<link rel="stylesheet" type="text/css" href="./swagger-ui.css">
|
|
9
|
+
<link rel="icon" type="image/png" href="./favicon-32x32.png" sizes="32x32"/>
|
|
10
|
+
<link rel="icon" type="image/png" href="./favicon-16x16.png" sizes="16x16"/>
|
|
11
|
+
<style>
|
|
12
|
+
html {
|
|
13
|
+
box-sizing: border-box;
|
|
14
|
+
overflow: -moz-scrollbars-vertical;
|
|
15
|
+
overflow-y: scroll;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
*,
|
|
19
|
+
*:before,
|
|
20
|
+
*:after {
|
|
21
|
+
box-sizing: inherit;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
body {
|
|
25
|
+
margin: 0;
|
|
26
|
+
background: #fafafa;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
.swagger-ui .topbar .download-url-wrapper {
|
|
31
|
+
display: none
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
</style>
|
|
36
|
+
|
|
37
|
+
<link rel="stylesheet" type="text/css" href="./main.css">
|
|
38
|
+
|
|
39
|
+
</head>
|
|
40
|
+
|
|
41
|
+
<body>
|
|
42
|
+
<div id="swagger-ui"></div>
|
|
43
|
+
|
|
44
|
+
<script src="./swagger-ui-bundle.js"></script>
|
|
45
|
+
<script src="./swagger-ui-standalone-preset.js"></script>
|
|
46
|
+
<script>
|
|
47
|
+
if (typeof Object.assign !== 'function') {
|
|
48
|
+
// Must be writable: true, enumerable: false, configurable: true
|
|
49
|
+
Object.defineProperty(Object, "assign", {
|
|
50
|
+
value: function assign(target, varArgs) { // .length of function is 2
|
|
51
|
+
'use strict';
|
|
52
|
+
if (target == null) { // TypeError if undefined or null
|
|
53
|
+
throw new TypeError('Cannot convert undefined or null to object');
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
var to = Object(target);
|
|
57
|
+
|
|
58
|
+
for (var index = 1; index < arguments.length; index++) {
|
|
59
|
+
var nextSource = arguments[index];
|
|
60
|
+
|
|
61
|
+
if (nextSource != null) { // Skip over if undefined or null
|
|
62
|
+
for (var nextKey in nextSource) {
|
|
63
|
+
// Avoid bugs when hasOwnProperty is shadowed
|
|
64
|
+
if (Object.prototype.hasOwnProperty.call(nextSource, nextKey)) {
|
|
65
|
+
to[nextKey] = nextSource[nextKey];
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
return to;
|
|
71
|
+
},
|
|
72
|
+
writable: true,
|
|
73
|
+
configurable: true
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
</script>
|
|
77
|
+
<script>
|
|
78
|
+
const origin = window.location.origin;
|
|
79
|
+
const initialOptions = {};
|
|
80
|
+
const currentUrl = origin + "/doc/swagger.json";
|
|
81
|
+
const urls = []
|
|
82
|
+
.map(function (o) {
|
|
83
|
+
if (!o.url.match(/^https?:/)) {
|
|
84
|
+
const url = origin + o.url;
|
|
85
|
+
return {
|
|
86
|
+
name: o.name,
|
|
87
|
+
url: url,
|
|
88
|
+
selected: url === currentUrl
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
return o;
|
|
92
|
+
})
|
|
93
|
+
.sort(function (a, b) {
|
|
94
|
+
return a.selected ? -1 : 1
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
const SwaggerUIBuilder = {
|
|
98
|
+
config: Object.assign({
|
|
99
|
+
urls: urls,
|
|
100
|
+
dom_id: '#swagger-ui',
|
|
101
|
+
deepLinking: true,
|
|
102
|
+
presets: [
|
|
103
|
+
SwaggerUIBundle.presets.apis,
|
|
104
|
+
SwaggerUIStandalonePreset
|
|
105
|
+
],
|
|
106
|
+
plugins: [
|
|
107
|
+
SwaggerUIBundle.plugins.DownloadUrl
|
|
108
|
+
],
|
|
109
|
+
layout: "StandaloneLayout",
|
|
110
|
+
validatorUrl: origin.match('0.0.0.0') || origin.match('localhost') ? null : undefined
|
|
111
|
+
}, initialOptions),
|
|
112
|
+
/**
|
|
113
|
+
*
|
|
114
|
+
*/
|
|
115
|
+
init: function () {
|
|
116
|
+
this.ui = SwaggerUIBundle(this.config);
|
|
117
|
+
|
|
118
|
+
if (this.config.oauth) {
|
|
119
|
+
this.ui.initOAuth(this.config.oauth);
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
if (this.config.authorize) {
|
|
123
|
+
this.ui.authActions.authorize(this.config.authorize);
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
window.ui = this.ui;
|
|
127
|
+
|
|
128
|
+
const event = new Event('swagger.init');
|
|
129
|
+
document.dispatchEvent(event);
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
</script>
|
|
134
|
+
|
|
135
|
+
<script src="./main.js"></script>
|
|
136
|
+
|
|
137
|
+
<script>
|
|
138
|
+
window.onload = function () {
|
|
139
|
+
SwaggerUIBuilder.init();
|
|
140
|
+
}
|
|
141
|
+
</script>
|
|
142
|
+
|
|
143
|
+
</body>
|
|
144
|
+
</html>
|
package/package.json
CHANGED
|
@@ -1,17 +1,21 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tsed/swagger",
|
|
3
|
-
"version": "7.0.0-
|
|
3
|
+
"version": "7.0.0-beta.1",
|
|
4
4
|
"description": "Swagger package for Ts.ED framework",
|
|
5
5
|
"private": false,
|
|
6
6
|
"source": "./src/index.ts",
|
|
7
|
-
"main": "./lib/index.js",
|
|
8
|
-
"typings": "./lib/index.d.ts",
|
|
7
|
+
"main": "./lib/cjs/index.js",
|
|
8
|
+
"typings": "./lib/types/index.d.ts",
|
|
9
9
|
"exports": {
|
|
10
|
-
"
|
|
11
|
-
"
|
|
10
|
+
"types": "./lib/types/index.d.ts",
|
|
11
|
+
"import": "./lib/esm/index.js",
|
|
12
|
+
"require": "./lib/cjs/index.js",
|
|
13
|
+
"default": "./lib/esm/index.js"
|
|
12
14
|
},
|
|
13
15
|
"scripts": {
|
|
14
|
-
"build": "
|
|
16
|
+
"build": "yarn run build:esm && yarn run build:cjs && cp -r ./views ./lib/views",
|
|
17
|
+
"build:cjs": "tsc --build tsconfig.compile.json",
|
|
18
|
+
"build:esm": "tsc --build tsconfig.compile.esm.json",
|
|
15
19
|
"start": "ts-node -r tsconfig-paths/register test/app/index.ts"
|
|
16
20
|
},
|
|
17
21
|
"dependencies": {
|
|
@@ -21,20 +25,20 @@
|
|
|
21
25
|
"tslib": "2.2.0"
|
|
22
26
|
},
|
|
23
27
|
"devDependencies": {
|
|
24
|
-
"@tsed/common": "7.0.0-
|
|
25
|
-
"@tsed/core": "7.0.0-
|
|
26
|
-
"@tsed/di": "7.0.0-
|
|
27
|
-
"@tsed/json-mapper": "7.0.0-
|
|
28
|
-
"@tsed/openspec": "7.0.0-
|
|
29
|
-
"@tsed/schema": "7.0.0-
|
|
28
|
+
"@tsed/common": "7.0.0-beta.1",
|
|
29
|
+
"@tsed/core": "7.0.0-beta.1",
|
|
30
|
+
"@tsed/di": "7.0.0-beta.1",
|
|
31
|
+
"@tsed/json-mapper": "7.0.0-beta.1",
|
|
32
|
+
"@tsed/openspec": "7.0.0-beta.1",
|
|
33
|
+
"@tsed/schema": "7.0.0-beta.1"
|
|
30
34
|
},
|
|
31
35
|
"peerDependencies": {
|
|
32
|
-
"@tsed/common": "^7.0.0-
|
|
33
|
-
"@tsed/core": "^7.0.0-
|
|
34
|
-
"@tsed/di": "^7.0.0-
|
|
35
|
-
"@tsed/json-mapper": "^7.0.0-
|
|
36
|
-
"@tsed/openspec": "^7.0.0-
|
|
37
|
-
"@tsed/schema": "^7.0.0-
|
|
36
|
+
"@tsed/common": "^7.0.0-beta.1",
|
|
37
|
+
"@tsed/core": "^7.0.0-beta.1",
|
|
38
|
+
"@tsed/di": "^7.0.0-beta.1",
|
|
39
|
+
"@tsed/json-mapper": "^7.0.0-beta.1",
|
|
40
|
+
"@tsed/openspec": "^7.0.0-beta.1",
|
|
41
|
+
"@tsed/schema": "^7.0.0-beta.1"
|
|
38
42
|
},
|
|
39
43
|
"repository": "https://github.com/tsedio/tsed",
|
|
40
44
|
"bugs": {
|
|
@@ -42,8 +46,5 @@
|
|
|
42
46
|
},
|
|
43
47
|
"homepage": "https://github.com/tsedio/tsed/tree/alpha/packages/specs/swagger",
|
|
44
48
|
"author": "Romain Lenzotti",
|
|
45
|
-
"license": "MIT"
|
|
46
|
-
"publishConfig": {
|
|
47
|
-
"tag": "alpha"
|
|
48
|
-
}
|
|
49
|
+
"license": "MIT"
|
|
49
50
|
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
{
|
|
2
|
+
"extends": "./tsconfig.compile.json",
|
|
3
|
+
"compilerOptions": {
|
|
4
|
+
"baseUrl": ".",
|
|
5
|
+
"module": "ES2020",
|
|
6
|
+
"rootDir": "src",
|
|
7
|
+
"outDir": "./lib/esm",
|
|
8
|
+
"declaration": true,
|
|
9
|
+
"declarationDir": "./lib/types"
|
|
10
|
+
},
|
|
11
|
+
"exclude": [
|
|
12
|
+
"node_modules",
|
|
13
|
+
"test",
|
|
14
|
+
"lib",
|
|
15
|
+
"benchmark",
|
|
16
|
+
"coverage",
|
|
17
|
+
"spec",
|
|
18
|
+
"views",
|
|
19
|
+
"**/*.benchmark.ts",
|
|
20
|
+
"**/*.spec.ts",
|
|
21
|
+
"keys",
|
|
22
|
+
"jest.config.js"
|
|
23
|
+
]
|
|
24
|
+
}
|