OpenAPITools / OpenAPITools/openapi-generator
[BUG] oneOf/required does not work correctly for golang
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 26.8k
- Forks
- 7.7k
- PR merge metrics
- PR metrics pending
Description
Hi
I have this yaml file:
openapi: 3.0.0
info:
version: '1.0.0'
title: 'Test'
paths: {}
components:
schemas:
Test:
type: object
oneOf:
- required:
- test1
- required:
- test2
properties:
normalField:
type: string
test1:
$ref: '#/components/schemas/Test1'
test2:
$ref: '#/components/schemas/Test2'
normalField2:
type: string
Test1:
type: object
required:
- a
- b
- c
properties:
a:
type: int
b:
type: string
c:
type: string
Test2:
type: object
required:
- ab
- bb
- cc
properties:
aa:
type: int
bb:
type: string
cc:
type: string
when I execute the generator for golang, then I receive this generated datatype:
// Test - struct for Test
type Test struct {
interface{} *interface{}
}
Is it possible to make this better, since basically it gives error and actually the fields are not included at all.
If I remove the oneOf, then it generates the correct datatype, but then I loose the checker functions.
thanks
Akos
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 provided YAML with the Go generator and inspect the generated Test datatype and checker behavior. Trace how oneOf and required are represented in the Go output; done means the generated type includes the relevant fields and preserves validation behavior without collapsing to interface{}.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go, openapi
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 25/100