rspec-api-文档 gem 显示“[二进制数据]”而不是响应正文

rspec-api-documentation gem shows `[binary data]` instead of the response body

在降价模式 (config.format = [:markdown]) 中使用 rspec-api-documentation gem 时,我注意到生成的文档缺少响应正文。

是否有永久修复方法?

此问题已记录在 this issue 中,目前似乎没有永久修复方法。解决方法已发布在问题评论中,它涉及猴子修补:

module RspecApiDocumentation
  class RackTestClient < ClientBase
    def response_body
      last_response.body.encode("utf-8")
    end
  end
end

在生成文档之前在初始化程序 (rspec_api_docs.rb) 中添加代码似乎可以解决问题。