Closed thornbird closed 8 years ago
It seems that you want to get responses that the root JSON is itself an array, you can try:
swagger_model :User do
property :id, :integer, :required, 'Id of the user'
property :email, :string, :required, 'email of the user'
end
swagger_api :index do
summary 'Returns the users'
response :ok
response :unauthorized
type "array[User]" #or 'type "array"; items "$ref" => "User"'
end
Thanks @zhengxu001 This trick or solution should be written in the ReadMe so that it won't cause more confusion.
Already find the trick, close issue.
Which version of swagger-docs provides support for the above syntax?
In swagger-docs, the response only takes a code, message and model. But model is with property and value, that means, it will present as a hash json. so there is no way for a response is an array json.
Let me find example. Previously in issue #112, jstoup111 expressed below how to represent response which is array of models.
The result would be like:
But how to express in the response includes an array of User, like below:
In OAI/OpenAPI-Specification, the array of model response could be like below:
but swagger-docs cannot generate such response. Any way?