OpenAPITools / OpenAPITools/openapi-generator

[BUG][Golang][Client] `composed-OneOf` become undefined

Open
#1,745 6 comments 8 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Client: Go Issue: Bug
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

4.0.0-SNAPSHOT 9e1cce2e7

OpenAPI declaration file content or url

https://github.com/OpenAPITools/openapi-generator/blob/master/modules/openapi-generator/src/test/resources/3_0/composed-oneof.yaml

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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.