diff options
Diffstat (limited to 'lib/api/project_snippets.rb')
-rw-r--r-- | lib/api/project_snippets.rb | 60 |
1 files changed, 30 insertions, 30 deletions
diff --git a/lib/api/project_snippets.rb b/lib/api/project_snippets.rb index a607df411a6..416cc7bc084 100644 --- a/lib/api/project_snippets.rb +++ b/lib/api/project_snippets.rb @@ -7,7 +7,7 @@ module API before { authenticate! } params do - requires :id, type: String, desc: 'The ID of a project' + requires :id, type: String, desc: "The ID of a project" end resource :projects, requirements: API::NAMESPACE_OR_PROJECT_REQUIREMENTS do helpers do @@ -24,7 +24,7 @@ module API end end - desc 'Get all project snippets' do + desc "Get all project snippets" do success Entities::ProjectSnippet end params do @@ -34,28 +34,28 @@ module API present paginate(snippets_for_current_user), with: Entities::ProjectSnippet end - desc 'Get a single project snippet' do + desc "Get a single project snippet" do success Entities::ProjectSnippet end params do - requires :snippet_id, type: Integer, desc: 'The ID of a project snippet' + requires :snippet_id, type: Integer, desc: "The ID of a project snippet" end get ":id/snippets/:snippet_id" do snippet = snippets_for_current_user.find(params[:snippet_id]) present snippet, with: Entities::ProjectSnippet end - desc 'Create a new project snippet' do + desc "Create a new project snippet" do success Entities::ProjectSnippet end params do - requires :title, type: String, desc: 'The title of the snippet' - requires :file_name, type: String, desc: 'The file name of the snippet' - requires :code, type: String, allow_blank: false, desc: 'The content of the snippet' - optional :description, type: String, desc: 'The description of a snippet' + requires :title, type: String, desc: "The title of the snippet" + requires :file_name, type: String, desc: "The file name of the snippet" + requires :code, type: String, allow_blank: false, desc: "The content of the snippet" + optional :description, type: String, desc: "The description of a snippet" requires :visibility, type: String, values: Gitlab::VisibilityLevel.string_values, - desc: 'The visibility of the snippet' + desc: "The visibility of the snippet" end post ":id/snippets" do authorize! :create_project_snippet, user_project @@ -73,24 +73,24 @@ module API end end - desc 'Update an existing project snippet' do + desc "Update an existing project snippet" do success Entities::ProjectSnippet end params do - requires :snippet_id, type: Integer, desc: 'The ID of a project snippet' - optional :title, type: String, desc: 'The title of the snippet' - optional :file_name, type: String, desc: 'The file name of the snippet' - optional :code, type: String, allow_blank: false, desc: 'The content of the snippet' - optional :description, type: String, desc: 'The description of a snippet' + requires :snippet_id, type: Integer, desc: "The ID of a project snippet" + optional :title, type: String, desc: "The title of the snippet" + optional :file_name, type: String, desc: "The file name of the snippet" + optional :code, type: String, allow_blank: false, desc: "The content of the snippet" + optional :description, type: String, desc: "The description of a snippet" optional :visibility, type: String, values: Gitlab::VisibilityLevel.string_values, - desc: 'The visibility of the snippet' + desc: "The visibility of the snippet" at_least_one_of :title, :file_name, :code, :visibility_level end # rubocop: disable CodeReuse/ActiveRecord put ":id/snippets/:snippet_id" do snippet = snippets_for_current_user.find_by(id: params.delete(:snippet_id)) - not_found!('Snippet') unless snippet + not_found!("Snippet") unless snippet authorize! :update_project_snippet, snippet @@ -100,7 +100,7 @@ module API snippet_params[:content] = snippet_params.delete(:code) if snippet_params[:code].present? UpdateSnippetService.new(user_project, current_user, snippet, - snippet_params).execute + snippet_params).execute render_spam_error! if snippet.spam? @@ -112,14 +112,14 @@ module API end # rubocop: enable CodeReuse/ActiveRecord - desc 'Delete a project snippet' + desc "Delete a project snippet" params do - requires :snippet_id, type: Integer, desc: 'The ID of a project snippet' + requires :snippet_id, type: Integer, desc: "The ID of a project snippet" end # rubocop: disable CodeReuse/ActiveRecord delete ":id/snippets/:snippet_id" do snippet = snippets_for_current_user.find_by(id: params[:snippet_id]) - not_found!('Snippet') unless snippet + not_found!("Snippet") unless snippet authorize! :admin_project_snippet, snippet @@ -127,26 +127,26 @@ module API end # rubocop: enable CodeReuse/ActiveRecord - desc 'Get a raw project snippet' + desc "Get a raw project snippet" params do - requires :snippet_id, type: Integer, desc: 'The ID of a project snippet' + requires :snippet_id, type: Integer, desc: "The ID of a project snippet" end # rubocop: disable CodeReuse/ActiveRecord get ":id/snippets/:snippet_id/raw" do snippet = snippets_for_current_user.find_by(id: params[:snippet_id]) - not_found!('Snippet') unless snippet + not_found!("Snippet") unless snippet - env['api.format'] = :txt - content_type 'text/plain' + env["api.format"] = :txt + content_type "text/plain" present snippet.content end # rubocop: enable CodeReuse/ActiveRecord - desc 'Get the user agent details for a project snippet' do + desc "Get the user agent details for a project snippet" do success Entities::UserAgentDetail end params do - requires :snippet_id, type: Integer, desc: 'The ID of a project snippet' + requires :snippet_id, type: Integer, desc: "The ID of a project snippet" end # rubocop: disable CodeReuse/ActiveRecord get ":id/snippets/:snippet_id/user_agent_detail" do @@ -154,7 +154,7 @@ module API snippet = Snippet.find_by!(id: params[:snippet_id], project_id: params[:id]) - break not_found!('UserAgentDetail') unless snippet.user_agent_detail + break not_found!("UserAgentDetail") unless snippet.user_agent_detail present snippet.user_agent_detail, with: Entities::UserAgentDetail end |