diff --git a/lib/plugin/utils/plugin-utils.ts b/lib/plugin/utils/plugin-utils.ts index 33bfe414a..7d1bd208b 100644 --- a/lib/plugin/utils/plugin-utils.ts +++ b/lib/plugin/utils/plugin-utils.ts @@ -125,7 +125,7 @@ export function getTypeReferenceAsString( } export function isPromiseOrObservable(type: string) { - return type.includes('Promise') || type.includes('Observable'); + return type.includes('Promise<') || type.includes('Observable<'); } export function hasPropertyKey( diff --git a/test/plugin/fixtures/app.controller.ts b/test/plugin/fixtures/app.controller.ts index e407a9db7..a73ae0731 100644 --- a/test/plugin/fixtures/app.controller.ts +++ b/test/plugin/fixtures/app.controller.ts @@ -3,6 +3,10 @@ import { ApiOperation } from '@nestjs/swagger'; class Cat {} +class PromiseCat {} + +class ObservableCat {} + @Controller('cats') export class AppController { onApplicationBootstrap() {} @@ -39,6 +43,24 @@ export class AppController { @Post() async testCreate2(): Promise {} + /** + * create a test PromiseCat + * + * @returns {Promise>} + * @memberof AppController + */ + @Post() + async testCreate3(): Promise {} + + /** + * create a test ObservableCat + * + * @returns {Promise} + * @memberof AppController + */ + @Post() + async testCreate4(): Promise {} + /** * find a Cat */ @@ -68,6 +90,10 @@ const common_1 = require(\"@nestjs/common\"); const swagger_1 = require(\"@nestjs/swagger\"); class Cat { } +class PromiseCat { +} +class ObservableCat { +} let AppController = exports.AppController = class AppController { onApplicationBootstrap() { } /** @@ -95,6 +121,20 @@ let AppController = exports.AppController = class AppController { * @memberof AppController */ async testCreate2() { } + /** + * create a test PromiseCat + * + * @returns {Promise>} + * @memberof AppController + */ + async testCreate3() { } + /** + * create a test ObservableCat + * + * @returns {Promise} + * @memberof AppController + */ + async testCreate4() { } /** * find a Cat */ @@ -122,6 +162,16 @@ __decorate([ (0, common_1.Post)(), openapi.ApiResponse({ status: 201, type: Cat }) ], AppController.prototype, \"testCreate2\", null); +__decorate([ + openapi.ApiOperation({ summary: \"create a test PromiseCat\" }), + (0, common_1.Post)(), + openapi.ApiResponse({ status: 201, type: PromiseCat }) +], AppController.prototype, \"testCreate3\", null); +__decorate([ + openapi.ApiOperation({ summary: \"create a test ObservableCat\" }), + (0, common_1.Post)(), + openapi.ApiResponse({ status: 201, type: ObservableCat }) +], AppController.prototype, \"testCreate4\", null); __decorate([ (0, swagger_1.ApiOperation)({ summary: \"find a Cat\" }), Get(),