@tsed/swagger 6.88.1 → 6.92.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.
Files changed (122) hide show
  1. package/lib/{SwaggerModule.d.ts → cjs/SwaggerModule.d.ts} +2 -0
  2. package/lib/cjs/SwaggerModule.js +129 -0
  3. package/lib/cjs/SwaggerModule.js.map +1 -0
  4. package/lib/{decorators → cjs/decorators}/docs.d.ts +0 -0
  5. package/lib/cjs/decorators/docs.js +18 -0
  6. package/lib/cjs/decorators/docs.js.map +1 -0
  7. package/lib/{decorators → cjs/decorators}/hidden.d.ts +0 -0
  8. package/lib/cjs/decorators/hidden.js +40 -0
  9. package/lib/cjs/decorators/hidden.js.map +1 -0
  10. package/lib/{index.d.ts → cjs/index.d.ts} +0 -0
  11. package/lib/cjs/index.js +9 -0
  12. package/lib/cjs/index.js.map +1 -0
  13. package/lib/{interfaces → cjs/interfaces}/SwaggerSettings.d.ts +0 -0
  14. package/lib/cjs/interfaces/SwaggerSettings.js +3 -0
  15. package/lib/cjs/interfaces/SwaggerSettings.js.map +1 -0
  16. package/lib/{interfaces → cjs/interfaces}/index.d.ts +0 -0
  17. package/lib/cjs/interfaces/index.js +5 -0
  18. package/lib/cjs/interfaces/index.js.map +1 -0
  19. package/lib/{middlewares → cjs/middlewares}/cssMiddleware.d.ts +0 -0
  20. package/lib/cjs/middlewares/cssMiddleware.js +23 -0
  21. package/lib/cjs/middlewares/cssMiddleware.js.map +1 -0
  22. package/lib/{middlewares → cjs/middlewares}/indexMiddleware.d.ts +0 -0
  23. package/lib/cjs/middlewares/indexMiddleware.js +24 -0
  24. package/lib/cjs/middlewares/indexMiddleware.js.map +1 -0
  25. package/lib/{middlewares → cjs/middlewares}/jsMiddleware.d.ts +0 -0
  26. package/lib/cjs/middlewares/jsMiddleware.js +18 -0
  27. package/lib/cjs/middlewares/jsMiddleware.js.map +1 -0
  28. package/lib/{middlewares → cjs/middlewares}/redirectMiddleware.d.ts +0 -0
  29. package/lib/cjs/middlewares/redirectMiddleware.js +16 -0
  30. package/lib/cjs/middlewares/redirectMiddleware.js.map +1 -0
  31. package/lib/{services → cjs/services}/SwaggerService.d.ts +0 -0
  32. package/lib/cjs/services/SwaggerService.js +103 -0
  33. package/lib/cjs/services/SwaggerService.js.map +1 -0
  34. package/lib/{utils → cjs/utils}/getSpecType.d.ts +0 -0
  35. package/lib/cjs/utils/getSpecType.js +21 -0
  36. package/lib/cjs/utils/getSpecType.js.map +1 -0
  37. package/lib/{utils → cjs/utils}/includeRoute.d.ts +0 -0
  38. package/lib/cjs/utils/includeRoute.js +20 -0
  39. package/lib/cjs/utils/includeRoute.js.map +1 -0
  40. package/lib/{utils → cjs/utils}/index.d.ts +0 -0
  41. package/lib/cjs/utils/index.js +11 -0
  42. package/lib/cjs/utils/index.js.map +1 -0
  43. package/lib/{utils → cjs/utils}/mapOpenSpec.d.ts +0 -0
  44. package/lib/cjs/utils/mapOpenSpec.js +40 -0
  45. package/lib/cjs/utils/mapOpenSpec.js.map +1 -0
  46. package/lib/{utils → cjs/utils}/mapOpenSpec2.d.ts +0 -0
  47. package/lib/cjs/utils/mapOpenSpec2.js +34 -0
  48. package/lib/cjs/utils/mapOpenSpec2.js.map +1 -0
  49. package/lib/{utils → cjs/utils}/mapOpenSpec3.d.ts +0 -0
  50. package/lib/cjs/utils/mapOpenSpec3.js +26 -0
  51. package/lib/cjs/utils/mapOpenSpec3.js.map +1 -0
  52. package/lib/{utils → cjs/utils}/mapOpenSpecInfo.d.ts +0 -0
  53. package/lib/cjs/utils/mapOpenSpecInfo.js +21 -0
  54. package/lib/cjs/utils/mapOpenSpecInfo.js.map +1 -0
  55. package/lib/{utils → cjs/utils}/matchPath.d.ts +0 -0
  56. package/lib/cjs/utils/matchPath.js +10 -0
  57. package/lib/cjs/utils/matchPath.js.map +1 -0
  58. package/lib/esm/SwaggerModule.js +126 -0
  59. package/lib/esm/SwaggerModule.js.map +1 -0
  60. package/lib/esm/decorators/docs.js +14 -0
  61. package/lib/esm/decorators/docs.js.map +1 -0
  62. package/lib/esm/decorators/hidden.js +36 -0
  63. package/lib/esm/decorators/hidden.js.map +1 -0
  64. package/lib/esm/index.js +6 -0
  65. package/lib/esm/index.js.map +1 -0
  66. package/lib/esm/interfaces/SwaggerSettings.js +2 -0
  67. package/lib/esm/interfaces/SwaggerSettings.js.map +1 -0
  68. package/lib/esm/interfaces/index.js +2 -0
  69. package/lib/esm/interfaces/index.js.map +1 -0
  70. package/lib/esm/middlewares/cssMiddleware.js +18 -0
  71. package/lib/esm/middlewares/cssMiddleware.js.map +1 -0
  72. package/lib/esm/middlewares/indexMiddleware.js +20 -0
  73. package/lib/esm/middlewares/indexMiddleware.js.map +1 -0
  74. package/lib/esm/middlewares/jsMiddleware.js +13 -0
  75. package/lib/esm/middlewares/jsMiddleware.js.map +1 -0
  76. package/lib/esm/middlewares/redirectMiddleware.js +12 -0
  77. package/lib/esm/middlewares/redirectMiddleware.js.map +1 -0
  78. package/lib/esm/services/SwaggerService.js +100 -0
  79. package/lib/esm/services/SwaggerService.js.map +1 -0
  80. package/lib/esm/utils/getSpecType.js +16 -0
  81. package/lib/esm/utils/getSpecType.js.map +1 -0
  82. package/lib/esm/utils/includeRoute.js +16 -0
  83. package/lib/esm/utils/includeRoute.js.map +1 -0
  84. package/lib/esm/utils/index.js +8 -0
  85. package/lib/esm/utils/index.js.map +1 -0
  86. package/lib/esm/utils/mapOpenSpec.js +36 -0
  87. package/lib/esm/utils/mapOpenSpec.js.map +1 -0
  88. package/lib/esm/utils/mapOpenSpec2.js +30 -0
  89. package/lib/esm/utils/mapOpenSpec2.js.map +1 -0
  90. package/lib/esm/utils/mapOpenSpec3.js +22 -0
  91. package/lib/esm/utils/mapOpenSpec3.js.map +1 -0
  92. package/lib/esm/utils/mapOpenSpecInfo.js +17 -0
  93. package/lib/esm/utils/mapOpenSpecInfo.js.map +1 -0
  94. package/lib/esm/utils/matchPath.js +5 -0
  95. package/lib/esm/utils/matchPath.js.map +1 -0
  96. package/lib/types/SwaggerModule.d.ts +30 -0
  97. package/lib/types/decorators/docs.d.ts +10 -0
  98. package/lib/types/decorators/hidden.d.ts +32 -0
  99. package/lib/types/index.d.ts +5 -0
  100. package/lib/types/interfaces/SwaggerSettings.d.ts +99 -0
  101. package/lib/types/interfaces/index.d.ts +9 -0
  102. package/lib/types/middlewares/cssMiddleware.d.ts +6 -0
  103. package/lib/types/middlewares/indexMiddleware.d.ts +10 -0
  104. package/lib/types/middlewares/jsMiddleware.d.ts +6 -0
  105. package/lib/types/middlewares/redirectMiddleware.d.ts +6 -0
  106. package/lib/types/services/SwaggerService.d.ts +29 -0
  107. package/lib/types/utils/getSpecType.d.ts +12 -0
  108. package/lib/types/utils/includeRoute.d.ts +3 -0
  109. package/lib/types/utils/index.d.ts +7 -0
  110. package/lib/types/utils/mapOpenSpec.d.ts +10 -0
  111. package/lib/types/utils/mapOpenSpec2.d.ts +9 -0
  112. package/lib/types/utils/mapOpenSpec3.d.ts +8 -0
  113. package/lib/types/utils/mapOpenSpecInfo.d.ts +6 -0
  114. package/lib/types/utils/matchPath.d.ts +1 -0
  115. package/lib/views/index.ejs +145 -0
  116. package/lib/views/index.html +144 -0
  117. package/package.json +22 -18
  118. package/tsconfig.compile.esm.json +24 -0
  119. package/lib/index.js +0 -623
  120. package/lib/index.js.map +0 -1
  121. package/lib/index.modern.js +0 -617
  122. package/lib/index.modern.js.map +0 -1
@@ -0,0 +1,16 @@
1
+ import { SpecTypes } from "@tsed/schema";
2
+ /**
3
+ * @ignore
4
+ * @param version
5
+ */
6
+ export function getSpecType(version) {
7
+ return version.startsWith("3.") ? SpecTypes.OPENAPI : SpecTypes.SWAGGER;
8
+ }
9
+ /**
10
+ * @ignore
11
+ * @param spec
12
+ */
13
+ export function getSpecTypeFromSpec(spec) {
14
+ return "openapi" in spec ? SpecTypes.OPENAPI : SpecTypes.SWAGGER;
15
+ }
16
+ //# sourceMappingURL=getSpecType.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getSpecType.js","sourceRoot":"","sources":["../../../src/utils/getSpecType.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,SAAS,EAAC,MAAM,cAAc,CAAC;AAEvC;;;GAGG;AACH,MAAM,UAAU,WAAW,CAAC,OAAe;IACzC,OAAO,OAAO,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC,CAAC,SAAS,CAAC,OAAO,CAAC;AAC1E,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,mBAAmB,CAAC,IAAoC;IACtE,OAAO,SAAS,IAAI,IAAI,CAAC,CAAC,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC,CAAC,SAAS,CAAC,OAAO,CAAC;AACnE,CAAC","sourcesContent":["import {OpenSpec2, OpenSpec3} from \"@tsed/openspec\";\nimport {SpecTypes} from \"@tsed/schema\";\n\n/**\n * @ignore\n * @param version\n */\nexport function getSpecType(version: string) {\n return version.startsWith(\"3.\") ? SpecTypes.OPENAPI : SpecTypes.SWAGGER;\n}\n\n/**\n * @ignore\n * @param spec\n */\nexport function getSpecTypeFromSpec(spec: Partial<OpenSpec2 | OpenSpec3>) {\n return \"openapi\" in spec ? SpecTypes.OPENAPI : SpecTypes.SWAGGER;\n}\n"]}
@@ -0,0 +1,16 @@
1
+ import { matchPath } from ".";
2
+ export function includeRoute(route, provider, conf) {
3
+ const hidden = provider.store.get("hidden");
4
+ const docs = provider.store.get("docs") || [];
5
+ const { doc, pathPatterns } = conf;
6
+ const inDoc = doc && docs.indexOf(doc) > -1;
7
+ const pathPatternMatch = pathPatterns && matchPath(route, pathPatterns);
8
+ if (hidden) {
9
+ return false;
10
+ }
11
+ if (!doc && !pathPatterns) {
12
+ return true;
13
+ }
14
+ return !!(inDoc || pathPatternMatch);
15
+ }
16
+ //# sourceMappingURL=includeRoute.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"includeRoute.js","sourceRoot":"","sources":["../../../src/utils/includeRoute.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,SAAS,EAAC,MAAM,GAAG,CAAC;AAG5B,MAAM,UAAU,YAAY,CAAC,KAAa,EAAE,QAA4B,EAAE,IAAqB;IAC7F,MAAM,MAAM,GAAG,QAAQ,CAAC,KAAK,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;IAC5C,MAAM,IAAI,GAAG,QAAQ,CAAC,KAAK,CAAC,GAAG,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC;IAC9C,MAAM,EAAC,GAAG,EAAE,YAAY,EAAC,GAAG,IAAI,CAAC;IACjC,MAAM,KAAK,GAAG,GAAG,IAAI,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC;IAC5C,MAAM,gBAAgB,GAAG,YAAY,IAAI,SAAS,CAAC,KAAK,EAAE,YAAY,CAAC,CAAC;IAExE,IAAI,MAAM,EAAE;QACV,OAAO,KAAK,CAAC;KACd;IAED,IAAI,CAAC,GAAG,IAAI,CAAC,YAAY,EAAE;QACzB,OAAO,IAAI,CAAC;KACb;IAED,OAAO,CAAC,CAAC,CAAC,KAAK,IAAI,gBAAgB,CAAC,CAAC;AACvC,CAAC","sourcesContent":["import {ControllerProvider} from \"@tsed/common\";\nimport {matchPath} from \".\";\nimport {SwaggerSettings} from \"..\";\n\nexport function includeRoute(route: string, provider: ControllerProvider, conf: SwaggerSettings): boolean {\n const hidden = provider.store.get(\"hidden\");\n const docs = provider.store.get(\"docs\") || [];\n const {doc, pathPatterns} = conf;\n const inDoc = doc && docs.indexOf(doc) > -1;\n const pathPatternMatch = pathPatterns && matchPath(route, pathPatterns);\n\n if (hidden) {\n return false;\n }\n\n if (!doc && !pathPatterns) {\n return true;\n }\n\n return !!(inDoc || pathPatternMatch);\n}\n"]}
@@ -0,0 +1,8 @@
1
+ export * from "./getSpecType";
2
+ export * from "./mapOpenSpec";
3
+ export * from "./mapOpenSpec2";
4
+ export * from "./mapOpenSpec3";
5
+ export * from "./mapOpenSpecInfo";
6
+ export * from "./mapOpenSpecInfo";
7
+ export * from "./matchPath";
8
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAC;AAC9B,cAAc,eAAe,CAAC;AAC9B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,mBAAmB,CAAC;AAClC,cAAc,mBAAmB,CAAC;AAClC,cAAc,aAAa,CAAC","sourcesContent":["export * from \"./getSpecType\";\nexport * from \"./mapOpenSpec\";\nexport * from \"./mapOpenSpec2\";\nexport * from \"./mapOpenSpec3\";\nexport * from \"./mapOpenSpecInfo\";\nexport * from \"./mapOpenSpecInfo\";\nexport * from \"./matchPath\";\n"]}
@@ -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,30 @@
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
+ */
10
+ export function mapOpenSpec2(spec, { version, specVersion, acceptMimes = ["application/json"] }) {
11
+ const { paths, security, tags, host, basePath, schemes, consumes = [], produces = ["application/json"], definitions, parameters, responses, securityDefinitions, externalDocs } = spec;
12
+ return {
13
+ swagger: specVersion,
14
+ consumes: uniq([...acceptMimes, ...consumes]),
15
+ produces: uniq([...produces]),
16
+ info: mapOpenSpecInfo(getValue(spec, "info", {})),
17
+ paths,
18
+ host,
19
+ basePath,
20
+ schemes,
21
+ definitions,
22
+ parameters,
23
+ responses,
24
+ security,
25
+ securityDefinitions,
26
+ tags,
27
+ externalDocs
28
+ };
29
+ }
30
+ //# 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;;;;;;GAMG;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 */\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,5 @@
1
+ import micromatch from "micromatch";
2
+ export function matchPath(path, patterns) {
3
+ return patterns && patterns.length ? micromatch.isMatch(path, patterns) : true;
4
+ }
5
+ //# sourceMappingURL=matchPath.js.map
@@ -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"]}
@@ -0,0 +1,30 @@
1
+ import { BeforeRoutesInit, Configuration, InjectorService, OnReady, PlatformApplication } from "@tsed/common";
2
+ import { SwaggerSettings } from "./interfaces";
3
+ import { SwaggerService } from "./services/SwaggerService";
4
+ import { Env } from "@tsed/core";
5
+ /**
6
+ * @ignore
7
+ */
8
+ export declare class SwaggerModule implements BeforeRoutesInit, OnReady {
9
+ injector: InjectorService;
10
+ app: PlatformApplication;
11
+ configuration: Configuration;
12
+ swaggerService: SwaggerService;
13
+ env: Env;
14
+ private loaded;
15
+ get settings(): SwaggerSettings[];
16
+ /**
17
+ *
18
+ */
19
+ $beforeRoutesInit(): void;
20
+ $onReady(): void;
21
+ generateSpecFiles(): Promise<void[]>;
22
+ private getUrls;
23
+ /**
24
+ *
25
+ * @param conf
26
+ * @param urls
27
+ */
28
+ private createRouter;
29
+ private middlewareSwaggerJson;
30
+ }
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Set the type documentation for this class.
3
+ *
4
+ * See [swagger documentation](/tutorials/swagger.html)
5
+ *
6
+ * @decorator
7
+ * @swagger
8
+ * @param docs
9
+ */
10
+ export declare function Docs(...docs: string[]): Function;
@@ -0,0 +1,32 @@
1
+ /**
2
+ * Disable documentation for the class and his endpoint.
3
+ *
4
+ * ````typescript
5
+ * @Controller('/')
6
+ * export class Ctrl {
7
+ *
8
+ * @Get('/')
9
+ * @Hidden()
10
+ * hiddenRoute(){
11
+ *
12
+ * }
13
+ * }
14
+ *
15
+ * @Controller('/')
16
+ * @Hidden()
17
+ * export class Ctrl {
18
+ * @Get('/')
19
+ * hiddenRoute() {
20
+ *
21
+ * }
22
+ * @Get('/2')
23
+ * hiddenRoute2() {
24
+ *
25
+ * }
26
+ * }
27
+ * ```
28
+ *
29
+ * @decorator
30
+ * @swagger
31
+ */
32
+ export declare function Hidden(): Function;
@@ -0,0 +1,5 @@
1
+ export * from "./services/SwaggerService";
2
+ export * from "./SwaggerModule";
3
+ export * from "./interfaces";
4
+ export * from "./decorators/docs";
5
+ export * from "./decorators/hidden";
@@ -0,0 +1,99 @@
1
+ import { OpenSpec2, OpenSpec3, OpenSpecVersions, OS2Versions, OS3Versions } from "@tsed/openspec";
2
+ export interface SwaggerUIOptions {
3
+ configUrl?: string;
4
+ url?: string;
5
+ urls?: {
6
+ url: string;
7
+ name: string;
8
+ primaryName?: string;
9
+ }[];
10
+ layout?: string;
11
+ validatorUrl?: string;
12
+ oauth?: any;
13
+ authorize?: any;
14
+ [key: string]: any;
15
+ }
16
+ export interface SwaggerSettingsBase {
17
+ /**
18
+ * The url subpath to access to the documentation.
19
+ */
20
+ path: string;
21
+ /**
22
+ * Specify the spec version you want to generate.
23
+ */
24
+ specVersion?: OpenSpecVersions;
25
+ /**
26
+ * Swagger file name. By default swagger.json
27
+ */
28
+ fileName?: string;
29
+ /**
30
+ * Hidden documentation. Use this to hide documentation link in the dropdown.
31
+ */
32
+ hidden?: string;
33
+ /**
34
+ * The documentation key used by `@Docs` decorator to create several swagger documentations.
35
+ */
36
+ doc?: string;
37
+ /**
38
+ * The path to the CSS file.
39
+ */
40
+ cssPath?: string;
41
+ /**
42
+ * The path to the JS file.
43
+ */
44
+ jsPath?: string;
45
+ /**
46
+ * The path to the ejs file to create html page.
47
+ */
48
+ viewPath?: string | false;
49
+ /**
50
+ * SwaggerUI options. See (https://github.com/swagger-api/swagger-ui/blob/HEAD/docs/usage/configuration.md)
51
+ */
52
+ options?: SwaggerUIOptions;
53
+ /**
54
+ * Display the search field in the navbar.
55
+ */
56
+ showExplorer?: boolean;
57
+ /**
58
+ * Load the base spec documentation from the specified path.
59
+ */
60
+ specPath?: string;
61
+ /**
62
+ * Write the `swagger.json` spec documentation on the specified path.
63
+ */
64
+ outFile?: string;
65
+ /**
66
+ * A function to generate the operationId.
67
+ */
68
+ operationIdFormatter?: (name: string, propertyKey: string, path: string) => string;
69
+ /**
70
+ * A pattern to generate the operationId. Format of operationId field (%c: class name, %m: method name).
71
+ */
72
+ operationIdPattern?: string;
73
+ /**
74
+ *
75
+ */
76
+ disableSpec?: boolean;
77
+ /**
78
+ * Include only controllers whose paths match the pattern list provided.
79
+ */
80
+ pathPatterns?: string[];
81
+ }
82
+ /**
83
+ * @deprecated Since 2021-09-03. Will be removed in v7.
84
+ */
85
+ export interface SwaggerOS2Settings extends SwaggerSettingsBase {
86
+ specVersion?: OS2Versions;
87
+ /**
88
+ * OpenSpec 2
89
+ */
90
+ spec?: Partial<OpenSpec2>;
91
+ }
92
+ export interface SwaggerOS3Settings extends SwaggerSettingsBase {
93
+ specVersion?: OS3Versions;
94
+ /**
95
+ * OpenSpec 3
96
+ */
97
+ spec?: Partial<OpenSpec3>;
98
+ }
99
+ export declare type SwaggerSettings = SwaggerOS2Settings | SwaggerOS3Settings;
@@ -0,0 +1,9 @@
1
+ import { SwaggerSettings } from "./SwaggerSettings";
2
+ declare global {
3
+ namespace TsED {
4
+ interface Configuration {
5
+ swagger: SwaggerSettings[];
6
+ }
7
+ }
8
+ }
9
+ export * from "./SwaggerSettings";
@@ -0,0 +1,6 @@
1
+ import { PlatformContext } from "@tsed/common";
2
+ /**
3
+ * @ignore
4
+ * @param path
5
+ */
6
+ export declare function cssMiddleware(path: string): (ctx: PlatformContext) => void;
@@ -0,0 +1,10 @@
1
+ import { PlatformContext } from "@tsed/common";
2
+ import { SwaggerSettings } from "../interfaces/SwaggerSettings";
3
+ /**
4
+ * @ignore
5
+ * @param viewPath
6
+ * @param conf
7
+ */
8
+ export declare function indexMiddleware(viewPath: string, conf: SwaggerSettings & {
9
+ urls: string[];
10
+ }): (ctx: PlatformContext) => Promise<void>;
@@ -0,0 +1,6 @@
1
+ import { PlatformContext } from "@tsed/common";
2
+ /**
3
+ * @ignore
4
+ * @param path
5
+ */
6
+ export declare function jsMiddleware(path: string): (ctx: PlatformContext) => void;
@@ -0,0 +1,6 @@
1
+ import { PlatformContext } from "@tsed/common";
2
+ /**
3
+ * @ignore
4
+ * @param path
5
+ */
6
+ export declare function redirectMiddleware(path: string): (ctx: PlatformContext) => void;
@@ -0,0 +1,29 @@
1
+ import { Configuration, ControllerProvider, InjectorService, Platform } from "@tsed/common";
2
+ import { OpenSpec2, OpenSpec3 } from "@tsed/openspec";
3
+ import { SpecSerializerOptions } from "@tsed/schema";
4
+ import { SwaggerOS2Settings, SwaggerOS3Settings, SwaggerSettings } from "../interfaces/SwaggerSettings";
5
+ export declare class SwaggerService {
6
+ #private;
7
+ private injectorService;
8
+ private platform;
9
+ private configuration;
10
+ constructor(injectorService: InjectorService, platform: Platform, configuration: Configuration);
11
+ /**
12
+ * Generate Spec for the given configuration
13
+ * @returns {Spec}
14
+ */
15
+ getOpenAPISpec(conf: SwaggerOS3Settings): OpenSpec3;
16
+ getOpenAPISpec(conf: SwaggerOS2Settings): OpenSpec2;
17
+ getOpenAPISpec(conf: SwaggerSettings): OpenSpec2;
18
+ /**
19
+ * Return the global api information.
20
+ */
21
+ protected getDefaultSpec(conf: Partial<SwaggerSettings>): Partial<OpenSpec2 | OpenSpec3>;
22
+ protected readSpecPath(path: string): any;
23
+ /**
24
+ *
25
+ * @param ctrl
26
+ * @param options
27
+ */
28
+ protected buildRoutes(ctrl: ControllerProvider, options: SpecSerializerOptions): Partial<OpenSpec2>;
29
+ }
@@ -0,0 +1,12 @@
1
+ import { OpenSpec2, OpenSpec3 } from "@tsed/openspec";
2
+ import { SpecTypes } from "@tsed/schema";
3
+ /**
4
+ * @ignore
5
+ * @param version
6
+ */
7
+ export declare function getSpecType(version: string): SpecTypes.SWAGGER | SpecTypes.OPENAPI;
8
+ /**
9
+ * @ignore
10
+ * @param spec
11
+ */
12
+ export declare function getSpecTypeFromSpec(spec: Partial<OpenSpec2 | OpenSpec3>): SpecTypes.SWAGGER | SpecTypes.OPENAPI;
@@ -0,0 +1,3 @@
1
+ import { ControllerProvider } from "@tsed/common";
2
+ import { SwaggerSettings } from "..";
3
+ export declare function includeRoute(route: string, provider: ControllerProvider, conf: SwaggerSettings): boolean;
@@ -0,0 +1,7 @@
1
+ export * from "./getSpecType";
2
+ export * from "./mapOpenSpec";
3
+ export * from "./mapOpenSpec2";
4
+ export * from "./mapOpenSpec3";
5
+ export * from "./mapOpenSpecInfo";
6
+ export * from "./mapOpenSpecInfo";
7
+ export * from "./matchPath";
@@ -0,0 +1,10 @@
1
+ import { OpenSpec2, OpenSpec3 } from "@tsed/openspec";
2
+ /**
3
+ * @ignore
4
+ * @param spec
5
+ * @param fileSpec
6
+ * @param version
7
+ * @param acceptMimes
8
+ * @param specVersion
9
+ */
10
+ export declare function mapOpenSpec(spec: any, { fileSpec, acceptMimes, specVersion, version }: any): Partial<OpenSpec2 | OpenSpec3>;
@@ -0,0 +1,9 @@
1
+ import { OpenSpec2 } from "@tsed/openspec";
2
+ /**
3
+ * @ignore
4
+ * @param spec
5
+ * @param version
6
+ * @param specVersion
7
+ * @param acceptMimes
8
+ */
9
+ export declare function mapOpenSpec2(spec: Partial<OpenSpec2>, { version, specVersion, acceptMimes }: any): Partial<OpenSpec2>;
@@ -0,0 +1,8 @@
1
+ import { OpenSpec3 } from "@tsed/openspec";
2
+ /**
3
+ * @ignore
4
+ * @param spec
5
+ * @param version
6
+ * @param specVersion
7
+ */
8
+ export declare function mapOpenSpec3(spec: any, { specVersion }: any): Partial<OpenSpec3>;
@@ -0,0 +1,6 @@
1
+ import { OpenSpecInfo } from "@tsed/openspec";
2
+ /**
3
+ * @ignore
4
+ * @param info
5
+ */
6
+ export declare function mapOpenSpecInfo(info: Partial<OpenSpecInfo>): OpenSpecInfo;
@@ -0,0 +1 @@
1
+ export declare function matchPath(path: string, patterns?: string[]): boolean;