Reputation: 403
I could not find any examples of this. Maybe because of the lack of my Swagger knowledge or maybe there are no similiar examples.
Is possible to write a swagger definition where an exposed type is a multidimentional array?
Upvotes: 2
Views: 1584
Reputation: 31760
Since swagger uses Json Schema to model the types being exposed over your API, you really need to know how to model a multidimensional (Nd) array in Json Schema.
The answer is: there is no built in support for Nd arrays in Json Schema.
However, json schema does support arrays, and there's nothing preventing the items in an array from being arrays themselves. So you can define Nd arrays by just using an arrays of arrays.
"2dArrayOfInt": {
"type": "array",
"items": {
"type": "array",
"items": {
"type": "integer" // This will be a 2d array of numbers
...
}
}
}
Not nice, but then neither are Nd arrays.
Upvotes: 3