[NETCONF-1083] OpenApi returns 400 error after PUT request on toaster data Created: 12/Jul/23 Updated: 14/Aug/23 Resolved: 14/Aug/23 |
|
| Status: | Resolved |
| Project: | netconf |
| Component/s: | restconf-openapi |
| Affects Version/s: | None |
| Fix Version/s: | 7.0.0, 4.0.9, 5.0.8, 6.0.2 |
| Type: | Bug | Priority: | Medium |
| Reporter: | Peter Suna | Assignee: | Oleksandr Zharov |
| Resolution: | Done | Votes: | 0 |
| Labels: | pt | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Attachments: |
|
| Description |
|
Prepared PUT request in OpenApi for "yang-ext:mount/toaster2:toaster" return 400 with error message "Error parsing input: Choose suitable module name for element toaster:\ntoaster\ntoaster2"
|
| Comments |
| Comment by Peter Suna [ 19/Jul/23 ] |
|
The issue is that Json require name of the model in top container.
{
"toaster2:toaster": {
"toasterSlot": [
{
"slotId": "Some slotId",
"slotInfo": {
"numberOfToastPrepared": 0
}
}
],
"darknessFactor": 0
}
}
To resolve this issue, it is necessary to add the module name to the top elements: `"toaster: {"` -> `"toaster2:toaster: {"` |
| Comment by Ivan Hrasko [ 19/Jul/23 ] |
|
Interestingly PUT /rests/data/network-topology:network-topology/topology=topology-netconf/node=17830-sim-device/yang-ext:mount/car:cars with payload: {
"cars": {
"car-entry": [
{
"id": "Some id",
"model": "Some model",
"manufacturer": "Some manufacturer",
"year": 0,
"category": "Some category"
}
]
}
}
works well. The problem lies somewhere else. with/rests/data/network-topology:network-topology/topology=topology-netconf/node=17830-sim-device/yang-ext:mount/car:cars |
| Comment by Peter Suna [ 20/Jul/23 ] |
|
It appears that this issue occurs only when there are two models with the same name of the root element within the schema context. This means that if we have two models structured like this:
module test {
yang-version 1;
namespace "http://netconfcentral.org/ns/test";
prefix tst;
list list {
key leaf;
leaf leaf {
type string;
}
}
}
module test2 {
yang-version 1;
namespace "http://netconfcentral.org/ns/test2";
prefix tst2;
list list {
key leaf2;
leaf leaf2 {
type string;
}
}
}
We must include the module name in the request body. Otherwise, requests like this will fail. curl --request PUT 'http://localhost:8181/rests/data/network-topology:network-topology/topology=topology-netconf/node=36001-sim-device/yang-ext:mount/test:list=string' \ --header 'accept: */*' \ --header 'Content-Type: application/json' \ --header 'Authorization: Basic YWRtaW46YWRtaW4=' \ --data '{ "list": [ { "leaf": "string" } ] }' Response:
{
"errors": {
"error": [
{
"error-tag": "malformed-message",
"error-info": "Choose suitable module name for element list:\ntest2\ntest",
"error-message": "Error parsing input: Choose suitable module name for element list:\ntest2\ntest",
"error-type": "protocol"
}
]
}
}
|