Skip to content

Commit 96fbd74

Browse files
committed
Fix API blueprint documentation.
- Switch from path segment expansion to simple string expansion because the former is not supported by Apiary
1 parent b57259d commit 96fbd74

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

lib/rspec_api_documentation/views/api_blueprint_index.rb

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -46,13 +46,13 @@ def examples
4646
private
4747

4848
# APIB follows the RFC 6570 to format URI templates.
49-
# According to it, path segment expansion (used to describe URI path
50-
# hierarchies) should be represented by `{/var}` and not by `/:var`
51-
# For example `/posts/:id` should become `/posts{/id}`
49+
# According to it, simple string expansion (used to perform variable
50+
# expansion) should be represented by `{var}` and not by `:var`
51+
# For example `/posts/:id` should become `/posts/{id}`
5252
# cf. https://github.com/apiaryio/api-blueprint/blob/format-1A/API%20Blueprint%20Specification.md#431-resource-section
53-
# cf. https://tools.ietf.org/html/rfc6570#section-3.2.6
53+
# cf. https://tools.ietf.org/html/rfc6570#section-3.2.2
5454
def format_route(example)
55-
route_uri = example[:route_uri].gsub(/\/:(.*?)([.\/?{]|$)/, '{/\1}\2')
55+
route_uri = example[:route_uri].gsub(/:(.*?)([.\/?{]|$)/, '{\1}\2')
5656
"#{route_uri}#{example[:route_optionals]}"
5757
end
5858

spec/views/api_blueprint_index_spec.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@
109109

110110
post_examples = post_route[:http_methods].map { |http_method| http_method[:examples] }.flatten
111111
expect(post_examples.size).to eq 2
112-
expect(post_route[:route]).to eq "/posts{/id}"
112+
expect(post_route[:route]).to eq "/posts/{id}"
113113
expect(post_route[:route_name]).to eq "Single Post"
114114
expect(post_route[:has_parameters?]).to eq true
115115
expect(post_route[:parameters]).to eq [{
@@ -130,7 +130,7 @@
130130

131131
post_w_optionals_examples = post_route_with_optionals[:http_methods].map { |http_method| http_method[:examples] }.flatten
132132
expect(post_w_optionals_examples.size).to eq 1
133-
expect(post_route_with_optionals[:route]).to eq "/posts{/id}{?option=:option}"
133+
expect(post_route_with_optionals[:route]).to eq "/posts/{id}{?option=:option}"
134134
expect(post_route_with_optionals[:route_name]).to eq "Single Post"
135135
expect(post_route_with_optionals[:has_parameters?]).to eq true
136136
expect(post_route_with_optionals[:parameters]).to eq [{

0 commit comments

Comments
 (0)