committee 5.6.0 → 5.6.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 10ed6ddc2d6c096a049a6275805284208597cfd4ce5914e55e589086c3102e5c
4
- data.tar.gz: d80857a5a6432b9df9bfb2468121e7cfee9d6e92452cf6ec15e45abc73ad11fe
3
+ metadata.gz: 07fd25d2379c9e5d324556185a1071995f394712a778f4d8ee2afda016601645
4
+ data.tar.gz: dd86ac014d3b34fc1f2d03456fe74190756084c8432858d20e01717562ff7c49
5
5
  SHA512:
6
- metadata.gz: ed48641dd4ad2db6df1e833f1dea1a761a53f2d7225c828ccf7b1ba9960d2f4ddc48cd1244c82ad77248b846a0744c026a755d5cab051afba91139e7e26a1ae8
7
- data.tar.gz: dbf05393911aa659514e8f90cb899cb5fbf30df3f6709ff95ab2ce5f9137dcdc4ce791667b937201a1a2daf5fe6e43325e1c05d8726118136be8adff9321afa2
6
+ metadata.gz: 2226c6247449ba57f98ec7fdf69c287d797ff7aabf92de710e91d7d080e3bc8ec65b9b88a5304e549d13f023c6238343c1971f801784f8b4fc2dce6587841e49
7
+ data.tar.gz: 589bf4caf9cdd2ded55739c90de5db53ebd21e52b66f30d4d883289349af9553fd619fd5d4b7328c0c85e5402f274018b00d6a7ed55e2fcc608157c99d87b2ec
@@ -111,7 +111,7 @@ module Committee
111
111
 
112
112
  def validate_post_request_params(path_params, query_params, body_params, headers, validator_option)
113
113
  content_type_key = headers.keys.detect { |k| k.casecmp?('Content-Type') }
114
- content_type = headers[content_type_key].to_s.split(';').first.to_s
114
+ content_type = Rack::MediaType.type(headers[content_type_key])
115
115
 
116
116
  # bad performance because when we coerce value, same check
117
117
  validate_path_and_query_params(path_params, query_params, headers, validator_option)
@@ -4,7 +4,7 @@ module Committee
4
4
  module SchemaValidator
5
5
  class << self
6
6
  def request_media_type(request)
7
- request.media_type.to_s
7
+ Rack::MediaType.type(request.env['CONTENT_TYPE'])
8
8
  end
9
9
 
10
10
  # @param [String] prefix
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Committee
4
- VERSION = '5.6.0'.freeze
4
+ VERSION = '5.6.1'.freeze
5
5
  end
@@ -0,0 +1,23 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "test_helper"
4
+
5
+ describe Committee::SchemaValidator do
6
+ it "parses simple content types" do
7
+ request = Rack::Request.new({ "CONTENT_TYPE" => "application/json" })
8
+ media_type = Committee::SchemaValidator.request_media_type(request)
9
+ assert_equal 'application/json', media_type
10
+ end
11
+
12
+ it "parses comma-delineated content types" do
13
+ request = Rack::Request.new({ "CONTENT_TYPE" => "multipart/form-data, application/json" })
14
+ media_type = Committee::SchemaValidator.request_media_type(request)
15
+ assert_equal 'multipart/form-data', media_type
16
+ end
17
+
18
+ it "parses semicolon-delineated content types" do
19
+ request = Rack::Request.new({ "CONTENT_TYPE" => "multipart/form-data; application/json" })
20
+ media_type = Committee::SchemaValidator.request_media_type(request)
21
+ assert_equal 'multipart/form-data', media_type
22
+ end
23
+ end
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.6.0
4
+ version: 5.6.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brandur
@@ -239,6 +239,7 @@ files:
239
239
  - test/schema_validator/open_api_3/operation_wrapper_test.rb
240
240
  - test/schema_validator/open_api_3/request_validator_test.rb
241
241
  - test/schema_validator/open_api_3/response_validator_test.rb
242
+ - test/schema_validator_test.rb
242
243
  - test/test/methods_new_version_test.rb
243
244
  - test/test/methods_test.rb
244
245
  - test/test/schema_coverage_test.rb