Ruby on rails 使用rspecapi文档生成器,我可以漂亮地打印请求体JSON吗?
我正在为我的rails应用程序使用,当我生成文档时,请求正文(JSON格式)的格式如下:Ruby on rails 使用rspecapi文档生成器,我可以漂亮地打印请求体JSON吗?,ruby-on-rails,rspec-api-documentation,Ruby On Rails,Rspec Api Documentation,我正在为我的rails应用程序使用,当我生成文档时,请求正文(JSON格式)的格式如下: {"user":{"email":"person1@example.com","password":"z5x6c7v8!@!"}} 有没有一种方法可以像下面这样漂亮地打印出来 { "user": { "email":"person1@example.com", "password":"password" } } 我似乎找不到任何这样做的配置选项。我正在使用
{"user":{"email":"person1@example.com","password":"z5x6c7v8!@!"}}
有没有一种方法可以像下面这样漂亮地打印出来
{
"user": {
"email":"person1@example.com",
"password":"password"
}
}
我似乎找不到任何这样做的配置选项。我正在使用以下两个标题:
header 'Content-Type', 'application/json'
header 'Accept', 'application/json'
您可以尝试以下方法:
RspecApiDocumentation.configure do |config|
config.request_body_formatter = proc do |params|
JSON.pretty_generate(params)
end
end