diff --git a/components/http/response/response.go b/components/http/response/response.go index 6d0b192..8e1b869 100644 --- a/components/http/response/response.go +++ b/components/http/response/response.go @@ -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 } diff --git a/generate_test.go b/generate_test.go index 91a7dd0..0f281a1 100644 --- a/generate_test.go +++ b/generate_test.go @@ -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}), @@ -46,8 +46,8 @@ 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( @@ -55,8 +55,8 @@ func TestSwaggerGeneration(t *testing.T) { "/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( @@ -64,8 +64,8 @@ func TestSwaggerGeneration(t *testing.T) { "/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}), ), }, @@ -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}), @@ -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}),