diff --git a/lib/apipie/extractor/collector.rb b/lib/apipie/extractor/collector.rb index 0aa6e7b5..195e4179 100644 --- a/lib/apipie/extractor/collector.rb +++ b/lib/apipie/extractor/collector.rb @@ -63,12 +63,12 @@ def refine_params_description(params_desc, recorded_params) # we specify what type it might be. At the end the first type # that left is taken as the more general one unless param_desc[:type] - param_desc[:type] = [:bool, :number] + param_desc[:type] = [:bool, :boolean, :number] param_desc[:type] << Hash if value.is_a? Hash param_desc[:type] << :undef end - if param_desc[:type].first == :bool && (! [true, false].include?(value)) + if [:boolean, :bool].include?(param_desc[:type].first) && (! [true, false, 1, 0].include?(value)) param_desc[:type].shift end diff --git a/lib/apipie/validator.rb b/lib/apipie/validator.rb index 30161b29..5c5791a2 100644 --- a/lib/apipie/validator.rb +++ b/lib/apipie/validator.rb @@ -398,11 +398,11 @@ def self.validate(value) class BooleanValidator < BaseValidator def validate(value) - %w[true false].include?(value.to_s) + %w[true false 1 0].include?(value.to_s) end def self.build(param_description, argument, options, block) - if argument == :bool + if argument == :bool || argument == :boolean self.new(param_description) end end @@ -412,7 +412,7 @@ def expected_type end def description - "Must be 'true' or 'false'" + "Must be 'true' or 'false' or '1' or '0'" end end