microsoft / microsoft/kiota

kiota go generator loses properties in schema that contains a `oneOf`

Open
#2,720 8 comments 0 reactions 0 assignees View on GitHub
generator type:bug WIP
Dominant language
C#
Stars
3.8k
Forks
333
Avg merge
16h 29m
Merged PRs (30d)
116

Description

Given a schema that contains `properties` and a `oneOf`, the properties of the schema are not present in the generated struct for the schema. An example:

```yaml
Widget:
type: object
properties:
kind:
type: string
id:
type: string
weight:
type: integer
format: int32
required:
- id
- kind
- weight
oneOf:
- $ref: '#/components/schemas/Gadget'
- $ref: '#/components/schemas/WingDing'
```

The `Widget` struct generated by Kiota looks like this:

```go
// Widget composed type wrapper for classes Gadget, WingDing
type Widget struct {
// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well.
additionalData map[string]any
// Composed type representation for type Gadget
gadget Gadgetable
// Serialization hint for the current wrapper.
SerializationHint *string
// Composed type representation for type WingDing
wingDing WingDingable
}
```

Note that the struct does not contain an `id` or `weight` property.

Contributor guide

Open the contributing guide

Research direction

Start with the Go generator logic that handles schemas containing properties and oneOf, using the Widget example in this issue as the reproduction case. Compare the generated Widget struct with the schema and verify that id, kind, and weight remain present alongside the composed-type fields when the issue is fixed.

Written by the indexing model from the issue text.

Assessment

Tech stack
go
Domain
devtools
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
54/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.