Skip to content

Commit 5a6fb33

Browse files
authored
Merge pull request #343 from ahx/2.6.0
2.6.0
2 parents d5e6f4c + d00aae5 commit 5a6fb33

File tree

6 files changed

+31
-29
lines changed

6 files changed

+31
-29
lines changed

CHANGELOG.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,10 @@
22

33
## Unreleased
44

5+
## 2.6.0
6+
57
- Middlewares now accept the OAD as a first positional argument instead of `:spec` inside the options hash.
6-
- No longer merge parameter schemas per of the same location (for example "query") in order to fix https://github.com/ahx/openapi_first/issues/320
8+
- No longer merge parameter schemas of the same location (for example "query") in order to fix [#320](https://github.com/ahx/openapi_first/issues/320). Use `OpenapiFirst::Schema::Hash` to validate multiple parameters schemas and return a single error object.
79
- `OpenapiFirst::Test::Methods[MyApplication]` returns a Module which adds an `app` method to be used by rack-test alonside the `assert_api_conform` method.
810
- Make default coverage report less verbose
911
The default formatter (TerminalFormatter) no longer prints all un-requested requests by default. You can set `test.coverage_formatter_options = { focused: false }` to get back the old behavior

Gemfile.lock

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
PATH
22
remote: .
33
specs:
4-
openapi_first (2.5.1)
4+
openapi_first (2.6.0)
55
hana (~> 1.3)
66
json_schemer (>= 2.1, < 3.0)
77
openapi_parameters (>= 0.3.3, < 2.0)
@@ -71,7 +71,7 @@ GEM
7171
racc (~> 1.4)
7272
nokogiri (1.18.6-x86_64-linux-gnu)
7373
racc (~> 1.4)
74-
openapi_parameters (0.4.0)
74+
openapi_parameters (0.5.0)
7575
rack (>= 2.2)
7676
parallel (1.26.3)
7777
parser (3.3.7.2)

benchmarks/Gemfile.lock

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
PATH
22
remote: ..
33
specs:
4-
openapi_first (2.5.1)
4+
openapi_first (2.6.0)
55
hana (~> 1.3)
66
json_schemer (>= 2.1, < 3.0)
77
openapi_parameters (>= 0.3.3, < 2.0)
@@ -15,7 +15,7 @@ GEM
1515
benchmark-memory (0.2.0)
1616
memory_profiler (~> 1)
1717
bigdecimal (3.1.9)
18-
committee (5.5.1)
18+
committee (5.5.2)
1919
json_schema (~> 0.14, >= 0.14.3)
2020
openapi_parser (~> 2.0)
2121
rack (>= 1.5, < 3.2)
@@ -26,12 +26,12 @@ GEM
2626
hana (~> 1.3)
2727
regexp_parser (~> 2.0)
2828
simpleidn (~> 0.2)
29-
logger (1.6.6)
29+
logger (1.7.0)
3030
memory_profiler (1.1.0)
3131
mustermann (3.0.3)
3232
ruby2_keywords (~> 0.0.1)
3333
nio4r (2.7.4)
34-
openapi_parameters (0.4.0)
34+
openapi_parameters (0.5.0)
3535
rack (>= 2.2)
3636
openapi_parser (2.2.4)
3737
optparse (0.6.0)
@@ -59,7 +59,7 @@ GEM
5959
rack-session (>= 2.0.0, < 3)
6060
tilt (~> 2.0)
6161
tilt (2.6.0)
62-
vernier (1.6.0)
62+
vernier (1.7.0)
6363
webrick (1.9.1)
6464

6565
PLATFORMS

lib/openapi_first/version.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# frozen_string_literal: true
22

33
module OpenapiFirst
4-
VERSION = '2.5.1'
4+
VERSION = '2.6.0'
55
end

spec/middlewares/request_validation_spec.rb

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
let(:app) do
1212
Rack::Builder.app do
1313
use Rack::Lint
14-
use(OpenapiFirst::Middlewares::RequestValidation, spec: File.expand_path('../data/petstore.yaml', __dir__))
14+
use(OpenapiFirst::Middlewares::RequestValidation, File.expand_path('../data/petstore.yaml', __dir__))
1515
use Rack::Lint
1616
run lambda { |_env|
1717
Rack::Response.new('hello', 200).finish
@@ -32,10 +32,10 @@
3232
end
3333
end
3434

35-
context 'when OAD is passed as first argument' do
35+
context 'when OAD is passed as spec: argument' do
3636
let(:app) do
3737
Rack::Builder.app do
38-
use(OpenapiFirst::Middlewares::RequestValidation, File.expand_path('../data/petstore-expanded.yaml', __dir__))
38+
use(OpenapiFirst::Middlewares::RequestValidation, spec: File.expand_path('../data/petstore-expanded.yaml', __dir__))
3939
run ->(_) {}
4040
end
4141
end
@@ -60,7 +60,7 @@
6060
let(:app) do
6161
Rack::Builder.app do
6262
use(OpenapiFirst::Middlewares::RequestValidation,
63-
spec: File.expand_path('../data/petstore-expanded.yaml', __dir__))
63+
File.expand_path('../data/petstore-expanded.yaml', __dir__))
6464
run ->(_) {}
6565
end
6666
end
@@ -92,8 +92,8 @@
9292
context 'with error_response: :default' do
9393
let(:app) do
9494
Rack::Builder.app do
95-
use OpenapiFirst::Middlewares::RequestValidation, spec: './spec/data/request-body-validation.yaml',
96-
error_response: :default
95+
use OpenapiFirst::Middlewares::RequestValidation, './spec/data/request-body-validation.yaml',
96+
error_response: :default
9797
run ->(_) {}
9898
end
9999
end
@@ -115,8 +115,8 @@ def content_type = 'text/plain'
115115
def status = 409
116116
end
117117
Rack::Builder.app do
118-
use OpenapiFirst::Middlewares::RequestValidation, spec: './spec/data/request-body-validation.yaml',
119-
error_response: custom_class
118+
use OpenapiFirst::Middlewares::RequestValidation, './spec/data/request-body-validation.yaml',
119+
error_response: custom_class
120120
run ->(_) {}
121121
end
122122
end
@@ -133,7 +133,7 @@ def status = 409
133133
let(:app) do
134134
Rack::Builder.app do
135135
use(OpenapiFirst::Middlewares::RequestValidation,
136-
spec: File.expand_path('../data/discriminator-refs.yaml', __dir__))
136+
File.expand_path('../data/discriminator-refs.yaml', __dir__))
137137
run lambda { |_env|
138138
Rack::Response.new('hello', 200).finish
139139
}
@@ -178,8 +178,8 @@ def status = 409
178178
end
179179
end
180180
Rack::Builder.app do
181-
use OpenapiFirst::Middlewares::RequestValidation, spec:,
182-
error_response: false
181+
use OpenapiFirst::Middlewares::RequestValidation, spec,
182+
error_response: false
183183
run lambda { |_env|
184184
Rack::Response.new('hello', 200).finish
185185
}
@@ -197,8 +197,8 @@ def status = 409
197197
context 'with error_response: nil' do
198198
let(:app) do
199199
Rack::Builder.app do
200-
use OpenapiFirst::Middlewares::RequestValidation, spec: './spec/data/request-body-validation.yaml',
201-
error_response: nil
200+
use OpenapiFirst::Middlewares::RequestValidation, './spec/data/request-body-validation.yaml',
201+
error_response: nil
202202
run ->(_) {}
203203
end
204204
end
@@ -214,7 +214,7 @@ def status = 409
214214
describe '#app' do
215215
it 'returns the next app in the stack' do
216216
app = double
217-
expect(described_class.new(app, spec: File.expand_path('../data/petstore.yaml', __dir__)).app).to eq app
217+
expect(described_class.new(app, File.expand_path('../data/petstore.yaml', __dir__)).app).to eq app
218218
end
219219
end
220220
end

spec/middlewares/response_validation_spec.rb

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,15 +25,15 @@
2525
end
2626
let(:response) { Rack::Response.new(response_body, status, headers) }
2727

28-
context 'with path to OAD as first argument' do
28+
context 'with path to OAD as spec: argument' do
2929
let(:response_body) { '2' }
3030

3131
let(:app) do
3232
res = response
3333
definition = spec
3434
Rack::Builder.app do
3535
use Rack::Lint
36-
use OpenapiFirst::Middlewares::ResponseValidation, definition
36+
use OpenapiFirst::Middlewares::ResponseValidation, spec: definition
3737
run ->(_env) { res.finish }
3838
end
3939
end
@@ -93,7 +93,7 @@
9393
res = response
9494
definition = spec
9595
Rack::Builder.app do
96-
use OpenapiFirst::Middlewares::ResponseValidation, spec: definition
96+
use OpenapiFirst::Middlewares::ResponseValidation, definition
9797
run ->(_env) { res.finish }
9898
end
9999
end
@@ -255,7 +255,7 @@
255255
context 'when response is invalid' do
256256
let(:app) do
257257
Rack::Builder.new.tap do |builder|
258-
builder.use(described_class, spec: './spec/data/petstore.yaml')
258+
builder.use(described_class, './spec/data/petstore.yaml')
259259
builder.run lambda { |_env|
260260
Rack::Response.new('{"foo": "bar"}', 200, { 'Content-Type' => 'application/json' }).finish
261261
}
@@ -271,7 +271,7 @@
271271
context 'with raise_error: false' do
272272
let(:app) do
273273
Rack::Builder.new.tap do |builder|
274-
builder.use(described_class, spec: './spec/data/petstore.yaml', raise_error: false)
274+
builder.use(described_class, './spec/data/petstore.yaml', raise_error: false)
275275
builder.run lambda { |_env|
276276
Rack::Response.new('{"foo": "bar"}', 200, { 'Content-Type' => 'application/json' }).finish
277277
}
@@ -289,7 +289,7 @@
289289
context 'when response is not valid JSON' do
290290
let(:app) do
291291
Rack::Builder.new.tap do |builder|
292-
builder.use(described_class, spec: './spec/data/petstore.yaml')
292+
builder.use(described_class, './spec/data/petstore.yaml')
293293
builder.run lambda { |_env|
294294
Rack::Response.new('{boofar}', 200, { 'Content-Type' => 'application/json' }).finish
295295
}

0 commit comments

Comments
 (0)