Swagger for Rails:如何描述请求的复杂参数?

时间:2014-07-07 09:59:43

标签: ruby-on-rails params swagger grape

当我使用招摇葡萄时,我可以形容复杂的参数:

PARAMS [:by_commentable] [:commentable_id] PARAMS [:by_commentable] [:commentable_type]

desc "Get a list of comments"
  params do
     group :by_commentable do
       requires :commentable_id, type: Integer, desc: "Filter by: Commentable object ID"
       requires :commentable_type, type: String, desc: "Filter by: Commentable object type"
     end
     paginatable_params.call Comment
    end
    get "", http_codes: standard_responses do
      apply_scopes(Comment.order_recent).page(params[:page]).per_page(params[:per_page])
    end
   end
  end

如何在Rails中做同样的事情?

谢谢!

1 个答案:

答案 0 :(得分:0)

我找到了解决方案,这是工作:

swagger_api :index do
  param :query, :by_text, :string, :optional, 'By Text'
  param :query, 'listing[id]', :integer, :optional, 'Id'
end

谢谢!