Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Léo-Paul Géneau
gitlab-ce
Commits
c6181f97
Commit
c6181f97
authored
Feb 23, 2017
by
Jarka Kadlecova
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
API issues - support filtering by iids
parent
90040620
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
68 additions
and
1 deletion
+68
-1
changelogs/unreleased/28257-issues-iids.yml
changelogs/unreleased/28257-issues-iids.yml
+4
-0
doc/api/issues.md
doc/api/issues.md
+6
-1
lib/api/issues.rb
lib/api/issues.rb
+1
-0
spec/requests/api/issues_spec.rb
spec/requests/api/issues_spec.rb
+57
-0
No files found.
changelogs/unreleased/28257-issues-iids.yml
0 → 100644
View file @
c6181f97
---
title
:
API issues - support filtering by iids
merge_request
:
author
:
doc/api/issues.md
View file @
c6181f97
...
...
@@ -25,6 +25,7 @@ GET /issues?labels=foo,bar
GET /issues?labels=foo,bar&state=opened
GET /issues?milestone=1.0.0
GET /issues?milestone=1.0.0&state=opened
GET /issues?iids[]=42&iids[]=43
```
| Attribute | Type | Required | Description |
...
...
@@ -32,6 +33,7 @@ GET /issues?milestone=1.0.0&state=opened
|
`state`
| string | no | Return all issues or just those that are
`opened`
or
`closed`
|
|
`labels`
| string | no | Comma-separated list of label names, issues must have all labels to be returned |
|
`milestone`
| string| no | The milestone title |
|
`iids`
| Array[integer] | no | Return only the issues having the given
`iid`
|
|
`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`
|
...
...
@@ -102,6 +104,7 @@ GET /groups/:id/issues?labels=foo,bar
GET /groups/:id/issues?labels=foo,bar&state=opened
GET /groups/:id/issues?milestone=1.0.0
GET /groups/:id/issues?milestone=1.0.0&state=opened
GET /groups/:id/issues?iids[]=42&iids[]=43
```
| Attribute | Type | Required | Description |
...
...
@@ -109,6 +112,7 @@ GET /groups/:id/issues?milestone=1.0.0&state=opened
|
`id`
| integer | yes | The ID of a group |
|
`state`
| string | no | Return all issues or just those that are
`opened`
or
`closed`
|
|
`labels`
| string | no | Comma-separated list of label names, issues must have all labels to be returned |
|
`iids`
| Array[integer] | no | Return only the issues having the given
`iid`
|
|
`milestone`
| string| no | The milestone title |
|
`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`
|
...
...
@@ -181,12 +185,13 @@ GET /projects/:id/issues?labels=foo,bar
GET /projects/:id/issues?labels=foo,bar&state=opened
GET /projects/:id/issues?milestone=1.0.0
GET /projects/:id/issues?milestone=1.0.0&state=opened
GET /projects/:id/issues?iids[]=42&iids[]=43
```
| Attribute | Type | Required | Description |
| --------- | ---- | -------- | ----------- |
|
`id`
| integer | yes | The ID of a project |
|
`iid
`
| integer | no | Return the issu
e having the given
`iid`
|
|
`iid
s`
| Array[integer] | no | Return only the mileston
e having the given
`iid`
|
|
`state`
| string | no | Return all issues or just those that are
`opened`
or
`closed`
|
|
`labels`
| string | no | Comma-separated list of label names, issues must have all labels to be returned |
|
`milestone`
| string| no | The milestone title |
...
...
lib/api/issues.rb
View file @
c6181f97
...
...
@@ -25,6 +25,7 @@ module API
optional
:sort
,
type:
String
,
values:
%w[asc desc]
,
default:
'desc'
,
desc:
'Return issues sorted in `asc` or `desc` order.'
optional
:milestone
,
type:
String
,
desc:
'Return issues for a specific milestone'
optional
:iids
,
type:
Array
[
Integer
],
desc:
'The IID array of issues'
use
:pagination
end
...
...
spec/requests/api/issues_spec.rb
View file @
c6181f97
...
...
@@ -212,6 +212,25 @@ describe API::Issues, api: true do
expect
(
json_response
.
first
[
'id'
]).
to
eq
(
confidential_issue
.
id
)
end
it
'returns an array of issues found by iids'
do
get
api
(
'/issues'
,
user
),
iids:
[
closed_issue
.
iid
]
expect
(
response
).
to
have_http_status
(
200
)
expect
(
response
).
to
include_pagination_headers
expect
(
json_response
).
to
be_an
Array
expect
(
json_response
.
length
).
to
eq
(
1
)
expect
(
json_response
.
first
[
'id'
]).
to
eq
(
closed_issue
.
id
)
end
it
'returns an empty array if iid does not exist'
do
get
api
(
"/issues"
,
user
),
iids:
[
99999
]
expect
(
response
).
to
have_http_status
(
200
)
expect
(
response
).
to
include_pagination_headers
expect
(
json_response
).
to
be_an
Array
expect
(
json_response
.
length
).
to
eq
(
0
)
end
it
'sorts by created_at descending by default'
do
get
api
(
'/issues'
,
user
)
...
...
@@ -377,6 +396,25 @@ describe API::Issues, api: true do
expect
(
json_response
.
first
[
'labels'
]).
to
eq
([
label_c
.
title
,
label_b
.
title
,
group_label
.
title
])
end
it
'returns an array of issues found by iids'
do
get
api
(
base_url
,
user
),
iids:
[
group_issue
.
iid
]
expect
(
response
).
to
have_http_status
(
200
)
expect
(
response
).
to
include_pagination_headers
expect
(
json_response
).
to
be_an
Array
expect
(
json_response
.
length
).
to
eq
(
1
)
expect
(
json_response
.
first
[
'id'
]).
to
eq
(
group_issue
.
id
)
end
it
'returns an empty array if iid does not exist'
do
get
api
(
base_url
,
user
),
iids:
[
99999
]
expect
(
response
).
to
have_http_status
(
200
)
expect
(
response
).
to
include_pagination_headers
expect
(
json_response
).
to
be_an
Array
expect
(
json_response
.
length
).
to
eq
(
0
)
end
it
'returns an empty array if no group issue matches labels'
do
get
api
(
"
#{
base_url
}
?labels=foo,bar"
,
user
)
...
...
@@ -586,6 +624,25 @@ describe API::Issues, api: true do
expect
(
json_response
.
first
[
'labels'
]).
to
eq
([
label_c
.
title
,
label_b
.
title
,
label
.
title
])
end
it
'returns an array of issues found by iids'
do
get
api
(
"
#{
base_url
}
/issues"
,
user
),
iids:
[
issue
.
iid
]
expect
(
response
).
to
have_http_status
(
200
)
expect
(
response
).
to
include_pagination_headers
expect
(
json_response
).
to
be_an
Array
expect
(
json_response
.
length
).
to
eq
(
1
)
expect
(
json_response
.
first
[
'id'
]).
to
eq
(
issue
.
id
)
end
it
'returns an empty array if iid does not exist'
do
get
api
(
"
#{
base_url
}
/issues"
,
user
),
iids:
[
99999
]
expect
(
response
).
to
have_http_status
(
200
)
expect
(
response
).
to
include_pagination_headers
expect
(
json_response
).
to
be_an
Array
expect
(
json_response
.
length
).
to
eq
(
0
)
end
it
'returns an empty array if not all labels matches'
do
get
api
(
"
#{
base_url
}
/issues?labels=
#{
label
.
title
}
,foo"
,
user
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment