OpenAPITools / OpenAPITools/openapi-generator
[BUG] [Golang] anyOf results in empty Go struct
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 26.8k
- Forks
- 7.7k
- PR merge metrics
- PR metrics pending
Description
Description
When Go model code is generated for an "anyOf" type then the result will be an empty struct.
Yaml:
RatType:
anyOf:
- type: string
enum:
- NR
- EUTRA
- WLAN
- VIRTUAL
- type: string
Actual:
type RatType struct {
}
Expected:
package openapi
type RatType string
// List of RatType
const (
NR RatType = "NR"
EUTRA RatType = "EUTRA"
WLAN RatType = "WLAN"
VIRTUAL RatType = "VIRTUAL"
)
openapi-generator version
4.0.0-SNAPSHOT
OpenAPI declaration file content or url
Command line used for generation
./run-in-docker.sh generate -i 5GC_APIs/TS29518_Namf_MT.yaml -g go -o /gen/out -Dmodels
Steps to reproduce
./run-in-docker.sh generate -i 5GC_APIs/TS29518_Namf_MT.yaml -g go -o /gen/out -Dmodels
cat out/model_rat_type.go
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
Reproduce the issue with the provided run-in-docker.sh command and inspect out/model_rat_type.go. Compare the generated result with the RatType declaration and the linked OpenAPI YAML entries. Done means the Go generator no longer emits an empty struct and produces the expected string type and enum constants.
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
- 45/100