oapi-codegen
oapi-codegen copied to clipboard
Generate client code cannot handle uuid
api file: https://github.com/circlefin/openapi/blob/master/openapi/yaml/payments.yaml
Generate with the following config
package: cccpayment # circle client payment
output: generated_payment/client.go
generate:
# types: true
models: true
client: true
using generated client
cardId := uuid.MustParse("11c24f97-3562-4e4a-b96d-d0b3c66c6d4c")
client.GetCard(ctx, cardId) // This will error out in constructing the request
Where the issues is
- See this block of generated code
pathParam0, err = runtime.StyleParamWithLocation("simple", false, "id", runtime.ParamLocationPath, id)
// This method cannot handle `value` taking on a uuid.UUID type.
func StyleParamWithLocation(style string, explode bool, paramName string, paramLocation ParamLocation, value interface{}) (string, error) {
- Error message
panic: unsupported type uuid.UUID [recovered]
panic: unsupported type uuid.UUID