feat: Update HTTP status code to 201 when returning from successful create operations

This commit is contained in:
Akhilesh Pandey 2023-05-31 15:34:53 +05:30
parent b6d0a97f19
commit 24a9888cfc
16 changed files with 16 additions and 16 deletions

View File

@ -44,6 +44,6 @@ func HandleCommentCreate(pullreqCtrl *pullreq.Controller) http.HandlerFunc {
return return
} }
render.JSON(w, http.StatusOK, comment) render.JSON(w, http.StatusCreated, comment)
} }
} }

View File

@ -38,6 +38,6 @@ func HandleCreate(pullreqCtrl *pullreq.Controller) http.HandlerFunc {
return return
} }
render.JSON(w, http.StatusOK, pr) render.JSON(w, http.StatusCreated, pr)
} }
} }

View File

@ -32,6 +32,6 @@ func HandleCreate(repoCtrl *repo.Controller) http.HandlerFunc {
return return
} }
render.JSON(w, http.StatusOK, repo) render.JSON(w, http.StatusCreated, repo)
} }
} }

View File

@ -39,6 +39,6 @@ func HandleCreateBranch(repoCtrl *repo.Controller) http.HandlerFunc {
return return
} }
render.JSON(w, http.StatusOK, branch) render.JSON(w, http.StatusCreated, branch)
} }
} }

View File

@ -39,6 +39,6 @@ func HandleCreatePath(repoCtrl *repo.Controller) http.HandlerFunc {
return return
} }
render.JSON(w, http.StatusOK, path) render.JSON(w, http.StatusCreated, path)
} }
} }

View File

@ -36,6 +36,6 @@ func HandleCreateCommitTag(repoCtrl *repo.Controller) http.HandlerFunc {
return return
} }
render.JSON(w, http.StatusOK, tag) render.JSON(w, http.StatusCreated, tag)
} }
} }

View File

@ -34,6 +34,6 @@ func HandleCreate(saCtrl *serviceaccount.Controller) http.HandlerFunc {
return return
} }
render.JSON(w, http.StatusOK, sa) render.JSON(w, http.StatusCreated, sa)
} }
} }

View File

@ -38,6 +38,6 @@ func HandleCreateToken(saCrl *serviceaccount.Controller) http.HandlerFunc {
return return
} }
render.JSON(w, http.StatusOK, tokenResponse) render.JSON(w, http.StatusCreated, tokenResponse)
} }
} }

View File

@ -32,6 +32,6 @@ func HandleCreate(spaceCtrl *space.Controller) http.HandlerFunc {
return return
} }
render.JSON(w, http.StatusOK, space) render.JSON(w, http.StatusCreated, space)
} }
} }

View File

@ -37,6 +37,6 @@ func HandleCreatePath(spaceCtrl *space.Controller) http.HandlerFunc {
return return
} }
render.JSON(w, http.StatusOK, path) render.JSON(w, http.StatusCreated, path)
} }
} }

View File

@ -34,6 +34,6 @@ func HandleCreateAccessToken(userCtrl *user.Controller) http.HandlerFunc {
return return
} }
render.JSON(w, http.StatusOK, tokenResponse) render.JSON(w, http.StatusCreated, tokenResponse)
} }
} }

View File

@ -33,6 +33,6 @@ func HandleCreate(userCtrl *user.Controller) http.HandlerFunc {
return return
} }
render.JSON(w, http.StatusOK, usr) render.JSON(w, http.StatusCreated, usr)
} }
} }

View File

@ -38,6 +38,6 @@ func HandleCreate(webhookCtrl *webhook.Controller) http.HandlerFunc {
return return
} }
render.JSON(w, http.StatusOK, hook) render.JSON(w, http.StatusCreated, hook)
} }
} }

View File

@ -37,7 +37,7 @@ func buildUser(reflector *openapi3.Reflector) {
opToken.WithTags("user") opToken.WithTags("user")
opToken.WithMapOfAnything(map[string]interface{}{"operationId": "createToken"}) opToken.WithMapOfAnything(map[string]interface{}{"operationId": "createToken"})
_ = reflector.SetRequest(&opToken, new(types.TokenResponse), http.MethodPost) _ = reflector.SetRequest(&opToken, new(types.TokenResponse), http.MethodPost)
_ = reflector.SetJSONResponse(&opToken, new(types.User), http.StatusOK) _ = reflector.SetJSONResponse(&opToken, new(types.User), http.StatusCreated)
_ = reflector.SetJSONResponse(&opToken, new(usererror.Error), http.StatusInternalServerError) _ = reflector.SetJSONResponse(&opToken, new(usererror.Error), http.StatusInternalServerError)
_ = reflector.Spec.AddOperation(http.MethodPost, "/user/token", opToken) _ = reflector.Spec.AddOperation(http.MethodPost, "/user/token", opToken)
} }

View File

@ -68,7 +68,7 @@ func buildAdmin(reflector *openapi3.Reflector) {
opCreate.WithTags("admin") opCreate.WithTags("admin")
opCreate.WithMapOfAnything(map[string]interface{}{"operationId": "adminCreateUser"}) opCreate.WithMapOfAnything(map[string]interface{}{"operationId": "adminCreateUser"})
_ = reflector.SetRequest(&opCreate, new(adminUsersCreateRequest), http.MethodPost) _ = reflector.SetRequest(&opCreate, new(adminUsersCreateRequest), http.MethodPost)
_ = reflector.SetJSONResponse(&opCreate, new(types.User), http.StatusOK) _ = reflector.SetJSONResponse(&opCreate, new(types.User), http.StatusCreated)
_ = reflector.SetJSONResponse(&opCreate, new(usererror.Error), http.StatusBadRequest) _ = reflector.SetJSONResponse(&opCreate, new(usererror.Error), http.StatusBadRequest)
_ = reflector.SetJSONResponse(&opCreate, new(usererror.Error), http.StatusInternalServerError) _ = reflector.SetJSONResponse(&opCreate, new(usererror.Error), http.StatusInternalServerError)
_ = reflector.SetJSONResponse(&opCreate, new(usererror.Error), http.StatusNotFound) _ = reflector.SetJSONResponse(&opCreate, new(usererror.Error), http.StatusNotFound)

View File

@ -90,7 +90,7 @@ func webhookOperations(reflector *openapi3.Reflector) {
createWebhook.WithTags("webhook") createWebhook.WithTags("webhook")
createWebhook.WithMapOfAnything(map[string]interface{}{"operationId": "createWebhook"}) createWebhook.WithMapOfAnything(map[string]interface{}{"operationId": "createWebhook"})
_ = reflector.SetRequest(&createWebhook, new(createWebhookRequest), http.MethodPost) _ = reflector.SetRequest(&createWebhook, new(createWebhookRequest), http.MethodPost)
_ = reflector.SetJSONResponse(&createWebhook, new(webhookType), http.StatusOK) _ = reflector.SetJSONResponse(&createWebhook, new(webhookType), http.StatusCreated)
_ = reflector.SetJSONResponse(&createWebhook, new(usererror.Error), http.StatusBadRequest) _ = reflector.SetJSONResponse(&createWebhook, new(usererror.Error), http.StatusBadRequest)
_ = reflector.SetJSONResponse(&createWebhook, new(usererror.Error), http.StatusInternalServerError) _ = reflector.SetJSONResponse(&createWebhook, new(usererror.Error), http.StatusInternalServerError)
_ = reflector.SetJSONResponse(&createWebhook, new(usererror.Error), http.StatusUnauthorized) _ = reflector.SetJSONResponse(&createWebhook, new(usererror.Error), http.StatusUnauthorized)