I'm using this wonderful lib: https://www.npmjs.com/package/ts-mixer
The whole traceback looks as follows:
(node:22654) UnhandledPromiseRejectionWarning: Error: A circular dependency has been detected (property key: "firstName"). Please, make sure that each side of a bidirectional relationships are using lazy resolvers ("type: () => ClassType").
at SchemaObjectFactory.createNotBuiltInTypeReference (/Users/albert/Documents/projects/albert/rlx/node_modules/@nestjs/swagger/dist/services/schema-object-factory.js:212:19)
at SchemaObjectFactory.mergePropertyWithMetadata (/Users/albert/Documents/projects/albert/rlx/node_modules/@nestjs/swagger/dist/services/schema-object-factory.js:143:25)
at /Users/albert/Documents/projects/albert/rlx/node_modules/@nestjs/swagger/dist/services/schema-object-factory.js:79:35
at Array.map (<anonymous>)
at SchemaObjectFactory.extractPropertiesFromType (/Users/albert/Documents/projects/albert/rlx/node_modules/@nestjs/swagger/dist/services/schema-object-factory.js:78:52)
at SchemaObjectFactory.exploreModelSchema (/Users/albert/Documents/projects/albert/rlx/node_modules/@nestjs/swagger/dist/services/schema-object-factory.js:92:41)
at /Users/albert/Documents/projects/albert/rlx/node_modules/@nestjs/swagger/dist/services/schema-object-factory.js:33:36
at Array.map (<anonymous>)
at SchemaObjectFactory.createFromModel (/Users/albert/Documents/projects/albert/rlx/node_modules/@nestjs/swagger/dist/services/schema-object-factory.js:20:45)
at exploreApiParametersMetadata (/Users/albert/Documents/projects/albert/rlx/node_modules/@nestjs/swagger/dist/explorers/api-parameters.explorer.js:33:55)
(Use `node --trace-warnings ...` to show where the warning was created)
(node:22654) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:22654) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
register-common-user.dto.ts
export class RegisterCommonUserDto {
@decorate(ApiProperty())
@decorate(IsNotEmpty())
@decorate(IsString())
firstName: string;
// @decorate(ApiProperty())
@decorate(IsNotEmpty())
@decorate(IsString())
lastName: string;
// @decorate(ApiProperty({enum: EUserRoleName}))
@decorate(IsNotEmpty())
@decorate(IsEnum(EUserRoleName))
roleName: EUserRoleName;
// @decorate(ApiProperty())
@decorate(IsNotEmpty())
@decorate(IsPhoneNumber())
phoneNumber: string;
// @decorate(ApiProperty())
@decorate(IsNotEmpty())
@decorate(IsEmail())
email: string;
}
register-user.dto.ts
export class RegisterUserDto extends Mixin(
RegisterFighterDto,
RegisterCommonUserDto,
RegisterLocationProviderDto,
) {}
The method:
@Post('register')
public async registerUser(@Body() registerUserDto: RegisterUserDto): Promise<any> {
// code
}
What might be causing the problem? It has surely something to do with the @ApiProperty
decorator being wrapped in decorate
, cos when I comment out that line, the error disappears. But in that case decorators don't get inherited and that's the whole point of using the ts-mixer lib.
EDIT:
Any ideas?
EDIT:
Are these libs incompatible or what?