Add missing description of label on API (#7159)

* add missing description of label on API

* fix comment head

* fix swagger
This commit is contained in:
Lunny Xiao 2019-06-16 20:39:52 +08:00 committed by GitHub
parent 367aeb169a
commit d8168b356d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 32 additions and 11 deletions

View file

@ -79,6 +79,7 @@ func (label *Label) APIFormat() *api.Label {
ID: label.ID, ID: label.ID,
Name: label.Name, Name: label.Name,
Color: strings.TrimLeft(label.Color, "#"), Color: strings.TrimLeft(label.Color, "#"),
Description: label.Description,
} }
} }

View file

@ -1,4 +1,5 @@
// Copyright 2016 The Gogs Authors. All rights reserved. // 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 // Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
@ -11,6 +12,7 @@ type Label struct {
Name string `json:"name"` Name string `json:"name"`
// example: 00aabb // example: 00aabb
Color string `json:"color"` Color string `json:"color"`
Description string `json:"description"`
URL string `json:"url"` URL string `json:"url"`
} }
@ -21,12 +23,14 @@ type CreateLabelOption struct {
// required:true // required:true
// example: #00aabb // 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 // EditLabelOption options for editing a label
type EditLabelOption struct { type EditLabelOption struct {
Name *string `json:"name"` Name *string `json:"name"`
Color *string `json:"color"` Color *string `json:"color"`
Description *string `json:"description"`
} }
// IssueLabelsOption a collection of labels // IssueLabelsOption a collection of labels

View file

@ -128,6 +128,7 @@ func CreateLabel(ctx *context.APIContext, form api.CreateLabelOption) {
Name: form.Name, Name: form.Name,
Color: form.Color, Color: form.Color,
RepoID: ctx.Repo.Repository.ID, RepoID: ctx.Repo.Repository.ID,
Description: form.Description,
} }
if err := models.NewLabel(label); err != nil { if err := models.NewLabel(label); err != nil {
ctx.Error(500, "NewLabel", err) ctx.Error(500, "NewLabel", err)
@ -185,6 +186,9 @@ func EditLabel(ctx *context.APIContext, form api.EditLabelOption) {
if form.Color != nil { if form.Color != nil {
label.Color = *form.Color label.Color = *form.Color
} }
if form.Description != nil {
label.Description = *form.Description
}
if err := models.UpdateLabel(label); err != nil { if err := models.UpdateLabel(label); err != nil {
ctx.ServerError("UpdateLabel", err) ctx.ServerError("UpdateLabel", err)
return return

View file

@ -7245,6 +7245,10 @@
"x-go-name": "Color", "x-go-name": "Color",
"example": "#00aabb" "example": "#00aabb"
}, },
"description": {
"type": "string",
"x-go-name": "Description"
},
"name": { "name": {
"type": "string", "type": "string",
"x-go-name": "Name" "x-go-name": "Name"
@ -7775,6 +7779,10 @@
"type": "string", "type": "string",
"x-go-name": "Color" "x-go-name": "Color"
}, },
"description": {
"type": "string",
"x-go-name": "Description"
},
"name": { "name": {
"type": "string", "type": "string",
"x-go-name": "Name" "x-go-name": "Name"
@ -8663,6 +8671,10 @@
"x-go-name": "Color", "x-go-name": "Color",
"example": "00aabb" "example": "00aabb"
}, },
"description": {
"type": "string",
"x-go-name": "Description"
},
"id": { "id": {
"type": "integer", "type": "integer",
"format": "int64", "format": "int64",