Skip to content

Commit d779806

Browse files
committed
mult form parameter support
1 parent 823f513 commit d779806

File tree

3 files changed

+13
-4
lines changed

3 files changed

+13
-4
lines changed

.generator/src/generator/templates/api_client.j2

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,8 @@ module {{ module_name }}
183183
:http_proxyaddr => @config.http_proxyaddr,
184184
:http_proxyport => @config.http_proxyport,
185185
:http_proxyuser => @config.http_proxyuser,
186-
:http_proxypass => @config.http_proxypass
186+
:http_proxypass => @config.http_proxypass,
187+
:query_string_normalizer => HTTParty::Request::NON_RAILS_QUERY_STRING_NORMALIZER
187188
}
188189

189190
req_opts[:pem] = File.read(@config.cert_file) if @config.cert_file

features/step_definitions/request.rb

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
require_relative '../scenarios_model_mapping'
77

88
SLEEP_AFTER_REQUEST = ENV.has_key?("SLEEP_AFTER_REQUEST") ? ENV["SLEEP_AFTER_REQUEST"].to_i : 0
9+
WebMock::Config.instance.query_values_notation = :flat_array
910

1011
module APIWorld
1112
def api
@@ -100,7 +101,7 @@ def relative_time(iso)
100101
return ret.rfc3339(3) if iso
101102
return ret.to_i
102103
end
103-
return nil
104+
nil
104105
}
105106
end
106107

@@ -221,7 +222,7 @@ def build_given(api_version, operation)
221222
def model_builder(param, obj)
222223
model = ScenariosModelMappings["v#{@api_version}.#{@operation_id}"][param]
223224
if model == 'File'
224-
return File.open(File.join(__dir__, "..", "v" + @api_version, obj))
225+
return File.open(File.join(__dir__, "..", "v" + @api_version, obj))
225226
end
226227
@api_client.convert_to_type(obj, model, "V#{@api_version}")
227228
end

features/support/env.rb

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,16 @@ def use_real_time?
5151
c.register_request_matcher :safe_headers do |r1, r2|
5252
r1.headers.slice(*filtered_headers) == r2.headers.slice(*filtered_headers)
5353
end
54+
c.register_request_matcher :ignore_query_param_ordering do |r1, r2|
55+
uri1 = URI(r1.uri)
56+
uri2 = URI(r2.uri)
57+
query1 = CGI.parse(uri1.query || '').transform_values(&:sort)
58+
query2 = CGI.parse(uri2.query || '').transform_values(&:sort)
59+
query1 == query2
60+
end
5461
c.default_cassette_options = {
5562
:record_on_error => false,
56-
:match_requests_on => [:method, :host, :safe_path, :query, :body_as_json, :safe_headers],
63+
:match_requests_on => [:method, :host, :safe_path, :ignore_query_param_ordering, :body_as_json, :safe_headers],
5764
}
5865
c.allow_http_connections_when_no_cassette = true
5966
RecordMode.send(ENV["RECORD"] || "false", c)

0 commit comments

Comments
 (0)