我需要描述一个包含字符串数组的多部分查询。但我遇到了一个问题,在查询中,数组元素被组合成一个字符串,而不是单独的字符串项。我使用的是 OpenApi 3.0.3)
requestBody: {
content: {
'multipart/form-data': {
schema: {
type: 'object',
properties: {
email: {
type: 'string',
},
password: {
type: 'string',
},
confirmPassword: {
type: 'string',
},
fullName: {
type: 'string',
},
avatar: {
type: 'string',
format: 'binary',
},
'genreIds[]': {
type: 'array',
items: {
oneOf: {
type: 'string',
},
},
},
'languageIds[]': {
type: 'array',
items: {
type: 'string',
default: '',
},
},
},
},
},
},
},
我收到的:
genreIds: [ '1234,55466,2455' ]
我期望的:genreIds: [ '1234','55466','2455' ]
尝试为
style: 'form'
的参数添加 explode: true
和 type: 'array'
:
'genreIds[]': {
type: 'array',
items: {
oneOf: {
type: 'string',
},
},
style: 'form',
explode: true
}
有关更多详细信息,请阅读 OpenAPI 3.0.3 文档。