Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support resource groupings for prefixed APIs #58

Closed
wants to merge 1 commit into from
Closed

Support resource groupings for prefixed APIs #58

wants to merge 1 commit into from

Conversation

aew
Copy link
Contributor

@aew aew commented Aug 26, 2013

The fact that an API has a prefix (e.g., /api) should not affect the
way resources are grouped for documentation purposes. This patch
updates the hardcoded single level of resource grouping to ignore the
prefix (which available as part of the route object).

The fact that an API has a prefix (e.g., /api) should not affect the
way resources are grouped for documentation purposes.  This patch
updates the hardcoded single level of resource grouping to ignore the
prefix (which available as part of the route object).
@aew
Copy link
Contributor Author

aew commented Aug 26, 2013

Note - this is an alternative implementation to https://github.com/tim-vandecasteele/grape-swagger/pull/52

@tim-vandecasteele
Copy link
Contributor

Thanks, has been merged.

@kranzky
Copy link

kranzky commented Nov 4, 2013

To get this to work properly, I needed to change parse_path to take the prefix into account as well, as follows:

            def parse_path(path, version)
              # adapt format to swagger format
              path = path.split(route.route_prefix).last
              parsed_path = path.gsub '(.:format)', ( @@hide_format ? '' : '.{format}')
              # This is attempting to emulate the behavior of
              # Rack::Mount::Strexp. We cannot use Strexp directly because
              # all it does is generate regular expressions for parsing URLs.
              # TODO: Implement a Racc tokenizer to properly generate the
              # parsed path.
              parsed_path = parsed_path.gsub(/:([a-zA-Z_]\w*)/, '{\1}')
              # add the version
              version ? parsed_path.gsub('{version}', version) : parsed_path
            end

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants