Commit b58af356 authored by Gary Holtz's avatar Gary Holtz

Adding documentation, a changelog, and review suggestions

parent 01b811ca
---
title: Add a commit message parameter for the suggestion endpoints
merge_request: 51245
author:
type: added
......@@ -21,6 +21,7 @@ PUT /suggestions/:id/apply
| Attribute | Type | Required | Description |
| --------- | ---- | -------- | ----------- |
| `id` | integer/string | yes | The ID of a suggestion |
| `commit_message` | string | no | A custom commit message to use instead of the default generated message or the project's default message |
```shell
curl --request PUT --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/suggestions/5/apply"
......
......@@ -12,13 +12,13 @@ module API
end
params do
requires :id, type: String, desc: 'The suggestion ID'
optional :message, type: String, desc: 'A commit message to use instead of the default generated message or project default message'
optional :commit_message, type: String, desc: "A custom commit message to use instead of the default generated message or the project's default message"
end
put ':id/apply' do
suggestion = Suggestion.find_by_id(params[:id])
if suggestion
apply_suggestions(suggestion, current_user, params[:message])
apply_suggestions(suggestion, current_user, params[:commit_message])
else
render_api_error!(_('Suggestion is not applicable as the suggestion was not found.'), :not_found)
end
......@@ -29,7 +29,7 @@ module API
end
params do
requires :ids, type: Array[Integer], coerce_with: ::API::Validations::Types::CommaSeparatedToIntegerArray.coerce, desc: "An array of suggestion ID's"
optional :message, type: String, desc: 'A commit message to use instead of the default generated message or project default message'
optional :commit_message, type: String, desc: "A custom commit message to use instead of the default generated message or the project's default message"
end
put 'batch_apply' do
ids = params[:ids]
......@@ -37,7 +37,7 @@ module API
suggestions = Suggestion.id_in(ids)
if suggestions.size == ids.length
apply_suggestions(suggestions, current_user, params[:message])
apply_suggestions(suggestions, current_user, params[:commit_message])
else
render_api_error!(_('Suggestions are not applicable as one or more suggestions were not found.'), :not_found)
end
......
......@@ -71,7 +71,7 @@ RSpec.describe API::Suggestions do
message = "cool custom commit message!"
put api(url, user), params: { message: message }
put api(url, user), params: { commit_message: message }
expect(response).to have_gitlab_http_status(:ok)
expect(project.repository.commit.message).to eq(message)
......@@ -143,7 +143,7 @@ RSpec.describe API::Suggestions do
message = "cool custom commit message!"
put api(url, user), params: { ids: [suggestion.id, suggestion2.id],
message: message }
commit_message: message }
expect(response).to have_gitlab_http_status(:ok)
expect(project.repository.commit.message).to eq(message)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment