Skip to content

Commit aa7c520

Browse files
committed
Update openapi_paramters to make parsing array query parameters more consistent
Now parsing an empty array query parameter like `ids=&` or `ids&` both result in an empty array value (`[]`) instead of `nil` or `""`.
1 parent 2ca05d6 commit aa7c520

5 files changed

Lines changed: 38 additions & 14 deletions

File tree

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
## Unreleased
44

5+
- Update openapi_paramters to make parsing array query parameters more consistent.
6+
Now parsing an empty array query parameter like `ids=&` or `ids&` both result in an empty array value (`[]`) instead of `nil` or `""`.
57
- Fix Test::Coverage.result returning < 100 even if plan is fully covered
68

79
## 2.9.3

Gemfile.lock

Lines changed: 25 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ PATH
44
openapi_first (2.9.3)
55
hana (~> 1.3)
66
json_schemer (>= 2.1, < 3.0)
7-
openapi_parameters (>= 0.5.1, < 2.0)
7+
openapi_parameters (>= 0.6.1, < 2.0)
88
rack (>= 2.2, < 4.0)
99

1010
GEM
@@ -137,11 +137,23 @@ GEM
137137
net-smtp (0.5.1)
138138
net-protocol
139139
nio4r (2.7.4)
140+
nokogiri (1.18.8-aarch64-linux-gnu)
141+
racc (~> 1.4)
142+
nokogiri (1.18.8-aarch64-linux-musl)
143+
racc (~> 1.4)
144+
nokogiri (1.18.8-arm-linux-gnu)
145+
racc (~> 1.4)
146+
nokogiri (1.18.8-arm-linux-musl)
147+
racc (~> 1.4)
140148
nokogiri (1.18.8-arm64-darwin)
141149
racc (~> 1.4)
150+
nokogiri (1.18.8-x86_64-darwin)
151+
racc (~> 1.4)
142152
nokogiri (1.18.8-x86_64-linux-gnu)
143153
racc (~> 1.4)
144-
openapi_parameters (0.5.1)
154+
nokogiri (1.18.8-x86_64-linux-musl)
155+
racc (~> 1.4)
156+
openapi_parameters (0.6.1)
145157
rack (>= 2.2)
146158
parallel (1.27.0)
147159
parser (3.3.8.0)
@@ -208,7 +220,7 @@ GEM
208220
rspec-core (~> 3.13.0)
209221
rspec-expectations (~> 3.13.0)
210222
rspec-mocks (~> 3.13.0)
211-
rspec-core (3.13.4)
223+
rspec-core (3.13.5)
212224
rspec-support (~> 3.13.0)
213225
rspec-expectations (3.13.5)
214226
diff-lcs (>= 1.2.0, < 2.0)
@@ -217,7 +229,7 @@ GEM
217229
diff-lcs (>= 1.2.0, < 2.0)
218230
rspec-support (~> 3.13.0)
219231
rspec-support (3.13.4)
220-
rubocop (1.76.2)
232+
rubocop (1.77.0)
221233
json (~> 2.3)
222234
language_server-protocol (~> 3.17.0.2)
223235
lint_roller (~> 1.1.0)
@@ -270,10 +282,14 @@ GEM
270282
zeitwerk (2.7.3)
271283

272284
PLATFORMS
273-
arm64-darwin-21
274-
arm64-darwin-22
275-
arm64-darwin-23
276-
x86_64-linux
285+
aarch64-linux-gnu
286+
aarch64-linux-musl
287+
arm-linux-gnu
288+
arm-linux-musl
289+
arm64-darwin
290+
x86_64-darwin
291+
x86_64-linux-gnu
292+
x86_64-linux-musl
277293

278294
DEPENDENCIES
279295
actionpack
@@ -292,4 +308,4 @@ DEPENDENCIES
292308
sinatra
293309

294310
BUNDLED WITH
295-
2.3.10
311+
2.6.9

benchmarks/Gemfile.lock

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ PATH
44
openapi_first (2.9.3)
55
hana (~> 1.3)
66
json_schemer (>= 2.1, < 3.0)
7-
openapi_parameters (>= 0.5.1, < 2.0)
7+
openapi_parameters (>= 0.6.1, < 2.0)
88
rack (>= 2.2, < 4.0)
99

1010
GEM
@@ -32,7 +32,7 @@ GEM
3232
mustermann (3.0.3)
3333
ruby2_keywords (~> 0.0.1)
3434
nio4r (2.7.4)
35-
openapi_parameters (0.5.1)
35+
openapi_parameters (0.6.1)
3636
rack (>= 2.2)
3737
openapi_parser (2.2.6)
3838
optparse (0.6.0)

openapi_first.gemspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,6 @@ Gem::Specification.new do |spec|
2525

2626
spec.add_dependency 'hana', '~> 1.3'
2727
spec.add_dependency 'json_schemer', '>= 2.1', '< 3.0'
28-
spec.add_dependency 'openapi_parameters', '>= 0.5.1', '< 2.0'
28+
spec.add_dependency 'openapi_parameters', '>= 0.6.1', '< 2.0'
2929
spec.add_dependency 'rack', '>= 2.2', '< 4.0'
3030
end

spec/middlewares/request_validation/query_parameter_validation_spec.rb

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -236,9 +236,15 @@
236236
expect(last_response.status).to eq 400
237237
end
238238

239-
it 'returns 400 if non-required array parameter is empty' do
239+
it 'passes if non-required array parameter is empty' do
240240
get '/search?term=Oscar&filter[id]=1&filter[tag]=&filter[other]=things'
241-
expect(last_response.status).to eq 400
241+
expect(last_response.status).to eq 200
242+
expect(last_request.env[OpenapiFirst::REQUEST].parsed_query).to eq(
243+
{ 'term' => 'Oscar',
244+
'filter[tag]' => [],
245+
'filter[id]' => 1,
246+
'filter[other]' => 'things' }
247+
)
242248
end
243249

244250
it 'passes if query parameters are valid' do

0 commit comments

Comments
 (0)