Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions lib/apipie_bindings/param.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,18 @@ def initialize(param)
@description = param[:description].gsub(/<\/?[^>]+?>/, "")
@required = !!param[:required]
@validator = param[:validator]
# We expect a value from API param docs, but in case it's not there, we want to show it in help by default
@show = param[:show].nil? ? true : param[:show]
end

def required?
@required
end

def show?
@show
end

def to_s
"<Param #{ required? ? '*' : '' }#{@name} (#{@expected_type.to_s.capitalize})>"
end
Expand Down
18 changes: 17 additions & 1 deletion test/unit/param_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,18 @@
"full_name" => "architecture[name]",
"name" => "name",
"required" => false,
"validator" => "Must be String"
"validator" => "Must be String",
"show" => true
},
{
"allow_nil" => false,
"description" => "",
"expected_type" => "integer",
"full_name" => "architecture[hidden]",
"name" => "hidden",
"required" => false,
"validator" => "Must be Integer",
"show" => false
}

],
Expand Down Expand Up @@ -54,4 +65,9 @@
param.inspect.must_equal "<Param *architecture (Hash)>"
end

it "should have show?" do
param.show?.must_equal true
param.params.first.show?.must_equal true
param.params.last.show?.must_equal false
end
end
Loading