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

702 Views Asked by At

While using the rspec-api-documentation gem in markdown mode (config.format = [:markdown]) I noticed that the documentation generated is lacking the response body.

Is there a permanent fix for this?

1

There are 1 best solutions below

0
On BEST ANSWER

The problem is documented in this issue and there does not seem to be a permanent fix at the moment. A workaround has been posted in the issues comment and it involves monkey-patching:

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

Adding the code in the initializer (rspec_api_docs.rb) before generating the documentation seems to solve the issue.