Skip to content
Open
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
8 changes: 8 additions & 0 deletions lib/rspec_api_documentation/example.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,14 @@ def has_parameters?
respond_to?(:parameters) && parameters.present?
end

def has_enum?
respond_to?(:parameters) && parameters.present? && parameters.any? { |i| i[:enum] }
end

def has_default?
respond_to?(:parameters) && parameters.present? && parameters.any? { |i| i[:default] }
end

def has_attributes?
respond_to?(:attributes) && attributes.present?
end
Expand Down
12 changes: 12 additions & 0 deletions templates/rspec_api_documentation/html_example.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,12 @@
<tr>
<th>Name</th>
<th>Description</th>
{{# has_enum? }}
<th>Accepted values</th>
{{/ has_enum? }}
{{# has_default? }}
<th>Default</th>
{{/ has_default? }}
</tr>
</thead>
<tbody>
Expand All @@ -47,6 +53,12 @@
<td>
<span class="description">{{ description }}</span>
</td>
{{# has_enum? }}
<td>{{ enum }}</td>
{{/ has_enum? }}
{{# has_default? }}
<td>{{ default }}</td>
{{/ has_default? }}
</tr>
{{/ parameters }}
</tbody>
Expand Down