committee 5.4.0 → 5.5.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f5faf4c2afbd4a226b5d7623150db5f5869f0ce2956ca4a81f202b1e015b48ed
4
- data.tar.gz: 3e9e8ac314318d9c550820699b89e0ea1dffca1b4571c0d0551341d4f36208ae
3
+ metadata.gz: 426a690ac272e53e30d9572a33564ea8cb7f2e92617e9dcd11b8061e32936b2f
4
+ data.tar.gz: c335a7d5bb6fe299d6584bf5838ac7972f9be312f431d15db8942cdd3c473cf4
5
5
  SHA512:
6
- metadata.gz: 727bda44ff877fbb9f6ce59b18c2a4dcff658fdf26f8dc8fa5e74d14d38b41f889ba611cc750e5010d8388eb27a605fa0b53724dfda7d74427df16104fb45103
7
- data.tar.gz: 981548a85d07a247ffaa9a03a85daad03857d2fe8538d8d8c99b645f1919b35067a84757f042403f5335b22481c994c9b24cf2fef235c45d1dfb914de16e525b
6
+ metadata.gz: 2e83410d227c6704e208c0bbac5e452a34887921fee1b3f9dbe5c082bbc5861533e49882428e94bb78140d647550047f57b990e7896583a6f18d8ee76d6fdb17
7
+ data.tar.gz: 610c2002488ee37be624df996fbfbfb9609c416a911583ed3177a0917061908c0efa71324d56b7b90e77ea538b8f6e00c8785c210bd2d8e67c8398177e3269fd
@@ -20,6 +20,7 @@ module Committee
20
20
  raise if @raise
21
21
  return @error_class.new(400, :bad_request, $!.message, request).render unless @ignore_error
22
22
  rescue Committee::NotFound => e
23
+ handle_exception($!, request.env)
23
24
  raise if @raise
24
25
  return @error_class.new(404, :not_found, e.message, request).render unless @ignore_error
25
26
  rescue JSON::ParserError
@@ -77,6 +77,7 @@ module Committee
77
77
  def parse_json(request)
78
78
  return nil if request.request_method == "GET" && !@allow_get_body
79
79
 
80
+ return nil if request.body.nil?
80
81
  body = request.body.read
81
82
  # if request body is empty, we just have empty params
82
83
  return nil if body.length == 0
@@ -21,8 +21,8 @@ module Committee
21
21
  private
22
22
 
23
23
  def check_content_type(request, content_type)
24
- # support post, put, patch only
25
- return true unless request.post? || request.put? || request.patch?
24
+ # support post, put, patch, options only
25
+ return true unless request.post? || request.put? || request.patch? || request.options?
26
26
  return true if @operation_object.valid_request_content_type?(content_type)
27
27
  return true if @operation_object.optional_body? && empty_request?(request)
28
28
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Committee
4
- VERSION = '5.4.0'.freeze
4
+ VERSION = '5.5.0'.freeze
5
5
  end
@@ -95,6 +95,13 @@ describe Committee::SchemaValidator::OpenAPI3::RequestValidator do
95
95
  assert_equal 400, last_response.status
96
96
  end
97
97
 
98
+ it "validates content_type for option request" do
99
+ @app = new_rack_app(check_content_type: true, schema: open_api_3_schema)
100
+ header "Content-Type", "text/html"
101
+ options "/validate", "{}"
102
+ assert_equal 400, last_response.status
103
+ end
104
+
98
105
  def new_rack_app(options = {})
99
106
  Rack::Builder.new {
100
107
  use Committee::Middleware::RequestValidation, options
@@ -58,13 +58,13 @@ describe Committee::Test::Methods do
58
58
 
59
59
  describe "assert_request_schema_confirm" do
60
60
  it "passes through a valid request" do
61
- @app = new_rack_app([])
61
+ @app = new_rack_app
62
62
  get "/apps"
63
63
  assert_request_schema_confirm
64
64
  end
65
65
 
66
66
  it "not exist required" do
67
- @app = new_rack_app([])
67
+ @app = new_rack_app
68
68
  get "/search/apps", {}
69
69
  e = assert_raises(Committee::InvalidRequest) do
70
70
  assert_request_schema_confirm
@@ -73,7 +73,7 @@ describe Committee::Test::Methods do
73
73
  end
74
74
 
75
75
  it "path undefined in schema" do
76
- @app = new_rack_app([])
76
+ @app = new_rack_app
77
77
  get "/undefined"
78
78
  e = assert_raises(Committee::InvalidRequest) do
79
79
  assert_request_schema_confirm
@@ -146,13 +146,13 @@ describe Committee::Test::Methods do
146
146
 
147
147
  describe "assert_request_schema_confirm" do
148
148
  it "passes through a valid request" do
149
- @app = new_rack_app([])
149
+ @app = new_rack_app
150
150
  get "/characters"
151
151
  assert_request_schema_confirm
152
152
  end
153
153
 
154
154
  it "not exist required" do
155
- @app = new_rack_app([])
155
+ @app = new_rack_app
156
156
  get "/validate", {"query_string" => "query", "query_integer_list" => [1, 2]}
157
157
  e = assert_raises(Committee::InvalidRequest) do
158
158
  assert_request_schema_confirm
@@ -162,7 +162,7 @@ describe Committee::Test::Methods do
162
162
  end
163
163
 
164
164
  it "path undefined in schema" do
165
- @app = new_rack_app([])
165
+ @app = new_rack_app
166
166
  get "/undefined"
167
167
  e = assert_raises(Committee::InvalidRequest) do
168
168
  assert_request_schema_confirm
@@ -350,7 +350,7 @@ describe Committee::Test::Methods do
350
350
 
351
351
  private
352
352
 
353
- def new_rack_app(response, headers={ "Content-Type" => "application/json" }, status_code = 200)
353
+ def new_rack_app(response = nil, headers={ "Content-Type" => "application/json" }, status_code = 200)
354
354
  Rack::Builder.new {
355
355
  run lambda { |_|
356
356
  [status_code, headers, [response]]
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: committee
3
3
  version: !ruby/object:Gem::Version
4
- version: 5.4.0
4
+ version: 5.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brandur
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2024-06-17 00:00:00.000000000 Z
13
+ date: 2024-11-25 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: json_schema
@@ -41,7 +41,7 @@ dependencies:
41
41
  version: '1.5'
42
42
  - - "<"
43
43
  - !ruby/object:Gem::Version
44
- version: '3.1'
44
+ version: '3.2'
45
45
  type: :runtime
46
46
  prerelease: false
47
47
  version_requirements: !ruby/object:Gem::Requirement
@@ -51,7 +51,7 @@ dependencies:
51
51
  version: '1.5'
52
52
  - - "<"
53
53
  - !ruby/object:Gem::Version
54
- version: '3.1'
54
+ version: '3.2'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: openapi_parser
57
57
  requirement: !ruby/object:Gem::Requirement
@@ -289,7 +289,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
289
289
  - !ruby/object:Gem::Version
290
290
  version: '0'
291
291
  requirements: []
292
- rubygems_version: 3.5.3
292
+ rubygems_version: 3.5.18
293
293
  signing_key:
294
294
  specification_version: 4
295
295
  summary: A collection of Rack middleware to support JSON Schema.