{"action":"closed","issue":{"url":"https://api.github.com/repos/CiscoDevNet/ydk-gen/issues/363","repository_url":"https://api.github.com/repos/CiscoDevNet/ydk-gen","labels_url":"https://api.github.com/repos/CiscoDevNet/ydk-gen/issues/363/labels{/name}","comments_url":"https://api.github.com/repos/CiscoDevNet/ydk-gen/issues/363/comments","events_url":"https://api.github.com/repos/CiscoDevNet/ydk-gen/issues/363/events","html_url":"https://github.com/CiscoDevNet/ydk-gen/issues/363","id":202225770,"number":363,"title":"Netconf key elements are not serialized in specified order","user":{"login":"wabain","id":7651435,"avatar_url":"https://avatars.githubusercontent.com/u/7651435?v=3","gravatar_id":"","url":"https://api.github.com/users/wabain","html_url":"https://github.com/wabain","followers_url":"https://api.github.com/users/wabain/followers","following_url":"https://api.github.com/users/wabain/following{/other_user}","gists_url":"https://api.github.com/users/wabain/gists{/gist_id}","starred_url":"https://api.github.com/users/wabain/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/wabain/subscriptions","organizations_url":"https://api.github.com/users/wabain/orgs","repos_url":"https://api.github.com/users/wabain/repos","events_url":"https://api.github.com/users/wabain/events{/privacy}","received_events_url":"https://api.github.com/users/wabain/received_events","type":"User","site_admin":false},"labels":[{"id":340069848,"url":"https://api.github.com/repos/CiscoDevNet/ydk-gen/labels/bug","name":"bug","color":"fc2929","default":true}],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2017-01-20T19:45:07Z","updated_at":"2017-02-20T16:21:06Z","closed_at":"2017-02-20T16:21:06Z","body":"The Python SDK places list keys before other elements when generating Netconf XML, but always sorts the key elements in alphabetical order. This behavior can cause XML generated by ydk by Cisco's ConfD.\r\n\r\nThe expected behavior is specified in RFCs [6020](https://tools.ietf.org/html/rfc6020#page-70) and [7950](https://tools.ietf.org/html/rfc7950#page-88), which state that:\r\n\r\n> The list's key nodes are encoded as subelements to the list's\r\n  identifier element, in the same order as they are defined within the\r\n  \"key\" statement.\r\n\r\n\r\n\r\nSample case, tested with 0.5.2 and master (cb522de4fa219ceb55945f09c6088091d0fb61cc):\r\n\r\n`ydk-id-order-bug.yang`\r\n\r\n```yang\r\nmodule ydk-id-order-bug {\r\n  namespace \"http://example.org/ns/yang/ydk-id-order-bug\";\r\n  prefix \"order-bug\";\r\n\r\n  list multi-key-list {\r\n    key \"c b\";\r\n\r\n    leaf a { type uint32; }\r\n    leaf b { type uint32; }\r\n    leaf c { type uint32; }\r\n  }\r\n}\r\n```\r\n\r\nBundle file: `ydk-id-order-bug.json`\r\n\r\n```json\r\n{\r\n   \"name\": \"ydk-id-order-bug\",\r\n   \"version\": \"0.1.0\",\r\n   \"ydk_version\": \"0.5.2\",\r\n   \"models\": {\r\n       \"file\": [\r\n           \"ydk-id-order-bug.yang\"\r\n       ]\r\n   }\r\n}\r\n```\r\n\r\nSample usage:\r\n\r\n```python\r\nfrom ydk.providers import CodecServiceProvider\r\nfrom ydk.services import CodecService\r\n\r\nfrom ydk.models.ydk_id_order_bug.ydk_id_order_bug import MultiKeyList\r\n\r\nmodel = MultiKeyList()\r\n\r\nmodel.a = 1\r\nmodel.b = 2\r\nmodel.c = 3\r\n\r\nsvc = CodecService()\r\nsp = CodecServiceProvider(type='xml')\r\n\r\nprint(svc.encode(sp, model))\r\n\r\n## Output:\r\n# <multi-key-list xmlns=\"http://example.org/ns/yang/ydk-id-order-bug\">\r\n#   <b>2</b>\r\n#   <c>3</c>\r\n#   <a>1</a>\r\n# </multi-key-list>\r\n\r\n## Expected output:\r\n# <multi-key-list xmlns=\"http://example.org/ns/yang/ydk-id-order-bug\">\r\n#   <c>3</c>\r\n#   <b>2</b>\r\n#   <a>1</a>\r\n# </multi-key-list>\r\n```\r\n"}}
{"actor":{"display_login":"abhikeshav"}}