Uploaded image for project: 'Configuration Persistence Service'
  1. Configuration Persistence Service
  2. CPS-1258

List attribute does not accept singular value attribute

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Not a Bug
    • Icon: Medium Medium
    • Jakarta Release
    • Jakarta Release
    • CPS-Core-REST
    • None

      CPS RESt does not support application/xml inout type and consequence the conversion of the device's configuration, which typically comes in an XML format, into JSON must be done before sending the request to update the anchor's data. The XML to JSON conversion has limitations and in corner cases, conversion into JSON List attribute is not possible if XML has only one element in the list - it is not possible to determine how XML should be converted to JSON. It is possible only if the client will have access to the YANG model to convert XML wisely. As long as CPS REST does not support application/xml Content-Type CPS REST should automatically convert the value attribute into a List with one element when the YANG model expects the list value.

      Happy Path

      original XML config

      <root>
      	<a>
      		<param>sub value</param>
      		<param-list>first</param-list>
      		<param-list>second</param-list>
      	</a>
      	<b>value</b>
      </root>
      

      auto-converted to JSON and expected by CPS

      {
      	"a": {
      		"param": "sub value ",
      		"param-list": ["first", "second"]
      	},
      	"b": "value"
      }
      

      Unhappy Path

      original XML config

      <root>
      	<a>
      		<param>sub value</param>
      		<param-list>first</param-list>
      	</a>
      	<b>value</b>
      </root>
      

      auto-converted to JSON (wrongly) but should be accepted by CPS as "param-list" string value may be auto-converted by CPS to "param-list" list value with one element)

      {
      	"a": {
      		"param": "sub value ",
      		"param-list": "first"
      	},
      	"b": "value"
      }
      

      Expected by CPS (as of today)

      {
      	"a": {
      		"param": "sub value ",
      		"param-list": ["first"]
      	},
      	"b": "value"
      }
      

            ToineSiebelink Toine Siebelink
            rajewluk Lukasz Rajewski
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: