Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG][GO] oneOf path parameters pointer is used as path parameter in request #14028

Open
5 of 6 tasks
NickUfer opened this issue Nov 15, 2022 · 0 comments · May be fixed by #20663
Open
5 of 6 tasks

[BUG][GO] oneOf path parameters pointer is used as path parameter in request #14028

NickUfer opened this issue Nov 15, 2022 · 0 comments · May be fixed by #20663

Comments

@NickUfer
Copy link
Contributor

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.

image

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
Steps to reproduce
Related issues/PRs
Suggest a fix
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
1 participant