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

Fail to show some operations when api version is part of path #192

Closed
carelvwyk opened this issue Jan 7, 2015 · 14 comments
Closed

Fail to show some operations when api version is part of path #192

carelvwyk opened this issue Jan 7, 2015 · 14 comments
Labels

Comments

@carelvwyk
Copy link

In Grape, if the api version is part of the path ( version 'v1', using: :path ), the grape-swagger route_match regex fails to match all paths.
To reproduce, add the following line to grape-swagger/example/api.rb below format :json (line 7): version 'v1', using: :path

In this case, grape generates routes with paths that looks as follows: /:version/invoices
Which is not properly matched by the regex in grape-swagger/lib/grape-swagger.rb line 23 (route_match = route_match.match('\/([\w|-]*?)[\.\/\(]') || route_match.match('\/([\w|-]*)'))

@dblock
Copy link
Member

dblock commented Jan 8, 2015

This looks legit, would you please write a spec for this?

@dblock dblock added the bug? label Jan 8, 2015
@carelvwyk
Copy link
Author

Ok, will do later today or tomorrow

@minch
Copy link
Contributor

minch commented Jan 20, 2015

I haven't had time to write a spec yet, will send a pr once I do, but I had the same problem and here's a potential fix:

minch@ae9e833

I say "potential" as I haven't written any specs or checked to see if this breaks anything else.

The issue, for me at least, is that the second regex doesn't match index routes when the format is not in the route (as it's been explicitly declared in the given resource, e.g., format :json).

Temporary workaround would also be to allow other formats, and use default_format.

@dblock
Copy link
Member

dblock commented Jan 20, 2015

Thanks @minch, looking forward to it.

@zosiu
Copy link

zosiu commented Jan 30, 2015

👍

2 similar comments
@vincentjames501
Copy link

+1

@aceunreal
Copy link

👍

@calfzhou
Copy link
Contributor

calfzhou commented Feb 6, 2015

Facing the same issue.

When version is in url path, operations such as get '/' do ... end will not show.

@dblock
Copy link
Member

dblock commented Feb 6, 2015

Still accepting spec + PR for a fix! :)

@minch
Copy link
Contributor

minch commented Feb 7, 2015

Lol, sorry guys I recently started a new job and have been crazy busy the past couple weeks.

I'll try to get a pr going soon..

@ahmeij
Copy link

ahmeij commented Feb 9, 2015

Just to confirm, the fix seems to work I see the missing endpoints again after hacking the method as indicated above. I'll try to produce a failing spec.

@tonycoco
Copy link

Additional information here: #189

@dm1try
Copy link
Member

dm1try commented Feb 13, 2015

@dblock
Copy link
Member

dblock commented Feb 13, 2015

@dblock dblock closed this as completed Feb 13, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

10 participants