How to define empty array in swagger
You don't. The idea is that
"photoUrls":[
"string"
]
shows your users that photoUrls
is an array of strings. Otherwise, they will have no way of knowing which datatype is used by the array.
You can specify an empty array []
as an example
for your array schema. This will override the default examples values generated by Swagger UI.
"photoUrls" : {
"type":"array",
"items":{
"type":"string"
},
"example": []
}
Ron's answer is more user-friendly for your users. Consider using some real-world example
values instead:
"photoUrls" : {
"type":"array",
"items":{
"type":"string",
"example": "http://example.com/images/pet.png"
},
}