tim-vandecasteele/grape-swagger — pull request #54 by calebwoods (2013-07-26 19:27:00+00:00)
Title: Grape Entity Support

Inspired by the on pull request #30 by @TLmaK0, this pull request adds support for generating swagger responseClass and models per the [Swagger API Declaration](https://github.com/wordnik/swagger-core/wiki/API-Declaration) based on Grape Entities.

Usage would look like the following

```ruby
module API

module Entities
class Status < Grape::Entity
expose :text, :documentation => { :type => "string", :desc => "Status update text." }
end
end

class Statuses < Grape::API
version 'v1'

desc 'Statuses index', {
:entity => API::Entities::Status
}
get '/statuses' do
statuses = Status.all
type = current_user.admin? ? :full : :default
present statuses, with: API::Entities::Status, :type => type
end
end
end
```

And would generate the following swagger json

```json
{
"apiVersion": "0.2",
"swaggerVersion": "1.1",
"basePath": [..],
"resourcePath": "/statuses.{format}"

...

"apis" : [...]
"models": {
"Status": {
"id": "Status",
"name" : "Status",
"properties": {
"text": {
"type": "string",
"desc": "Status update text."
}
}
}
}
```