lib/grape-dsl/doc.rb in grape-dsl-2.2.1 vs lib/grape-dsl/doc.rb in grape-dsl-2.3.0

- old
+ new

@@ -81,41 +81,43 @@ content_type= "TXT" end end - content_type ||= "TXT" - case content_type.to_s.downcase + content_type ||= 'TXT' + content_type = content_type.keys if content_type.class <= ::Hash - when "json" - begin + [*content_type].each do |one_content_type| - tmp_array.push [wrapper_begin,content_type.to_s,wrapper_end].join + case one_content_type.to_s.downcase - require "json" + when 'json' + begin - formatted_string= params.to_json + tmp_array.push [wrapper_begin,one_content_type.to_s,wrapper_end].join - { - "{" => "{\n", - "}" => "\n}", - "," => ",\n" - }.each do |from,to| - formatted_string.gsub!(from,to) - end + require 'json' - formatted_string.gsub!(/^"/," \"") + formatted_string= params.to_json - tmp_array.push formatted_string - tmp_array.push wrapper_close - end + { + '{' => "{\n", + '}' => "\n}", + ',' => ",\n" + }.each do |from,to| + formatted_string.gsub!(from,to) + end - when "txt" - begin - tmp_array.push(params.inspect) - end + formatted_string.gsub!(/^"/," \"") + tmp_array.push formatted_string + tmp_array.push wrapper_close + end + when "txt" + tmp_array.push(params.inspect) + + end end return tmp_array \ No newline at end of file