-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Version Mounting sees the last mounted version only #1682
Comments
👍 getting a similar issues. We have
We also have an non versioned ping endpoints
However the routes show my ping endpoints with a version. |
It seems to be breaking our specs only starting from 1.0.1. Works fine on 1.0.0 Code to it's bare minimum: module Api
module V5
class Base < Grape::API
version ['v5_1', 'v5']
mount Api::V5::Version
end
end
end
module Api
module V5_1
class Base < Grape::API
version 'v5_1'
mount Api::V5_1::Version
end
end
end
class Api::V5::Version < Grape::API
resource :version do
desc 'Return the current API version'
get do
{ version: version }
end
end
end
class Api::V5_1::Version < Api::V5::Version
end
# a shared spec example
shared_examples '/v5/version' do
it 'returns the current API version' do
get api_path(version, 'version')
expect(response.body).to eq({ version: version }.to_json)
end
end
describe '/api/v5/version' do
it_behaves_like '/v5/version' do
let(:version) { 'v5' }
end
end
describe '/api/v5_1/version' do
it_behaves_like '/v5/version' do
let(:version) { 'v5_1' }
end
end RSpec failure Failures:
1) /api/v5/version behaves like /v5/version returns the current API version
Failure/Error: get api_path(version, 'version')
ActionController::RoutingError:
No route matches [GET] "/api/v5/version"
Shared Example Group: "/v5/version" called from ./spec/api/v5/version_spec.rb:4
# ./spec/api/shared/v5/version.rb:5:in `block (2 levels) in <top (required)>'
# -e:1:in `<main>'
Finished in 1.06 seconds (files took 0.78781 seconds to load)
1 example, 1 failure
Failed examples:
rspec ./spec/api/v5/version_spec.rb:4 # /api/v5/version behaves like /v5/version returns the current API version |
Please PR a failing spec, hopefully with a fix. |
@dblock what i noticed is, since im mounting the same APIs - same path - with different header versions then i run rake grape:routes only 1 version of the APIs mounted gets registered. |
Is this a dup of #570 ? |
After reading the thread, yes it is. |
Closing as dup, please move any relevant info to #570. |
Hi,
im trying to mount 3 different versions of API into my app, i followed the guideline but there seems to be an odd behavior, only the last mounted version gets accepted, the other versions throws invalid header version error, i tried to debug in grape's code of Header class i found that the versions array is only the last mounted version only.
it's a Rails project and my files are as below:
1- in config/routes i add the following line
mount Api => '/api'
2- in app/api/api.rb
3- inside each of the V{VERSION} classes i add the version
V3::Base
version 'v3', using: :header, vendor: 'X'
V2::Base
version 'v2', using: :header, vendor: 'X'
V1::Base
version 'v1', using: :path
then in each version base class i mount the endpoints. for example
is there something missing i need to add?
The text was updated successfully, but these errors were encountered: