Skip to content

Preserve YANG elements order when generating structs #942

Open
@hellt

Description

@hellt

Hi all,
I wonder which code path is responsible to sort alphabetically generated struct's fields?

consider the following module:

module test {
  yang-version 1.1;
  namespace "urn:srlinux:ndk:test";
  prefix srl-labs;

  container app {
    leaf name {
      type string;
    }
    leaf address {
      type string;
    }
  }
}

The generated struct will have fields sorted as

type Foo struct {
  Address string
  Name string
}

and I would like to maintain the order of the struct fields (Name first, Address second). Would you hint me where the relevant code path is so that we might implement a preserve-yang-elements-order flag?

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