2

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":"person1@example.com","password":"z5x6c7v8!@!"}}

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

{
    "user": {
        "email":"person1@example.com",
        "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'
cm1745
  • 120
  • 2
  • 12

1 Answers1

2

You can try this:

RspecApiDocumentation.configure do |config|
  config.request_body_formatter = proc do |params|
    JSON.pretty_generate(params)
  end
end
Roman Kiselenko
  • 43,210
  • 9
  • 91
  • 103