diff options
author | Oswaldo Ferreira <oswaldo@gitlab.com> | 2017-07-25 12:35:45 +0300 |
---|---|---|
committer | Rémy Coutable <remy@rymai.me> | 2017-07-25 12:35:45 +0300 |
commit | 33dc5171e5885bbc1de1db7b9be58453edfa9453 (patch) | |
tree | 70953a20215c456e1007a0df3849db00a98cbe34 /config | |
parent | d5801545ec25780402c30c4d30d4efa16f0728a4 (diff) |
Resolve "More RESTful API: include resource URLs in responses"
Diffstat (limited to 'config')
-rw-r--r-- | config/initializers/grape_route_helpers_fix.rb | 35 | ||||
-rw-r--r-- | config/routes/api.rb | 2 |
2 files changed, 36 insertions, 1 deletions
diff --git a/config/initializers/grape_route_helpers_fix.rb b/config/initializers/grape_route_helpers_fix.rb new file mode 100644 index 00000000000..d3cf9e453d0 --- /dev/null +++ b/config/initializers/grape_route_helpers_fix.rb @@ -0,0 +1,35 @@ +if defined?(GrapeRouteHelpers) + module GrapeRouteHelpers + class DecoratedRoute + # GrapeRouteHelpers gem tries to parse the versions + # from a string, not supporting Grape `version` array definition. + # + # Without the following fix, we get this on route helpers generation: + # + # => undefined method `scan' for ["v3", "v4"] + # + # 2.0.0 implementation of this method: + # + # ``` + # def route_versions + # version_pattern = /[^\[",\]\s]+/ + # if route_version + # route_version.scan(version_pattern) + # else + # [nil] + # end + # end + # ``` + def route_versions + return [nil] if route_version.nil? || route_version.empty? + + if route_version.is_a?(String) + version_pattern = /[^\[",\]\s]+/ + route_version.scan(version_pattern) + else + route_version + end + end + end + end +end diff --git a/config/routes/api.rb b/config/routes/api.rb index 69c8efc151c..ce7a7c88900 100644 --- a/config/routes/api.rb +++ b/config/routes/api.rb @@ -1,2 +1,2 @@ API::API.logger Rails.logger -mount API::API => '/api' +mount API::API => '/' |