Repository: oxidecomputer/oxide.go
Pull request #284: Update to omicron 5cfd735
Author: login: karencfv
Created: 2025-04-22T00:42:29Z | Merged: 2025-04-23T01:14:27Z



Diff:
diff --git a/VERSION_OMICRON b/VERSION_OMICRON
index fa11ddf..f22ebd2 100644
--- a/VERSION_OMICRON
+++ b/VERSION_OMICRON
@@ -1 +1 @@
-rel/v14/rc1
\ No newline at end of file
+5cfd735
\ No newline at end of file
diff --git a/internal/generate/types.go b/internal/generate/types.go
index b4d1513..9c5a7ea 100644
--- a/internal/generate/types.go
+++ b/internal/generate/types.go
@@ -724,6 +724,7 @@ func createOneOf(s *openapi3.Schema, name, typeName string) ([]TypeTemplate, []E
 			}
 
 			propertyName := strcase.ToCamel(prop)
+
 			// Avoids duplication for every enum
 			if !containsMatchFirstWord(parsedProperties, propertyName) {
 				field := TypeFields{
@@ -753,6 +754,15 @@ func createOneOf(s *openapi3.Schema, name, typeName string) ([]TypeTemplate, []E
 
 				enumFieldName = strcase.ToCamel(p.Value.Enum[0].(string))
 			}
+
+			// Enums can appear in a valid OpenAPI spec as a OneOf without necessarily
+			// being identified as such. If we find an object with a single property
+			// nested inside a OneOf we will assume this is an enum and modify the name of
+			// the struct that will be created out of this object.
+			// e.g. https://github.com/oxidecomputer/omicron/blob/158c0b205f23772dc6c4c97633fd1769cc0e00d4/openapi/nexus.json#L18637-L18682
+			if len(keys) == 1 && p.Value.Enum == nil {
+				enumFieldName = propertyName
+			}
 		}
 
 		// TODO: This is the only place that has an "additional name" at the end
diff --git a/oxide/types.go b/oxide/types.go
index ac0f99e..c799258 100644
--- a/oxide/types.go
+++ b/oxide/types.go
@@ -3725,6 +3725,40 @@ type InstanceUpdate struct {
 	Ncpus InstanceCpuCount `json:"ncpus,omitempty" yaml:"ncpus,omitempty"`
 }
 
+// InterfaceNumUnknown is the type definition for a InterfaceNumUnknown.
+//
+// Required fields:
+// - Unknown
+type InterfaceNumUnknown struct {
+	Unknown *int `json:"unknown,omitempty" yaml:"unknown,omitempty"`
+}
+
+// InterfaceNumIfIndex is the type definition for a InterfaceNumIfIndex.
+//
+// Required fields:
+// - IfIndex
+type InterfaceNumIfIndex struct {
+	IfIndex *int `json:"if_index,omitempty" yaml:"if_index,omitempty"`
+}
+
+// InterfaceNumPortNumber is the type definition for a InterfaceNumPortNumber.
+//
+// Required fields:
+// - PortNumber
+type InterfaceNumPortNumber struct {
+	PortNumber *int `json:"port_number,omitempty" yaml:"port_number,omitempty"`
+}
+
+// InterfaceNum is the type definition for a InterfaceNum.
+type InterfaceNum struct {
+	// Unknown is the type definition for a Unknown.
+	Unknown *int `json:"unknown,omitempty" yaml:"unknown,omitempty"`
+	// IfIndex is the type definition for a IfIndex.
+	IfIndex *int `json:"if_index,omitempty" yaml:"if_index,omitempty"`
+	// PortNumber is the type definition for a PortNumber.
+	PortNumber *int `json:"port_number,omitempty" yaml:"port_number,omitempty"`
+}
+
 // InternetGateway is an internet gateway provides a path between VPC networks and external networks.
 //
 // Required fields:
@@ -4184,7 +4218,7 @@ type LldpNeighbor struct {
 	// LocalPort is the port on which the neighbor was seen
 	LocalPort string `json:"local_port,omitempty" yaml:"local_port,omitempty"`
 	// ManagementIp is the LLDP management IP(s) advertised by the neighbor
-	ManagementIp []IpNet `json:"management_ip,omitempty" yaml:"management_ip,omitempty"`
+	ManagementIp []ManagementAddress `json:"management_ip,omitempty" yaml:"management_ip,omitempty"`
 	// SystemDescription is the LLDP system description advertised by the neighbor
 	SystemDescription string `json:"system_description,omitempty" yaml:"system_description,omitempty"`
 	// SystemName is the LLDP system name advertised by the neighbor
@@ -4264,6 +4298,17 @@ type LoopbackAddressResultsPage struct {
 // MacAddr is a Media Access Control address, in EUI-48 format
 type MacAddr string
 
+// ManagementAddress is the type definition for a ManagementAddress.
+//
+// Required fields:
+// - Addr
+// - InterfaceNum
+type ManagementAddress struct {
+	Addr         NetworkAddress `json:"addr,omitempty" yaml:"addr,omitempty"`
+	InterfaceNum InterfaceNum   `json:"interface_num,omitempty" yaml:"interface_num,omitempty"`
+	Oid          []string       `json:"oid" yaml:"oid"`
+}
+
 // Measurement is a `Measurement` is a timestamped datum from a single metric
 //
 // Required fields:
@@ -4313,6 +4358,30 @@ type NameOrIdSortMode string
 // NameSortMode is sort in increasing order of "name"
 type NameSortMode string
 
+// NetworkAddressIpAddr is the type definition for a NetworkAddressIpAddr.
+//
+// Required fields:
+// - IpAddr
+type NetworkAddressIpAddr struct {
+	IpAddr string `json:"ip_addr,omitempty" yaml:"ip_addr,omitempty"`
+}
+
+// NetworkAddressIeee802 is the type definition for a NetworkAddressIeee802.
+//
+// Required fields:
+// - IEEE802
+type NetworkAddressIeee802 struct {
+	IEEE802 []string `json:"i_e_e_e802,omitempty" yaml:"i_e_e_e802,omitempty"`
+}
+
+// NetworkAddress is the type definition for a NetworkAddress.
+type NetworkAddress struct {
+	// IpAddr is the type definition for a IpAddr.
+	IpAddr string `json:"ip_addr,omitempty" yaml:"ip_addr,omitempty"`
+	// IEEE802 is the type definition for a IEEE802.
+	IEEE802 []string `json:"i_e_e_e802,omitempty" yaml:"i_e_e_e802,omitempty"`
+}
+
 // NetworkInterface is information required to construct a virtual network interface
 //
 // Required fields:
@@ -8998,7 +9067,6 @@ type VpcRouterRouteDeleteParams struct {
 //
 // Required fields:
 // - Route
-// - Router
 type VpcRouterRouteViewParams struct {
 	Route   NameOrId `json:"route,omitempty" yaml:"route,omitempty"`
 	Project NameOrId `json:"project,omitempty" yaml:"project,omitempty"`
@@ -11349,7 +11417,6 @@ func (p *VpcRouterRouteDeleteParams) Validate() error {
 func (p *VpcRouterRouteViewParams) Validate() error {
 	v := new(Validator)
 	v.HasRequiredStr(string(p.Route), "Route")
-	v.HasRequiredStr(string(p.Router), "Router")
 	if !v.IsValid() {
 		return fmt.Errorf("validation error:\n%v", v.Error())
 	}


Reviews:
user: login: karencfv
state: COMMENTED
author_association: CONTRIBUTOR
submitted_at: 2025-04-22T00:44:36Z
user: login: sudomateo
body: I haven't used the affected upstream API routes but the changes here look good to me.
state: APPROVED
author_association: COLLABORATOR
submitted_at: 2025-04-22T23:39:21Z

Review comments:
diff_hunk: @@ -753,6 +754,15 @@ func createOneOf(s *openapi3.Schema, name, typeName string) ([]TypeTemplate, []E
 
 				enumFieldName = strcase.ToCamel(p.Value.Enum[0].(string))
 			}
+
+			// Enums can appear in a valid OpenAPI spec as a OneOf without necessarily
+			// being identified as such. If we find an object with a single property
+			// nested inside a OneOf we will assume this is an enum and modify the name of
+			// the struct that will be created out of this object.
+			// e.g. https://github.com/oxidecomputer/omicron/blob/158c0b205f23772dc6c4c97633fd1769cc0e00d4/openapi/nexus.json#L18637-L18682
+			if len(keys) == 1 && p.Value.Enum == nil {
+				enumFieldName = propertyName
+			}
path: internal/generate/types.go
user: login: karencfv
body: This code handles the case for https://github.com/oxidecomputer/oxide.go/pull/284/files#diff-841a2b1b5f072b633551cac9c34c9732a722b415e297a1530b92d5988962062eR3728-R3750 Without handling, the result was that they all were named `InterfaceNum` because they aren't being explicitly marked as an enum, but used as one, and OpenAPI still sees this as a valid spec
created_at: 2025-04-22T00:44:36Z
author_association: CONTRIBUTOR
diff_hunk: @@ -4313,6 +4358,30 @@ type NameOrIdSortMode string
 // NameSortMode is sort in increasing order of "name"
 type NameSortMode string
 
+// NetworkAddressIpAddr is the type definition for a NetworkAddressIpAddr.
+//
+// Required fields:
+// - IpAddr
+type NetworkAddressIpAddr struct {
+	IpAddr string `json:"ip_addr,omitempty" yaml:"ip_addr,omitempty"`
+}
+
+// NetworkAddressIeee802 is the type definition for a NetworkAddressIeee802.
+//
+// Required fields:
+// - IEEE802
+type NetworkAddressIeee802 struct {
+	IEEE802 []string `json:"i_e_e_e802,omitempty" yaml:"i_e_e_e802,omitempty"`
path: oxide/types.go
user: login: sudomateo
body: The `i_e_e_e802` JSON field read weird to me but that's how it is in the OpenAPI specification on omicron.
created_at: 2025-04-22T23:35:53Z
author_association: COLLABORATOR
diff_hunk: @@ -753,6 +754,15 @@ func createOneOf(s *openapi3.Schema, name, typeName string) ([]TypeTemplate, []E
 
 				enumFieldName = strcase.ToCamel(p.Value.Enum[0].(string))
 			}
+
+			// Enums can appear in a valid OpenAPI spec as a OneOf without necessarily
+			// being identified as such. If we find an object with a single property
+			// nested inside a OneOf we will assume this is an enum and modify the name of
+			// the struct that will be created out of this object.
+			// e.g. https://github.com/oxidecomputer/omicron/blob/158c0b205f23772dc6c4c97633fd1769cc0e00d4/openapi/nexus.json#L18637-L18682
+			if len(keys) == 1 && p.Value.Enum == nil {
+				enumFieldName = propertyName
+			}
path: internal/generate/types.go
user: login: sudomateo
body: Makes sense to me!
created_at: 2025-04-22T23:36:30Z
author_association: COLLABORATOR

PR comments:
user: login: sudomateo
created_at: 2025-04-22T23:40:01Z
body: Just FYI the commit and PR title typo `Upodate`. Should be `Update`.
author_association: COLLABORATOR
user: login: karencfv
created_at: 2025-04-23T01:15:04Z
body: > Just FYI the commit and PR title typo Upodate. Should be Update.

lol whoops
author_association: CONTRIBUTOR