Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
140 changes: 140 additions & 0 deletions internal/test/issues/issue1957/issue1957.gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 14 additions & 0 deletions internal/test/issues/issue1957/issue1957_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,4 +51,18 @@ func TestGeneratedCode(t *testing.T) {
require.NotZero(t, theType.Id)
})
})

t.Run("For a field with optional required fields (via AnyOf) and those fields having an AllOf", func(t *testing.T) {
t.Run("An optional field with x-go-type-skip-optional-pointer should be a non-pointer", func(t *testing.T) {
anID := ID(uuid.New())

theType := TypeWithComplexAllOf{
EitherId: anID,
}

require.IsType(t, ID{}, theType.EitherId)

require.NotZero(t, theType.Id)
})
})
}
18 changes: 18 additions & 0 deletions internal/test/issues/issue1957/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -53,3 +53,21 @@ components:
allOf:
- $ref: '#/components/schemas/ID'
- x-go-type-skip-optional-pointer: true
TypeWithComplexAllOf:
type: object
required:
- id
oneOf:
- required: [ either_id ]
- required: [ or_id ]
properties:
id:
$ref: '#/components/schemas/ID'
either_id:
allOf:
- $ref: '#/components/schemas/ID'
- x-go-type-skip-optional-pointer: true
or_id:
allOf:
- $ref: '#/components/schemas/ID'
- x-go-type-skip-optional-pointer: true
Loading