fix: StateType and TimeStamp are strings, not empty structs

Swagger spec didn't define these properly. StateType is "open"|"closed",
TimeStamp is a date string. Both were generated as struct{} which fails
to unmarshal JSON. Also change from pointer to value type in Issue, PR,
Milestone, Notification structs.

Co-Authored-By: Virgil <virgil@lethean.io>
This commit is contained in:
Snider 2026-03-22 14:07:10 +00:00
parent c7c279fc17
commit 33eb5bc91a
5 changed files with 8 additions and 10 deletions

View file

@ -30,11 +30,9 @@ type Permission struct {
Push bool `json:"push,omitempty"`
}
// StateType — StateType issue state type
// StateType has no fields in the swagger spec.
type StateType struct{}
// StateType is the state of an issue or PR: "open", "closed".
type StateType string
// TimeStamp — TimeStamp defines a timestamp
// TimeStamp has no fields in the swagger spec.
type TimeStamp struct{}
// TimeStamp is a Forgejo timestamp string.
type TimeStamp string

View file

@ -71,7 +71,7 @@ type Issue struct {
PullRequest *PullRequestMeta `json:"pull_request,omitempty"`
Ref string `json:"ref,omitempty"`
Repository *RepositoryMeta `json:"repository,omitempty"`
State *StateType `json:"state,omitempty"`
State StateType `json:"state,omitempty"`
Title string `json:"title,omitempty"`
URL string `json:"url,omitempty"`
Updated time.Time `json:"updated_at,omitempty"`

View file

@ -30,7 +30,7 @@ type Milestone struct {
Description string `json:"description,omitempty"`
ID int64 `json:"id,omitempty"`
OpenIssues int64 `json:"open_issues,omitempty"`
State *StateType `json:"state,omitempty"`
State StateType `json:"state,omitempty"`
Title string `json:"title,omitempty"`
Updated time.Time `json:"updated_at,omitempty"`
}

View file

@ -15,7 +15,7 @@ type NotificationSubject struct {
HTMLURL string `json:"html_url,omitempty"`
LatestCommentHTMLURL string `json:"latest_comment_html_url,omitempty"`
LatestCommentURL string `json:"latest_comment_url,omitempty"`
State *StateType `json:"state,omitempty"`
State StateType `json:"state,omitempty"`
Title string `json:"title,omitempty"`
Type *NotifySubjectType `json:"type,omitempty"`
URL string `json:"url,omitempty"`

View file

@ -87,7 +87,7 @@ type PullRequest struct {
RequestedReviewers []*User `json:"requested_reviewers,omitempty"`
RequestedReviewersTeams []*Team `json:"requested_reviewers_teams,omitempty"`
ReviewComments int64 `json:"review_comments,omitempty"` // number of review comments made on the diff of a PR review (not including comments on commits or issues in a PR)
State *StateType `json:"state,omitempty"`
State StateType `json:"state,omitempty"`
Title string `json:"title,omitempty"`
URL string `json:"url,omitempty"`
Updated time.Time `json:"updated_at,omitempty"`