Skip to content
This repository was archived by the owner on Nov 20, 2018. It is now read-only.

Commit af6a0b1

Browse files
committed
Now serializing empty lists for the query protocol.
Fixes #49
1 parent 13bddfc commit af6a0b1

File tree

2 files changed

+44
-0
lines changed

2 files changed

+44
-0
lines changed

lib/aws/query/builder.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,10 @@ def structure(param_list, shape, prefix, values)
3838
end
3939

4040
def list(param_list, shape, prefix, values)
41+
if values.empty?
42+
param_list.set(prefix, '')
43+
return
44+
end
4145
member_shape = shape.members
4246
if flat?(shape)
4347
if member_shape.serialized_name

spec/aws/query/builder_spec.rb

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,26 @@ def query_params(params = {})
132132
])
133133
end
134134

135+
it 'serializes empty lists' do
136+
rules['members'] = {
137+
'config' => {
138+
'type' => 'structure',
139+
'members' => {
140+
'items' => {
141+
'type' => 'flat_list',
142+
'members' => {
143+
'type' => 'string'
144+
}
145+
}
146+
}
147+
}
148+
}
149+
params = { config: { items: [] }}
150+
expect(query_params(params)).to eq([
151+
['config.items', ''],
152+
])
153+
end
154+
135155
end
136156

137157
describe 'non-flattened lists' do
@@ -192,6 +212,26 @@ def query_params(params = {})
192212
])
193213
end
194214

215+
it 'serializes empty lists' do
216+
rules['members'] = {
217+
'config' => {
218+
'type' => 'structure',
219+
'members' => {
220+
'items' => {
221+
'type' => 'list',
222+
'members' => {
223+
'type' => 'string'
224+
}
225+
}
226+
}
227+
}
228+
}
229+
params = { config: { items: [] }}
230+
expect(query_params(params)).to eq([
231+
['config.items', ''],
232+
])
233+
end
234+
195235
end
196236

197237
describe 'flattened maps' do

0 commit comments

Comments
 (0)