【发布时间】:2018-07-12 12:38:16
【问题描述】:
我正在使用 rspec api 文档、apime 和 oauth2 协议来为我们的 api 构建验收测试。一切都很好,除了请求正文如下所示:
我从上面生成的文档中注意到的:
Content-Type: application/x-www-form-urlencoded
post "/api/v1/ticket_carts" do
header "Content-Type", "application/json"
我试图检查服务器上的参数
def create
render json: params
# options = set_ticket_cart_protected_params(filter_params)
# adapter = Adapter::TicketCart.new(options)
# @handler = adapter.handler
# @handler.call
# render json: @handler.order, serializer: adapter.serializer_class
end
响应看起来像这样:
据我所见,服务器仍然以表单编码格式从客户端获取参数。
我的结论是,rspec api 文档没有将 content-type 作为 application/json 发送到服务器。
我做错了什么或者需要采取哪些其他步骤才能使 rspec api 文档发送正确的内容类型 (application/json)?
【问题讨论】:
标签: ruby-on-rails rspec-api-documentation apitome