-
-
Notifications
You must be signed in to change notification settings - Fork 995
Open
Description
Hi, i'm trying to use generated client, but i'm getting this error:
error formatting 'request': unsupported type []gen_client.PaymentQueryRequestCurrencies
Here are my code and specs:
openapi spec:
"/some/path/foo/bar": {
"get": {
"tags": [
"Payments"
],
"summary": "search",
"operationId": "search",
"parameters": [
{
"name": "merchantId",
"in": "query",
"required": true,
"schema": {
"type": "string"
}
},
{
"name": "request",
"in": "query",
"required": true,
"schema": {
"$ref": "#/components/schemas/PaymentQueryRequest"
}
}
],
"responses": {
"200": {
...
"PaymentQueryRequest": {
"required": [
"currencies",
... (other params)
],
"type": "object",
"properties": {
... (params definitions)
"currencies": {
"type": "array",
"description": "Array of ISO 3-letter currency, e.g. SEK,EUR,USD",
"example": "SEK, EUR, USD",
"items": {
"type": "string",
"description": "Array of ISO 3-letter currency, e.g. SEK,EUR,USD",
"example": "SEK, EUR, USD",
"enum": [
"ADA",
(long currencies list)
"ZWL"
]
}
},
... (params definitions)
...
my codegen settings:
package: gen_client
output: gen/client/client.gen.go
generate:
models: true
client: true
using like this: //go:generate go tool oapi-codegen -config ../../../openapi/codegen-client.yaml ../../../openapi/openapi.json
go.mod
github.com/oapi-codegen/nethttp-middleware v1.1.2
github.com/oapi-codegen/oapi-codegen/v2 v2.5.0
github.com/oapi-codegen/runtime v1.1.2
client code:
resp, err := a.oapiClient.Search(ctx, &gen.SearchParams{
MerchantId: a.MerchantID,
Request: gen.PaymentQueryRequest{
Id: txID,
Currencies: []gen.PaymentQueryRequestCurrencies{},
InitiatedPsps: []gen.PaymentQueryRequestInitiatedPsps{},
Psps: []gen.PaymentQueryRequestPsps{},
States: []gen.PaymentQueryRequestStates{},
Statuses: []gen.PaymentQueryRequestStatuses{},
TxTypes: []gen.PaymentQueryRequestTxTypes{},
},
})
if err != nil {
return nil, fmt.Errorf("search tx: %w", err)
}
generated object PaymentQueryRequest
type PaymentQueryRequest struct {
... (other fields)
// Currencies Array of ISO 3-letter currency, e.g. SEK,EUR,USD
Currencies []PaymentQueryRequestCurrencies `json:"currencies"`
... (other fields)
}
Isn't those fields supposed to have form tag? All fields in PaymentQueryRequest have only json tag
also I've tried with nils instead of empty slices – same error happens
Metadata
Metadata
Assignees
Labels
No labels