From 851d567776f3e1cadf12b171662c8d0f8ab2c256 Mon Sep 17 00:00:00 2001 From: Gusted Date: Fri, 9 Aug 2024 23:36:03 +0200 Subject: [PATCH] [CHORE] Fix swagger deprecation message - Fix "WARNING: item list for enum is not a valid JSON array, using the old deprecated format" messages from https://github.com/go-swagger/go-swagger in the CI. --- modules/structs/activity.go | 2 +- modules/structs/attachment.go | 2 +- modules/structs/hook.go | 2 +- modules/structs/issue.go | 2 +- modules/structs/issue_milestone.go | 2 +- modules/structs/org.go | 4 ++-- modules/structs/org_team.go | 6 +++--- modules/structs/repo.go | 8 ++++---- modules/structs/repo_collaborator.go | 2 +- modules/structs/repo_file.go | 2 +- services/forms/repo_form.go | 2 +- 11 files changed, 17 insertions(+), 17 deletions(-) diff --git a/modules/structs/activity.go b/modules/structs/activity.go index ea27fbfd77..1bb83135c3 100644 --- a/modules/structs/activity.go +++ b/modules/structs/activity.go @@ -10,7 +10,7 @@ type Activity struct { UserID int64 `json:"user_id"` // Receiver user // the type of action // - // enum: create_repo,rename_repo,star_repo,watch_repo,commit_repo,create_issue,create_pull_request,transfer_repo,push_tag,comment_issue,merge_pull_request,close_issue,reopen_issue,close_pull_request,reopen_pull_request,delete_tag,delete_branch,mirror_sync_push,mirror_sync_create,mirror_sync_delete,approve_pull_request,reject_pull_request,comment_pull,publish_release,pull_review_dismissed,pull_request_ready_for_review,auto_merge_pull_request + // enum: ["create_repo", "rename_repo", "star_repo", "watch_repo", "commit_repo", "create_issue", "create_pull_request", "transfer_repo", "push_tag", "comment_issue", "merge_pull_request", "close_issue", "reopen_issue", "close_pull_request", "reopen_pull_request", "delete_tag", "delete_branch", "mirror_sync_push", "mirror_sync_create", "mirror_sync_delete", "approve_pull_request", "reject_pull_request", "comment_pull", "publish_release", "pull_review_dismissed", "pull_request_ready_for_review", "auto_merge_pull_request"] OpType string `json:"op_type"` ActUserID int64 `json:"act_user_id"` ActUser *User `json:"act_user"` diff --git a/modules/structs/attachment.go b/modules/structs/attachment.go index c8a2c6634b..c97cdcb83c 100644 --- a/modules/structs/attachment.go +++ b/modules/structs/attachment.go @@ -18,7 +18,7 @@ type Attachment struct { Created time.Time `json:"created_at"` UUID string `json:"uuid"` DownloadURL string `json:"browser_download_url"` - // Enum: attachment,external + // enum: ["attachment", "external"] Type string `json:"type"` } diff --git a/modules/structs/hook.go b/modules/structs/hook.go index bb40aa06c0..b7f8861b76 100644 --- a/modules/structs/hook.go +++ b/modules/structs/hook.go @@ -45,7 +45,7 @@ type CreateHookOptionConfig map[string]string // CreateHookOption options when create a hook type CreateHookOption struct { // required: true - // enum: forgejo,dingtalk,discord,gitea,gogs,msteams,slack,telegram,feishu,wechatwork,packagist + // enum: ["forgejo", "dingtalk", "discord", "gitea", "gogs", "msteams", "slack", "telegram", "feishu", "wechatwork", "packagist"] Type string `json:"type" binding:"Required"` // required: true Config CreateHookOptionConfig `json:"config" binding:"Required"` diff --git a/modules/structs/issue.go b/modules/structs/issue.go index 7ba7f77158..a67bdcf50e 100644 --- a/modules/structs/issue.go +++ b/modules/structs/issue.go @@ -63,7 +63,7 @@ type Issue struct { // Whether the issue is open or closed // // type: string - // enum: open,closed + // enum: ["open", "closed"] State StateType `json:"state"` IsLocked bool `json:"is_locked"` Comments int `json:"comments"` diff --git a/modules/structs/issue_milestone.go b/modules/structs/issue_milestone.go index a840cf1820..051824469a 100644 --- a/modules/structs/issue_milestone.go +++ b/modules/structs/issue_milestone.go @@ -31,7 +31,7 @@ type CreateMilestoneOption struct { Description string `json:"description"` // swagger:strfmt date-time Deadline *time.Time `json:"due_on"` - // enum: open,closed + // enum: ["open", "closed"] State string `json:"state"` } diff --git a/modules/structs/org.go b/modules/structs/org.go index c0a545ac1c..b2b2c61a01 100644 --- a/modules/structs/org.go +++ b/modules/structs/org.go @@ -38,7 +38,7 @@ type CreateOrgOption struct { Website string `json:"website" binding:"ValidUrl;MaxSize(255)"` Location string `json:"location" binding:"MaxSize(50)"` // possible values are `public` (default), `limited` or `private` - // enum: public,limited,private + // enum: ["public", "limited", "private"] Visibility string `json:"visibility" binding:"In(,public,limited,private)"` RepoAdminChangeTeamAccess bool `json:"repo_admin_change_team_access"` } @@ -53,7 +53,7 @@ type EditOrgOption struct { Website string `json:"website" binding:"ValidUrl;MaxSize(255)"` Location string `json:"location" binding:"MaxSize(50)"` // possible values are `public`, `limited` or `private` - // enum: public,limited,private + // enum: ["public", "limited", "private"] Visibility string `json:"visibility" binding:"In(,public,limited,private)"` RepoAdminChangeTeamAccess *bool `json:"repo_admin_change_team_access"` } diff --git a/modules/structs/org_team.go b/modules/structs/org_team.go index f8899b236b..4417758024 100644 --- a/modules/structs/org_team.go +++ b/modules/structs/org_team.go @@ -11,7 +11,7 @@ type Team struct { Description string `json:"description"` Organization *Organization `json:"organization"` IncludesAllRepositories bool `json:"includes_all_repositories"` - // enum: none,read,write,admin,owner + // enum: ["none", "read", "write", "admin", "owner"] Permission string `json:"permission"` // example: ["repo.code","repo.issues","repo.ext_issues","repo.wiki","repo.pulls","repo.releases","repo.projects","repo.ext_wiki"] // Deprecated: This variable should be replaced by UnitsMap and will be dropped in later versions. @@ -27,7 +27,7 @@ type CreateTeamOption struct { Name string `json:"name" binding:"Required;AlphaDashDot;MaxSize(255)"` Description string `json:"description" binding:"MaxSize(255)"` IncludesAllRepositories bool `json:"includes_all_repositories"` - // enum: read,write,admin + // enum: ["read", "write", "admin"] Permission string `json:"permission"` // example: ["repo.actions","repo.code","repo.issues","repo.ext_issues","repo.wiki","repo.ext_wiki","repo.pulls","repo.releases","repo.projects","repo.ext_wiki"] // Deprecated: This variable should be replaced by UnitsMap and will be dropped in later versions. @@ -43,7 +43,7 @@ type EditTeamOption struct { Name string `json:"name" binding:"AlphaDashDot;MaxSize(255)"` Description *string `json:"description" binding:"MaxSize(255)"` IncludesAllRepositories *bool `json:"includes_all_repositories"` - // enum: read,write,admin + // enum: ["read", "write", "admin"] Permission string `json:"permission"` // example: ["repo.code","repo.issues","repo.ext_issues","repo.wiki","repo.pulls","repo.releases","repo.projects","repo.ext_wiki"] // Deprecated: This variable should be replaced by UnitsMap and will be dropped in later versions. diff --git a/modules/structs/repo.go b/modules/structs/repo.go index 76479ad79d..f2fe9c7ac3 100644 --- a/modules/structs/repo.go +++ b/modules/structs/repo.go @@ -109,7 +109,7 @@ type Repository struct { Internal bool `json:"internal"` MirrorInterval string `json:"mirror_interval"` // ObjectFormatName of the underlying git repository - // enum: sha1,sha256 + // enum: ["sha1", "sha256"] ObjectFormatName string `json:"object_format_name"` // swagger:strfmt date-time MirrorUpdated time.Time `json:"mirror_updated,omitempty"` @@ -154,10 +154,10 @@ type CreateRepoOption struct { // DefaultBranch of the repository (used when initializes and in template) DefaultBranch string `json:"default_branch" binding:"GitRefName;MaxSize(100)"` // TrustModel of the repository - // enum: default,collaborator,committer,collaboratorcommitter + // enum: ["default", "collaborator", "committer", "collaboratorcommitter"] TrustModel string `json:"trust_model"` // ObjectFormatName of the underlying git repository - // enum: sha1,sha256 + // enum: ["sha1", "sha256"] ObjectFormatName string `json:"object_format_name" binding:"MaxSize(6)"` } @@ -359,7 +359,7 @@ type MigrateRepoOptions struct { // required: true RepoName string `json:"repo_name" binding:"Required;AlphaDashDot;MaxSize(100)"` - // enum: git,github,gitea,gitlab,gogs,onedev,gitbucket,codebase + // enum: ["git", "github", "gitea", "gitlab", "gogs", "onedev", "gitbucket", "codebase"] Service string `json:"service"` AuthUsername string `json:"auth_username"` AuthPassword string `json:"auth_password"` diff --git a/modules/structs/repo_collaborator.go b/modules/structs/repo_collaborator.go index 7d39b5a798..2f03f0a725 100644 --- a/modules/structs/repo_collaborator.go +++ b/modules/structs/repo_collaborator.go @@ -5,7 +5,7 @@ package structs // AddCollaboratorOption options when adding a user as a collaborator of a repository type AddCollaboratorOption struct { - // enum: read,write,admin + // enum: ["read", "write", "admin"] Permission *string `json:"permission"` } diff --git a/modules/structs/repo_file.go b/modules/structs/repo_file.go index 82bde96ab6..00c804146a 100644 --- a/modules/structs/repo_file.go +++ b/modules/structs/repo_file.go @@ -68,7 +68,7 @@ func (o *UpdateFileOptions) Branch() string { type ChangeFileOperation struct { // indicates what to do with the file // required: true - // enum: create,update,delete + // enum: ["create", "update", "delete"] Operation string `json:"operation" binding:"Required"` // path to the existing or new file // required: true diff --git a/services/forms/repo_form.go b/services/forms/repo_form.go index 0fd8965df9..e18bcfdd8d 100644 --- a/services/forms/repo_form.go +++ b/services/forms/repo_form.go @@ -429,7 +429,7 @@ func (f *InitializeLabelsForm) Validate(req *http.Request, errs binding.Errors) // swagger:model MergePullRequestOption type MergePullRequestForm struct { // required: true - // enum: merge,rebase,rebase-merge,squash,fast-forward-only,manually-merged + // enum: ["merge", "rebase", "rebase-merge", "squash", "fast-forward-only", "manually-merged"] Do string `binding:"Required;In(merge,rebase,rebase-merge,squash,fast-forward-only,manually-merged)"` MergeTitleField string MergeMessageField string