Skip to content

Commit

Permalink
🐛 if no schema api, error occured in ParameterCoercer
Browse files Browse the repository at this point in the history
  • Loading branch information
ota42y committed Jan 16, 2017
1 parent 64cfe9b commit accea6f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
2 changes: 2 additions & 0 deletions lib/committee/parameter_coercer.rb
Expand Up @@ -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]

Expand Down
7 changes: 7 additions & 0 deletions test/middleware/request_validation_test.rb
Expand Up @@ -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"
Expand Down

0 comments on commit accea6f

Please sign in to comment.