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
Jérome Perrin
gitlab-ce
Commits
93f4234d
Commit
93f4234d
authored
Nov 07, 2016
by
Sean McGivern
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'add-api-label-id' into 'master'
Expose Label id to API Closes #23448 See merge request !7275
parents
6f307295
63f0b099
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
111 additions
and
90 deletions
+111
-90
changelogs/unreleased/add-api-label-id.yml
changelogs/unreleased/add-api-label-id.yml
+4
-0
doc/api/labels.md
doc/api/labels.md
+100
-89
lib/api/entities.rb
lib/api/entities.rb
+1
-1
spec/requests/api/labels_spec.rb
spec/requests/api/labels_spec.rb
+6
-0
No files found.
changelogs/unreleased/add-api-label-id.yml
0 → 100644
View file @
93f4234d
---
title
:
Expose label IDs in API
merge_request
:
7275
author
:
Rares Sfirlogea
doc/api/labels.md
View file @
93f4234d
...
@@ -20,56 +20,61 @@ Example response:
...
@@ -20,56 +20,61 @@ Example response:
```
json
```
json
[
[
{
{
"name"
:
"bug"
,
"id"
:
1
,
"color"
:
"#d9534f"
,
"name"
:
"bug"
,
"description"
:
"Bug reported by user"
,
"color"
:
"#d9534f"
,
"open_issues_count"
:
1
,
"description"
:
"Bug reported by user"
,
"closed_issues_count"
:
0
,
"open_issues_count"
:
1
,
"open_merge_requests_count"
:
1
,
"closed_issues_count"
:
0
,
"subscribed"
:
false
,
"open_merge_requests_count"
:
1
,
"priority"
:
10
"subscribed"
:
false
,
},
"priority"
:
10
{
},
"color"
:
"#d9534f"
,
{
"name"
:
"confirmed"
,
"id"
:
4
,
"description"
:
"Confirmed issue"
,
"color"
:
"#d9534f"
,
"open_issues_count"
:
2
,
"name"
:
"confirmed"
,
"closed_issues_count"
:
5
,
"description"
:
"Confirmed issue"
,
"open_merge_requests_count"
:
0
,
"open_issues_count"
:
2
,
"subscribed"
:
false
,
"closed_issues_count"
:
5
,
"priority"
:
null
"open_merge_requests_count"
:
0
,
},
"subscribed"
:
false
,
{
"priority"
:
null
"name"
:
"critical"
,
},
"color"
:
"#d9534f"
,
{
"description"
:
"Critical issue. Need fix ASAP"
,
"id"
:
7
,
"open_issues_count"
:
1
,
"name"
:
"critical"
,
"closed_issues_count"
:
3
,
"color"
:
"#d9534f"
,
"open_merge_requests_count"
:
1
,
"description"
:
"Critical issue. Need fix ASAP"
,
"subscribed"
:
false
,
"open_issues_count"
:
1
,
"priority"
:
null
"closed_issues_count"
:
3
,
},
"open_merge_requests_count"
:
1
,
{
"subscribed"
:
false
,
"name"
:
"documentation"
,
"priority"
:
null
"color"
:
"#f0ad4e"
,
},
"description"
:
"Issue about documentation"
,
{
"open_issues_count"
:
1
,
"id"
:
8
,
"closed_issues_count"
:
0
,
"name"
:
"documentation"
,
"open_merge_requests_count"
:
2
,
"color"
:
"#f0ad4e"
,
"subscribed"
:
false
,
"description"
:
"Issue about documentation"
,
"priority"
:
null
"open_issues_count"
:
1
,
},
"closed_issues_count"
:
0
,
{
"open_merge_requests_count"
:
2
,
"color"
:
"#5cb85c"
,
"subscribed"
:
false
,
"name"
:
"enhancement"
,
"priority"
:
null
"description"
:
"Enhancement proposal"
,
},
"open_issues_count"
:
1
,
{
"closed_issues_count"
:
0
,
"id"
:
9
,
"open_merge_requests_count"
:
1
,
"color"
:
"#5cb85c"
,
"subscribed"
:
false
,
"name"
:
"enhancement"
,
"priority"
:
null
"description"
:
"Enhancement proposal"
,
}
"open_issues_count"
:
1
,
"closed_issues_count"
:
0
,
"open_merge_requests_count"
:
1
,
"subscribed"
:
true
,
"priority"
:
null
}
]
]
```
```
...
@@ -100,13 +105,15 @@ Example response:
...
@@ -100,13 +105,15 @@ Example response:
```
json
```
json
{
{
"name"
:
"feature"
,
"id"
:
10
,
"color"
:
"#5843AD"
,
"name"
:
"feature"
,
"open_issues_count"
:
1
,
"color"
:
"#5843AD"
,
"closed_issues_count"
:
0
,
"description"
:
null
,
"open_merge_requests_count"
:
1
,
"open_issues_count"
:
0
,
"description"
:
null
,
"closed_issues_count"
:
0
,
"priority"
:
null
"open_merge_requests_count"
:
0
,
"subscribed"
:
false
,
"priority"
:
null
}
}
```
```
...
@@ -135,15 +142,15 @@ Example response:
...
@@ -135,15 +142,15 @@ Example response:
```
json
```
json
{
{
"title"
:
"feature"
,
"id"
:
1
,
"color"
:
"#5843AD
"
,
"name"
:
"bug
"
,
"description"
:
"New feature proposal
"
,
"color"
:
"#d9534f
"
,
"updated_at"
:
"2015-11-03T21:22:30.737Z
"
,
"description"
:
"Bug reported by user
"
,
"template"
:
false
,
"open_issues_count"
:
1
,
"project_id"
:
1
,
"closed_issues_count"
:
0
,
"created_at"
:
"2015-11-03T21:22:30.737Z"
,
"open_merge_requests_count"
:
1
,
"id"
:
9
,
"subscribed"
:
false
,
"priority"
:
null
"priority"
:
null
}
}
```
```
...
@@ -178,13 +185,15 @@ Example response:
...
@@ -178,13 +185,15 @@ Example response:
```
json
```
json
{
{
"color"
:
"#8E44AD"
,
"id"
:
8
,
"name"
:
"docs"
,
"name"
:
"docs"
,
"description"
:
"Documentation"
,
"color"
:
"#8E44AD"
,
"open_issues_count"
:
1
,
"description"
:
"Documentation"
,
"closed_issues_count"
:
0
,
"open_issues_count"
:
1
,
"open_merge_requests_count"
:
1
,
"closed_issues_count"
:
0
,
"priority"
:
null
"open_merge_requests_count"
:
2
,
"subscribed"
:
false
,
"priority"
:
null
}
}
```
```
...
@@ -213,14 +222,15 @@ Example response:
...
@@ -213,14 +222,15 @@ Example response:
```
json
```
json
{
{
"name"
:
"Docs"
,
"id"
:
1
,
"color"
:
"#cc0033"
,
"name"
:
"bug"
,
"description"
:
""
,
"color"
:
"#d9534f"
,
"open_issues_count"
:
0
,
"description"
:
"Bug reported by user"
,
"closed_issues_count"
:
0
,
"open_issues_count"
:
1
,
"open_merge_requests_count"
:
0
,
"closed_issues_count"
:
0
,
"subscribed"
:
true
,
"open_merge_requests_count"
:
1
,
"priority"
:
null
"subscribed"
:
true
,
"priority"
:
null
}
}
```
```
...
@@ -249,13 +259,14 @@ Example response:
...
@@ -249,13 +259,14 @@ Example response:
```
json
```
json
{
{
"name"
:
"Docs"
,
"id"
:
1
,
"color"
:
"#cc0033"
,
"name"
:
"bug"
,
"description"
:
""
,
"color"
:
"#d9534f"
,
"open_issues_count"
:
0
,
"description"
:
"Bug reported by user"
,
"closed_issues_count"
:
0
,
"open_issues_count"
:
1
,
"open_merge_requests_count"
:
0
,
"closed_issues_count"
:
0
,
"subscribed"
:
false
,
"open_merge_requests_count"
:
1
,
"priority"
:
null
"subscribed"
:
false
,
"priority"
:
null
}
}
```
```
lib/api/entities.rb
View file @
93f4234d
...
@@ -433,7 +433,7 @@ module API
...
@@ -433,7 +433,7 @@ module API
end
end
class
LabelBasic
<
Grape
::
Entity
class
LabelBasic
<
Grape
::
Entity
expose
:name
,
:color
,
:description
expose
:
id
,
:
name
,
:color
,
:description
end
end
class
Label
<
LabelBasic
class
Label
<
LabelBasic
...
...
spec/requests/api/labels_spec.rb
View file @
93f4234d
...
@@ -17,12 +17,18 @@ describe API::API, api: true do
...
@@ -17,12 +17,18 @@ describe API::API, api: true do
group
=
create
(
:group
)
group
=
create
(
:group
)
group_label
=
create
(
:group_label
,
group:
group
)
group_label
=
create
(
:group_label
,
group:
group
)
project
.
update
(
group:
group
)
project
.
update
(
group:
group
)
expected_keys
=
[
'id'
,
'name'
,
'color'
,
'description'
,
'open_issues_count'
,
'closed_issues_count'
,
'open_merge_requests_count'
,
'subscribed'
,
'priority'
]
get
api
(
"/projects/
#{
project
.
id
}
/labels"
,
user
)
get
api
(
"/projects/
#{
project
.
id
}
/labels"
,
user
)
expect
(
response
).
to
have_http_status
(
200
)
expect
(
response
).
to
have_http_status
(
200
)
expect
(
json_response
).
to
be_an
Array
expect
(
json_response
).
to
be_an
Array
expect
(
json_response
.
size
).
to
eq
(
3
)
expect
(
json_response
.
size
).
to
eq
(
3
)
expect
(
json_response
.
first
.
keys
).
to
match_array
expected_keys
expect
(
json_response
.
map
{
|
l
|
l
[
'name'
]
}).
to
match_array
([
group_label
.
name
,
priority_label
.
name
,
label1
.
name
])
expect
(
json_response
.
map
{
|
l
|
l
[
'name'
]
}).
to
match_array
([
group_label
.
name
,
priority_label
.
name
,
label1
.
name
])
expect
(
json_response
.
last
[
'name'
]).
to
eq
(
label1
.
name
)
expect
(
json_response
.
last
[
'name'
]).
to
eq
(
label1
.
name
)
expect
(
json_response
.
last
[
'color'
]).
to
be_present
expect
(
json_response
.
last
[
'color'
]).
to
be_present
...
...
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