Search code examples
swaggerswagger-ui

How to define empty array in swagger


I know how to make array of string data in swagger like this:

"photoUrls" : {
    "type":"array",
    "items":{
         "type":"string"
    }
}

It will show output like this:

"photoUrls":[
    "string"
]

How to make output like this?:

"photoUrls":[]

Solution

  • 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.