summaryrefslogtreecommitdiff
path: root/lib/api/files.rb
diff options
context:
space:
mode:
Diffstat (limited to 'lib/api/files.rb')
-rw-r--r--lib/api/files.rb10
1 files changed, 7 insertions, 3 deletions
diff --git a/lib/api/files.rb b/lib/api/files.rb
index 521287ee2b4..e2ac7142bc4 100644
--- a/lib/api/files.rb
+++ b/lib/api/files.rb
@@ -1,10 +1,13 @@
module API
class Files < Grape::API
+ # Prevents returning plain/text responses for files with .txt extension
+ after_validation { content_type "application/json" }
+
helpers do
def commit_params(attrs)
{
file_path: attrs[:file_path],
- start_branch: attrs[:branch],
+ start_branch: attrs[:start_branch] || attrs[:branch],
branch_name: attrs[:branch],
commit_message: attrs[:commit_message],
file_content: attrs[:content],
@@ -37,8 +40,9 @@ module API
params :simple_file_params do
requires :file_path, type: String, desc: 'The url encoded path to the file. Ex. lib%2Fclass%2Erb'
- requires :branch, type: String, desc: 'The name of branch'
- requires :commit_message, type: String, desc: 'Commit Message'
+ requires :branch, type: String, desc: 'Name of the branch to commit into. To create a new branch, also provide `start_branch`.'
+ requires :commit_message, type: String, desc: 'Commit message'
+ optional :start_branch, type: String, desc: 'Name of the branch to start the new commit from'
optional :author_email, type: String, desc: 'The email of the author'
optional :author_name, type: String, desc: 'The name of the author'
end