Skip to content

Commit

Permalink
Raise error when parameter attributes misses required keys
Browse files Browse the repository at this point in the history
  • Loading branch information
skryukov committed Oct 23, 2023
1 parent ae33d45 commit 7287a7d
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions lib/skooma/objects/parameter/keywords/value_parser.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,11 @@ module Keywords
module ValueParser
class << self
def call(instance, result)
type = result.sibling(instance, "in").annotation
key = result.sibling(instance, "name").annotation
raise Error, "Missing key: #{key}" unless key
type = result.sibling(instance, "in")&.annotation
raise Error, "Missing `in` key #{result.path}" unless type

key = result.sibling(instance, "name")&.annotation
raise Error, "Missing `name` key #{instance.path}: #{key}" unless key

case type
when "query"
Expand All @@ -30,7 +32,7 @@ def call(instance, result)
when "cookie"
# instance["headers"]["Cookie"]
else
raise Error, "Unknown location: #{result.sibling(instance, "in").annotation}"
raise Error, "Unknown location: #{type}"
end
end

Expand Down

0 comments on commit 7287a7d

Please sign in to comment.