ruby-grape / grape

An opinionated framework for creating REST-like APIs in Ruby.
http://www.ruby-grape.org
MIT License
9.89k stars 1.22k forks source link

Grape route error #1387

Open TigerWolf opened 8 years ago

TigerWolf commented 8 years ago

After upgrading to 0.16.2 from 0.15.0 I get this error:

Mustermann::CompileError - can't use the same capture name twice: "/(*:path)*path(.json)":

I have looked at the UPGRADING document and it doesn't look like I am using any of the deprecated methods.

In my routes.rb file I am using: mount Base => '/'

Is there any more information I can provide to help debug this issue?

dblock commented 8 years ago

This is just a regex error in an API declaration, no? Do you have a route that looks like the one above in the error?

TigerWolf commented 8 years ago

It doesn't appear to be a regex error as it works with 0.15.0. My routes:

Rails.application.routes.draw do
  root 'timetable#index'

  namespace :timetable do
    get 'index'
  end

  mount Base => '/'
end
TigerWolf commented 8 years ago

It appears that the commit that introduced this issue is: https://github.com/ruby-grape/grape/commit/9f4ba67d4aca90f04a65c5ff921b1687942eb99c

dblock commented 8 years ago

Yes, the router was replaced, it's a lot of changes. I would look at the stack that gets there or try to build a spec that reproduces this problem to start.

saubi1993 commented 7 years ago

make sure all child mounted apis are inherited by parent grape api instead of Grape::API. For Ex

class Root < Grape::API mount Base end

class Base < Root end

jnardone commented 7 years ago

@dblock is @saubi1993's comment preceding this accurate? should mounted APIs inherit from their parent class vs. Grape::API? I have never seen this documented elsewhere and am skeptical it has any practical benefit. If it does, it would be good to call this out explicilty (and loudly) in the documentation.

dblock commented 7 years ago

I think I agree with you @jnardone, @saubi1993 care to clarify?

saubi1993 commented 7 years ago

I was having an issue, where routes were repeating twice i.e. if route path was like /api/v1/users/1/latest, rake routes was generating /api/v1/users/1/users/1/latest and before callback was executing twice before API was even executed. Doing Above resolved the issue @dblock