Rez*_*eza 11 swagger typescript openapi nestjs
我有一个类,其中一个属性可以是字符串或字符串数组,不知道如何在 swagger 中定义它
@ApiProperty({
description: `to email address`,
type: ???, <- what should be here?
required: true,
})
to: string | Array<string>;
Run Code Online (Sandbox Code Playgroud)
我试过
@ApiProperty({
description: `to email address(es)`,
additionalProperties: {
oneOf: [
{ type: 'string' },
{ type: 'Array<string>' },
],
},
required: true,
})
Run Code Online (Sandbox Code Playgroud)
和
@ApiProperty({
description: `to email address(es)`,
additionalProperties: {
oneOf: [
{ type: 'string' },
{ type: 'string[]' },
],
},
required: true,
})
Run Code Online (Sandbox Code Playgroud)
和
@ApiProperty({
description: `to email address(es)`,
additionalProperties: {
oneOf: [
{ type: 'string' },
{ type: '[string]' },
],
},
required: true,
})
Run Code Online (Sandbox Code Playgroud)
但结果如下图所示,这是不正确的
Cha*_*ran 19
请尝试
@ApiProperty({
oneOf: [
{ type: 'string' },
{
type: 'array',
items: {
type: 'string'
}
}
]
})
Run Code Online (Sandbox Code Playgroud)
Array<TItem>
可以在 OpenAPI 中表示为{type: 'array', items: { type: TItem } }
归档时间: |
|
查看次数: |
15914 次 |
最近记录: |