From 385433d2f4522690ae01ff262e6c8952d88d75af Mon Sep 17 00:00:00 2001 From: Jochen Peters Date: Sat, 5 Sep 2020 13:58:33 +0200 Subject: [PATCH] additional data for type StopWatch in swagger api (#12458) * additional data for type StopWatch in swagger api * fix lint-backend issue with gofmt * fix format in v1_json with 'make generate-swagger' * using issue.LoadRepo() instead of getRepositoryByID() Co-authored-by: jochen@homeland Co-authored-by: zeripath --- models/issue_stopwatch.go | 10 ++++++++-- modules/structs/issue_stopwatch.go | 7 +++++-- templates/swagger/v1_json.tmpl | 12 ++++++++++++ 3 files changed, 25 insertions(+), 4 deletions(-) diff --git a/models/issue_stopwatch.go b/models/issue_stopwatch.go index 79ce48c4c..f80ce4139 100644 --- a/models/issue_stopwatch.go +++ b/models/issue_stopwatch.go @@ -201,9 +201,15 @@ func (sw *Stopwatch) APIFormat() (api.StopWatch, error) { if err != nil { return api.StopWatch{}, err } + if err := issue.LoadRepo(); err != nil { + return api.StopWatch{}, err + } return api.StopWatch{ - Created: sw.CreatedUnix.AsTime(), - IssueIndex: issue.Index, + Created: sw.CreatedUnix.AsTime(), + IssueIndex: issue.Index, + IssueTitle: issue.Title, + RepoOwnerName: issue.Repo.OwnerName, + RepoName: issue.Repo.Name, }, nil } diff --git a/modules/structs/issue_stopwatch.go b/modules/structs/issue_stopwatch.go index 10510e36e..8599e0727 100644 --- a/modules/structs/issue_stopwatch.go +++ b/modules/structs/issue_stopwatch.go @@ -11,8 +11,11 @@ import ( // StopWatch represent a running stopwatch type StopWatch struct { // swagger:strfmt date-time - Created time.Time `json:"created"` - IssueIndex int64 `json:"issue_index"` + Created time.Time `json:"created"` + IssueIndex int64 `json:"issue_index"` + IssueTitle string `json:"issue_title"` + RepoOwnerName string `json:"repo_owner_name"` + RepoName string `json:"repo_name"` } // StopWatches represent a list of stopwatches diff --git a/templates/swagger/v1_json.tmpl b/templates/swagger/v1_json.tmpl index 3c563aa67..09acd3a0a 100644 --- a/templates/swagger/v1_json.tmpl +++ b/templates/swagger/v1_json.tmpl @@ -14698,6 +14698,18 @@ "type": "integer", "format": "int64", "x-go-name": "IssueIndex" + }, + "issue_title": { + "type": "string", + "x-go-name": "IssueTitle" + }, + "repo_name": { + "type": "string", + "x-go-name": "RepoName" + }, + "repo_owner_name": { + "type": "string", + "x-go-name": "RepoOwnerName" } }, "x-go-package": "code.gitea.io/gitea/modules/structs"