Commit 4cb6a9bb authored by Andy Soiron's avatar Andy Soiron Committed by Dmytro Zaporozhets

Return slug in /api/v4/projects/ID/services

parent df14a8b0
---
title: Add slug to services API response
merge_request: 22518
author:
type: added
...@@ -19,6 +19,7 @@ Example response: ...@@ -19,6 +19,7 @@ Example response:
{ {
"id": 75, "id": 75,
"title": "Jenkins CI", "title": "Jenkins CI",
"slug": "jenkins",
"created_at": "2019-11-20T11:20:25.297Z", "created_at": "2019-11-20T11:20:25.297Z",
"updated_at": "2019-11-20T12:24:37.498Z", "updated_at": "2019-11-20T12:24:37.498Z",
"active": true, "active": true,
...@@ -38,6 +39,7 @@ Example response: ...@@ -38,6 +39,7 @@ Example response:
{ {
"id": 76, "id": 76,
"title": "Alerts endpoint", "title": "Alerts endpoint",
"slug": "alerts",
"created_at": "2019-11-20T11:20:25.297Z", "created_at": "2019-11-20T11:20:25.297Z",
"updated_at": "2019-11-20T12:24:37.498Z", "updated_at": "2019-11-20T12:24:37.498Z",
"active": true, "active": true,
...@@ -753,6 +755,7 @@ Example response: ...@@ -753,6 +755,7 @@ Example response:
{ {
"id": 4, "id": 4,
"title": "Slack slash commands", "title": "Slack slash commands",
"slug": "slack-slash-commands",
"created_at": "2017-06-27T05:51:39-07:00", "created_at": "2017-06-27T05:51:39-07:00",
"updated_at": "2017-06-27T05:51:39-07:00", "updated_at": "2017-06-27T05:51:39-07:00",
"active": true, "active": true,
......
...@@ -1129,7 +1129,11 @@ module API ...@@ -1129,7 +1129,11 @@ module API
end end
class ProjectServiceBasic < Grape::Entity class ProjectServiceBasic < Grape::Entity
expose :id, :title, :created_at, :updated_at, :active expose :id, :title
expose :slug do |service|
service.to_param.dasherize
end
expose :created_at, :updated_at, :active
expose :commit_events, :push_events, :issues_events, :confidential_issues_events expose :commit_events, :push_events, :issues_events, :confidential_issues_events
expose :merge_requests_events, :tag_push_events, :note_events expose :merge_requests_events, :tag_push_events, :note_events
expose :confidential_note_events, :pipeline_events, :wiki_page_events expose :confidential_note_events, :pipeline_events, :wiki_page_events
......
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
"properties": { "properties": {
"id": { "type": "integer" }, "id": { "type": "integer" },
"title": { "type": "string" }, "title": { "type": "string" },
"slug": { "type": "string" },
"created_at": { "type": "date-time" }, "created_at": { "type": "date-time" },
"updated_at": { "type": "date-time" }, "updated_at": { "type": "date-time" },
"active": { "type": "boolean" }, "active": { "type": "boolean" },
......
...@@ -35,6 +35,7 @@ describe API::Services do ...@@ -35,6 +35,7 @@ describe API::Services do
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(200)
expect(json_response).to be_an Array expect(json_response).to be_an Array
expect(json_response.count).to eq(1) expect(json_response.count).to eq(1)
expect(json_response.first['slug']).to eq('emails-on-push')
expect(response).to match_response_schema('public_api/v4/services') expect(response).to match_response_schema('public_api/v4/services')
end end
end end
...@@ -61,6 +62,7 @@ describe API::Services do ...@@ -61,6 +62,7 @@ describe API::Services do
put api("/projects/#{project.id}/services/#{dashed_service}?#{query_strings}", user), params: service_attrs put api("/projects/#{project.id}/services/#{dashed_service}?#{query_strings}", user), params: service_attrs
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(200)
expect(json_response['slug']).to eq(dashed_service)
events.each do |event| events.each do |event|
next if event == "foo" next if event == "foo"
......
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