这是一个忙碌的一周。我正在开发一个Rails项目,并且包含Grape
以实现API。葡萄API(swagger doc)'desc'的全局配置
API有两个部分
- 无需身份验证(无头)
- 验证需要
我安装的应用程序与所有工作...
- 葡萄
- 葡萄Sw 012
- 葡萄扬鞭的Rails
对于声称头需要我用一些像这样的事情......
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
现在的问题是,我这描述了很多类似的安装API类的。
有没有一种方法可以使这种常见的(种类继承),所以我不需要用每个葡萄方法定义它。
desc 'List all profiles' do
headers Authorization: {
description: 'Validates identity through JWT provided in auth/login',
required: true
}
end
在此先感谢,并希望你们享受周末。