Skip to content

oneOf subtypes not linked correctly to parent type #233

Closed
@sdufel

Description

@sdufel

Preliminary checks

  • I am using the latest version, or the latest version that corresponds to my Oxide installation.
  • There is no open issue that reports the same problem.

What was the expected behaviour

For API types specified to return oneOf a number of types, the SDK parses responses to the correct type.

What is the current behaviour and what actions did you take to get there

Specifically for the Datum type, it appears that all type options are being generated - however the generic type is being created as the first variant, rather than a generic type / interface.

Generated code example:

// Datum is a `Datum` is a single sampled data point from a metric.
type Datum struct {
	// Datum is the type definition for a Datum.
	Datum *bool `json:"datum,omitempty" yaml:"datum,omitempty"` // <- this is only one of the possible type for a Datum
	// Type is the type definition for a Type.
	Type DatumType `json:"type,omitempty" yaml:"type,omitempty"`
}

In this case, DatumBool, DatumI32, etc are all created, but they are not available as fields of the Datum struct.

When invoking the disk_metrics_list endpoint, this manifests as the following error:

error decoding response body: json: cannot unmarshal object into Go struct field Datum.items.datum.datum of type bool

Go SDK version

v0.1.0-beta7

Operating system

macOS 14.6.1

Anything else you would like to add?

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions