oapi-codegen
oapi-codegen copied to clipboard
enum not generated when used with anyof
The types generated from the following spec sample will not generate the enum definition:
openapi: 3.0.0
paths:
/test:
get:
operationId: Test
responses:
"200":
content:
application/json:
schema:
$ref: '#/components/schemas/test'
components:
schemas:
test:
type: object
anyOf:
- properties:
fieldA:
type: string
- properties:
fieldA:
type: string
enum:
- foo
- bar
resulting in undefined: Test1FieldA with the following generated code
// Code generated by github.com/deepmap/oapi-codegen/v2 version v2.0.0 DO NOT EDIT.
// Test defines model for test.
type Test struct {
union json.RawMessage
}
// Test0 defines model for .
type Test0 struct {
FieldA *string `json:"fieldA,omitempty"`
}
// Test1 defines model for .
type Test1 struct {
FieldA *Test1FieldA `json:"fieldA,omitempty"`
}
I have seen that a similar issue was fixed before but it deals with a different usecase:
components:
schemas:
test:
properties:
fieldA:
anyOf:
- type: string
- type: string
enum:
- foo
- bar
Related to #648