【问题标题】:Swagger for Rails: how to describe complex parameters of request?Swagger for Rails:如何描述请求的复杂参数?
【发布时间】:2014-07-07 09:59:42
【问题描述】:

当我将 swagger 用于葡萄时,我可以描述复杂的参数:

参数[:by_commentable][:commentable_id] 参数[: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 中做同样的事情?

谢谢!

【问题讨论】:

    标签: ruby-on-rails params swagger grape


    【解决方案1】:

    我找到了解决办法,可以了:

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

    谢谢!

    【讨论】:

      猜你喜欢
      • 2022-06-10
      • 2014-02-03
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-11-21
      • 1970-01-01
      • 2021-11-27
      • 2023-03-09
      相关资源
      最近更新 更多