Skip to content

Rewind rack.input in Base before reading request body for Rack 3 support#73

Merged
cilim merged 1 commit into
masterfrom
fix/72-rack-3-additional-support
Jun 26, 2026
Merged

Rewind rack.input in Base before reading request body for Rack 3 support#73
cilim merged 1 commit into
masterfrom
fix/72-rack-3-additional-support

Conversation

@cilim

@cilim cilim commented Jun 23, 2026

Copy link
Copy Markdown
Member

Rack 3 support

Resolves: #72

Summary

Fixes missing JSON, plain text, and XML requestBody examples in generated docs, and a NoMethodError on bodyless requests, when running the dox formatter against request specs on Rails apps using Rack 3.

Problem

Rack 3 dropped the implicit rewind on Rack::Request#body. Dox::Formatters::Multipart was fixed in v3.0.1 (#71), but Json, Plain, and Xml still inherit from Formatters::Base, which reads the request body without rewinding first.

By the time the formatter runs, Rails has already consumed the body during request processing, so http_env.body.read returns "". For JSON requests this silently omits requestBody examples from the generated spec. For bodyless requests, Rack 3 returns nil instead of StringIO(""), which causes Formatters::Plain to raise NoMethodError on body.encoding.

Test plan

  • bundle exec rspec spec/formatters/
  • bundle exec rspec

@cilim
cilim merged commit 2a5572b into master Jun 26, 2026
6 checks passed
@cilim
cilim deleted the fix/72-rack-3-additional-support branch June 26, 2026 10:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Incomplete Rack 3 support in Base/Plain formatters (request bodies dropped + nil crash)

2 participants