Skip to content

Commit

Permalink
Fix endpoint return code and description mismatch
Browse files Browse the repository at this point in the history
  • Loading branch information
anilsenay committed Apr 24, 2024
1 parent c56432a commit bdec91c
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
4 changes: 2 additions & 2 deletions components/http/response/response.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,8 @@ func hasStructFields(s interface{}) bool {
}

func (c CustomResponse) Description() string {
return c.returnCodeString
return c.descriptionString
}
func (c CustomResponse) ReturnCode() string {
return c.descriptionString
return c.returnCodeString
}
20 changes: 10 additions & 10 deletions generate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ func TestSwaggerGeneration(t *testing.T) {
endpoint.GET,
"/product",
endpoint.WithTags("product"),
endpoint.WithErrors([]response.Response{response.New(models.UnsuccessfulResponse{}, "Bad Request", "400")}),
endpoint.WithSuccessfulReturns([]response.Response{response.New(models.EmptySuccessfulResponse{}, "OK", "200")}),
endpoint.WithErrors([]response.Response{response.New(models.UnsuccessfulResponse{}, "400", "Bad Request")}),
endpoint.WithSuccessfulReturns([]response.Response{response.New(models.EmptySuccessfulResponse{}, "200", "OK")}),
endpoint.WithDescription(desc),
endpoint.WithProduce([]mime.MIME{mime.JSON, mime.XML}),
endpoint.WithConsume([]mime.MIME{mime.JSON}),
Expand All @@ -46,26 +46,26 @@ func TestSwaggerGeneration(t *testing.T) {
"/product/{id}",
endpoint.WithTags("product"),
endpoint.WithParams(parameter.IntParam("id", parameter.Path, parameter.WithRequired())),
endpoint.WithSuccessfulReturns([]response.Response{response.New(models.SuccessfulResponse{}, "Request Accepted", "201")}),
endpoint.WithErrors([]response.Response{response.New(models.UnsuccessfulResponse{}, "Bad Request", "400")}),
endpoint.WithSuccessfulReturns([]response.Response{response.New(models.SuccessfulResponse{}, "201", "Request Accepted")}),
endpoint.WithErrors([]response.Response{response.New(models.UnsuccessfulResponse{}, "400", "Bad Request")}),
endpoint.WithProduce([]mime.MIME{mime.JSON, mime.XML}),
),
endpoint.New(
endpoint.GET,
"/product/{id}/detail",
endpoint.WithTags("product"),
endpoint.WithParams(parameter.IntParam("id", parameter.Path, parameter.WithRequired())),
endpoint.WithSuccessfulReturns([]response.Response{response.New(models.SuccessfulResponse{}, "Request Accepted", "201")}),
endpoint.WithErrors([]response.Response{response.New(models.UnsuccessfulResponse{}, "Bad Request", "400")}),
endpoint.WithSuccessfulReturns([]response.Response{response.New(models.SuccessfulResponse{}, "201", "Request Accepted")}),
endpoint.WithErrors([]response.Response{response.New(models.UnsuccessfulResponse{}, "400", "Bad Request")}),
endpoint.WithProduce([]mime.MIME{mime.JSON, mime.XML}),
),
endpoint.New(
endpoint.POST,
"/product",
endpoint.WithTags("product"),
endpoint.WithBody(models.ProductPost{}),
endpoint.WithSuccessfulReturns([]response.Response{response.New(models.SuccessfulResponse{}, "Request Accepted", "201")}),
endpoint.WithErrors([]response.Response{response.New(models.UnsuccessfulResponse{}, "Bad Request", "400")}),
endpoint.WithSuccessfulReturns([]response.Response{response.New(models.SuccessfulResponse{}, "201", "Request Accepted")}),
endpoint.WithErrors([]response.Response{response.New(models.UnsuccessfulResponse{}, "400", "Bad Request")}),
endpoint.WithProduce([]mime.MIME{mime.JSON, mime.XML}),
),
},
Expand All @@ -77,7 +77,7 @@ func TestSwaggerGeneration(t *testing.T) {
endpoint.New(
endpoint.GET,
"/deeplynested",
endpoint.WithSuccessfulReturns([]response.Response{response.New(models.ComplexSuccessfulResponse{}, "OK", "200")}),
endpoint.WithSuccessfulReturns([]response.Response{response.New(models.ComplexSuccessfulResponse{}, "200", "OK")}),
endpoint.WithDescription(desc),
endpoint.WithProduce([]mime.MIME{mime.JSON, mime.XML}),
endpoint.WithConsume([]mime.MIME{mime.JSON}),
Expand All @@ -86,7 +86,7 @@ func TestSwaggerGeneration(t *testing.T) {
endpoint.New(
endpoint.GET,
"/arraydeeplynested",
endpoint.WithSuccessfulReturns([]response.Response{response.New([]models.ComplexSuccessfulResponse{}, "OK", "200")}),
endpoint.WithSuccessfulReturns([]response.Response{response.New([]models.ComplexSuccessfulResponse{}, "200", "OK")}),
endpoint.WithDescription(desc),
endpoint.WithProduce([]mime.MIME{mime.JSON, mime.XML}),
endpoint.WithConsume([]mime.MIME{mime.JSON}),
Expand Down

0 comments on commit bdec91c

Please sign in to comment.