From 33eb5bc91a45052816d48b995363418e769938f8 Mon Sep 17 00:00:00 2001 From: Snider Date: Sun, 22 Mar 2026 14:07:10 +0000 Subject: [PATCH] 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 --- types/common.go | 10 ++++------ types/issue.go | 2 +- types/milestone.go | 2 +- types/notification.go | 2 +- types/pr.go | 2 +- 5 files changed, 8 insertions(+), 10 deletions(-) diff --git a/types/common.go b/types/common.go index df9223c..f25b84f 100644 --- a/types/common.go +++ b/types/common.go @@ -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 diff --git a/types/issue.go b/types/issue.go index 841f6ae..f411c8e 100644 --- a/types/issue.go +++ b/types/issue.go @@ -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"` diff --git a/types/milestone.go b/types/milestone.go index 6d294d5..fab5844 100644 --- a/types/milestone.go +++ b/types/milestone.go @@ -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"` } diff --git a/types/notification.go b/types/notification.go index 3d84aa7..dccc380 100644 --- a/types/notification.go +++ b/types/notification.go @@ -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"` diff --git a/types/pr.go b/types/pr.go index 6aa28ed..274d649 100644 --- a/types/pr.go +++ b/types/pr.go @@ -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"`