Commit faf95438 authored by Stan Hu's avatar Stan Hu

Use view=simple for simplifying merge requests API

parent e17ac570
......@@ -25,7 +25,7 @@ Parameters:
| `order_by`| string | no | Return requests ordered by `created_at` or `updated_at` fields. Default is `created_at` |
| `sort` | string | no | Return requests sorted in `asc` or `desc` order. Default is `desc` |
| `milestone` | string | no | Return merge requests for a specific milestone |
| `simple` | boolean | no | Returns the `iid`, URL, title, description, and basic state of merge request |
| `view` | string | no | If `simple`, returns the `iid`, URL, title, description, and basic state of merge request |
| `labels` | string | no | Return merge requests matching a comma separated list of labels |
| `created_after` | datetime | no | Return merge requests created after the given time (inclusive) |
| `created_before` | datetime | no | Return merge requests created before the given time (inclusive) |
......
......@@ -48,7 +48,7 @@ module API
merge_requests = paginate(merge_requests)
.preload(:target_project)
return merge_requests if params[:simple]
return merge_requests if args[:view] == 'simple'
merge_requests
.preload(:notes, :author, :assignee, :milestone, :merge_request_diff, :labels)
......@@ -82,7 +82,7 @@ module API
optional :labels, type: String, desc: 'Comma-separated list of label names'
optional :created_after, type: DateTime, desc: 'Return merge requests created after the specified time'
optional :created_before, type: DateTime, desc: 'Return merge requests created before the specified time'
optional :simple, type: Boolean, default: false, desc: 'Returns the `iid`, URL, title, description, and basic state of merge request'
optional :view, type: String, values: %w[simple], desc: 'If simple, returns the `iid`, URL, title, description, and basic state of merge request'
use :pagination
end
get ":id/merge_requests" do
......@@ -94,7 +94,7 @@ module API
current_user: current_user,
project: user_project }
if params[:simple]
if params[:view] == 'simple'
options[:with] = Entities::MergeRequestSimple
else
options[:issuable_metadata] = issuable_meta_data(merge_requests, 'MergeRequest')
......
......@@ -70,7 +70,7 @@ describe API::MergeRequests do
end
it "returns an array of all merge_requests using simple mode" do
get api("/projects/#{project.id}/merge_requests?simple=true", user)
get api("/projects/#{project.id}/merge_requests?view=simple", user)
expect(response).to have_http_status(200)
expect(response).to include_pagination_headers
......
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