【发布时间】:2021-03-04 10:42:48
【问题描述】:
我有一个类,其中一个属性可以是字符串或字符串数组,不知道我应该如何在 swagger 中定义它
@ApiProperty({
description: `to email address`,
type: ???, <- what should be here?
required: true,
})
to: string | Array<string>;
更新
正如@Youba 建议的答案,我试过了
@ApiProperty({
description: `to email address(es)`,
additionalProperties: {
oneOf: [
{ type: 'string' },
{ type: 'Array<string>' },
],
},
required: true,
})
和
@ApiProperty({
description: `to email address(es)`,
additionalProperties: {
oneOf: [
{ type: 'string' },
{ type: 'string[]' },
],
},
required: true,
})
和
@ApiProperty({
description: `to email address(es)`,
additionalProperties: {
oneOf: [
{ type: 'string' },
{ type: '[string]' },
],
},
required: true,
})
但结果如下图,不正确
【问题讨论】:
标签: typescript swagger nestjs openapi