Its been an interesting an busy week. I am working on a Rails project and included Grape
to implement the API.
The API has 2 sections
- No auth required (no headers)
- Auth required
I setup the app with and all is working...
- Grape
- Grape Swagger
- Grape Swagger Rails
For stating that a header is required I use some thing like this...
class ProfilesApi < Grape::API
resource :profiles do
desc 'List all profiles' do
headers Authorization: {
description: 'Validates identity through JWT provided in auth/login',
required: true
}
end
get do
present User.all, with: Presenters::ProfilePresenter
end
end
end
Now the problem is that I this description in a lot of similar mountable API classes.
Is there a way that can kind of make this common (kind of inherited) so that I don't need to define it wit every Grape method.
desc 'List all profiles' do
headers Authorization: {
description: 'Validates identity through JWT provided in auth/login',
required: true
}
end
Thanks in advance and hope you guys enjoy the weekend.