Skip to content

get rid of types with duplicate names in the API #10293

Closed

Description

@ahl

We have a few types in the API with the suffix "2". This happens when we add two types with identical names; schemars appends "2" (and "3" and "4"...) to disambiguate the types. Currently we have these:

  • SwitchInterfaceKind2
  • SwitchPortGeometry2
  • TxEqConfig2

Here are the type definitions with conflicting names:

#[derive(Copy, Clone, Debug, Deserialize, Serialize, JsonSchema)]
#[serde(tag = "type", rename_all = "snake_case")]
pub enum SwitchInterfaceKind {
/// Primary interfaces are associated with physical links. There is exactly
/// one primary interface per physical link.
Primary,
/// VLAN interfaces allow physical interfaces to be multiplexed onto
/// multiple logical links, each distinguished by a 12-bit 802.1Q Ethernet
/// tag.
Vlan(SwitchVlanInterface),
/// Loopback interfaces are anchors for IP addresses that are not specific
/// to any particular port.
Loopback,
}

/// Describes the kind of an switch interface.
#[derive(Clone, Debug, Deserialize, JsonSchema, Serialize, PartialEq)]
#[serde(rename_all = "snake_case")]
pub enum SwitchInterfaceKind {
/// Primary interfaces are associated with physical links. There is exactly
/// one primary interface per physical link.
Primary,
/// VLAN interfaces allow physical interfaces to be multiplexed onto
/// multiple logical links, each distinguished by a 12-bit 802.1Q Ethernet
/// tag.
Vlan,
/// Loopback interfaces are anchors for IP addresses that are not specific
/// to any particular port.
Loopback,
}

/// The link geometry associated with a switch port.
#[derive(Copy, Clone, Debug, Deserialize, Serialize, JsonSchema)]
#[serde(rename_all = "snake_case")]
pub enum SwitchPortGeometry {
/// The port contains a single QSFP28 link with four lanes.
Qsfp28x1,
/// The port contains two QSFP28 links each with two lanes.
Qsfp28x2,
/// The port contains four SFP28 links each with one lane.
Sfp28x4,
}

/// The link geometry associated with a switch port.
#[derive(Clone, Debug, Deserialize, JsonSchema, Serialize, PartialEq)]
#[serde(rename_all = "lowercase")]
pub enum SwitchPortGeometry {
/// The port contains a single QSFP28 link with four lanes.
Qsfp28x1,
/// The port contains two QSFP28 links each with two lanes.
Qsfp28x2,
/// The port contains four SFP28 links each with one lane.
Sfp28x4,
}

/// Per-port tx-eq overrides. This can be used to fine-tune the transceiver
/// equalization settings to improve signal integrity.
#[derive(
Clone, Copy, Debug, Deserialize, Serialize, PartialEq, Eq, Hash, JsonSchema,
)]
pub struct TxEqConfig {
/// Pre-cursor tap1
pub pre1: Option<i32>,
/// Pre-cursor tap2
pub pre2: Option<i32>,
/// Main tap
pub main: Option<i32>,
/// Post-cursor tap2
pub post2: Option<i32>,
/// Post-cursor tap1
pub post1: Option<i32>,
}

/// Per-port tx-eq overrides. This can be used to fine-tune the transceiver
/// equalization settings to improve signal integrity.
#[derive(Clone, Debug, Deserialize, JsonSchema, Serialize, PartialEq)]
pub struct TxEqConfig {
/// Pre-cursor tap1
pub pre1: Option<i32>,
/// Pre-cursor tap2
pub pre2: Option<i32>,
/// Main tap
pub main: Option<i32>,
/// Post-cursor tap2
pub post2: Option<i32>,
/// Post-cursor tap1
pub post1: Option<i32>,
}

SwitchInterfaceKind has a slightly different structure (the Vlan variant); I'm not sure if the distinction is important. SwitchPortGeometry and TxEqConfig look to be identical--I'm not sure if there's some contextual reason why the types cannot be shared.

Activity

  1. added a commit that references this issue on May 8, 2026
    9e56717
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions