committee 4.99.0.beta1 → 5.0.0.beta1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (33) hide show
  1. checksums.yaml +4 -4
  2. data/lib/committee/drivers/open_api_2/driver.rb +1 -1
  3. data/lib/committee/drivers/open_api_2/parameter_schema_builder.rb +1 -1
  4. data/lib/committee/drivers.rb +21 -9
  5. data/lib/committee/middleware/base.rb +5 -4
  6. data/lib/committee/middleware/request_validation.rb +1 -8
  7. data/lib/committee/middleware/response_validation.rb +13 -14
  8. data/lib/committee/request_unpacker.rb +1 -1
  9. data/lib/committee/schema_validator/hyper_schema/response_validator.rb +1 -1
  10. data/lib/committee/schema_validator/open_api_3/operation_wrapper.rb +32 -33
  11. data/lib/committee/schema_validator/open_api_3/request_validator.rb +2 -2
  12. data/lib/committee/schema_validator/open_api_3.rb +23 -18
  13. data/lib/committee/schema_validator/option.rb +3 -18
  14. data/lib/committee/test/methods.rb +2 -7
  15. data/lib/committee/version.rb +5 -0
  16. data/lib/committee.rb +9 -2
  17. data/test/committee_test.rb +28 -2
  18. data/test/drivers/open_api_3/driver_test.rb +1 -1
  19. data/test/drivers_test.rb +20 -7
  20. data/test/middleware/base_test.rb +6 -13
  21. data/test/middleware/request_validation_open_api_3_test.rb +38 -42
  22. data/test/middleware/request_validation_test.rb +1 -28
  23. data/test/middleware/response_validation_open_api_3_test.rb +46 -3
  24. data/test/middleware/response_validation_test.rb +6 -25
  25. data/test/schema_validator/hyper_schema/response_validator_test.rb +10 -0
  26. data/test/schema_validator/hyper_schema/string_params_coercer_test.rb +1 -1
  27. data/test/schema_validator/open_api_3/operation_wrapper_test.rb +55 -11
  28. data/test/schema_validator/open_api_3/request_validator_test.rb +10 -0
  29. data/test/schema_validator/open_api_3/response_validator_test.rb +14 -0
  30. data/test/test/methods_new_version_test.rb +1 -1
  31. data/test/test/methods_test.rb +11 -31
  32. data/test/test_helper.rb +11 -3
  33. metadata +11 -16
@@ -57,16 +57,6 @@ describe Committee::Test::Methods do
57
57
  end
58
58
  assert_match(/response header must be set to/i, e.message)
59
59
  end
60
-
61
- it "outputs deprecation warning" do
62
- @app = new_rack_app(JSON.generate([ValidApp]))
63
- get "/apps"
64
- _, err = capture_io do
65
- assert_schema_conform
66
- end
67
- assert_match(/\[DEPRECATION\] Now assert_schema_conform check response schema only/i, err)
68
- assert_match(/\[DEPRECATION\] Pass expected response status code/i, err)
69
- end
70
60
  end
71
61
 
72
62
  describe "assert_request_schema_confirm" do
@@ -99,14 +89,14 @@ describe Committee::Test::Methods do
99
89
  it "passes through a valid response" do
100
90
  @app = new_rack_app(JSON.generate([ValidApp]))
101
91
  get "/apps"
102
- assert_response_schema_confirm
92
+ assert_response_schema_confirm(200)
103
93
  end
104
94
 
105
95
  it "detects an invalid response Content-Type" do
106
96
  @app = new_rack_app(JSON.generate([ValidApp]), {})
107
97
  get "/apps"
108
98
  e = assert_raises(Committee::InvalidResponse) do
109
- assert_response_schema_confirm
99
+ assert_response_schema_confirm(200)
110
100
  end
111
101
  assert_match(/response header must be set to/i, e.message)
112
102
  end
@@ -133,14 +123,14 @@ describe Committee::Test::Methods do
133
123
  it "passes through a valid response" do
134
124
  @app = new_rack_app(JSON.generate(@correct_response))
135
125
  get "/characters"
136
- assert_schema_conform
126
+ assert_schema_conform(200)
137
127
  end
138
128
 
139
129
  it "detects an invalid response Content-Type" do
140
130
  @app = new_rack_app(JSON.generate([@correct_response]), {})
141
131
  get "/characters"
142
132
  e = assert_raises(Committee::InvalidResponse) do
143
- assert_schema_conform
133
+ assert_schema_conform(200)
144
134
  end
145
135
  assert_match(/response definition does not exist/i, e.message)
146
136
  end
@@ -151,20 +141,10 @@ describe Committee::Test::Methods do
151
141
  get "/characters"
152
142
 
153
143
  e = assert_raises(Committee::InvalidResponse) do
154
- assert_schema_conform
144
+ assert_schema_conform(419)
155
145
  end
156
146
  assert_match(/status code definition does not exist/i, e.message)
157
147
  end
158
-
159
- it "outputs deprecation warning" do
160
- @app = new_rack_app(JSON.generate(@correct_response))
161
- get "/characters"
162
- _, err = capture_io do
163
- assert_schema_conform
164
- end
165
- assert_match(/\[DEPRECATION\] Now assert_schema_conform check response schema only/i, err)
166
- assert_match(/\[DEPRECATION\] Pass expected response status code/i, err)
167
- end
168
148
  end
169
149
 
170
150
  describe "assert_request_schema_confirm" do
@@ -198,14 +178,14 @@ describe Committee::Test::Methods do
198
178
  it "passes through a valid response" do
199
179
  @app = new_rack_app(JSON.generate(@correct_response))
200
180
  get "/characters"
201
- assert_response_schema_confirm
181
+ assert_response_schema_confirm(200)
202
182
  end
203
183
 
204
184
  it "detects an invalid response Content-Type" do
205
185
  @app = new_rack_app(JSON.generate([@correct_response]), {})
206
186
  get "/characters"
207
187
  e = assert_raises(Committee::InvalidResponse) do
208
- assert_response_schema_confirm
188
+ assert_response_schema_confirm(200)
209
189
  end
210
190
  assert_match(/response definition does not exist/i, e.message)
211
191
  end
@@ -216,7 +196,7 @@ describe Committee::Test::Methods do
216
196
  get "/characters"
217
197
 
218
198
  e = assert_raises(Committee::InvalidResponse) do
219
- assert_response_schema_confirm
199
+ assert_response_schema_confirm(419)
220
200
  end
221
201
  assert_match(/status code definition does not exist/i, e.message)
222
202
  end
@@ -249,7 +229,7 @@ describe Committee::Test::Methods do
249
229
  end
250
230
  it 'records openapi coverage' do
251
231
  get "/posts"
252
- assert_response_schema_confirm
232
+ assert_response_schema_confirm(200)
253
233
  assert_equal({
254
234
  '/threads/{id}' => {
255
235
  'get' => {
@@ -290,7 +270,7 @@ describe Committee::Test::Methods do
290
270
  it 'can record openapi coverage correctly when prefix is set' do
291
271
  @committee_options.merge!(prefix: '/api')
292
272
  post "/api/likes"
293
- assert_response_schema_confirm
273
+ assert_response_schema_confirm(200)
294
274
  assert_equal({
295
275
  '/threads/{id}' => {
296
276
  'get' => {
@@ -330,7 +310,7 @@ describe Committee::Test::Methods do
330
310
 
331
311
  it 'records openapi coverage correctly with path param' do
332
312
  get "/threads/asd"
333
- assert_response_schema_confirm
313
+ assert_response_schema_confirm(200)
334
314
  assert_equal({
335
315
  '/threads/{id}' => {
336
316
  'get' => {
data/test/test_helper.rb CHANGED
@@ -60,11 +60,11 @@ def open_api_2_form_schema
60
60
  end
61
61
 
62
62
  def open_api_3_schema
63
- @open_api_3_schema ||= Committee::Drivers.load_from_file(open_api_3_schema_path)
63
+ @open_api_3_schema ||= Committee::Drivers.load_from_file(open_api_3_schema_path, parser_options:{strict_reference_validation: true})
64
64
  end
65
65
 
66
66
  def open_api_3_coverage_schema
67
- @open_api_3_coverage_schema ||= Committee::Drivers.load_from_file(open_api_3_coverage_schema_path)
67
+ @open_api_3_coverage_schema ||= Committee::Drivers.load_from_file(open_api_3_coverage_schema_path, parser_options:{strict_reference_validation: true})
68
68
  end
69
69
 
70
70
  # Don't cache this because we'll often manipulate the created hash in tests.
@@ -82,7 +82,11 @@ def open_api_2_form_data
82
82
  end
83
83
 
84
84
  def open_api_3_data
85
- YAML.load_file(open_api_3_schema_path)
85
+ if YAML.respond_to?(:unsafe_load_file)
86
+ YAML.unsafe_load_file(open_api_3_schema_path)
87
+ else
88
+ YAML.load_file(open_api_3_schema_path)
89
+ end
86
90
  end
87
91
 
88
92
  def hyper_schema_schema_path
@@ -108,3 +112,7 @@ end
108
112
  def open_api_3_0_1_schema_path
109
113
  "./test/data/openapi3/3_0_1.yaml"
110
114
  end
115
+
116
+ def open_api_3_invalid_reference_path
117
+ "./test/data/openapi3/invalid_reference.yaml"
118
+ end
metadata CHANGED
@@ -1,16 +1,16 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: committee
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.99.0.beta1
4
+ version: 5.0.0.beta1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brandur
8
8
  - geemus (Wesley Beary)
9
9
  - ota42y
10
- autorequire:
10
+ autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2023-01-24 00:00:00.000000000 Z
13
+ date: 2023-01-25 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: json_schema
@@ -50,20 +50,14 @@ dependencies:
50
50
  name: openapi_parser
51
51
  requirement: !ruby/object:Gem::Requirement
52
52
  requirements:
53
- - - ">="
54
- - !ruby/object:Gem::Version
55
- version: 0.11.1
56
- - - "<"
53
+ - - "~>"
57
54
  - !ruby/object:Gem::Version
58
55
  version: '1.0'
59
56
  type: :runtime
60
57
  prerelease: false
61
58
  version_requirements: !ruby/object:Gem::Requirement
62
59
  requirements:
63
- - - ">="
64
- - !ruby/object:Gem::Version
65
- version: 0.11.1
66
- - - "<"
60
+ - - "~>"
67
61
  - !ruby/object:Gem::Version
68
62
  version: '1.0'
69
63
  - !ruby/object:Gem::Dependency
@@ -220,7 +214,7 @@ dependencies:
220
214
  - - ">="
221
215
  - !ruby/object:Gem::Version
222
216
  version: '0'
223
- description:
217
+ description:
224
218
  email:
225
219
  - brandur@mutelight.org
226
220
  - geemus+github@gmail.com
@@ -275,6 +269,7 @@ files:
275
269
  - lib/committee/test/schema_coverage.rb
276
270
  - lib/committee/utils.rb
277
271
  - lib/committee/validation_error.rb
272
+ - lib/committee/version.rb
278
273
  - test/bin/committee_stub_test.rb
279
274
  - test/bin_test.rb
280
275
  - test/committee_test.rb
@@ -311,7 +306,7 @@ homepage: https://github.com/interagent/committee
311
306
  licenses:
312
307
  - MIT
313
308
  metadata: {}
314
- post_install_message:
309
+ post_install_message:
315
310
  rdoc_options: []
316
311
  require_paths:
317
312
  - lib
@@ -319,15 +314,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
319
314
  requirements:
320
315
  - - ">="
321
316
  - !ruby/object:Gem::Version
322
- version: 2.4.0
317
+ version: 2.6.0
323
318
  required_rubygems_version: !ruby/object:Gem::Requirement
324
319
  requirements:
325
320
  - - ">"
326
321
  - !ruby/object:Gem::Version
327
322
  version: 1.3.1
328
323
  requirements: []
329
- rubygems_version: 3.3.3
330
- signing_key:
324
+ rubygems_version: 3.2.3
325
+ signing_key:
331
326
  specification_version: 4
332
327
  summary: A collection of Rack middleware to support JSON Schema.
333
328
  test_files: []