From aa66cca792788026862fc8cc8a44f8f150c1c77b Mon Sep 17 00:00:00 2001 From: Atefeh Mohseni Ejiyeh Date: Fri, 16 Aug 2024 00:45:45 +0000 Subject: [PATCH] fix: [CODE-2192]: (Swagger) Add Update default-branch API (#2519) * add update default branch open api --- app/api/openapi/repo.go | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/app/api/openapi/repo.go b/app/api/openapi/repo.go index cdd2dad8c..9819d2cbd 100644 --- a/app/api/openapi/repo.go +++ b/app/api/openapi/repo.go @@ -50,6 +50,11 @@ type updateRepoRequest struct { repo.UpdateInput } +type updateDefaultBranchRequest struct { + repoRequest + repo.UpdateDefaultBranchInput +} + type moveRepoRequest struct { repoRequest repo.MoveInput @@ -693,6 +698,17 @@ func repoOperations(reflector *openapi3.Reflector) { _ = reflector.SetJSONResponse(&opUpdate, new(usererror.Error), http.StatusNotFound) _ = reflector.Spec.AddOperation(http.MethodPatch, "/repos/{repo_ref}", opUpdate) + opUpdateDefaultBranch := openapi3.Operation{} + opUpdateDefaultBranch.WithTags("repository") + opUpdateDefaultBranch.WithMapOfAnything(map[string]interface{}{"operationId": "updateDefaultBranch"}) + _ = reflector.SetRequest(&opUpdateDefaultBranch, new(updateDefaultBranchRequest), http.MethodPost) + _ = reflector.SetJSONResponse(&opUpdateDefaultBranch, new(repo.RepositoryOutput), http.StatusOK) + _ = reflector.SetJSONResponse(&opUpdateDefaultBranch, new(usererror.Error), http.StatusBadRequest) + _ = reflector.SetJSONResponse(&opUpdateDefaultBranch, new(usererror.Error), http.StatusInternalServerError) + _ = reflector.SetJSONResponse(&opUpdateDefaultBranch, new(usererror.Error), http.StatusUnauthorized) + _ = reflector.SetJSONResponse(&opUpdateDefaultBranch, new(usererror.Error), http.StatusForbidden) + _ = reflector.Spec.AddOperation(http.MethodPost, "/repos/{repo_ref}/default-branch", opUpdateDefaultBranch) + opDelete := openapi3.Operation{} opDelete.WithTags("repository") opDelete.WithMapOfAnything(map[string]interface{}{"operationId": "deleteRepository"})