Skip to content
Snippets Groups Projects
Unverified Commit b1e070bf 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 1cd570cf
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
@@ -12,7 +12,7 @@ module 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 @@ module 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 @@ module 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 @@ module API
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
@@ -16,7 +16,7 @@ module 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
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 @@ module 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
Loading
Loading
@@ -7,7 +7,7 @@ module 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
include PaginationParams
 
before { authenticate! }
Loading
Loading
Loading
Loading
@@ -23,7 +23,7 @@ module 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 commits' do
success Entities::Commit
end
Loading
Loading
Loading
Loading
@@ -31,7 +31,7 @@ module API
params do
requires :id, type: String, desc: 'The ID of the project'
end
resource :projects, requirements: API::PROJECT_ENDPOINT_REQUIREMENTS do
resource :projects, requirements: API::NAMESPACE_OR_PROJECT_REQUIREMENTS do
before { authorize_admin_project }
 
desc "Get a specific project's deploy keys" do
Loading
Loading
Loading
Loading
@@ -10,7 +10,7 @@ module API
params do
requires :id, type: String, desc: 'The project ID'
end
resource :projects, requirements: API::PROJECT_ENDPOINT_REQUIREMENTS do
resource :projects, requirements: API::NAMESPACE_OR_PROJECT_REQUIREMENTS do
desc 'Get all deployments of the project' do
detail 'This feature was introduced in GitLab 8.11.'
success Entities::Deployment
Loading
Loading
Loading
Loading
@@ -17,7 +17,7 @@ module API
params do
requires :id, type: String, desc: "The ID of a #{parent_type}"
end
resource parent_type.pluralize.to_sym, requirements: API::PROJECT_ENDPOINT_REQUIREMENTS do
resource parent_type.pluralize.to_sym, requirements: API::NAMESPACE_OR_PROJECT_REQUIREMENTS do
desc "Get a list of #{noteable_type.to_s.downcase} discussions" do
success Entities::Discussion
end
Loading
Loading
Loading
Loading
@@ -11,7 +11,7 @@ module API
params do
requires :id, type: String, desc: 'The project ID'
end
resource :projects, requirements: API::PROJECT_ENDPOINT_REQUIREMENTS do
resource :projects, requirements: API::NAMESPACE_OR_PROJECT_REQUIREMENTS do
desc 'Get all environments of the project' do
detail 'This feature was introduced in GitLab 8.11.'
success Entities::Environment
Loading
Loading
Loading
Loading
@@ -97,7 +97,7 @@ module 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 "List a Project's visible events" do
success Entities::Event
end
Loading
Loading
Loading
Loading
@@ -2,7 +2,7 @@
 
module API
class Files < Grape::API
FILE_ENDPOINT_REQUIREMENTS = API::PROJECT_ENDPOINT_REQUIREMENTS.merge(file_path: API::NO_SLASH_URL_PART_REGEX)
FILE_ENDPOINT_REQUIREMENTS = API::NAMESPACE_OR_PROJECT_REQUIREMENTS.merge(file_path: API::NO_SLASH_URL_PART_REGEX)
 
# Prevents returning plain/text responses for files with .txt extension
after_validation { content_type "application/json" }
Loading
Loading
Loading
Loading
@@ -19,7 +19,7 @@ module API
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
segment ':id/boards' do
desc 'Find a group board' do
detail 'This feature was introduced in 10.6'
Loading
Loading
Loading
Loading
@@ -12,7 +12,7 @@ module API
params do
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 a list of group milestones' do
success Entities::Milestone
end
Loading
Loading
Loading
Loading
@@ -11,7 +11,7 @@ module API
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 group-level variables' do
success Entities::Variable
end
Loading
Loading
Loading
Loading
@@ -140,7 +140,7 @@ module API
params do
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 a group. Available only for users who can administrate groups.' do
success Entities::Group
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