[BUG][GO] oneOf path parameters pointer is used as path parameter in request
Created by: NickUfer
Bug Report Checklist
-
Have you provided a full/minimal spec to reproduce the issue? -
Have you validated the input using an OpenAPI validator (example)? -
Have you tested with the latest master to confirm the issue still exists? -
Have you searched for related issues/PRs? -
What's the actual output vs expected output? -
[Optional] Sponsorship to speed up the bug fix or feature request (example)
Description
When a path parameter is a oneOf the whole oneOf is serialized and not one of the set values.
This is caused by the parameterToString
method which serializes the struct to a string
func parameterToString(obj interface{}, collectionFormat string) string {
var delimiter string
switch collectionFormat {
case "pipes":
delimiter = "|"
case "ssv":
delimiter = " "
case "tsv":
delimiter = "\t"
case "csv":
delimiter = ","
}
if reflect.TypeOf(obj).Kind() == reflect.Slice {
return strings.Trim(strings.Replace(fmt.Sprint(obj), " ", delimiter, -1), "[]")
} else if t, ok := obj.(time.Time); ok {
return t.Format(time.RFC3339)
}
return fmt.Sprintf("%v", obj) // <---- ## HERE ##
}
openapi-generator version
6.2.1
OpenAPI declaration file content or url
https://gist.github.com/NickUfer/e5f80d9d2173344b4b3331df83e2080e
Generation Details
config file:
disallowAdditionalPropertiesIfNotPresent: true
packageName: directusclient
generateInterfaces: true
structPrefix: true
enumClassPrefix: true
cmd:
generate -i /tmp/oas.yaml -g go -o "/tmp/directusclient" -c /tmp/go.yml