Skip to content

Commit 385433d

Browse files
Jochen Petersjochen@homelandzeripath
authored
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 <no-go@localhost> Co-authored-by: zeripath <[email protected]>
1 parent dba5d82 commit 385433d

File tree

3 files changed

+25
-4
lines changed

3 files changed

+25
-4
lines changed

models/issue_stopwatch.go

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -201,9 +201,15 @@ func (sw *Stopwatch) APIFormat() (api.StopWatch, error) {
201201
if err != nil {
202202
return api.StopWatch{}, err
203203
}
204+
if err := issue.LoadRepo(); err != nil {
205+
return api.StopWatch{}, err
206+
}
204207
return api.StopWatch{
205-
Created: sw.CreatedUnix.AsTime(),
206-
IssueIndex: issue.Index,
208+
Created: sw.CreatedUnix.AsTime(),
209+
IssueIndex: issue.Index,
210+
IssueTitle: issue.Title,
211+
RepoOwnerName: issue.Repo.OwnerName,
212+
RepoName: issue.Repo.Name,
207213
}, nil
208214
}
209215

modules/structs/issue_stopwatch.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,11 @@ import (
1111
// StopWatch represent a running stopwatch
1212
type StopWatch struct {
1313
// swagger:strfmt date-time
14-
Created time.Time `json:"created"`
15-
IssueIndex int64 `json:"issue_index"`
14+
Created time.Time `json:"created"`
15+
IssueIndex int64 `json:"issue_index"`
16+
IssueTitle string `json:"issue_title"`
17+
RepoOwnerName string `json:"repo_owner_name"`
18+
RepoName string `json:"repo_name"`
1619
}
1720

1821
// StopWatches represent a list of stopwatches

templates/swagger/v1_json.tmpl

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14698,6 +14698,18 @@
1469814698
"type": "integer",
1469914699
"format": "int64",
1470014700
"x-go-name": "IssueIndex"
14701+
},
14702+
"issue_title": {
14703+
"type": "string",
14704+
"x-go-name": "IssueTitle"
14705+
},
14706+
"repo_name": {
14707+
"type": "string",
14708+
"x-go-name": "RepoName"
14709+
},
14710+
"repo_owner_name": {
14711+
"type": "string",
14712+
"x-go-name": "RepoOwnerName"
1470114713
}
1470214714
},
1470314715
"x-go-package": "code.gitea.io/gitea/modules/structs"

0 commit comments

Comments
 (0)