Commit 93d6f569 authored by Nick Thomas's avatar Nick Thomas
Browse files

Merge branch 'if-52811-fix_namespaces_api_routing' into 'master'

Fix API::Namespaces routing to accept namepaces with dots

See merge request gitlab-org/gitlab-ce!22912
parents 55447c09 b1e070bf
---
title: Fix API::Namespaces routing to accept namepaces with dots
merge_request: 22912
author:
type: fixed
...@@ -511,7 +511,7 @@ module EE ...@@ -511,7 +511,7 @@ module EE
params do params do
requires :id, type: String, desc: 'The ID of a project' requires :id, type: String, desc: 'The ID of a project'
end end
resource :projects, requirements: ::API::API::PROJECT_ENDPOINT_REQUIREMENTS do resource :projects, requirements: ::API::API::NAMESPACE_OR_PROJECT_REQUIREMENTS do
# ... # ...
end end
end end
......
...@@ -12,7 +12,7 @@ class AccessRequests < Grape::API ...@@ -12,7 +12,7 @@ class AccessRequests < Grape::API
params do params do
requires :id, type: String, desc: "The #{source_type} ID" requires :id, type: String, desc: "The #{source_type} ID"
end 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 desc "Gets a list of access requests for a #{source_type}." do
detail 'This feature was introduced in GitLab 8.11.' detail 'This feature was introduced in GitLab 8.11.'
success Entities::AccessRequester success Entities::AccessRequester
......
...@@ -7,8 +7,8 @@ class API < Grape::API ...@@ -7,8 +7,8 @@ class API < Grape::API
LOG_FILENAME = Rails.root.join("log", "api_json.log") LOG_FILENAME = Rails.root.join("log", "api_json.log")
NO_SLASH_URL_PART_REGEX = %r{[^/]+} NO_SLASH_URL_PART_REGEX = %r{[^/]+}
PROJECT_ENDPOINT_REQUIREMENTS = { id: NO_SLASH_URL_PART_REGEX }.freeze NAMESPACE_OR_PROJECT_REQUIREMENTS = { id: NO_SLASH_URL_PART_REGEX }.freeze
COMMIT_ENDPOINT_REQUIREMENTS = PROJECT_ENDPOINT_REQUIREMENTS.merge(sha: 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, insert_before Grape::Middleware::Error,
GrapeLogging::Middleware::RequestLogger, GrapeLogging::Middleware::RequestLogger,
......
...@@ -14,7 +14,7 @@ class AwardEmoji < Grape::API ...@@ -14,7 +14,7 @@ class AwardEmoji < Grape::API
params do params do
requires :id, type: String, desc: 'The ID of a project' requires :id, type: String, desc: 'The ID of a project'
end end
resource :projects, requirements: API::PROJECT_ENDPOINT_REQUIREMENTS do resource :projects, requirements: API::NAMESPACE_OR_PROJECT_REQUIREMENTS do
AWARDABLES.each do |awardable_params| AWARDABLES.each do |awardable_params|
awardable_string = awardable_params[:type].pluralize awardable_string = awardable_params[:type].pluralize
awardable_id_string = "#{awardable_params[:type]}_#{awardable_params[:find_by]}" awardable_id_string = "#{awardable_params[:type]}_#{awardable_params[:find_by]}"
......
...@@ -22,7 +22,7 @@ def find_source_if_admin(source_type) ...@@ -22,7 +22,7 @@ def find_source_if_admin(source_type)
params do params do
requires :id, type: String, desc: "The ID of a #{source_type}" requires :id, type: String, desc: "The ID of a #{source_type}"
end 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 desc "Gets a list of #{source_type} badges viewable by the authenticated user." do
detail 'This feature was introduced in GitLab 10.6.' detail 'This feature was introduced in GitLab 10.6.'
success Entities::Badge success Entities::Badge
......
...@@ -16,7 +16,7 @@ def board_parent ...@@ -16,7 +16,7 @@ def board_parent
params do params do
requires :id, type: String, desc: 'The ID of a project' requires :id, type: String, desc: 'The ID of a project'
end end
resource :projects, requirements: API::PROJECT_ENDPOINT_REQUIREMENTS do resource :projects, requirements: API::NAMESPACE_OR_PROJECT_REQUIREMENTS do
segment ':id/boards' do segment ':id/boards' do
desc 'Get all project boards' do desc 'Get all project boards' do
detail 'This feature was introduced in 8.13' detail 'This feature was introduced in 8.13'
......
...@@ -6,7 +6,7 @@ module API ...@@ -6,7 +6,7 @@ module API
class Branches < Grape::API class Branches < Grape::API
include PaginationParams 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 } before { authorize! :download_code, user_project }
...@@ -20,7 +20,7 @@ class Branches < Grape::API ...@@ -20,7 +20,7 @@ class Branches < Grape::API
params do params do
requires :id, type: String, desc: 'The ID of a project' requires :id, type: String, desc: 'The ID of a project'
end 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 desc 'Get a project repository branches' do
success Entities::Branch success Entities::Branch
end end
......
...@@ -7,7 +7,7 @@ class CommitStatuses < Grape::API ...@@ -7,7 +7,7 @@ class CommitStatuses < Grape::API
params do params do
requires :id, type: String, desc: 'The ID of a project' requires :id, type: String, desc: 'The ID of a project'
end end
resource :projects, requirements: API::PROJECT_ENDPOINT_REQUIREMENTS do resource :projects, requirements: API::NAMESPACE_OR_PROJECT_REQUIREMENTS do
include PaginationParams include PaginationParams
before { authenticate! } before { authenticate! }
......
...@@ -23,7 +23,7 @@ def authorize_push_to_branch!(branch) ...@@ -23,7 +23,7 @@ def authorize_push_to_branch!(branch)
params do params do
requires :id, type: String, desc: 'The ID of a project' requires :id, type: String, desc: 'The ID of a project'
end 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 desc 'Get a project repository commits' do
success Entities::Commit success Entities::Commit
end end
......
...@@ -31,7 +31,7 @@ def find_by_deploy_key(project, key_id) ...@@ -31,7 +31,7 @@ def find_by_deploy_key(project, key_id)
params do params do
requires :id, type: String, desc: 'The ID of the project' requires :id, type: String, desc: 'The ID of the project'
end end
resource :projects, requirements: API::PROJECT_ENDPOINT_REQUIREMENTS do resource :projects, requirements: API::NAMESPACE_OR_PROJECT_REQUIREMENTS do
before { authorize_admin_project } before { authorize_admin_project }
desc "Get a specific project's deploy keys" do desc "Get a specific project's deploy keys" do
......
...@@ -10,7 +10,7 @@ class Deployments < Grape::API ...@@ -10,7 +10,7 @@ class Deployments < Grape::API
params do params do
requires :id, type: String, desc: 'The project ID' requires :id, type: String, desc: 'The project ID'
end 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 desc 'Get all deployments of the project' do
detail 'This feature was introduced in GitLab 8.11.' detail 'This feature was introduced in GitLab 8.11.'
success Entities::Deployment success Entities::Deployment
......
...@@ -17,7 +17,7 @@ class Discussions < Grape::API ...@@ -17,7 +17,7 @@ class Discussions < Grape::API
params do params do
requires :id, type: String, desc: "The ID of a #{parent_type}" requires :id, type: String, desc: "The ID of a #{parent_type}"
end 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 desc "Get a list of #{noteable_type.to_s.downcase} discussions" do
success Entities::Discussion success Entities::Discussion
end end
......
...@@ -11,7 +11,7 @@ class Environments < Grape::API ...@@ -11,7 +11,7 @@ class Environments < Grape::API
params do params do
requires :id, type: String, desc: 'The project ID' requires :id, type: String, desc: 'The project ID'
end 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 desc 'Get all environments of the project' do
detail 'This feature was introduced in GitLab 8.11.' detail 'This feature was introduced in GitLab 8.11.'
success Entities::Environment success Entities::Environment
......
...@@ -97,7 +97,7 @@ def present_events(events, redact: true) ...@@ -97,7 +97,7 @@ def present_events(events, redact: true)
params do params do
requires :id, type: String, desc: 'The ID of a project' requires :id, type: String, desc: 'The ID of a project'
end 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 desc "List a Project's visible events" do
success Entities::Event success Entities::Event
end end
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
module API module API
class Files < Grape::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 # Prevents returning plain/text responses for files with .txt extension
after_validation { content_type "application/json" } after_validation { content_type "application/json" }
......
...@@ -19,7 +19,7 @@ def board_parent ...@@ -19,7 +19,7 @@ def board_parent
requires :id, type: String, desc: 'The ID of a group' requires :id, type: String, desc: 'The ID of a group'
end end
resource :groups, requirements: API::PROJECT_ENDPOINT_REQUIREMENTS do resource :groups, requirements: API::NAMESPACE_OR_PROJECT_REQUIREMENTS do
segment ':id/boards' do segment ':id/boards' do
desc 'Find a group board' do desc 'Find a group board' do
detail 'This feature was introduced in 10.6' detail 'This feature was introduced in 10.6'
......
...@@ -12,7 +12,7 @@ class GroupMilestones < Grape::API ...@@ -12,7 +12,7 @@ class GroupMilestones < Grape::API
params do params do
requires :id, type: String, desc: 'The ID of a group' requires :id, type: String, desc: 'The ID of a group'
end 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 desc 'Get a list of group milestones' do
success Entities::Milestone success Entities::Milestone
end end
......
...@@ -11,7 +11,7 @@ class GroupVariables < Grape::API ...@@ -11,7 +11,7 @@ class GroupVariables < Grape::API
requires :id, type: String, desc: 'The ID of a group' requires :id, type: String, desc: 'The ID of a group'
end end
resource :groups, requirements: API::PROJECT_ENDPOINT_REQUIREMENTS do resource :groups, requirements: API::NAMESPACE_OR_PROJECT_REQUIREMENTS do
desc 'Get group-level variables' do desc 'Get group-level variables' do
success Entities::Variable success Entities::Variable
end end
......
...@@ -140,7 +140,7 @@ def present_groups(params, groups) ...@@ -140,7 +140,7 @@ def present_groups(params, groups)
params do params do
requires :id, type: String, desc: 'The ID of a group' requires :id, type: String, desc: 'The ID of a group'
end 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 desc 'Update a group. Available only for users who can administrate groups.' do
success Entities::Group success Entities::Group
end end
......
...@@ -101,7 +101,7 @@ def find_issues(args = {}) ...@@ -101,7 +101,7 @@ def find_issues(args = {})
params do params do
requires :id, type: String, desc: 'The ID of a group' requires :id, type: String, desc: 'The ID of a group'
end end
resource :groups, requirements: API::PROJECT_ENDPOINT_REQUIREMENTS do resource :groups, requirements: API::NAMESPACE_OR_PROJECT_REQUIREMENTS do
desc 'Get a list of group issues' do desc 'Get a list of group issues' do
success Entities::IssueBasic success Entities::IssueBasic
end end
...@@ -128,7 +128,7 @@ def find_issues(args = {}) ...@@ -128,7 +128,7 @@ def find_issues(args = {})
params do params do
requires :id, type: String, desc: 'The ID of a project' requires :id, type: String, desc: 'The ID of a project'
end end
resource :projects, requirements: API::PROJECT_ENDPOINT_REQUIREMENTS do resource :projects, requirements: API::NAMESPACE_OR_PROJECT_REQUIREMENTS do
include TimeTrackingEndpoints include TimeTrackingEndpoints
desc 'Get a list of project issues' do desc 'Get a list of project issues' do
......
...@@ -14,7 +14,7 @@ def authorize_download_artifacts! ...@@ -14,7 +14,7 @@ def authorize_download_artifacts!
params do params do
requires :id, type: String, desc: 'The ID of a project' requires :id, type: String, desc: 'The ID of a project'
end end
resource :projects, requirements: API::PROJECT_ENDPOINT_REQUIREMENTS do resource :projects, requirements: API::NAMESPACE_OR_PROJECT_REQUIREMENTS do
desc 'Download the artifacts archive from a job' do desc 'Download the artifacts archive from a job' do
detail 'This feature was introduced in GitLab 8.10' detail 'This feature was introduced in GitLab 8.10'
end end
......
...@@ -9,7 +9,7 @@ class Jobs < Grape::API ...@@ -9,7 +9,7 @@ class Jobs < Grape::API
params do params do
requires :id, type: String, desc: 'The ID of a project' requires :id, type: String, desc: 'The ID of a project'
end end
resource :projects, requirements: API::PROJECT_ENDPOINT_REQUIREMENTS do resource :projects, requirements: API::NAMESPACE_OR_PROJECT_REQUIREMENTS do
helpers do helpers do
params :optional_scope do params :optional_scope do
optional :scope, types: [String, Array[String]], desc: 'The scope of builds to show', optional :scope, types: [String, Array[String]], desc: 'The scope of builds to show',
......
...@@ -9,7 +9,7 @@ class Labels < Grape::API ...@@ -9,7 +9,7 @@ class Labels < Grape::API
params do params do
requires :id, type: String, desc: 'The ID of a project' requires :id, type: String, desc: 'The ID of a project'
end end
resource :projects, requirements: API::PROJECT_ENDPOINT_REQUIREMENTS do resource :projects, requirements: API::NAMESPACE_OR_PROJECT_REQUIREMENTS do
desc 'Get all labels of the project' do desc 'Get all labels of the project' do
success Entities::Label success Entities::Label
end end
......
...@@ -12,7 +12,7 @@ class Members < Grape::API ...@@ -12,7 +12,7 @@ class Members < Grape::API
params do params do
requires :id, type: String, desc: "The #{source_type} ID" requires :id, type: String, desc: "The #{source_type} ID"
end 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 group or project members viewable by the authenticated user.' do desc 'Gets a list of group or project members viewable by the authenticated user.' do
success Entities::Member success Entities::Member
end end
......
...@@ -10,7 +10,7 @@ class MergeRequestDiffs < Grape::API ...@@ -10,7 +10,7 @@ class MergeRequestDiffs < Grape::API
params do params do
requires :id, type: String, desc: 'The ID of a project' requires :id, type: String, desc: 'The ID of a project'
end end
resource :projects, requirements: API::PROJECT_ENDPOINT_REQUIREMENTS do resource :projects, requirements: API::NAMESPACE_OR_PROJECT_REQUIREMENTS do
desc 'Get a list of merge request diff versions' do desc 'Get a list of merge request diff versions' do
detail 'This feature was introduced in GitLab 8.12.' detail 'This feature was introduced in GitLab 8.12.'
success Entities::MergeRequestDiff success Entities::MergeRequestDiff
......
...@@ -135,7 +135,7 @@ def authorize_push_to_merge_request!(merge_request) ...@@ -135,7 +135,7 @@ def authorize_push_to_merge_request!(merge_request)
params do params do
requires :id, type: String, desc: 'The ID of a group' requires :id, type: String, desc: 'The ID of a group'
end end
resource :groups, requirements: API::PROJECT_ENDPOINT_REQUIREMENTS do resource :groups, requirements: API::NAMESPACE_OR_PROJECT_REQUIREMENTS do
desc 'Get a list of group merge requests' do desc 'Get a list of group merge requests' do
success Entities::MergeRequestBasic success Entities::MergeRequestBasic
end end
...@@ -154,7 +154,7 @@ def authorize_push_to_merge_request!(merge_request) ...@@ -154,7 +154,7 @@ def authorize_push_to_merge_request!(merge_request)
params do params do
requires :id, type: String, desc: 'The ID of a project' requires :id, type: String, desc: 'The ID of a project'
end end
resource :projects, requirements: API::PROJECT_ENDPOINT_REQUIREMENTS do resource :projects, requirements: API::NAMESPACE_OR_PROJECT_REQUIREMENTS do
include TimeTrackingEndpoints include TimeTrackingEndpoints
helpers do helpers do
......
...@@ -28,7 +28,7 @@ class Namespaces < Grape::API ...@@ -28,7 +28,7 @@ class Namespaces < Grape::API
params do params do
requires :id, type: String, desc: "Namespace's ID or path" requires :id, type: String, desc: "Namespace's ID or path"
end end
get ':id' do get ':id', requirements: API::NAMESPACE_OR_PROJECT_REQUIREMENTS do
present user_namespace, with: Entities::Namespace, current_user: current_user present user_namespace, with: Entities::Namespace, current_user: current_user
end end
end end
......
...@@ -16,7 +16,7 @@ class Notes < Grape::API ...@@ -16,7 +16,7 @@ class Notes < Grape::API
params do params do
requires :id, type: String, desc: "The ID of a #{parent_type}" requires :id, type: String, desc: "The ID of a #{parent_type}"
end 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
noteables_str = noteable_type.to_s.underscore.pluralize noteables_str = noteable_type.to_s.underscore.pluralize
desc "Get a list of #{noteable_type.to_s.downcase} notes" do desc "Get a list of #{noteable_type.to_s.downcase} notes" do
......
...@@ -58,7 +58,7 @@ class NotificationSettings < Grape::API ...@@ -58,7 +58,7 @@ class NotificationSettings < Grape::API
params do params do
requires :id, type: String, desc: "The #{source_type} ID" requires :id, type: String, desc: "The #{source_type} ID"
end end
resource source_type.pluralize, requirements: API::PROJECT_ENDPOINT_REQUIREMENTS do resource source_type.pluralize, requirements: API::NAMESPACE_OR_PROJECT_REQUIREMENTS do
desc "Get #{source_type} level notification level settings, defaults to Global" do desc "Get #{source_type} level notification level settings, defaults to Global" do
detail 'This feature was introduced in GitLab 8.12' detail 'This feature was introduced in GitLab 8.12'
success Entities::NotificationSetting success Entities::NotificationSetting
......
...@@ -4,7 +4,7 @@ module API ...@@ -4,7 +4,7 @@ module API
class PagesDomains < Grape::API class PagesDomains < Grape::API
include PaginationParams include PaginationParams
PAGES_DOMAINS_ENDPOINT_REQUIREMENTS = API::PROJECT_ENDPOINT_REQUIREMENTS.merge(domain: API::NO_SLASH_URL_PART_REGEX) PAGES_DOMAINS_ENDPOINT_REQUIREMENTS = API::NAMESPACE_OR_PROJECT_REQUIREMENTS.merge(domain: API::NO_SLASH_URL_PART_REGEX)
before do before do
authenticate! authenticate!
...@@ -54,7 +54,7 @@ def normalize_params_file_to_string ...@@ -54,7 +54,7 @@ def normalize_params_file_to_string
params do params do
requires :id, type: String, desc: 'The ID of a project' requires :id, type: String, desc: 'The ID of a project'
end end
resource :projects, requirements: API::PROJECT_ENDPOINT_REQUIREMENTS do resource :projects, requirements: API::NAMESPACE_OR_PROJECT_REQUIREMENTS do
before do before do
require_pages_enabled! require_pages_enabled!
end end
......
...@@ -9,7 +9,7 @@ class PipelineSchedules < Grape::API ...@@ -9,7 +9,7 @@ class PipelineSchedules < Grape::API
params do params do
requires :id, type: String, desc: 'The ID of a project' requires :id, type: String, desc: 'The ID of a project'
end end
resource :projects, requirements: API::PROJECT_ENDPOINT_REQUIREMENTS do resource :projects, requirements: API::NAMESPACE_OR_PROJECT_REQUIREMENTS do
desc 'Get all pipeline schedules' do desc 'Get all pipeline schedules' do
success Entities::PipelineSchedule success Entities::PipelineSchedule
end end
......
...@@ -9,7 +9,7 @@ class Pipelines < Grape::API ...@@ -9,7 +9,7 @@ class Pipelines < Grape::API
params do params do
requires :id, type: String, desc: 'The project ID' requires :id, type: String, desc: 'The project ID'
end end
resource :projects, requirements: API::PROJECT_ENDPOINT_REQUIREMENTS do resource :projects, requirements: API::NAMESPACE_OR_PROJECT_REQUIREMENTS do
desc 'Get all Pipelines of the project' do desc 'Get all Pipelines of the project' do
detail 'This feature was introduced in GitLab 8.11.' detail 'This feature was introduced in GitLab 8.11.'
success Entities::PipelineBasic success Entities::PipelineBasic
......
...@@ -29,7 +29,7 @@ class ProjectHooks < Grape::API ...@@ -29,7 +29,7 @@ class ProjectHooks < Grape::API
params do params do
requires :id, type: String, desc: 'The ID of a project' requires :id, type: String, desc: 'The ID of a project'
end end
resource :projects, requirements: API::PROJECT_ENDPOINT_REQUIREMENTS do resource :projects, requirements: API::NAMESPACE_OR_PROJECT_REQUIREMENTS do
desc 'Get project hooks' do desc 'Get project hooks' do
success Entities::ProjectHook success Entities::ProjectHook
end end
......
...@@ -23,7 +23,7 @@ def validate_file! ...@@ -23,7 +23,7 @@ def validate_file!
forbidden! unless Gitlab::CurrentSettings.import_sources.include?('gitlab_project') forbidden! unless Gitlab::CurrentSettings.import_sources.include?('gitlab_project')
end end
resource :projects, requirements: API::PROJECT_ENDPOINT_REQUIREMENTS do resource :projects, requirements: API::NAMESPACE_OR_PROJECT_REQUIREMENTS do
params do params do
requires :path, type: String, desc: 'The new project path and name' requires :path, type: String, desc: 'The new project path and name'
requires :file, type: File, desc: 'The project export file to be imported' requires :file, type: File, desc: 'The project export file to be imported'
......
...@@ -12,7 +12,7 @@ class ProjectMilestones < Grape::API ...@@ -12,7 +12,7 @@ class ProjectMilestones < Grape::API
params do params do
requires :id, type: String, desc: 'The ID of a project' requires :id, type: String, desc: 'The ID of a project'
end end
resource :projects, requirements: API::PROJECT_ENDPOINT_REQUIREMENTS do resource :projects, requirements: API::NAMESPACE_OR_PROJECT_REQUIREMENTS do
desc 'Get a list of project milestones' do desc 'Get a list of project milestones' do
success Entities::Milestone success Entities::Milestone
end end
......
...@@ -9,7 +9,7 @@ class ProjectSnippets < Grape::API ...@@ -9,7 +9,7 @@ class ProjectSnippets < Grape::API
params do params do
requires :id, type: String, desc: 'The ID of a project' requires :id, type: String, desc: 'The ID of a project'
end end
resource :projects, requirements: API::PROJECT_ENDPOINT_REQUIREMENTS do resource :projects, requirements: API::NAMESPACE_OR_PROJECT_REQUIREMENTS do
helpers do helpers do
def handle_project_member_errors(errors) def handle_project_member_errors(errors)
if errors[:project_access].any? if errors[:project_access].any?
......
...@@ -128,7 +128,7 @@ def translate_params_for_compatibility(params) ...@@ -128,7 +128,7 @@ def translate_params_for_compatibility(params)
end end