- CPS-461Getting issue details... STATUS
Introduction
Yang module used for testing
It has been noted that the json content for read and write requests in CPS-Core is inconsistent
Description | Response for getDataNode root node | Response for getDataNode non root node | body when writing (root) DataNode |
---|---|---|---|
Operation | GET | GET | POST/PUT |
xPath | / | /bookstore/categories[@code='01'] | / |
Response /Body |
| { } |
|
Notes | The response includes the 'value' of the bookstore node ie. the leaves and children | <= Same | the body needs to include the whole container object. |
Solution
# | Solutions | Issues |
---|---|---|
1 | Use the parent node xpath in order to wrap the queried leaves. eg query xpath = /bookstore/categories[@code='01'] => categories | This should be reasonably straightforward as the node is named after the container name given by the module yang file. |
For the JSON output of Get DataNode we need to alter the DataMapUtils class. The function toDataMap translates a datanode object to a JSON output. We only want this to occur on the top node and as such we can create a new method which is called before toDataMap:
public static Map<String, Object> toDataMapTopNode(final DataNode dataNode) {
final String nodeName = dataNode.getXpath().substring(dataNode.getXpath().lastIndexOf('/') + 1)
.replaceAll("\\[.*?\\]", "");
return ImmutableMap.<String, Object>builder().put(nodeName,
toDataMap(dataNode)
).build();
}
We only want the container name on the top level of the JSON output and as such have to distinguish between a top level node and non top level node. We create an outer map to wrap the inner map which creates the appropriate levels in the JSON output.
This produces the following response in the Post Request output:
Description | Response for getDataNode root node | Response for getDataNode non root node |
---|---|---|
Operation | GET | GET |
xPath | / | /bookstore/categories[@code='01'] |
Response /Body | { } } | { } } |
Notes | Response includes the container bookstore | The response includes the list categories |
Tests would need to be updated to accept the new JSON output which is returned. Examples would need to be updated in openapi
Outstanding issues:
Backwards Incompatibility: | New endpoint vs new version of interface |
---|---|
Other Endpoints: | Is this effecting any other endpoints |