Skip to content

Commit 82a5eea

Browse files
author
khiav reoy
committed
Fix: params is not the same in RESTful APIs with different verbs
1 parent adb498a commit 82a5eea

File tree

2 files changed

+17
-16
lines changed

2 files changed

+17
-16
lines changed

lib/rspec_api_documentation/views/api_blueprint_index.rb

+4-3
Original file line numberDiff line numberDiff line change
@@ -10,23 +10,24 @@ def sections
1010
super.map do |section|
1111
routes = section[:examples].group_by { |e| "#{e.route_uri}#{e.route_optionals}#{e.route_name}" }.map do |route, examples|
1212
attrs = fields(:attributes, examples)
13-
params = fields(:parameters, examples)
1413

1514
methods = examples.group_by(&:http_method).map do |http_method, examples|
15+
params = fields(:parameters, examples)
16+
1617
{
18+
"has_parameters?".to_sym => params.size > 0,
1719
http_method: http_method,
20+
parameters: params,
1821
description: examples.first.respond_to?(:action_name) && examples.first.action_name,
1922
examples: examples
2023
}
2124
end
2225

2326
{
2427
"has_attributes?".to_sym => attrs.size > 0,
25-
"has_parameters?".to_sym => params.size > 0,
2628
route: format_route(examples[0]),
2729
route_name: examples[0][:route_name],
2830
attributes: attrs,
29-
parameters: params,
3031
http_methods: methods
3132
}
3233
end

templates/rspec_api_documentation/api_blueprint_index.mustache

+13-13
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,10 @@ description: {{ description }}
2323

2424
explanation: {{ explanation }}
2525
{{/ explanation }}
26-
{{# has_parameters? }}
26+
{{# has_attributes? }}
2727

28-
+ Parameters
29-
{{# parameters }}
28+
+ Attributes (object)
29+
{{# attributes }}
3030
+ {{ name }}{{# example }}: {{ example }}{{/ example }}{{# properties_description }} ({{ properties_description }}){{/ properties_description }}{{# description }} - {{ description }}{{/ description }}
3131
{{# has_default?}}
3232
+ Default: `{{default}}`
@@ -40,12 +40,15 @@ explanation: {{ explanation }}
4040
{{# annotations }}
4141
{{ . }}
4242
{{/ annotations }}
43-
{{/ parameters }}
44-
{{/ has_parameters? }}
45-
{{# has_attributes? }}
43+
{{/ attributes }}
44+
{{/ has_attributes? }}
45+
{{# http_methods }}
4646

47-
+ Attributes (object)
48-
{{# attributes }}
47+
### {{ description }} [{{ http_method }}]
48+
{{# has_parameters? }}
49+
50+
+ Parameters
51+
{{# parameters }}
4952
+ {{ name }}{{# example }}: {{ example }}{{/ example }}{{# properties_description }} ({{ properties_description }}){{/ properties_description }}{{# description }} - {{ description }}{{/ description }}
5053
{{# has_default?}}
5154
+ Default: `{{default}}`
@@ -59,11 +62,8 @@ explanation: {{ explanation }}
5962
{{# annotations }}
6063
{{ . }}
6164
{{/ annotations }}
62-
{{/ attributes }}
63-
{{/ has_attributes? }}
64-
{{# http_methods }}
65-
66-
### {{ description }} [{{ http_method }}]
65+
{{/ parameters }}
66+
{{/ has_parameters? }}
6767
{{# examples }}
6868
{{# requests }}
6969
{{# has_request? }}

0 commit comments

Comments
 (0)