diff --git a/lib/committee/parameter_coercer.rb b/lib/committee/parameter_coercer.rb index eb732487..36d57e18 100644 --- a/lib/committee/parameter_coercer.rb +++ b/lib/committee/parameter_coercer.rb @@ -9,6 +9,8 @@ def initialize(params, schema, options = {}) def call coerced = {} + return coerced unless @schema.respond_to?(:properties) + @schema.properties.each do |k, s| original_val = @params[k] diff --git a/test/middleware/request_validation_test.rb b/test/middleware/request_validation_test.rb index 13ed06f3..ff0bccdd 100644 --- a/test/middleware/request_validation_test.rb +++ b/test/middleware/request_validation_test.rb @@ -38,6 +38,13 @@ def app assert_match /invalid request/i, last_response.body end + it "pass non-exist schema link and coerce_date_times option enable" do + @app = new_rack_app(coerce_date_times: true, schema: hyper_schema) + header "Content-Type", "application/json" + get "/apps", JSON.generate({}) + assert_equal 200, last_response.status + end + it "detects an invalid request" do @app = new_rack_app(schema: hyper_schema) header "Content-Type", "application/json"