我创建了一个NestJs项目,并添加了@nestjs/swagger作为插件(启用了introspectComments
)
现在Swagger工作得很好,我可以看到文档像预期的那样工作,除了嵌套对象和对象数组
// users/dto/create-user.dto.ts
import { CurrencyCode } from './currencies';
export class CreateCheckoutDto {
//This works well and I can see the example correctly in Swagger's docs
/**
* @example john
*/
name: string;
// but this object appears empty as '{}'
// without its props
items: Item[];
// This causes an error
// A circular dependency has been detected (property key: "items2"). Please, make sure that each side of a bidirectional relationships are using lazy resolvers ("type: () => ClassType").
}
items2: [{ test: string; }]
export interface Item {
/**
* @example anything
*/
test: string
}
字符串
1条答案
按热度按时间ar7v8xwq1#
解决方案这个问题是通过从TS接口切换到js类来解决的,所以,
字符串
使用
型