#Using the @ApiProperty decorator on a property with a null type causes a circular dependency error

6 messages · Page 1 of 1 (latest)

empty adder
#

While using the response object interface, I set up a specific API to only return a null value for that property, and while documenting it, I ran into a problem: Circular dependency error when using @ApiProperty({type: null}).

export class ModifyPasswordRes implements Res<null> {
  @ApiProperty({ type: null }) // Error occurs even without 'type: null'
  data: null;

  @ApiProperty()
  statusCode: number;

  @ApiProperty()
  statusMsg: string;
}

/**
  * Error: A circular dependency has been detected (property key: "data"). Please, make sure that each side of a bidirectional relationships are using lazy resolvers ("type: () => ClassType").
*/

I'd like to indicate in the Swagger documentation that the response property data for this API unconditionally returns null, is there any way to do that?

heavy dust
#

Oh, hmm, I can imagine why this would be happening, but I also see the possible use case for it. This would be a tricky one to represent correctly. Out of curiosity, can you to type: 'null' or will that not work?

empty adder
#

It doesn't work with or without { type: null }, I get the same circular dependency error.

heavy dust
#

Right, but type: 'null', as in the string 'null' instead of the type. Does it work then? It might not, but I just want to check

empty adder
#

Oh, that's right, it works.
But it's only really "working".
If you actually connect to localhost, you'll get the following result in the Example Value:

{
  "data": "Unknown Type: null",
  "statusCode": 0,
  "statusMsg": "string"
}

In Schema, we got the following response

ModifyPasswordRes{
data*       null
            nullable: true
statusCode* number
statusMsg*  string
}

I want "null" to be displayed correctly in the example value as well.

empty adder
#

Nobody has answer?