Skip to content

Commit

Permalink
fixes #10167 - change default API from v1 to v2
Browse files Browse the repository at this point in the history
  • Loading branch information
Joseph Magen authored and ohadlevy committed Apr 20, 2015
1 parent 2b6605c commit 823e62f
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion app/controllers/api/v1/base_controller.rb
Expand Up @@ -5,7 +5,7 @@ class BaseController < Api::BaseController

resource_description do
api_version "v1"
app_info "Foreman v1 is currently the default API version. Users are recommended to use API v2 as future versions of Foreman will change the default to v2 and then deprecate and/or remove v1. You may explicitly use v1 by either passing 'version=1' in the Accept Header or using api/v1/ in the URL."
app_info N_("Foreman API v1 is deprecated. Please use v2. If you still need to use v1, you may do so by either passing 'version=1' in the Accept Header or using api/v1/ in the URL.")
end
end
end
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/api/v2/base_controller.rb
Expand Up @@ -5,7 +5,7 @@ class BaseController < Api::BaseController

resource_description do
api_version "v2"
app_info N_("Foreman v2 is stable and recommended for use. You may use v2 by either passing 'version=2' in the Accept Header or using api/v2/ in the URL.")
app_info N_("Foreman API v2 is currently the default API version.")
end

def_param_group :pagination do
Expand Down
2 changes: 1 addition & 1 deletion config/routes/api/v1.rb
@@ -1,7 +1,7 @@
# config/routes/api/v1.rb
Foreman::Application.routes.draw do
namespace :api, :defaults => {:format => 'json'} do
scope "(:apiv)", :module => :v1, :defaults => {:apiv => 'v1'}, :apiv => /v1|v2/, :constraints => ApiConstraints.new(:version => 1, :default => true) do
scope "(:apiv)", :module => :v1, :defaults => {:apiv => 'v1'}, :apiv => /v1|v2/, :constraints => ApiConstraints.new(:version => 1) do
resources :architectures, :except => [:new, :edit]
resources :audits, :only => [:index, :show]
resources :auth_source_ldaps, :except => [:new, :edit]
Expand Down
2 changes: 1 addition & 1 deletion config/routes/api/v2.rb
Expand Up @@ -2,7 +2,7 @@
Foreman::Application.routes.draw do
namespace :api, :defaults => {:format => 'json'} do
# new v2 routes that point to v2
scope "(:apiv)", :module => :v2, :defaults => {:apiv => 'v2'}, :apiv => /v1|v2/, :constraints => ApiConstraints.new(:version => 2) do
scope "(:apiv)", :module => :v2, :defaults => {:apiv => 'v2'}, :apiv => /v1|v2/, :constraints => ApiConstraints.new(:version => 2, :default => true) do
resources :architectures, :except => [:new, :edit] do
constraints(:id => /[^\/]+/) do
resources :hosts, :except => [:new, :edit]
Expand Down

0 comments on commit 823e62f

Please sign in to comment.