Using RSpec API Documentation Generator, can I pretty print the request body JSON?

455 Views Asked by At

I'm using the RSpec API Documentation Generator Gem for my rails app, and when I generate the docs, the request body (JSON format) is formatted like so:

{"user":{"email":"[email protected]","password":"z5x6c7v8!@!"}}

is there a way to pretty print it similar to the following?

{
    "user": {
        "email":"[email protected]",
        "password":"password"
    }
}

I can't seem to find any configuration options to do so. I am using both of the following headers:

header 'Content-Type', 'application/json'
header 'Accept', 'application/json'
1

There are 1 best solutions below

0
On BEST ANSWER

You can try this:

RspecApiDocumentation.configure do |config|
  config.request_body_formatter = proc do |params|
    JSON.pretty_generate(params)
  end
end