OpenAPITools / OpenAPITools/openapi-generator
[BUG][GO] Some errors with `oneOf` type
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
We are generating client specs for go using 5g 3gpp swagger specs found here (https://raw.githubusercontent.com/jdegre/5GC_APIs/master/TS29522_TrafficInfluence.yaml)
java openapi-generator-cli-6.0.0.jar generate -i https://raw.githubusercontent.com/jdegre/5GC_APIs/master/TS29522_TrafficInfluence.yaml -g go -o ./client_trafficInfluence
Running gofmt you will see the files have some errors
gofmt -s -w .
specs/client_trafficInfluence/model_ip_addr.go:20:11: expected type, found '{'
specs/client_trafficInfluence/model_ip_addr.go:25:2: expected declaration, found 'return'
specs/client_trafficInfluence/model_ip_addr.go:34:2: expected declaration, found match
specs/client_trafficInfluence/model_route_to_location.go:20:2: expected '}', found 'interface'
specs/client_trafficInfluence/model_route_to_location.go:27:2: expected declaration, found 'if'
For example the type Interface{} is used twice on the definition. While t should define a sere of properies.
// IpAddr - Contains an IP adresse.
type IpAddr struct {
Interface{} *interface{}
}
// interface{}AsIpAddr is a convenience function that returns interface{} wrapped in IpAddr
func Interface{}AsIpAddr(v *interface{}) IpAddr {
return IpAddr{
Interface{}: v,
}
}
This is how it should look like (extracted from the server case)
// IpAddr - Contains an IP adresse.
type IpAddr struct {
// String identifying a IPv4 address formatted in the 'dotted decimal' notation as defined in RFC 1166.
Ipv4Addr string `json:"ipv4Addr,omitempty"`
Ipv6Addr Ipv6Addr1 `json:"ipv6Addr,omitempty"`
Ipv6Prefix Ipv6Prefix `json:"ipv6Prefix,omitempty"`
}
openapi-generator version
6.0.0
Generation Details
java openapi-generator-cli-6.0.0.jar generate -i https://raw.githubusercontent.com/jdegre/5GC_APIs/master/TS29522_TrafficInfluence.yaml -g go -o ./client_trafficInfluence
Steps to reproduce
Just run that command and it will generate the files
Related issues/PRs
https://github.com/OpenAPITools/openapi-generator/issues/12955
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
Run the listed openapi-generator 6.0.0 command against TS29522_TrafficInfluence.yaml and inspect the generated model_ip_addr.go and model_route_to_location.go files. Compare the generated oneOf models with the shown server-side IpAddr shape; done means the Go output represents the properties correctly and passes gofmt without syntax errors.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go, java
- Domain
- api, tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100