Skip to content

Commit 4a9fbe1

Browse files
authored
Add show? method to param description (#84)
1 parent 6ba6cdf commit 4a9fbe1

File tree

2 files changed

+23
-1
lines changed

2 files changed

+23
-1
lines changed

lib/apipie_bindings/param.rb

+6
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,18 @@ def initialize(param)
1313
@description = param[:description].gsub(/<\/?[^>]+?>/, "")
1414
@required = !!param[:required]
1515
@validator = param[:validator]
16+
# We expect a value from API param docs, but in case it's not there, we want to show it in help by default
17+
@show = param[:show].nil? ? true : param[:show]
1618
end
1719

1820
def required?
1921
@required
2022
end
2123

24+
def show?
25+
@show
26+
end
27+
2228
def to_s
2329
"<Param #{ required? ? '*' : '' }#{@name} (#{@expected_type.to_s.capitalize})>"
2430
end

test/unit/param_test.rb

+17-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,18 @@
1616
"full_name" => "architecture[name]",
1717
"name" => "name",
1818
"required" => false,
19-
"validator" => "Must be String"
19+
"validator" => "Must be String",
20+
"show" => true
21+
},
22+
{
23+
"allow_nil" => false,
24+
"description" => "",
25+
"expected_type" => "integer",
26+
"full_name" => "architecture[hidden]",
27+
"name" => "hidden",
28+
"required" => false,
29+
"validator" => "Must be Integer",
30+
"show" => false
2031
}
2132

2233
],
@@ -54,4 +65,9 @@
5465
param.inspect.must_equal "<Param *architecture (Hash)>"
5566
end
5667

68+
it "should have show?" do
69+
param.show?.must_equal true
70+
param.params.first.show?.must_equal true
71+
param.params.last.show?.must_equal false
72+
end
5773
end

0 commit comments

Comments
 (0)