@tsed/swagger 6.105.3 → 6.105.4

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.
@@ -35,7 +35,7 @@ let SwaggerService = class SwaggerService {
35
35
  };
36
36
  this.platform.getMountedControllers().forEach(({ route, provider }) => {
37
37
  if ((0, includeRoute_1.includeRoute)(route, provider, conf)) {
38
- const spec = this.buildRoutes(provider, {
38
+ const spec = (0, schema_1.getSpec)(provider.token, {
39
39
  ...options,
40
40
  rootPath: route.replace(provider.path, "")
41
41
  });
@@ -71,26 +71,6 @@ let SwaggerService = class SwaggerService {
71
71
  }
72
72
  return {};
73
73
  }
74
- /**
75
- *
76
- * @param ctrl
77
- * @param options
78
- */
79
- buildRoutes(ctrl, options) {
80
- const rootPath = options.rootPath + ctrl.path;
81
- ctrl.children
82
- .map((ctrl) => this.injectorService.getProvider(ctrl))
83
- .forEach((provider) => {
84
- if (!provider.store.get("hidden")) {
85
- const spec = this.buildRoutes(provider, {
86
- ...options,
87
- rootPath
88
- });
89
- options.append(spec);
90
- }
91
- });
92
- return (0, schema_1.getSpec)(ctrl.token, options);
93
- }
94
74
  };
95
75
  _SwaggerService_specs = new WeakMap();
96
76
  SwaggerService = (0, tslib_1.__decorate)([
@@ -1 +1 @@
1
- {"version":3,"file":"SwaggerService.js","sourceRoot":"","sources":["../../../src/services/SwaggerService.ts"],"names":[],"mappings":";;;;;AAAA,yCAAsG;AACtG,qCAAoC;AAEpC,yCAAuE;AACvE,yDAAoB;AAEpB,sDAAyD;AACzD,wDAAmD;AACnD,sDAAiD;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,gCAA6C,IAAI,GAAG,EAAE,EAAC;IAMpD,CAAC;IAeG,cAAc,CA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K,CAAC,GAAG,CAAC,QAAQ,CAAC,EAAE;gBACjC,MAAM,IAAI,GAAG,IAAI,CAAC,WAAW,CAAC,QAAQ,EAAE;oBACtC,GAAG,OAAO;oBACV,QAAQ;iBACT,CAAC,CAAC;gBAEH,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;aACtB;QACH,CAAC,CAAC,CAAC;QAEL,OAAO,IAAA,gBAAO,EAAC,IAAI,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;IACtC,CAAC;CACF,CAAA;;AA7GY,cAAc;IAD1B,IAAA,mBAAU,GAAE;IAOR,wBAAA,IAAA,sBAAa,GAAE,CAAA;kDAFS,wBAAe;QACtB,iBAAQ;GALjB,cAAc,CA6G1B;AA7GY,wCAAc","sourcesContent":["import {Configuration, ControllerProvider, Injectable, InjectorService, Platform} from \"@tsed/common\";\nimport {getValue} from \"@tsed/core\";\nimport {OpenSpec2, OpenSpec3} from \"@tsed/openspec\";\nimport {getSpec, mergeSpec, SpecSerializerOptions} from \"@tsed/schema\";\nimport Fs from \"fs\";\nimport {SwaggerOS2Settings, SwaggerOS3Settings, SwaggerSettings} from \"../interfaces/SwaggerSettings\";\nimport {getSpecTypeFromSpec} from \"../utils/getSpecType\";\nimport {includeRoute} from \"../utils/includeRoute\";\nimport {mapOpenSpec} from \"../utils/mapOpenSpec\";\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 getOpenAPISpec(conf: SwaggerOS3Settings): OpenSpec3;\n /**\n * @deprecated\n */\n public getOpenAPISpec(conf: SwaggerOS2Settings): OpenSpec2;\n /**\n * @deprecated\n */\n public getOpenAPISpec(conf: SwaggerSettings): OpenSpec2;\n public getOpenAPISpec(conf: SwaggerSettings) {\n if (!this.#specs.has(conf.path)) {\n const defaultSpec: any = this.getDefaultSpec(conf);\n const specType = getSpecTypeFromSpec(defaultSpec);\n let finalSpec: any = {};\n\n const options: SpecSerializerOptions = {\n paths: {},\n tags: [],\n schemas: {},\n specType,\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<OpenSpec2 | OpenSpec3> {\n const {version = \"1.0.0\", acceptMimes} = this.configuration;\n const {specPath, specVersion} = conf;\n const fileSpec: Partial<OpenSpec2 | 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":["../../../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,CAAC,CAAC;aACzB;SACF;QAED,OAAO,EAAE,CAAC;IACZ,CAAC;CACF,CAAA;;AArFY,cAAc;IAD1B,IAAA,mBAAU,GAAE;IAOR,wBAAA,IAAA,sBAAa,GAAE,CAAA;kDAFS,wBAAe;QACtB,iBAAQ;GALjB,cAAc,CAqF1B;AArFY,wCAAc","sourcesContent":["import {Configuration, ControllerProvider, Injectable, InjectorService, Platform} from \"@tsed/common\";\nimport {getValue} from \"@tsed/core\";\nimport {OpenSpec2, OpenSpec3} from \"@tsed/openspec\";\nimport {getSpec, mergeSpec, SpecSerializerOptions} from \"@tsed/schema\";\nimport Fs from \"fs\";\nimport {SwaggerOS2Settings, SwaggerOS3Settings, SwaggerSettings} from \"../interfaces/SwaggerSettings\";\nimport {getSpecTypeFromSpec} from \"../utils/getSpecType\";\nimport {includeRoute} from \"../utils/includeRoute\";\nimport {mapOpenSpec} from \"../utils/mapOpenSpec\";\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 getOpenAPISpec(conf: SwaggerOS3Settings): OpenSpec3;\n /**\n * @deprecated\n */\n public getOpenAPISpec(conf: SwaggerOS2Settings): OpenSpec2;\n /**\n * @deprecated\n */\n public getOpenAPISpec(conf: SwaggerSettings): OpenSpec2;\n public getOpenAPISpec(conf: SwaggerSettings) {\n if (!this.#specs.has(conf.path)) {\n const defaultSpec: any = this.getDefaultSpec(conf);\n const specType = getSpecTypeFromSpec(defaultSpec);\n let finalSpec: any = {};\n\n const options: SpecSerializerOptions = {\n paths: {},\n tags: [],\n schemas: {},\n specType,\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 = getSpec(provider.token, {\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<OpenSpec2 | OpenSpec3> {\n const {version = \"1.0.0\", acceptMimes} = this.configuration;\n const {specPath, specVersion} = conf;\n const fileSpec: Partial<OpenSpec2 | 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"]}
@@ -32,7 +32,7 @@ let SwaggerService = class SwaggerService {
32
32
  };
33
33
  this.platform.getMountedControllers().forEach(({ route, provider }) => {
34
34
  if (includeRoute(route, provider, conf)) {
35
- const spec = this.buildRoutes(provider, {
35
+ const spec = getSpec(provider.token, {
36
36
  ...options,
37
37
  rootPath: route.replace(provider.path, "")
38
38
  });
@@ -68,26 +68,6 @@ let SwaggerService = class SwaggerService {
68
68
  }
69
69
  return {};
70
70
  }
71
- /**
72
- *
73
- * @param ctrl
74
- * @param options
75
- */
76
- buildRoutes(ctrl, options) {
77
- const rootPath = options.rootPath + ctrl.path;
78
- ctrl.children
79
- .map((ctrl) => this.injectorService.getProvider(ctrl))
80
- .forEach((provider) => {
81
- if (!provider.store.get("hidden")) {
82
- const spec = this.buildRoutes(provider, {
83
- ...options,
84
- rootPath
85
- });
86
- options.append(spec);
87
- }
88
- });
89
- return getSpec(ctrl.token, options);
90
- }
91
71
  };
92
72
  _SwaggerService_specs = new WeakMap();
93
73
  SwaggerService = __decorate([
@@ -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,EAAwB,MAAM,cAAc,CAAC;AACvE,OAAO,EAAE,MAAM,IAAI,CAAC;AAEpB,OAAO,EAAC,mBAAmB,EAAC,MAAM,sBAAsB,CAAC;AACzD,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,gCAA6C,IAAI,GAAG,EAAE,EAAC;IAMpD,CAAC;IAeG,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,MAAM,QAAQ,GAAG,mBAAmB,CAAC,WAAW,CAAC,CAAC;YAClD,IAAI,SAAS,GAAQ,EAAE,CAAC;YAExB,MAAM,OAAO,GAA0B;gBACrC,KAAK,EAAE,EAAE;gBACT,IAAI,EAAE,EAAE;gBACR,OAAO,EAAE,EAAE;gBACX,QAAQ;gBACR,oBAAoB,EAAE,IAAI,CAAC,oBAAoB;gBAC/C,kBAAkB,EAAE,IAAI,CAAC,kBAAkB;gBAC3C,MAAM,C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from \"@tsed/core\";\nimport {OpenSpec2, OpenSpec3} from \"@tsed/openspec\";\nimport {getSpec, mergeSpec, SpecSerializerOptions} from \"@tsed/schema\";\nimport Fs from \"fs\";\nimport {SwaggerOS2Settings, SwaggerOS3Settings, SwaggerSettings} from \"../interfaces/SwaggerSettings\";\nimport {getSpecTypeFromSpec} from \"../utils/getSpecType\";\nimport {includeRoute} from \"../utils/includeRoute\";\nimport {mapOpenSpec} from \"../utils/mapOpenSpec\";\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 getOpenAPISpec(conf: SwaggerOS3Settings): OpenSpec3;\n /**\n * @deprecated\n */\n public getOpenAPISpec(conf: SwaggerOS2Settings): OpenSpec2;\n /**\n * @deprecated\n */\n public getOpenAPISpec(conf: SwaggerSettings): OpenSpec2;\n public getOpenAPISpec(conf: SwaggerSettings) {\n if (!this.#specs.has(conf.path)) {\n const defaultSpec: any = this.getDefaultSpec(conf);\n const specType = getSpecTypeFromSpec(defaultSpec);\n let finalSpec: any = {};\n\n const options: SpecSerializerOptions = {\n paths: {},\n tags: [],\n schemas: {},\n specType,\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<OpenSpec2 | OpenSpec3> {\n const {version = \"1.0.0\", acceptMimes} = this.configuration;\n const {specPath, specVersion} = conf;\n const fileSpec: Partial<OpenSpec2 | 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,EAAsB,UAAU,EAAE,eAAe,EAAE,QAAQ,EAAC,MAAM,cAAc,CAAC;AACtG,OAAO,EAAC,QAAQ,EAAC,MAAM,YAAY,CAAC;AAEpC,OAAO,EAAC,OAAO,EAAE,SAAS,EAAwB,MAAM,cAAc,CAAC;AACvE,OAAO,EAAE,MAAM,IAAI,CAAC;AAEpB,OAAO,EAAC,mBAAmB,EAAC,MAAM,sBAAsB,CAAC;AACzD,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;Q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SAAS,CAAQ,CAAC,CAAC;SACtE;QAED,OAAO,uBAAA,IAAI,6BAAO,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACpC,CAAC;IAED;;OAEG;IACO,cAAc,CAAC,IAA8B;QACrD,MAAM,EAAC,OAAO,GAAG,OAAO,EAAE,WAAW,EAAC,GAAG,IAAI,CAAC,aAAa,CAAC;QAC5D,MAAM,EAAC,QAAQ,EAAE,WAAW,EAAC,GAAG,IAAI,CAAC;QACrC,MAAM,QAAQ,GAAmC,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,YAAY,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;QAE7F,OAAO,WAAW,CAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,CAAC,EAAE;YAC7C,QAAQ;YACR,OAAO;YACP,WAAW;YACX,WAAW;SACZ,CAAC,CAAC;IACL,CAAC;IAES,YAAY,CAAC,IAAY;QACjC,IAAI,GAAG,IAAI,CAAC,aAAa,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;QACxC,IAAI,EAAE,CAAC,UAAU,CAAC,IAAI,CAAC,EAAE;YACvB,MAAM,IAAI,GAAG,EAAE,CAAC,YAAY,CAAC,IAAI,EAAE,EAAC,QAAQ,EAAE,MAAM,EAAC,CAAC,CAAC;YACvD,0BAA0B;YAC1B,IAAI,IAAI,KAAK,EAAE,EAAE;gBACf,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;aACzB;SACF;QAED,OAAO,EAAE,CAAC;IACZ,CAAC;CACF,CAAA;;AArFY,cAAc;IAD1B,UAAU,EAAE;IAOR,WAAA,aAAa,EAAE,CAAA;qCAFS,eAAe;QACtB,QAAQ;GALjB,cAAc,CAqF1B;SArFY,cAAc","sourcesContent":["import {Configuration, ControllerProvider, Injectable, InjectorService, Platform} from \"@tsed/common\";\nimport {getValue} from \"@tsed/core\";\nimport {OpenSpec2, OpenSpec3} from \"@tsed/openspec\";\nimport {getSpec, mergeSpec, SpecSerializerOptions} from \"@tsed/schema\";\nimport Fs from \"fs\";\nimport {SwaggerOS2Settings, SwaggerOS3Settings, SwaggerSettings} from \"../interfaces/SwaggerSettings\";\nimport {getSpecTypeFromSpec} from \"../utils/getSpecType\";\nimport {includeRoute} from \"../utils/includeRoute\";\nimport {mapOpenSpec} from \"../utils/mapOpenSpec\";\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 getOpenAPISpec(conf: SwaggerOS3Settings): OpenSpec3;\n /**\n * @deprecated\n */\n public getOpenAPISpec(conf: SwaggerOS2Settings): OpenSpec2;\n /**\n * @deprecated\n */\n public getOpenAPISpec(conf: SwaggerSettings): OpenSpec2;\n public getOpenAPISpec(conf: SwaggerSettings) {\n if (!this.#specs.has(conf.path)) {\n const defaultSpec: any = this.getDefaultSpec(conf);\n const specType = getSpecTypeFromSpec(defaultSpec);\n let finalSpec: any = {};\n\n const options: SpecSerializerOptions = {\n paths: {},\n tags: [],\n schemas: {},\n specType,\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 = getSpec(provider.token, {\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<OpenSpec2 | OpenSpec3> {\n const {version = \"1.0.0\", acceptMimes} = this.configuration;\n const {specPath, specVersion} = conf;\n const fileSpec: Partial<OpenSpec2 | 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"]}
@@ -1,6 +1,5 @@
1
- import { Configuration, ControllerProvider, InjectorService, Platform } from "@tsed/common";
1
+ import { Configuration, InjectorService, Platform } from "@tsed/common";
2
2
  import { OpenSpec2, OpenSpec3 } from "@tsed/openspec";
3
- import { SpecSerializerOptions } from "@tsed/schema";
4
3
  import { SwaggerOS2Settings, SwaggerOS3Settings, SwaggerSettings } from "../interfaces/SwaggerSettings";
5
4
  export declare class SwaggerService {
6
5
  #private;
@@ -26,10 +25,4 @@ export declare class SwaggerService {
26
25
  */
27
26
  protected getDefaultSpec(conf: Partial<SwaggerSettings>): Partial<OpenSpec2 | OpenSpec3>;
28
27
  protected readSpecPath(path: string): any;
29
- /**
30
- *
31
- * @param ctrl
32
- * @param options
33
- */
34
- protected buildRoutes(ctrl: ControllerProvider, options: SpecSerializerOptions): Partial<OpenSpec2>;
35
28
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tsed/swagger",
3
- "version": "6.105.3",
3
+ "version": "6.105.4",
4
4
  "description": "Swagger package for Ts.ED framework",
5
5
  "private": false,
6
6
  "source": "./src/index.ts",
@@ -20,26 +20,26 @@
20
20
  "start": "ts-node -r tsconfig-paths/register test/app/index.ts"
21
21
  },
22
22
  "dependencies": {
23
- "@tsed/openspec": "6.105.3",
23
+ "@tsed/openspec": "6.105.4",
24
24
  "fs-extra": "9.0.1",
25
25
  "micromatch": "4.0.4",
26
26
  "swagger-ui-dist": "^4.5.2",
27
27
  "tslib": "2.2.0"
28
28
  },
29
29
  "devDependencies": {
30
- "@tsed/common": "6.105.3",
31
- "@tsed/core": "6.105.3",
32
- "@tsed/di": "6.105.3",
33
- "@tsed/json-mapper": "6.105.3",
34
- "@tsed/openspec": "6.105.3",
35
- "@tsed/schema": "6.105.3",
30
+ "@tsed/common": "6.105.4",
31
+ "@tsed/core": "6.105.4",
32
+ "@tsed/di": "6.105.4",
33
+ "@tsed/json-mapper": "6.105.4",
34
+ "@tsed/openspec": "6.105.4",
35
+ "@tsed/schema": "6.105.4",
36
36
  "@types/swagger-ui-dist": ">=3.30.1"
37
37
  },
38
38
  "peerDependencies": {
39
- "@tsed/common": "^6.105.3",
40
- "@tsed/core": "^6.105.3",
41
- "@tsed/json-mapper": "^6.105.3",
42
- "@tsed/schema": "^6.105.3"
39
+ "@tsed/common": "^6.105.4",
40
+ "@tsed/core": "^6.105.4",
41
+ "@tsed/json-mapper": "^6.105.4",
42
+ "@tsed/schema": "^6.105.4"
43
43
  },
44
44
  "repository": "https://github.com/tsedio/tsed",
45
45
  "bugs": {