OpenAPITools / OpenAPITools/openapi-generator
[BUG][Golang][Client] `composed-OneOf` become undefined
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 26.8k
- Forks
- 7.7k
- PR merge metrics
- PR metrics pending
Description
Description
composed-oneOf generates undefined type OneOfObjA.
here is generated code
this api should return one of ObjA or ObjB.
but Golang doesn't have such feature to describe TypeA | TypeB.
FYI https://developers.google.com/protocol-buffers/docs/reference/go-generated#oneof
openapi-generator version
OpenAPI declaration file content or url
Command line used for generation
generate -t modules/openapi-generator/src/main/resources/go -i modules/openapi-generator/src/test/resources/3_0/composed-oneof.yaml -g go -o $GOPATH/src/github.com/zigen/go-sample-api -DpackageName=go_sample_api
https://github.com/zigen/openapi-generator-go-client-oas3-repro/blob/master/go-oneof.sh
Steps to reproduce
generate spec modules/openapi-generator/src/test/resources/3_0/composed-oneof.yam to golang and import it.
this repo includes steps to repro, generated conde and example client.
https://github.com/zigen/openapi-generator-go-client-oas3-repro
Related issues/PRs
https://github.com/OpenAPITools/openapi-generator/pull/1360
https://github.com/OpenAPITools/openapi-generator/issues/500
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 with modules/openapi-generator/src/test/resources/3_0/composed-oneof.yaml and the Go generator templates under modules/openapi-generator/src/main/resources/go. Run the reported generate command or go-oneof.sh from the linked reproduction repository and inspect the generated api_default.go around the undefined OneOfObjA type. Done means the composed-oneOf specification generates a Go client that can be imported without the undefined type error.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go, openapi
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100