From 64b04c234010e863be685b2954cfa33eea68d06b Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Sun, 13 Nov 2022 19:48:40 -0500 Subject: [PATCH] update any http.StatusAccepted (202) and http.StatusCreated (201) to be http.StatusOK (200) to make caller's life easier (#9) --- api/message_bus/openapi.yaml | 8 ++++---- route/api_route_action.go | 2 +- route/api_route_event.go | 2 +- route/api_route_event_test.go | 2 +- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/api/message_bus/openapi.yaml b/api/message_bus/openapi.yaml index d98c8c9..804be09 100644 --- a/api/message_bus/openapi.yaml +++ b/api/message_bus/openapi.yaml @@ -85,7 +85,7 @@ paths: requestBody: $ref: "#/components/requestBodies/RegisterEventType" responses: - "201": + "200": $ref: "#/components/responses/RegisterEventTypeOK" "400": $ref: "#/components/responses/ResponseBadRequest" @@ -139,7 +139,7 @@ paths: requestBody: $ref: "#/components/requestBodies/PublishEvent" responses: - "201": + "200": $ref: "#/components/responses/PublishEventOK" "400": $ref: "#/components/responses/ResponseBadRequest" @@ -184,7 +184,7 @@ paths: requestBody: $ref: "#/components/requestBodies/RegisterActionType" responses: - "201": + "200": $ref: "#/components/responses/RegisterActionTypeOK" "400": $ref: "#/components/responses/ResponseBadRequest" @@ -238,7 +238,7 @@ paths: requestBody: $ref: "#/components/requestBodies/TriggerAction" responses: - "202": + "200": $ref: "#/components/responses/TriggerActionOK" "400": $ref: "#/components/responses/ResponseBadRequest" diff --git a/route/api_route_action.go b/route/api_route_action.go index defc6ef..017f6c3 100644 --- a/route/api_route_action.go +++ b/route/api_route_action.go @@ -47,7 +47,7 @@ func (r *APIRoute) RegisterActionType(c echo.Context) error { return c.JSON(http.StatusBadRequest, codegen.ResponseBadRequest{Message: &message}) } - return c.JSON(http.StatusCreated, result) + return c.JSON(http.StatusOK, result) } func (r *APIRoute) GetActionTypesBySourceID(c echo.Context, sourceID codegen.SourceID) error { diff --git a/route/api_route_event.go b/route/api_route_event.go index c941673..40f94a6 100644 --- a/route/api_route_event.go +++ b/route/api_route_event.go @@ -48,7 +48,7 @@ func (r *APIRoute) RegisterEventType(ctx echo.Context) error { return ctx.JSON(http.StatusBadRequest, codegen.ResponseBadRequest{Message: &message}) } - return ctx.JSON(http.StatusCreated, result) + return ctx.JSON(http.StatusOK, result) } func (r *APIRoute) GetEventTypesBySourceID(ctx echo.Context, sourceID codegen.SourceID) error { diff --git a/route/api_route_event_test.go b/route/api_route_event_test.go index 7902999..51f34e0 100644 --- a/route/api_route_event_test.go +++ b/route/api_route_event_test.go @@ -54,7 +54,7 @@ func TestEventRoute(t *testing.T) { err = apiRoute.RegisterEventType(e.NewContext(req, rec)) assert.NilError(t, err) - assert.Equal(t, rec.Code, http.StatusCreated) + assert.Equal(t, rec.Code, http.StatusOK) var actualEventType model.EventType err = json2.UnmarshalFromString(rec.Body.String(), &actualEventType)