@tsed/swagger 7.0.0-beta.2 → 7.0.0-beta.20

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 (63) hide show
  1. package/jest.config.js +14 -0
  2. package/lib/cjs/SwaggerModule.js +32 -28
  3. package/lib/cjs/SwaggerModule.js.map +1 -1
  4. package/lib/cjs/index.js +15 -5
  5. package/lib/cjs/index.js.map +1 -1
  6. package/lib/cjs/interfaces/SwaggerSettings.js.map +1 -1
  7. package/lib/cjs/interfaces/interfaces.js +3 -0
  8. package/lib/cjs/interfaces/interfaces.js.map +1 -0
  9. package/lib/cjs/middlewares/cssMiddleware.js +1 -1
  10. package/lib/cjs/middlewares/cssMiddleware.js.map +1 -1
  11. package/lib/cjs/middlewares/jsMiddleware.js +1 -1
  12. package/lib/cjs/middlewares/jsMiddleware.js.map +1 -1
  13. package/lib/cjs/package.json +3 -0
  14. package/lib/cjs/services/SwaggerService.js +23 -83
  15. package/lib/cjs/services/SwaggerService.js.map +1 -1
  16. package/lib/cjs/utils/includeRoute.js +2 -2
  17. package/lib/cjs/utils/includeRoute.js.map +1 -1
  18. package/lib/cjs/utils/matchPath.js +1 -1
  19. package/lib/cjs/utils/matchPath.js.map +1 -1
  20. package/lib/esm/SwaggerModule.js +25 -21
  21. package/lib/esm/SwaggerModule.js.map +1 -1
  22. package/lib/esm/index.js +15 -5
  23. package/lib/esm/index.js.map +1 -1
  24. package/lib/esm/interfaces/SwaggerSettings.js.map +1 -1
  25. package/lib/esm/interfaces/interfaces.js +2 -0
  26. package/lib/esm/interfaces/interfaces.js.map +1 -0
  27. package/lib/esm/package.json +3 -0
  28. package/lib/esm/services/SwaggerService.js +23 -83
  29. package/lib/esm/services/SwaggerService.js.map +1 -1
  30. package/lib/esm/utils/includeRoute.js +1 -1
  31. package/lib/esm/utils/includeRoute.js.map +1 -1
  32. package/lib/types/SwaggerModule.d.ts +3 -2
  33. package/lib/types/index.d.ts +12 -2
  34. package/lib/types/interfaces/SwaggerSettings.d.ts +9 -2
  35. package/lib/types/interfaces/{index.d.ts → interfaces.d.ts} +0 -1
  36. package/lib/types/services/SwaggerService.d.ts +6 -16
  37. package/lib/types/utils/includeRoute.d.ts +3 -3
  38. package/package.json +30 -21
  39. package/readme.md +74 -87
  40. package/lib/cjs/interfaces/index.js +0 -5
  41. package/lib/cjs/interfaces/index.js.map +0 -1
  42. package/lib/cjs/utils/index.js +0 -9
  43. package/lib/cjs/utils/index.js.map +0 -1
  44. package/lib/cjs/utils/mapOpenSpec.js +0 -29
  45. package/lib/cjs/utils/mapOpenSpec.js.map +0 -1
  46. package/lib/cjs/utils/mapOpenSpec3.js +0 -26
  47. package/lib/cjs/utils/mapOpenSpec3.js.map +0 -1
  48. package/lib/cjs/utils/mapOpenSpecInfo.js +0 -21
  49. package/lib/cjs/utils/mapOpenSpecInfo.js.map +0 -1
  50. package/lib/esm/interfaces/index.js +0 -2
  51. package/lib/esm/interfaces/index.js.map +0 -1
  52. package/lib/esm/utils/index.js +0 -6
  53. package/lib/esm/utils/index.js.map +0 -1
  54. package/lib/esm/utils/mapOpenSpec.js +0 -25
  55. package/lib/esm/utils/mapOpenSpec.js.map +0 -1
  56. package/lib/esm/utils/mapOpenSpec3.js +0 -22
  57. package/lib/esm/utils/mapOpenSpec3.js.map +0 -1
  58. package/lib/esm/utils/mapOpenSpecInfo.js +0 -17
  59. package/lib/esm/utils/mapOpenSpecInfo.js.map +0 -1
  60. package/lib/types/utils/index.d.ts +0 -5
  61. package/lib/types/utils/mapOpenSpec.d.ts +0 -10
  62. package/lib/types/utils/mapOpenSpec3.d.ts +0 -8
  63. package/lib/types/utils/mapOpenSpecInfo.d.ts +0 -6
@@ -1 +1 @@
1
- {"version":3,"file":"SwaggerModule.js","sourceRoot":"","sources":["../../src/SwaggerModule.ts"],"names":[],"mappings":";AAAA,OAAO,EAEL,aAAa,EACb,QAAQ,EACR,MAAM,EACN,eAAe,EACf,MAAM,EACN,aAAa,EAEb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C,IAAI,CAAC,CAAC,CAAC,CAAC;SAC3F;QAED,IAAI,QAAQ,EAAE;YACZ,IAAI,OAAO,EAAE;gBACX,MAAM,CAAC,GAAG,CAAC,WAAW,EAAE,aAAa,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;aAChE;YAED,IAAI,MAAM,EAAE;gBACV,MAAM,CAAC,GAAG,CAAC,UAAU,EAAE,aAAa,CAAC,YAAY,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;aAC7D;YAED,MAAM,CAAC,GAAG,CAAC,GAAG,EAAE,aAAa,CAAC,eAAe,CAAC,QAAQ,EAAE,EAAC,IAAI,EAAE,GAAG,IAAI,EAAC,CAAC,CAAC,CAAC,CAAC;YAC3E,MAAM,CAAC,OAAO,CAAC,GAAG,EAAE,EAAC,IAAI,EAAE,aAAa,EAAC,CAAC,CAAC;SAC5C;QAED,OAAO,MAAM,CAAC;IAChB,CAAC;IAEO,qBAAqB,CAAC,IAAqB;QACjD,OAAO,CAAC,GAAoB,EAAE,EAAE;YAC9B,GAAG,CAAC,QAAQ,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,cAAc,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC,CAAC;QAC1E,CAAC,CAAC;IACJ,CAAC;CACF,CAAA;AA3HC;IADC,MAAM,EAAE;8BACC,eAAe;+CAAC;AAG1B;IADC,MAAM,EAAE;8BACJ,mBAAmB;0CAAC;AAGzB;IADC,aAAa,EAAE;;oDACa;AAG7B;IADC,MAAM,EAAE;8BACO,cAAc;qDAAC;AAG/B;IADC,QAAQ,CAAC,KAAK,CAAC;;0CACP;AAdE,aAAa;IADzB,MAAM,EAAE;GACI,aAAa,CA6HzB;SA7HY,aAAa","sourcesContent":["import {\n OnRoutesInit,\n Configuration,\n Constant,\n Inject,\n InjectorService,\n Module,\n normalizePath,\n OnReady,\n PlatformApplication,\n PlatformContext,\n PlatformRouter,\n useCtxHandler\n} from \"@tsed/common\";\nimport Fs from \"fs\";\nimport {join} from \"path\";\nimport {SwaggerSettings} from \"./interfaces\";\nimport {cssMiddleware} from \"./middlewares/cssMiddleware\";\nimport {indexMiddleware} from \"./middlewares/indexMiddleware\";\nimport {jsMiddleware} from \"./middlewares/jsMiddleware\";\nimport {redirectMiddleware} from \"./middlewares/redirectMiddleware\";\nimport {SwaggerService} from \"./services/SwaggerService\";\nimport {Env} from \"@tsed/core\";\n\nconst swaggerUiPath = require(\"swagger-ui-dist\").absolutePath();\n\n/**\n * @ignore\n */\n@Module()\nexport class SwaggerModule implements OnRoutesInit, OnReady {\n @Inject()\n injector: InjectorService;\n\n @Inject()\n app: PlatformApplication;\n\n @Configuration()\n configuration: Configuration;\n\n @Inject()\n swaggerService: SwaggerService;\n\n @Constant(\"env\")\n env: Env;\n\n private loaded = false;\n\n get settings() {\n return ([] as SwaggerSettings[]).concat(this.configuration.get<SwaggerSettings[]>(\"swagger\")).filter((o) => !!o);\n }\n\n /**\n *\n */\n $onRoutesInit() {\n if (this.loaded) {\n return;\n }\n\n const urls: any[] = this.getUrls();\n\n this.settings.forEach((conf: SwaggerSettings) => {\n const {path = \"/\"} = conf;\n\n this.app.get(path, useCtxHandler(redirectMiddleware(path)));\n this.app.use(path, this.createRouter(conf, urls));\n });\n\n this.loaded = true;\n }\n\n $onReady() {\n // istanbul ignore next\n if (this.configuration.getBestHost) {\n const host = this.configuration.getBestHost();\n const url = host.toString();\n\n const displayLog = (conf: SwaggerSettings) => {\n const {path = \"/\", fileName = \"swagger.json\", doc} = conf;\n\n this.injector.logger.info(`[${doc || \"default\"}] Swagger JSON is available on ${url}${normalizePath(path, fileName)}`);\n this.injector.logger.info(`[${doc || \"default\"}] Swagger UI is available on ${url}${path}/`);\n };\n\n this.settings.forEach((conf) => {\n displayLog(conf);\n });\n }\n\n this.generateSpecFiles();\n }\n\n generateSpecFiles() {\n return Promise.all(\n this.settings.map((conf) => {\n const {outFile} = conf;\n\n if (this.env === Env.PROD || outFile) {\n const spec = this.swaggerService.getOpenAPISpec(conf);\n\n if (outFile) {\n return Fs.writeFile(outFile, JSON.stringify(spec, null, 2), {encoding: \"utf8\"}, () => {});\n }\n }\n })\n );\n }\n\n private getUrls() {\n return this.settings.reduce((acc: any[], conf) => {\n const {path = \"/\", fileName = \"swagger.json\", doc, hidden} = conf;\n\n if (!hidden) {\n acc.push({url: normalizePath(path, fileName), name: doc || path});\n }\n\n return acc;\n }, []);\n }\n\n /**\n *\n * @param conf\n * @param urls\n */\n private createRouter(conf: SwaggerSettings, urls: string[]) {\n const {disableSpec = false, fileName = \"swagger.json\", cssPath, jsPath, viewPath = join(__dirname, \"../views/index.ejs\")} = conf;\n const router = PlatformRouter.create(this.injector);\n\n if (!disableSpec) {\n router.get(normalizePath(\"/\", fileName), useCtxHandler(this.middlewareSwaggerJson(conf)));\n }\n\n if (viewPath) {\n if (cssPath) {\n router.get(\"/main.css\", useCtxHandler(cssMiddleware(cssPath)));\n }\n\n if (jsPath) {\n router.get(\"/main.js\", useCtxHandler(jsMiddleware(jsPath)));\n }\n\n router.get(\"/\", useCtxHandler(indexMiddleware(viewPath, {urls, ...conf})));\n router.statics(\"/\", {root: swaggerUiPath});\n }\n\n return router;\n }\n\n private middlewareSwaggerJson(conf: SwaggerSettings) {\n return (ctx: PlatformContext) => {\n ctx.response.status(200).body(this.swaggerService.getOpenAPISpec(conf));\n };\n }\n}\n"]}
1
+ {"version":3,"file":"SwaggerModule.js","sourceRoot":"","sources":["../../src/SwaggerModule.ts"],"names":[],"mappings":";AAAA,OAAO,EAEL,aAAa,EACb,QAAQ,EACR,MAAM,EACN,eAAe,EACf,MAAM,EACN,aAAa,EAEb,mBAAmB,EAEpB,MAAM,cAAc,CAAC;AACtB,OAAO,EAAC,cAAc,EAAE,iBAAiB,EAAC,MAAM,uBAAuB,CAAC;AACxE,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,EAAC,IAAI,EAAC,MAAM,MAAM,CAAC;AAC1B,OAAO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gBACX,MAAM,CAAC,GAAG,CAAC,WAAW,EAAE,iBAAiB,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;aACpE;YAED,IAAI,MAAM,EAAE;gBACV,MAAM,CAAC,GAAG,CAAC,UAAU,EAAE,iBAAiB,CAAC,YAAY,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;aACjE;YAED,MAAM,CAAC,GAAG,CAAC,GAAG,EAAE,iBAAiB,CAAC,eAAe,CAAC,QAAQ,EAAE,EAAC,IAAI,EAAE,GAAG,IAAI,EAAC,CAAC,CAAC,CAAC,CAAC;YAC/E,MAAM,CAAC,OAAO,CAAC,GAAG,EAAE,EAAC,IAAI,EAAE,YAAY,EAAE,EAAC,CAAC,CAAC;SAC7C;QAED,OAAO,MAAM,CAAC;IAChB,CAAC;IAEO,qBAAqB,CAAC,IAAqB;QACjD,OAAO,KAAK,EAAE,GAAoB,EAAE,EAAE;YACpC,GAAG,CAAC,QAAQ,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,MAAM,IAAI,CAAC,cAAc,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC,CAAC;QAChF,CAAC,CAAC;IACJ,CAAC;CACF,CAAA;AA3HC;IADC,MAAM,EAAE;8BACC,eAAe;+CAAC;AAG1B;IADC,MAAM,EAAE;8BACJ,mBAAmB;0CAAC;AAGzB;IADC,aAAa,EAAE;;oDACa;AAG7B;IADC,MAAM,EAAE;8BACO,cAAc;qDAAC;AAG/B;IADC,QAAQ,CAAC,KAAK,CAAC;;0CACP;AAdE,aAAa;IADzB,MAAM,EAAE;GACI,aAAa,CA6HzB;SA7HY,aAAa","sourcesContent":["import {\n OnRoutesInit,\n Configuration,\n Constant,\n Inject,\n InjectorService,\n Module,\n normalizePath,\n OnReady,\n PlatformApplication,\n PlatformContext\n} from \"@tsed/common\";\nimport {PlatformRouter, useContextHandler} from \"@tsed/platform-router\";\nimport Fs from \"fs\";\nimport {join} from \"path\";\nimport {Env} from \"@tsed/core\";\nimport {absolutePath} from \"swagger-ui-dist\";\nimport {SwaggerSettings} from \"./interfaces/SwaggerSettings\";\nimport {cssMiddleware} from \"./middlewares/cssMiddleware\";\nimport {indexMiddleware} from \"./middlewares/indexMiddleware\";\nimport {jsMiddleware} from \"./middlewares/jsMiddleware\";\nimport {redirectMiddleware} from \"./middlewares/redirectMiddleware\";\nimport {SwaggerService} from \"./services/SwaggerService\";\n\n/**\n * @ignore\n */\n@Module()\nexport class SwaggerModule implements OnRoutesInit, OnReady {\n @Inject()\n injector: InjectorService;\n\n @Inject()\n app: PlatformApplication;\n\n @Configuration()\n configuration: Configuration;\n\n @Inject()\n swaggerService: SwaggerService;\n\n @Constant(\"env\")\n env: Env;\n\n private loaded = false;\n\n get settings() {\n return ([] as SwaggerSettings[]).concat(this.configuration.get<SwaggerSettings[]>(\"swagger\")).filter((o) => !!o);\n }\n\n /**\n *\n */\n $onRoutesInit() {\n if (this.loaded) {\n return;\n }\n\n const urls: any[] = this.getUrls();\n\n this.settings.forEach((conf: SwaggerSettings) => {\n const {path = \"/\"} = conf;\n\n this.app.get(path, useContextHandler(redirectMiddleware(path)));\n this.app.use(path, this.createRouter(conf, urls));\n });\n\n this.loaded = true;\n }\n\n $onReady() {\n // istanbul ignore next\n if (this.configuration.getBestHost) {\n const host = this.configuration.getBestHost();\n const url = host.toString();\n\n const displayLog = (conf: SwaggerSettings) => {\n const {path = \"/\", fileName = \"swagger.json\", doc} = conf;\n\n this.injector.logger.info(`[${doc || \"default\"}] Swagger JSON is available on ${url}${normalizePath(path, fileName)}`);\n this.injector.logger.info(`[${doc || \"default\"}] Swagger UI is available on ${url}${path}/`);\n };\n\n this.settings.forEach((conf) => {\n displayLog(conf);\n });\n }\n\n this.generateSpecFiles();\n }\n\n generateSpecFiles() {\n return Promise.all(\n this.settings.map(async (conf) => {\n const {outFile} = conf;\n\n if (this.env === Env.PROD || outFile) {\n const spec = await this.swaggerService.getOpenAPISpec(conf);\n\n if (outFile) {\n return Fs.writeFile(outFile, JSON.stringify(spec, null, 2), {encoding: \"utf8\"}, () => {});\n }\n }\n })\n );\n }\n\n private getUrls() {\n return this.settings.reduce((acc: any[], conf) => {\n const {path = \"/\", fileName = \"swagger.json\", doc, hidden} = conf;\n\n if (!hidden) {\n acc.push({url: normalizePath(path, fileName), name: doc || path});\n }\n\n return acc;\n }, []);\n }\n\n /**\n *\n * @param conf\n * @param urls\n */\n private createRouter(conf: SwaggerSettings, urls: string[]) {\n const {disableSpec = false, fileName = \"swagger.json\", cssPath, jsPath, viewPath = join(__dirname, \"../views/index.ejs\")} = conf;\n const router = new PlatformRouter(this.injector);\n\n if (!disableSpec) {\n router.get(normalizePath(\"/\", fileName), useContextHandler(this.middlewareSwaggerJson(conf)));\n }\n\n if (viewPath) {\n if (cssPath) {\n router.get(\"/main.css\", useContextHandler(cssMiddleware(cssPath)));\n }\n\n if (jsPath) {\n router.get(\"/main.js\", useContextHandler(jsMiddleware(jsPath)));\n }\n\n router.get(\"/\", useContextHandler(indexMiddleware(viewPath, {urls, ...conf})));\n router.statics(\"/\", {root: absolutePath()});\n }\n\n return router;\n }\n\n private middlewareSwaggerJson(conf: SwaggerSettings) {\n return async (ctx: PlatformContext) => {\n ctx.response.status(200).body(await this.swaggerService.getOpenAPISpec(conf));\n };\n }\n}\n"]}
package/lib/esm/index.js CHANGED
@@ -1,6 +1,16 @@
1
- export * from "./services/SwaggerService";
2
- export * from "./SwaggerModule";
3
- export * from "./interfaces";
4
- export * from "./decorators/docs";
5
- export * from "./decorators/hidden";
1
+ /**
2
+ * @file Automatically generated by barrelsby.
3
+ */
4
+ export * from "./SwaggerModule.js";
5
+ export * from "./decorators/docs.js";
6
+ export * from "./decorators/hidden.js";
7
+ export * from "./interfaces/SwaggerSettings.js";
8
+ export * from "./interfaces/interfaces.js";
9
+ export * from "./middlewares/cssMiddleware.js";
10
+ export * from "./middlewares/indexMiddleware.js";
11
+ export * from "./middlewares/jsMiddleware.js";
12
+ export * from "./middlewares/redirectMiddleware.js";
13
+ export * from "./services/SwaggerService.js";
14
+ export * from "./utils/includeRoute.js";
15
+ export * from "./utils/matchPath.js";
6
16
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,2BAA2B,CAAC;AAC1C,cAAc,iBAAiB,CAAC;AAChC,cAAc,cAAc,CAAC;AAC7B,cAAc,mBAAmB,CAAC;AAClC,cAAc,qBAAqB,CAAC","sourcesContent":["export * from \"./services/SwaggerService\";\nexport * from \"./SwaggerModule\";\nexport * from \"./interfaces\";\nexport * from \"./decorators/docs\";\nexport * from \"./decorators/hidden\";\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,cAAc,iBAAiB,CAAC;AAChC,cAAc,mBAAmB,CAAC;AAClC,cAAc,qBAAqB,CAAC;AACpC,cAAc,8BAA8B,CAAC;AAC7C,cAAc,yBAAyB,CAAC;AACxC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,+BAA+B,CAAC;AAC9C,cAAc,4BAA4B,CAAC;AAC3C,cAAc,kCAAkC,CAAC;AACjD,cAAc,2BAA2B,CAAC;AAC1C,cAAc,sBAAsB,CAAC;AACrC,cAAc,mBAAmB,CAAC","sourcesContent":["/**\n * @file Automatically generated by barrelsby.\n */\n\nexport * from \"./SwaggerModule\";\nexport * from \"./decorators/docs\";\nexport * from \"./decorators/hidden\";\nexport * from \"./interfaces/SwaggerSettings\";\nexport * from \"./interfaces/interfaces\";\nexport * from \"./middlewares/cssMiddleware\";\nexport * from \"./middlewares/indexMiddleware\";\nexport * from \"./middlewares/jsMiddleware\";\nexport * from \"./middlewares/redirectMiddleware\";\nexport * from \"./services/SwaggerService\";\nexport * from \"./utils/includeRoute\";\nexport * from \"./utils/matchPath\";\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"SwaggerSettings.js","sourceRoot":"","sources":["../../../src/interfaces/SwaggerSettings.ts"],"names":[],"mappings":"","sourcesContent":["import {OpenSpec3, OpenSpecVersions, OS3Versions} from \"@tsed/openspec\";\n\nexport interface SwaggerUIOptions {\n configUrl?: string;\n url?: string;\n urls?: {url: string; name: string; primaryName?: string}[];\n layout?: string;\n validatorUrl?: string;\n oauth?: any;\n authorize?: any;\n\n [key: string]: any;\n}\n\nexport interface SwaggerSettingsBase {\n /**\n * The url subpath to access to the documentation.\n */\n path: string;\n /**\n * Specify the spec version you want to generate.\n */\n specVersion?: OpenSpecVersions;\n /**\n * Swagger file name. By default swagger.json\n */\n fileName?: string;\n /**\n * Hidden documentation. Use this to hide documentation link in the dropdown.\n */\n hidden?: string;\n /**\n * The documentation key used by `@Docs` decorator to create several swagger documentations.\n */\n doc?: string;\n /**\n * The path to the CSS file.\n */\n cssPath?: string;\n /**\n * The path to the JS file.\n */\n jsPath?: string;\n /**\n * The path to the ejs file to create html page.\n */\n viewPath?: string | false;\n /**\n * SwaggerUI options. See (https://github.com/swagger-api/swagger-ui/blob/HEAD/docs/usage/configuration.md)\n */\n options?: SwaggerUIOptions;\n /**\n * Display the search field in the navbar.\n */\n showExplorer?: boolean;\n /**\n * Load the base spec documentation from the specified path.\n */\n specPath?: string;\n /**\n * Write the `swagger.json` spec documentation on the specified path.\n */\n outFile?: string;\n /**\n * A function to generate the operationId.\n */\n operationIdFormatter?: (name: string, propertyKey: string, path: string) => string;\n /**\n * A pattern to generate the operationId. Format of operationId field (%c: class name, %m: method name).\n */\n operationIdPattern?: string;\n /**\n *\n */\n disableSpec?: boolean;\n /**\n * Include only controllers whose paths match the pattern list provided.\n */\n pathPatterns?: string[];\n}\n\nexport interface SwaggerOS3Settings extends SwaggerSettingsBase {\n specVersion?: OS3Versions;\n /**\n * OpenSpec 3\n */\n spec?: Partial<OpenSpec3>;\n}\n\nexport type SwaggerSettings = SwaggerOS3Settings;\n"]}
1
+ {"version":3,"file":"SwaggerSettings.js","sourceRoot":"","sources":["../../../src/interfaces/SwaggerSettings.ts"],"names":[],"mappings":"","sourcesContent":["import {OpenSpec2, OpenSpec3, OpenSpecVersions, OS2Versions, OS3Versions} from \"@tsed/openspec\";\n\nexport interface SwaggerUIOptions {\n configUrl?: string;\n url?: string;\n urls?: {url: string; name: string; primaryName?: string}[];\n layout?: string;\n validatorUrl?: string;\n oauth?: any;\n authorize?: any;\n\n [key: string]: any;\n}\n\nexport interface SwaggerSettingsBase {\n /**\n * The url subpath to access to the documentation.\n */\n path: string;\n /**\n * Specify the spec version you want to generate.\n */\n specVersion?: OpenSpecVersions;\n /**\n * Swagger file name. By default swagger.json\n */\n fileName?: string;\n /**\n * Hidden documentation. Use this to hide documentation link in the dropdown.\n */\n hidden?: string;\n /**\n * The documentation key used by `@Docs` decorator to create several swagger documentations.\n */\n doc?: string;\n /**\n * The path to the CSS file.\n */\n cssPath?: string;\n /**\n * The path to the JS file.\n */\n jsPath?: string;\n /**\n * The path to the ejs file to create html page.\n */\n viewPath?: string | false;\n /**\n * SwaggerUI options. See (https://github.com/swagger-api/swagger-ui/blob/HEAD/docs/usage/configuration.md)\n */\n options?: SwaggerUIOptions;\n /**\n * Display the search field in the navbar.\n */\n showExplorer?: boolean;\n /**\n * Load the base spec documentation from the specified path.\n */\n specPath?: string;\n /**\n * Write the `swagger.json` spec documentation on the specified path.\n */\n outFile?: string;\n /**\n * A function to generate the operationId.\n */\n operationIdFormatter?: (name: string, propertyKey: string, path: string) => string;\n /**\n * A pattern to generate the operationId. Format of operationId field (%c: class name, %m: method name).\n */\n operationIdPattern?: string;\n /**\n *\n */\n disableSpec?: boolean;\n /**\n * Include only controllers whose paths match the pattern list provided.\n */\n pathPatterns?: string[];\n}\n\nexport interface SwaggerOS2Settings extends SwaggerSettingsBase {\n specVersion?: OS2Versions;\n /**\n * OpenSpec 2\n */\n spec?: Partial<OpenSpec2>;\n}\n\nexport interface SwaggerOS3Settings extends SwaggerSettingsBase {\n specVersion?: OS3Versions;\n /**\n * OpenSpec 3\n */\n spec?: Partial<OpenSpec3>;\n}\n\nexport type SwaggerSettings = SwaggerOS2Settings | SwaggerOS3Settings;\n"]}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=interfaces.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"interfaces.js","sourceRoot":"","sources":["../../../src/interfaces/interfaces.ts"],"names":[],"mappings":"","sourcesContent":["import {SwaggerSettings} from \"./SwaggerSettings\";\n\ndeclare global {\n namespace TsED {\n interface Configuration {\n swagger: SwaggerSettings[];\n }\n }\n}\n"]}
@@ -0,0 +1,3 @@
1
+ {
2
+ "type": "module"
3
+ }
@@ -1,97 +1,37 @@
1
- var _SwaggerService_specs;
2
- import { __classPrivateFieldGet, __decorate, __metadata, __param } from "tslib";
1
+ import { __decorate, __metadata, __param } from "tslib";
3
2
  import { Configuration, Injectable, InjectorService, Platform } from "@tsed/common";
4
- import { getValue } from "@tsed/core";
5
- import { getSpec, mergeSpec, SpecTypes } from "@tsed/schema";
6
- import Fs from "fs";
7
- import { includeRoute } from "../utils/includeRoute";
8
- import { mapOpenSpec } from "../utils/mapOpenSpec";
3
+ import { generateSpec } from "@tsed/schema";
4
+ import { includeRoute } from "../utils/includeRoute.js";
9
5
  let SwaggerService = class SwaggerService {
6
+ injectorService;
7
+ platform;
8
+ configuration;
9
+ #specs = new Map();
10
10
  constructor(injectorService, platform, configuration) {
11
11
  this.injectorService = injectorService;
12
12
  this.platform = platform;
13
13
  this.configuration = configuration;
14
- _SwaggerService_specs.set(this, new Map());
15
14
  }
16
- /**
17
- * Generate Spec for the given configuration
18
- * @returns {Spec}
19
- */
20
- getOpenAPISpec(conf) {
21
- if (!__classPrivateFieldGet(this, _SwaggerService_specs, "f").has(conf.path)) {
22
- const defaultSpec = this.getDefaultSpec(conf);
23
- let finalSpec = {};
24
- const options = {
25
- paths: {},
26
- tags: [],
27
- schemas: {},
28
- specType: SpecTypes.OPENAPI,
29
- operationIdFormatter: conf.operationIdFormatter,
30
- operationIdPattern: conf.operationIdPattern,
31
- append(spec) {
32
- finalSpec = mergeSpec(finalSpec, spec);
33
- }
34
- };
35
- this.platform.getMountedControllers().forEach(({ route, provider }) => {
36
- if (includeRoute(route, provider, conf)) {
37
- const spec = this.buildRoutes(provider, {
38
- ...options,
39
- rootPath: route.replace(provider.path, "")
40
- });
41
- options.append(spec);
42
- }
15
+ async getOpenAPISpec(conf) {
16
+ if (!this.#specs.has(conf.path)) {
17
+ const { version = "1.0.0", acceptMimes } = this.configuration;
18
+ const specPath = conf.specPath ? this.configuration.resolve(conf.specPath) : conf.specPath;
19
+ const tokens = this.platform
20
+ .getMountedControllers()
21
+ .filter(({ route, provider }) => includeRoute(route, provider, conf))
22
+ .map(({ route, provider }) => ({ token: provider.token, rootPath: route }));
23
+ const spec = await generateSpec({
24
+ tokens,
25
+ ...conf,
26
+ specPath,
27
+ version,
28
+ acceptMimes
43
29
  });
44
- __classPrivateFieldGet(this, _SwaggerService_specs, "f").set(conf.path, mergeSpec(defaultSpec, finalSpec));
30
+ this.#specs.set(conf.path, spec);
45
31
  }
46
- return __classPrivateFieldGet(this, _SwaggerService_specs, "f").get(conf.path);
47
- }
48
- /**
49
- * Return the global api information.
50
- */
51
- getDefaultSpec(conf) {
52
- const { version = "1.0.0", acceptMimes } = this.configuration;
53
- const { specPath, specVersion } = conf;
54
- const fileSpec = specPath ? this.readSpecPath(specPath) : {};
55
- return mapOpenSpec(getValue(conf, "spec", {}), {
56
- fileSpec,
57
- version,
58
- specVersion,
59
- acceptMimes
60
- });
61
- }
62
- readSpecPath(path) {
63
- path = this.configuration.resolve(path);
64
- if (Fs.existsSync(path)) {
65
- const json = Fs.readFileSync(path, { encoding: "utf8" });
66
- /* istanbul ignore else */
67
- if (json !== "") {
68
- return JSON.parse(json);
69
- }
70
- }
71
- return {};
72
- }
73
- /**
74
- *
75
- * @param ctrl
76
- * @param options
77
- */
78
- buildRoutes(ctrl, options) {
79
- const rootPath = options.rootPath + ctrl.path;
80
- ctrl.children
81
- .map((ctrl) => this.injectorService.getProvider(ctrl))
82
- .forEach((provider) => {
83
- if (!provider.store.get("hidden")) {
84
- const spec = this.buildRoutes(provider, {
85
- ...options,
86
- rootPath
87
- });
88
- options.append(spec);
89
- }
90
- });
91
- return getSpec(ctrl.token, options);
32
+ return this.#specs.get(conf.path);
92
33
  }
93
34
  };
94
- _SwaggerService_specs = new WeakMap();
95
35
  SwaggerService = __decorate([
96
36
  Injectable(),
97
37
  __param(2, Configuration()),
@@ -1 +1 @@
1
- {"version":3,"file":"SwaggerService.js","sourceRoot":"","sources":["../../../src/services/SwaggerService.ts"],"names":[],"mappings":";;AAAA,OAAO,EAAC,aAAa,EAAsB,UAAU,EAAE,eAAe,EAAE,QAAQ,EAAC,MAAM,cAAc,CAAC;AACtG,OAAO,EAAC,QAAQ,EAAC,MAAM,YAAY,CAAC;AAEpC,OAAO,EAAC,OAAO,EAAE,SAAS,EAAyB,SAAS,EAAC,MAAM,cAAc,CAAC;AAClF,OAAO,EAAE,MAAM,IAAI,CAAC;AAEpB,OAAO,EAAC,YAAY,EAAC,MAAM,uBAAuB,CAAC;AACnD,OAAO,EAAC,WAAW,EAAC,MAAM,sBAAsB,CAAC;AAGjD,IAAa,cAAc,GAA3B,MAAa,cAAc;IAGzB,YACU,eAAgC,EAChC,QAAkB,EACD,aAA4B;QAF7C,oBAAe,GAAf,eAAe,CAAiB;QAChC,aAAQ,GAAR,QAAQ,CAAU;QACD,kBAAa,GAAb,aAAa,CAAe;QALvD,gCAAiC,IAAI,GAAG,EAAE,EAAC;IAMxC,CAAC;IAEJ;;;OAGG;IACI,cAAc,CAAC,IAAqB;QACzC,IAAI,CAAC,uBAAA,IAAI,6BAAO,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE;YAC/B,MAAM,WAAW,GAAQ,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC;YACnD,IAAI,SAAS,GAAQ,EAAE,CAAC;YAExB,MAAM,OAAO,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AC;IACtC,CAAC;CACF,CAAA;;AAnGY,cAAc;IAD1B,UAAU,EAAE;IAOR,WAAA,aAAa,EAAE,CAAA;qCAFS,eAAe;QACtB,QAAQ;GALjB,cAAc,CAmG1B;SAnGY,cAAc","sourcesContent":["import {Configuration, ControllerProvider, Injectable, InjectorService, Platform} from \"@tsed/common\";\nimport {getValue} from \"@tsed/core\";\nimport {OpenSpec3} from \"@tsed/openspec\";\nimport {getSpec, mergeSpec, SpecSerializerOptions, SpecTypes} from \"@tsed/schema\";\nimport Fs from \"fs\";\nimport {SwaggerSettings} from \"../interfaces/SwaggerSettings\";\nimport {includeRoute} from \"../utils/includeRoute\";\nimport {mapOpenSpec} from \"../utils/mapOpenSpec\";\n\n@Injectable()\nexport class SwaggerService {\n #specs: Map<string, OpenSpec3> = new Map();\n\n constructor(\n private injectorService: InjectorService,\n private platform: Platform,\n @Configuration() private configuration: Configuration\n ) {}\n\n /**\n * Generate Spec for the given configuration\n * @returns {Spec}\n */\n public getOpenAPISpec(conf: SwaggerSettings) {\n if (!this.#specs.has(conf.path)) {\n const defaultSpec: any = this.getDefaultSpec(conf);\n let finalSpec: any = {};\n\n const options: SpecSerializerOptions = {\n paths: {},\n tags: [],\n schemas: {},\n specType: SpecTypes.OPENAPI,\n operationIdFormatter: conf.operationIdFormatter,\n operationIdPattern: conf.operationIdPattern,\n append(spec: any) {\n finalSpec = mergeSpec(finalSpec, spec);\n }\n };\n\n this.platform.getMountedControllers().forEach(({route, provider}) => {\n if (includeRoute(route, provider, conf)) {\n const spec = this.buildRoutes(provider, {\n ...options,\n rootPath: route.replace(provider.path, \"\")\n });\n\n options.append(spec);\n }\n });\n\n this.#specs.set(conf.path, mergeSpec(defaultSpec, finalSpec) as any);\n }\n\n return this.#specs.get(conf.path);\n }\n\n /**\n * Return the global api information.\n */\n protected getDefaultSpec(conf: Partial<SwaggerSettings>): Partial<OpenSpec3> {\n const {version = \"1.0.0\", acceptMimes} = this.configuration;\n const {specPath, specVersion} = conf;\n const fileSpec: Partial<OpenSpec3> = specPath ? this.readSpecPath(specPath) : {};\n\n return mapOpenSpec(getValue(conf, \"spec\", {}), {\n fileSpec,\n version,\n specVersion,\n acceptMimes\n });\n }\n\n protected readSpecPath(path: string) {\n path = this.configuration.resolve(path);\n if (Fs.existsSync(path)) {\n const json = Fs.readFileSync(path, {encoding: \"utf8\"});\n /* istanbul ignore else */\n if (json !== \"\") {\n return JSON.parse(json);\n }\n }\n\n return {};\n }\n\n /**\n *\n * @param ctrl\n * @param options\n */\n protected buildRoutes(ctrl: ControllerProvider, options: SpecSerializerOptions) {\n const rootPath = options.rootPath + ctrl.path;\n\n ctrl.children\n .map((ctrl) => this.injectorService.getProvider(ctrl))\n .forEach((provider: ControllerProvider) => {\n if (!provider.store.get(\"hidden\")) {\n const spec = this.buildRoutes(provider, {\n ...options,\n rootPath\n });\n\n options.append(spec);\n }\n });\n\n return getSpec(ctrl.token, options);\n }\n}\n"]}
1
+ {"version":3,"file":"SwaggerService.js","sourceRoot":"","sources":["../../../src/services/SwaggerService.ts"],"names":[],"mappings":";AAAA,OAAO,EAAC,aAAa,EAAE,UAAU,EAAE,eAAe,EAAE,QAAQ,EAAC,MAAM,cAAc,CAAC;AAElF,OAAO,EAAC,YAAY,EAAC,MAAM,cAAc,CAAC;AAE1C,OAAO,EAAC,YAAY,EAAC,MAAM,uBAAuB,CAAC;AAGnD,IAAa,cAAc,GAA3B,MAAa,cAAc;IAIf;IACA;IACiB;IAL3B,MAAM,GAAuC,IAAI,GAAG,EAAE,CAAC;IAEvD,YACU,eAAgC,EAChC,QAAkB,EACD,aAA4B;QAF7C,oBAAe,GAAf,eAAe,CAAiB;QAChC,aAAQ,GAAR,QAAQ,CAAU;QACD,kBAAa,GAAb,aAAa,CAAe;IACpD,CAAC;IASG,KAAK,CAAC,cAAc,CAAC,IAAqB;QAC/C,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE;YAC/B,MAAM,EAAC,OAAO,GAAG,OAAO,EAAE,WAAW,EAAC,GAAG,IAAI,CAAC,aAAa,CAAC;YAC5D,MAAM,QAAQ,GAAG,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,aAAa,CAAC,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC;YAE3F,MAAM,MAAM,GAAG,IAAI,CAAC,QAAQ;iBACzB,qBAAqB,EAAE;iBACvB,MAAM,CAAC,CAAC,EAAC,KAAK,EAAE,QAAQ,EAAC,EAAE,EAAE,CAAC,YAAY,CAAC,KAAK,EAAE,QAAQ,EAAE,IAAI,CAAC,CAAC;iBAClE,GAAG,CAAC,CAAC,EAAC,KAAK,EAAE,QAAQ,EAAC,EAAE,EAAE,CAAC,CAAC,EAAC,KAAK,EAAE,QAAQ,CAAC,KAAK,EAAE,QAAQ,EAAE,KAAK,EAAC,CAAC,CAAC,CAAC;YAE1E,MAAM,IAAI,GAAG,MAAM,YAAY,CAAC;gBAC9B,MAAM;gBACN,GAAG,IAAI;gBACP,QAAQ;gBACR,OAAO;gBACP,WAAW;aACZ,CAAC,CAAC;YAEH,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;SAClC;QAED,OAAO,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACpC,CAAC;CACF,CAAA;AAvCY,cAAc;IAD1B,UAAU,EAAE;IAOR,WAAA,aAAa,EAAE,CAAA;qCAFS,eAAe;QACtB,QAAQ;GALjB,cAAc,CAuC1B;SAvCY,cAAc","sourcesContent":["import {Configuration, Injectable, InjectorService, Platform} from \"@tsed/common\";\nimport {OpenSpec2, OpenSpec3} from \"@tsed/openspec\";\nimport {generateSpec} from \"@tsed/schema\";\nimport {SwaggerOS2Settings, SwaggerOS3Settings, SwaggerSettings} from \"../interfaces/SwaggerSettings\";\nimport {includeRoute} from \"../utils/includeRoute\";\n\n@Injectable()\nexport class SwaggerService {\n #specs: Map<string, OpenSpec3 | OpenSpec2> = new Map();\n\n constructor(\n private injectorService: InjectorService,\n private platform: Platform,\n @Configuration() private configuration: Configuration\n ) {}\n\n /**\n * Generate Spec for the given configuration\n * @returns {Spec}\n */\n public async getOpenAPISpec(conf: SwaggerOS3Settings): Promise<OpenSpec3>;\n public async getOpenAPISpec(conf: SwaggerOS2Settings): Promise<OpenSpec2>;\n public async getOpenAPISpec(conf: SwaggerSettings): Promise<OpenSpec2>;\n public async getOpenAPISpec(conf: SwaggerSettings) {\n if (!this.#specs.has(conf.path)) {\n const {version = \"1.0.0\", acceptMimes} = this.configuration;\n const specPath = conf.specPath ? this.configuration.resolve(conf.specPath) : conf.specPath;\n\n const tokens = this.platform\n .getMountedControllers()\n .filter(({route, provider}) => includeRoute(route, provider, conf))\n .map(({route, provider}) => ({token: provider.token, rootPath: route}));\n\n const spec = await generateSpec({\n tokens,\n ...conf,\n specPath,\n version,\n acceptMimes\n });\n\n this.#specs.set(conf.path, spec);\n }\n\n return this.#specs.get(conf.path);\n }\n}\n"]}
@@ -1,4 +1,4 @@
1
- import { matchPath } from ".";
1
+ import { matchPath } from "./matchPath.js";
2
2
  export function includeRoute(route, provider, conf) {
3
3
  const hidden = provider.store.get("hidden");
4
4
  const docs = provider.store.get("docs") || [];
@@ -1 +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"]}
1
+ {"version":3,"file":"includeRoute.js","sourceRoot":"","sources":["../../../src/utils/includeRoute.ts"],"names":[],"mappings":"AAEA,OAAO,EAAC,SAAS,EAAC,MAAM,aAAa,CAAC;AAEtC,MAAM,UAAU,YAAY,CAAC,KAAa,EAAE,QAAkB,EAAE,IAAqB;IACnF,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 {Provider} from \"@tsed/di\";\nimport {SwaggerSettings} from \"../interfaces/SwaggerSettings\";\nimport {matchPath} from \"./matchPath\";\n\nexport function includeRoute(route: string, provider: Provider, 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"]}
@@ -1,6 +1,7 @@
1
1
  import { OnRoutesInit, Configuration, InjectorService, OnReady, PlatformApplication } from "@tsed/common";
2
- import { SwaggerService } from "./services/SwaggerService";
3
2
  import { Env } from "@tsed/core";
3
+ import { SwaggerSettings } from "./interfaces/SwaggerSettings";
4
+ import { SwaggerService } from "./services/SwaggerService";
4
5
  /**
5
6
  * @ignore
6
7
  */
@@ -11,7 +12,7 @@ export declare class SwaggerModule implements OnRoutesInit, OnReady {
11
12
  swaggerService: SwaggerService;
12
13
  env: Env;
13
14
  private loaded;
14
- get settings(): import("./interfaces").SwaggerOS3Settings[];
15
+ get settings(): SwaggerSettings[];
15
16
  /**
16
17
  *
17
18
  */
@@ -1,5 +1,15 @@
1
- export * from "./services/SwaggerService";
1
+ /**
2
+ * @file Automatically generated by barrelsby.
3
+ */
2
4
  export * from "./SwaggerModule";
3
- export * from "./interfaces";
4
5
  export * from "./decorators/docs";
5
6
  export * from "./decorators/hidden";
7
+ export * from "./interfaces/SwaggerSettings";
8
+ export * from "./interfaces/interfaces";
9
+ export * from "./middlewares/cssMiddleware";
10
+ export * from "./middlewares/indexMiddleware";
11
+ export * from "./middlewares/jsMiddleware";
12
+ export * from "./middlewares/redirectMiddleware";
13
+ export * from "./services/SwaggerService";
14
+ export * from "./utils/includeRoute";
15
+ export * from "./utils/matchPath";
@@ -1,4 +1,4 @@
1
- import { OpenSpec3, OpenSpecVersions, OS3Versions } from "@tsed/openspec";
1
+ import { OpenSpec2, OpenSpec3, OpenSpecVersions, OS2Versions, OS3Versions } from "@tsed/openspec";
2
2
  export interface SwaggerUIOptions {
3
3
  configUrl?: string;
4
4
  url?: string;
@@ -79,6 +79,13 @@ export interface SwaggerSettingsBase {
79
79
  */
80
80
  pathPatterns?: string[];
81
81
  }
82
+ export interface SwaggerOS2Settings extends SwaggerSettingsBase {
83
+ specVersion?: OS2Versions;
84
+ /**
85
+ * OpenSpec 2
86
+ */
87
+ spec?: Partial<OpenSpec2>;
88
+ }
82
89
  export interface SwaggerOS3Settings extends SwaggerSettingsBase {
83
90
  specVersion?: OS3Versions;
84
91
  /**
@@ -86,4 +93,4 @@ export interface SwaggerOS3Settings extends SwaggerSettingsBase {
86
93
  */
87
94
  spec?: Partial<OpenSpec3>;
88
95
  }
89
- export declare type SwaggerSettings = SwaggerOS3Settings;
96
+ export declare type SwaggerSettings = SwaggerOS2Settings | SwaggerOS3Settings;
@@ -6,4 +6,3 @@ declare global {
6
6
  }
7
7
  }
8
8
  }
9
- export * from "./SwaggerSettings";
@@ -1,7 +1,6 @@
1
- import { Configuration, ControllerProvider, InjectorService, Platform } from "@tsed/common";
2
- import { OpenSpec3 } from "@tsed/openspec";
3
- import { SpecSerializerOptions } from "@tsed/schema";
4
- import { SwaggerSettings } from "../interfaces/SwaggerSettings";
1
+ import { Configuration, InjectorService, Platform } from "@tsed/common";
2
+ import { OpenSpec2, OpenSpec3 } from "@tsed/openspec";
3
+ import { SwaggerOS2Settings, SwaggerOS3Settings, SwaggerSettings } from "../interfaces/SwaggerSettings";
5
4
  export declare class SwaggerService {
6
5
  #private;
7
6
  private injectorService;
@@ -12,16 +11,7 @@ export declare class SwaggerService {
12
11
  * Generate Spec for the given configuration
13
12
  * @returns {Spec}
14
13
  */
15
- getOpenAPISpec(conf: SwaggerSettings): OpenSpec3<import("@tsed/openspec").OS3Schema> | undefined;
16
- /**
17
- * Return the global api information.
18
- */
19
- protected getDefaultSpec(conf: Partial<SwaggerSettings>): Partial<OpenSpec3>;
20
- protected readSpecPath(path: string): any;
21
- /**
22
- *
23
- * @param ctrl
24
- * @param options
25
- */
26
- protected buildRoutes(ctrl: ControllerProvider, options: SpecSerializerOptions): Partial<OpenSpec3<import("@tsed/openspec").OS3Schema>>;
14
+ getOpenAPISpec(conf: SwaggerOS3Settings): Promise<OpenSpec3>;
15
+ getOpenAPISpec(conf: SwaggerOS2Settings): Promise<OpenSpec2>;
16
+ getOpenAPISpec(conf: SwaggerSettings): Promise<OpenSpec2>;
27
17
  }
@@ -1,3 +1,3 @@
1
- import { ControllerProvider } from "@tsed/common";
2
- import { SwaggerSettings } from "..";
3
- export declare function includeRoute(route: string, provider: ControllerProvider, conf: SwaggerSettings): boolean;
1
+ import { Provider } from "@tsed/di";
2
+ import { SwaggerSettings } from "../interfaces/SwaggerSettings";
3
+ export declare function includeRoute(route: string, provider: Provider, conf: SwaggerSettings): boolean;
package/package.json CHANGED
@@ -1,10 +1,11 @@
1
1
  {
2
2
  "name": "@tsed/swagger",
3
- "version": "7.0.0-beta.2",
3
+ "version": "7.0.0-beta.20",
4
4
  "description": "Swagger package for Ts.ED framework",
5
5
  "private": false,
6
6
  "source": "./src/index.ts",
7
7
  "main": "./lib/cjs/index.js",
8
+ "module": "./lib/esm/index.js",
8
9
  "typings": "./lib/types/index.d.ts",
9
10
  "exports": {
10
11
  "types": "./lib/types/index.d.ts",
@@ -13,38 +14,46 @@
13
14
  "default": "./lib/esm/index.js"
14
15
  },
15
16
  "scripts": {
16
- "build": "yarn run build:esm && yarn run build:cjs && cp -r ./views ./lib/views",
17
+ "clean": "rm -rf lib",
18
+ "build": "yarn clean && yarn barrels && yarn run build:esm && yarn run build:cjs && cp -r ./views ./lib/views",
17
19
  "build:cjs": "tsc --build tsconfig.compile.json",
18
20
  "build:esm": "tsc --build tsconfig.compile.esm.json",
19
- "start": "ts-node -r tsconfig-paths/register test/app/index.ts"
21
+ "barrels": "yarn barrelsby --delete -d ./src -e \"\\.spec\\.ts\" -e \"__mock__\" -e \".benchmark.ts\"",
22
+ "start": "ts-node -r tsconfig-paths/register test/app/index.ts",
23
+ "test": "cross-env NODE_ENV=test yarn jest --max-workers=2"
20
24
  },
21
25
  "dependencies": {
22
- "fs-extra": "9.0.1",
23
- "micromatch": "^4.0.2",
24
- "swagger-ui-dist": "^3.46.0",
25
- "tslib": "2.2.0"
26
+ "@tsed/openspec": "7.0.0-beta.20",
27
+ "fs-extra": "10.0.1",
28
+ "micromatch": "4.0.5",
29
+ "swagger-ui-dist": "^4.5.2",
30
+ "tslib": "2.4.0"
26
31
  },
27
32
  "devDependencies": {
28
- "@tsed/common": "7.0.0-beta.2",
29
- "@tsed/core": "7.0.0-beta.2",
30
- "@tsed/di": "7.0.0-beta.2",
31
- "@tsed/json-mapper": "7.0.0-beta.2",
32
- "@tsed/openspec": "7.0.0-beta.2",
33
- "@tsed/schema": "7.0.0-beta.2"
33
+ "@tsed/common": "7.0.0-beta.20",
34
+ "@tsed/core": "7.0.0-beta.20",
35
+ "@tsed/di": "7.0.0-beta.20",
36
+ "@tsed/json-mapper": "7.0.0-beta.20",
37
+ "@tsed/openspec": "7.0.0-beta.20",
38
+ "@tsed/schema": "7.0.0-beta.20",
39
+ "@types/swagger-ui-dist": ">=3.30.1"
34
40
  },
35
41
  "peerDependencies": {
36
- "@tsed/common": "^7.0.0-beta.2",
37
- "@tsed/core": "^7.0.0-beta.2",
38
- "@tsed/di": "^7.0.0-beta.2",
39
- "@tsed/json-mapper": "^7.0.0-beta.2",
40
- "@tsed/openspec": "^7.0.0-beta.2",
41
- "@tsed/schema": "^7.0.0-beta.2"
42
+ "@tsed/common": "^7.0.0-beta.20"
43
+ },
44
+ "peerDependenciesMeta": {
45
+ "@tsed/common": {
46
+ "optional": false
47
+ }
42
48
  },
43
49
  "repository": "https://github.com/tsedio/tsed",
44
50
  "bugs": {
45
51
  "url": "https://github.com/tsedio/tsed/issues"
46
52
  },
47
- "homepage": "https://github.com/tsedio/tsed/tree/alpha/packages/specs/swagger",
53
+ "homepage": "https://github.com/tsedio/tsed/tree/beta/packages/specs/swagger",
48
54
  "author": "Romain Lenzotti",
49
- "license": "MIT"
55
+ "license": "MIT",
56
+ "publishConfig": {
57
+ "tag": "beta"
58
+ }
50
59
  }