OpenAPITools / OpenAPITools/openapi-generator
[BUG] Object array in oneof item generate wrong go data structure
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 26.8k
- Forks
- 7.7k
- PR merge metrics
- PR metrics pending
Description
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
Object array in oneof item generate wrong go data structure
openapi-generator version
openapi-generator-cli-7.0.0.jar
OpenAPI declaration file content or url
some content of yaml file
openapi: 3.0.3
testOneOfObject:
oneOf:
- type: string
nullable: true
- type: array
items:
type: object
(for JSON code), so it becomes more readable. If it is longer than about ten lines,
please create a Gist (https://gist.github.com) or upload it somewhere else and
link it here.
-->
Generation Details
java -jar ${jar} generate -i ${yamlfile} -g go -o out/test -p packageName=test
The go code is wrong
type TestOneOfObjectstruct {
ArrayOfMapmapOfStringinterface{} *[]map[string]interface{}
String *string
}
ArrayOfMapmapOfStringinterface{} *[]map[string]interface{} should be ArrayOfMapmapOfStringinterface []map[string]interface{}
If the item type in array is an specific structure, it works well, but it generate wrong go code if the type is object
Steps to reproduce
Related issues/PRs
Suggest a fix
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the issue with the provided OpenAPI 3.0.3 declaration and the java -jar ${jar} generate -g go command. Inspect the generated TestOneOfObject structure and verify that the object-array field is emitted as a slice rather than a pointer to a slice; done means the generated Go code is valid and matches the expected declaration.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go, java, openapi
- Domain
- api, tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100