Skip to content

Documentation no longer include JSON response body when using with Rack >= 2.1.0Β #456

Open
@sikachu

Description

@sikachu

Hello,

This issue is pretty much for reporting the incompatibility to the gem author, and hopefully it will help anyone who runs into this problem to understand what's going on.

Basically, after we upgrade our dependencies to use Rack 2.1.1, we noticed that our generated documentation no longer show JSON response but instead showing [binary data] instead.

Digging in further, we found out that in rack/rack@8c62821, especially this change, MockResponse#body now creates a buffer and use << to join the content together. However, on line 195, the author uses String.new without specifying the encoding, resulting in Ruby creating a new String with ASCII-8BIT encoding by default.

As it turns out, rspec_api_documentation relies on string encoding to determine if it should include the response body in the documentation or not:

if response_body.encoding == Encoding::ASCII_8BIT
"[binary data]"
else
formatter = RspecApiDocumentation.configuration.response_body_formatter
return formatter.call(response_content_type, response_body)
end

Hence, the change in Rack broke this conditional.

I've reported this issue to Rack in rack/rack#1486, and hopefully we can solve this soon.

The solution right now for us is to lock Rack to ~> 2.0.8 for now.

Thank you very much.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions