aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLunny Xiao <xiaolunwen@gmail.com>2019-06-16 20:39:52 +0800
committerGitHub <noreply@github.com>2019-06-16 20:39:52 +0800
commitd8168b356d3ddaf3c38815a46ab075bf5bbe93c6 (patch)
tree96d31b185042027171574e6a370c90f6b3b0e508
parent367aeb169ac9f213a047bad24bbb3a4f58e3362a (diff)
downloadgitea-d8168b356d3ddaf3c38815a46ab075bf5bbe93c6.tar.gz
gitea-d8168b356d3ddaf3c38815a46ab075bf5bbe93c6.zip
Add missing description of label on API (#7159)
* add missing description of label on API * fix comment head * fix swagger
-rw-r--r--models/issue_label.go7
-rw-r--r--modules/structs/issue_label.go14
-rw-r--r--routers/api/v1/repo/label.go10
-rw-r--r--templates/swagger/v1_json.tmpl12
4 files changed, 32 insertions, 11 deletions
diff --git a/models/issue_label.go b/models/issue_label.go
index 363d4bb814..7af6060f87 100644
--- a/models/issue_label.go
+++ b/models/issue_label.go
@@ -76,9 +76,10 @@ type Label struct {
// APIFormat converts a Label to the api.Label format
func (label *Label) APIFormat() *api.Label {
return &api.Label{
- ID: label.ID,
- Name: label.Name,
- Color: strings.TrimLeft(label.Color, "#"),
+ ID: label.ID,
+ Name: label.Name,
+ Color: strings.TrimLeft(label.Color, "#"),
+ Description: label.Description,
}
}
diff --git a/modules/structs/issue_label.go b/modules/structs/issue_label.go
index f0821fbaf5..0789624ab1 100644
--- a/modules/structs/issue_label.go
+++ b/modules/structs/issue_label.go
@@ -1,4 +1,5 @@
// Copyright 2016 The Gogs Authors. All rights reserved.
+// Copyright 2019 The Gitea Authors. All rights reserved.
// Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file.
@@ -10,8 +11,9 @@ type Label struct {
ID int64 `json:"id"`
Name string `json:"name"`
// example: 00aabb
- Color string `json:"color"`
- URL string `json:"url"`
+ Color string `json:"color"`
+ Description string `json:"description"`
+ URL string `json:"url"`
}
// CreateLabelOption options for creating a label
@@ -20,13 +22,15 @@ type CreateLabelOption struct {
Name string `json:"name" binding:"Required"`
// required:true
// example: #00aabb
- Color string `json:"color" binding:"Required;Size(7)"`
+ Color string `json:"color" binding:"Required;Size(7)"`
+ Description string `json:"description"`
}
// EditLabelOption options for editing a label
type EditLabelOption struct {
- Name *string `json:"name"`
- Color *string `json:"color"`
+ Name *string `json:"name"`
+ Color *string `json:"color"`
+ Description *string `json:"description"`
}
// IssueLabelsOption a collection of labels
diff --git a/routers/api/v1/repo/label.go b/routers/api/v1/repo/label.go
index 1cd8890ca9..98ccee37bd 100644
--- a/routers/api/v1/repo/label.go
+++ b/routers/api/v1/repo/label.go
@@ -125,9 +125,10 @@ func CreateLabel(ctx *context.APIContext, form api.CreateLabelOption) {
// "201":
// "$ref": "#/responses/Label"
label := &models.Label{
- Name: form.Name,
- Color: form.Color,
- RepoID: ctx.Repo.Repository.ID,
+ Name: form.Name,
+ Color: form.Color,
+ RepoID: ctx.Repo.Repository.ID,
+ Description: form.Description,
}
if err := models.NewLabel(label); err != nil {
ctx.Error(500, "NewLabel", err)
@@ -185,6 +186,9 @@ func EditLabel(ctx *context.APIContext, form api.EditLabelOption) {
if form.Color != nil {
label.Color = *form.Color
}
+ if form.Description != nil {
+ label.Description = *form.Description
+ }
if err := models.UpdateLabel(label); err != nil {
ctx.ServerError("UpdateLabel", err)
return
diff --git a/templates/swagger/v1_json.tmpl b/templates/swagger/v1_json.tmpl
index 6f9585fae2..6c2708dd96 100644
--- a/templates/swagger/v1_json.tmpl
+++ b/templates/swagger/v1_json.tmpl
@@ -7245,6 +7245,10 @@
"x-go-name": "Color",
"example": "#00aabb"
},
+ "description": {
+ "type": "string",
+ "x-go-name": "Description"
+ },
"name": {
"type": "string",
"x-go-name": "Name"
@@ -7775,6 +7779,10 @@
"type": "string",
"x-go-name": "Color"
},
+ "description": {
+ "type": "string",
+ "x-go-name": "Description"
+ },
"name": {
"type": "string",
"x-go-name": "Name"
@@ -8663,6 +8671,10 @@
"x-go-name": "Color",
"example": "00aabb"
},
+ "description": {
+ "type": "string",
+ "x-go-name": "Description"
+ },
"id": {
"type": "integer",
"format": "int64",