Skip to content

Commit

Permalink
fix: api response encoding to api base (#85)
Browse files Browse the repository at this point in the history
* fix: api response encoding to api base

Signed-off-by: Lawrence Zawila <[email protected]>

* fix: swagger definition for connector configs

Signed-off-by: Lawrence Zawila <[email protected]>

Signed-off-by: Lawrence Zawila <[email protected]>
  • Loading branch information
darkmatterpool authored Jan 11, 2023
1 parent 580c619 commit 0a8c9cc
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 12 deletions.
8 changes: 5 additions & 3 deletions internal/app/api/connectorconfigs.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import (
"encoding/json"
"net/http"

"github.com/formancehq/go-libs/api"

"github.com/formancehq/payments/internal/app/connectors/bankingcircle"
"github.com/formancehq/payments/internal/app/connectors/configtemplate"
"github.com/formancehq/payments/internal/app/connectors/currencycloud"
Expand All @@ -27,9 +29,9 @@ func connectorConfigsHandler() http.HandlerFunc {
wise.Config{},
)

w.Header().Set("Content-Type", "application/json")

err := json.NewEncoder(w).Encode(configs)
err := json.NewEncoder(w).Encode(api.BaseResponse[configtemplate.Configs]{
Data: &configs,
})
if err != nil {
handleServerError(w, r, err)

Expand Down
8 changes: 5 additions & 3 deletions internal/app/api/stripe.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import (
"encoding/json"
"net/http"

"github.com/formancehq/go-libs/api"

"github.com/formancehq/payments/internal/app/models"

"github.com/pkg/errors"
Expand Down Expand Up @@ -97,9 +99,9 @@ func handleStripeTransfers(repo stripeTransfersRepository) http.HandlerFunc {
return
}

w.Header().Set("Content-Type", "application/json")

err = json.NewEncoder(w).Encode(transferResponse)
err = json.NewEncoder(w).Encode(api.BaseResponse[stripe.Transfer]{
Data: transferResponse,
})
if err != nil {
handleServerError(w, r, err)

Expand Down
17 changes: 11 additions & 6 deletions swagger.yml
Original file line number Diff line number Diff line change
Expand Up @@ -415,17 +415,22 @@ components:

ConnectorsConfigsResponse:
type: object
required:
- data
properties:
connector:
data:
type: object
properties:
key:
connector:
type: object
properties:
dataType:
type: string
required:
type: boolean
key:
type: object
properties:
dataType:
type: string
required:
type: boolean

TaskResponse:
type: object
Expand Down

0 comments on commit 0a8c9cc

Please sign in to comment.