Skip to content
Snippets Groups Projects
Unverified Commit 2da33538 authored by Imre (Admin)'s avatar Imre (Admin)
Browse files

Fix API::Namespaces to accept namepaces with dots

It also renames the API::PROJECT_ENDPOINT_REQUIREMENTS constant to
API::NAMESPACE_OR_PROJECT_REQUIREMENTS
parent 0642a3d4
No related branches found
No related tags found
No related merge requests found
Showing
with 26 additions and 21 deletions
---
title: Fix API::Namespaces routing to accept namepaces with dots
merge_request: 22912
author:
type: fixed
Loading
Loading
@@ -511,7 +511,7 @@ module EE
params do
requires :id, type: String, desc: 'The ID of a project'
end
resource :projects, requirements: ::API::API::PROJECT_ENDPOINT_REQUIREMENTS do
resource :projects, requirements: ::API::API::NAMESPACE_OR_PROJECT_REQUIREMENTS do
# ...
end
end
Loading
Loading
Loading
Loading
@@ -33,7 +33,7 @@ def link
requires :id, type: String, desc: 'The ID of a group'
end
 
resource :groups, requirements: API::PROJECT_ENDPOINT_REQUIREMENTS do
resource :groups, requirements: API::NAMESPACE_OR_PROJECT_REQUIREMENTS do
desc 'Update epic issue association' do
end
params do
Loading
Loading
Loading
Loading
@@ -48,7 +48,7 @@ def find_epics(args = {})
requires :id, type: String, desc: 'The ID of a group'
end
 
resource :groups, requirements: API::PROJECT_ENDPOINT_REQUIREMENTS do
resource :groups, requirements: API::NAMESPACE_OR_PROJECT_REQUIREMENTS do
desc 'Get epics for the group' do
success EE::API::Entities::Epic
end
Loading
Loading
Loading
Loading
@@ -26,7 +26,7 @@ def authorize_can_admin!
requires :id, type: String, desc: 'The ID of a project'
end
 
resource :projects, requirements: API::PROJECT_ENDPOINT_REQUIREMENTS do
resource :projects, requirements: API::NAMESPACE_OR_PROJECT_REQUIREMENTS do
desc 'Get project software license policies' do
success Entities::ManagedLicense
end
Loading
Loading
Loading
Loading
@@ -86,7 +86,7 @@ def verify_package_file(package_file, uploaded_file)
params do
requires :id, type: String, desc: 'The ID of a project'
end
resource :projects, requirements: API::PROJECT_ENDPOINT_REQUIREMENTS do
resource :projects, requirements: API::NAMESPACE_OR_PROJECT_REQUIREMENTS do
before do
authorize_packages_feature!
end
Loading
Loading
Loading
Loading
@@ -26,7 +26,7 @@ def handle_merge_request_errors!(errors)
requires :id, type: String, desc: 'The ID of a project'
requires :merge_request_iid, type: Integer, desc: 'The IID of a merge request'
end
resource :projects, requirements: ::API::API::PROJECT_ENDPOINT_REQUIREMENTS do
resource :projects, requirements: ::API::API::NAMESPACE_OR_PROJECT_REQUIREMENTS do
segment ':id/merge_requests/:merge_request_iid' do
# Get the status of the merge request's approvals
#
Loading
Loading
Loading
Loading
@@ -8,7 +8,7 @@ class ProjectApprovals < ::Grape::API
params do
requires :id, type: String, desc: 'The ID of a project'
end
resource :projects, requirements: ::API::API::PROJECT_ENDPOINT_REQUIREMENTS do
resource :projects, requirements: ::API::API::NAMESPACE_OR_PROJECT_REQUIREMENTS do
segment ':id/approvals' do
desc 'Get all project approvers and related configuration' do
detail 'This feature was introduced in 10.6'
Loading
Loading
Loading
Loading
@@ -44,7 +44,7 @@ def project
params do
requires :id, type: String, desc: 'The ID of a project'
end
resource :projects, requirements: API::PROJECT_ENDPOINT_REQUIREMENTS do
resource :projects, requirements: API::NAMESPACE_OR_PROJECT_REQUIREMENTS do
desc 'Triggers a pull mirror operation'
post ":id/mirror/pull" do
authenticate_with_webhook_token!
Loading
Loading
Loading
Loading
@@ -3,7 +3,7 @@ class Unleash < Grape::API
include PaginationParams
 
namespace :feature_flags do
resource :unleash, requirements: API::PROJECT_ENDPOINT_REQUIREMENTS do
resource :unleash, requirements: API::NAMESPACE_OR_PROJECT_REQUIREMENTS do
params do
requires :project_id, type: String, desc: 'The ID of a project'
optional :instance_id, type: String, desc: 'The Instance ID of Unleash Client'
Loading
Loading
Loading
Loading
@@ -17,7 +17,7 @@ def board_parent
params do
requires :id, type: String, desc: 'The ID of a project'
end
resource :projects, requirements: ::API::API::PROJECT_ENDPOINT_REQUIREMENTS do
resource :projects, requirements: ::API::API::NAMESPACE_OR_PROJECT_REQUIREMENTS do
segment ':id/boards' do
desc 'Create a project board' do
detail 'This feature was introduced in 10.4'
Loading
Loading
Loading
Loading
@@ -20,7 +20,7 @@ def board_parent
requires :id, type: String, desc: 'The ID of a group'
end
 
resource :groups, requirements: ::API::API::PROJECT_ENDPOINT_REQUIREMENTS do
resource :groups, requirements: ::API::API::NAMESPACE_OR_PROJECT_REQUIREMENTS do
segment ':id/boards' do
desc 'Create a group board' do
detail 'This feature was introduced in 10.4'
Loading
Loading
Loading
Loading
@@ -13,7 +13,7 @@ module MergeRequests
params do
requires :id, type: String, desc: 'The ID of a project'
end
resource :projects, requirements: ::API::API::PROJECT_ENDPOINT_REQUIREMENTS do
resource :projects, requirements: ::API::API::NAMESPACE_OR_PROJECT_REQUIREMENTS do
# Get the status of the merge request's approvals
#
# Parameters:
Loading
Loading
Loading
Loading
@@ -16,7 +16,7 @@ def authorize_can_read!
end
end
 
resource :groups, requirements: ::API::API::PROJECT_ENDPOINT_REQUIREMENTS do
resource :groups, requirements: ::API::API::NAMESPACE_OR_PROJECT_REQUIREMENTS do
desc 'Create a todo on an epic' do
success ::API::Entities::Todo
end
Loading
Loading
Loading
Loading
@@ -12,7 +12,7 @@ class AccessRequests < Grape::API
params do
requires :id, type: String, desc: "The #{source_type} ID"
end
resource source_type.pluralize, requirements: API::PROJECT_ENDPOINT_REQUIREMENTS do
resource source_type.pluralize, requirements: API::NAMESPACE_OR_PROJECT_REQUIREMENTS do
desc "Gets a list of access requests for a #{source_type}." do
detail 'This feature was introduced in GitLab 8.11.'
success Entities::AccessRequester
Loading
Loading
Loading
Loading
@@ -7,8 +7,8 @@ class API < Grape::API
LOG_FILENAME = Rails.root.join("log", "api_json.log")
 
NO_SLASH_URL_PART_REGEX = %r{[^/]+}
PROJECT_ENDPOINT_REQUIREMENTS = { id: NO_SLASH_URL_PART_REGEX }.freeze
COMMIT_ENDPOINT_REQUIREMENTS = PROJECT_ENDPOINT_REQUIREMENTS.merge(sha: NO_SLASH_URL_PART_REGEX).freeze
NAMESPACE_OR_PROJECT_REQUIREMENTS = { id: NO_SLASH_URL_PART_REGEX }.freeze
COMMIT_ENDPOINT_REQUIREMENTS = NAMESPACE_OR_PROJECT_REQUIREMENTS.merge(sha: NO_SLASH_URL_PART_REGEX).freeze
 
insert_before Grape::Middleware::Error,
GrapeLogging::Middleware::RequestLogger,
Loading
Loading
Loading
Loading
@@ -14,7 +14,7 @@ class AwardEmoji < Grape::API
params do
requires :id, type: String, desc: 'The ID of a project'
end
resource :projects, requirements: API::PROJECT_ENDPOINT_REQUIREMENTS do
resource :projects, requirements: API::NAMESPACE_OR_PROJECT_REQUIREMENTS do
AWARDABLES.each do |awardable_params|
awardable_string = awardable_params[:type].pluralize
awardable_id_string = "#{awardable_params[:type]}_#{awardable_params[:find_by]}"
Loading
Loading
Loading
Loading
@@ -22,7 +22,7 @@ def find_source_if_admin(source_type)
params do
requires :id, type: String, desc: "The ID of a #{source_type}"
end
resource source_type.pluralize, requirements: API::PROJECT_ENDPOINT_REQUIREMENTS do
resource source_type.pluralize, requirements: API::NAMESPACE_OR_PROJECT_REQUIREMENTS do
desc "Gets a list of #{source_type} badges viewable by the authenticated user." do
detail 'This feature was introduced in GitLab 10.6.'
success Entities::Badge
Loading
Loading
Loading
Loading
@@ -18,7 +18,7 @@ def board_parent
params do
requires :id, type: String, desc: 'The ID of a project'
end
resource :projects, requirements: API::PROJECT_ENDPOINT_REQUIREMENTS do
resource :projects, requirements: API::NAMESPACE_OR_PROJECT_REQUIREMENTS do
segment ':id/boards' do
desc 'Get all project boards' do
detail 'This feature was introduced in 8.13'
Loading
Loading
Loading
Loading
@@ -6,7 +6,7 @@ module API
class Branches < Grape::API
include PaginationParams
 
BRANCH_ENDPOINT_REQUIREMENTS = API::PROJECT_ENDPOINT_REQUIREMENTS.merge(branch: API::NO_SLASH_URL_PART_REGEX)
BRANCH_ENDPOINT_REQUIREMENTS = API::NAMESPACE_OR_PROJECT_REQUIREMENTS.merge(branch: API::NO_SLASH_URL_PART_REGEX)
 
before { authorize! :download_code, user_project }
 
Loading
Loading
@@ -20,7 +20,7 @@ class Branches < Grape::API
params do
requires :id, type: String, desc: 'The ID of a project'
end
resource :projects, requirements: API::PROJECT_ENDPOINT_REQUIREMENTS do
resource :projects, requirements: API::NAMESPACE_OR_PROJECT_REQUIREMENTS do
desc 'Get a project repository branches' do
success Entities::Branch
end
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment