Skip to content

API version not found when api nested #636

Closed
@yanguango

Description

@yanguango

I have two api(APIOne and APITwo) mounted in API, which is mounted in routes, but when I access http://lvh.me:3000/one/v1/hello, I got 404 API Version Not Found.

class API < Grape::API
  mount APIOne => '/one'
  mount APITwo => '/two'
end
class APIOne < Grape::API
  version 'v1', :using => :path

  get '/hello' do
    'hello'
  end
end
class APITwo < Grape::API
  version 'v1', :using => :path

  get '/world' do
    'world'
  end
end
Testgrape::Application.routes.draw do
  mount API, :at => "/"
end

I have traced the code about parsing path, I found problem is here https://github.com/intridea/grape/blob/master/lib/grape/middleware/versioner/path.rb#L34 The path here is /one/v1/hello, then potential_version = pieces[1], potential_version got one, instead of v1.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions