ygot icon indicating copy to clipboard operation
ygot copied to clipboard

ygot doesn't support a union with multiple enums

Open upavlo opened this issue 6 years ago • 2 comments

When generating a proto message, if more than one enum is defined within a union then ygot will pick whatever the first enum that is declared in the schema, instead of listing them all within oneof message.

Consider example:

container bar {
    leaf my-mode {
        type union {
            type string;
            type enumeration {
                enum short;
                enum long;
                enum wide;
            }
            type enumeration {
                enum red;
                enum green;
                enum blue;
            }
        }
    }
}

When this is given to ygot the oneof message will contain one string and one enum (the first one).

In the real openconfig schema the following leafs have a union type with multiple enums:

  • /openconfig-network-instance/network-instances/network-instance/protocols/protocol/isis/interfaces/interface/levels/level/afi-safi/af/segment-routing/adjacency-sids/adjacency-sid/state/sid-id
  • /openconfig-network-instance/network-instances/network-instance/protocols/protocol/isis/interfaces/interface/levels/level/afi-safi/af/segment-routing/adjacency-sids/adjacency-sid/config/sid-id

Interestingly, if union contains multiple identifyrefs then each one will have an entry in the oneof message.

upavlo avatar Oct 12 '18 09:10 upavlo

Confirmed that this an issue with the given OC paths. sid-id's DYNAMIC enum value is ungenerated.

wenovus avatar Jun 02 '20 00:06 wenovus

Fixing https://github.com/openconfig/goyang/issues/131 is a prerequisite.

wenovus avatar Oct 06 '20 21:10 wenovus