Commit 422aa5a6 authored by Rémy Coutable's avatar Rémy Coutable

[API] Fix URLs in the 'Link' header for 'GET...

[API] Fix URLs in the 'Link' header for 'GET /projects/:id/repository/contributors' when no value is passed for 'order_by' or 'sort'
Signed-off-by: default avatarRémy Coutable <remy@rymai.me>
parent 4ed152e4
---
title: '[API] Fix URLs in the `Link` header for `GET /projects/:id/repository/contributors`
when no value is passed for `order_by` or `sort`'
merge_request: 18393
author:
type: fixed
...@@ -183,7 +183,7 @@ GET /projects/:id/repository/contributors ...@@ -183,7 +183,7 @@ GET /projects/:id/repository/contributors
Parameters: Parameters:
- `id` (required) - The ID or [URL-encoded path of the project](README.md#namespaced-path-encoding) owned by the authenticated user - `id` (required) - The ID or [URL-encoded path of the project](README.md#namespaced-path-encoding) owned by the authenticated user
- `order_by` (optional) - Return contributors ordered by `name`, `email`, or `commits` fields. If not given contributors are ordered by commit date. - `order_by` (optional) - Return contributors ordered by `name`, `email`, or `commits` (orders by commit date) fields. Default is `commits`
- `sort` (optional) - Return contributors sorted in `asc` or `desc` order. Default is `asc` - `sort` (optional) - Return contributors sorted in `asc` or `desc` order. Default is `asc`
Response: Response:
......
...@@ -111,8 +111,8 @@ module API ...@@ -111,8 +111,8 @@ module API
end end
params do params do
use :pagination use :pagination
optional :order_by, type: String, values: %w[email name commits], default: nil, desc: 'Return contributors ordered by `name` or `email` or `commits`' optional :order_by, type: String, values: %w[email name commits], default: 'commits', desc: 'Return contributors ordered by `name` or `email` or `commits`'
optional :sort, type: String, values: %w[asc desc], default: nil, desc: 'Sort by asc (ascending) or desc (descending)' optional :sort, type: String, values: %w[asc desc], default: 'asc', desc: 'Sort by asc (ascending) or desc (descending)'
end end
get ':id/repository/contributors' do get ':id/repository/contributors' do
begin begin
......
...@@ -427,5 +427,20 @@ describe API::Repositories do ...@@ -427,5 +427,20 @@ describe API::Repositories do
let(:request) { get api(route, guest) } let(:request) { get api(route, guest) }
end end
end end
# Regression: https://gitlab.com/gitlab-org/gitlab-ce/issues/45363
describe 'Links header contains working URLs when no `order_by` nor `sort` is given' do
let(:project) { create(:project, :public, :repository) }
let(:current_user) { nil }
it 'returns `Link` header that includes URLs with default value for `order_by` & `sort`' do
get api(route, current_user)
first_link_url = response.headers['Link'].split(';').first
expect(first_link_url).to include('order_by=commits')
expect(first_link_url).to include('sort=asc')
end
end
end end
end end
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