rspec_api_documentation 4.0.0 → 4.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 9cff1f54aa57141a0f21909348c9cf326a75ea93
4
- data.tar.gz: 356b837bc052ff05738e2d95cbfec04e1c3a6cf5
3
+ metadata.gz: 3fdee8e89c27e8a561132407268a857e5b19aa8f
4
+ data.tar.gz: d56e732d91259b9ebb6dc61beacc44625257a1a9
5
5
  SHA512:
6
- metadata.gz: 80c655256dc7447ef2af3ee6abf54569ea05730216cae2ae1408ddaf1de4028b75979a759247c4a5615a86a9a9d47a723dc129af1b32832db68b5926d0597ee9
7
- data.tar.gz: 3feddb137db8775facd2c454304fe8e4793fc61add4c050ea27235bf62c2d6ee75f3359b4982186aa66773a84d0bdba6cb135b1c13fbac8148b015a6e3bb6bdf
6
+ metadata.gz: b60c664a190f76360dddd09be2c8645c98ad692374f28b2f6417afaa5548565d0ddcd346a45a1e9057f8750aa98db5f5957bca7a3ad7823c1e0cea009bf1ae33
7
+ data.tar.gz: 9f66c3c77dfe4e33999858f7d22a1a34438c33f8bee65838775f6b4c05163e299174e75be56281121ed0443b03125e0ef590cba95383318f00f6018c033b0e65
@@ -74,12 +74,7 @@ module RspecApiDocumentation
74
74
  end
75
75
 
76
76
  def query_hash
77
- strings = query_string.split("&")
78
- arrays = strings.map do |segment|
79
- k,v = segment.split("=")
80
- [k, v && CGI.unescape(v)]
81
- end
82
- Hash[arrays]
77
+ Rack::Utils.parse_nested_query(query_string)
83
78
  end
84
79
 
85
80
  def headers(method, path, params, request_headers)
@@ -79,6 +79,19 @@ module RspecApiDocumentation
79
79
  add_setting :request_headers_to_include, :default => nil
80
80
  add_setting :response_headers_to_include, :default => nil
81
81
 
82
+ # Change how the post body is formatted by default, you can still override by `raw_post`
83
+ # Can be :json, :xml, or a proc that will be passed the params
84
+ #
85
+ # RspecApiDocumentation.configure do |config|
86
+ # config.post_body_formatter = Proc.new do |params|
87
+ # # convert to whatever you want
88
+ # params.to_s
89
+ # end
90
+ # end
91
+ #
92
+ # See RspecApiDocumentation::DSL::Endpoint#do_request
93
+ add_setting :post_body_formatter, :default => Proc.new { |_| Proc.new { |params| params } }
94
+
82
95
  def client_method=(new_client_method)
83
96
  RspecApiDocumentation::DSL::Resource.module_eval <<-RUBY
84
97
  alias :#{new_client_method} #{client_method}
@@ -38,7 +38,19 @@ module RspecApiDocumentation::DSL
38
38
  if method == :get && !query_string.blank?
39
39
  path_or_query += "?#{query_string}"
40
40
  else
41
- params_or_body = respond_to?(:raw_post) ? raw_post : params
41
+ formatter = RspecApiDocumentation.configuration.post_body_formatter
42
+ case formatter
43
+ when :json
44
+ params_or_body = params.to_json
45
+ when :xml
46
+ params_or_body = params.to_xml
47
+ when Proc
48
+ params_or_body = formatter.call(params)
49
+ else
50
+ params_or_body = params
51
+ end
52
+
53
+ params_or_body = respond_to?(:raw_post) ? raw_post : params_or_body
42
54
  end
43
55
 
44
56
  rspec_api_documentation_client.send(method, path_or_query, params_or_body, headers)
@@ -1,5 +1,6 @@
1
1
  require 'active_support'
2
2
  require 'active_support/inflector'
3
+ require 'active_support/core_ext/hash/conversions'
3
4
  require 'cgi'
4
5
  require 'json'
5
6
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rspec_api_documentation
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.0.0
4
+ version: 4.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chris Cahoon
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2014-06-30 00:00:00.000000000 Z
13
+ date: 2014-08-04 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: rspec