[NETCONF-1054] OpenApi: POST examples are incorrect Created: 13/Jun/23 Updated: 12/Sep/23 Resolved: 08/Sep/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, 6.0.3 |
| Type: | Bug | Priority: | Highest |
| Reporter: | Ivan Hrasko | Assignee: | Yaroslav Lastivka |
| Resolution: | Done | Votes: | 0 |
| Labels: | pt | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Attachments: |
|
||||||||||||||||||||||||||||||||
| Issue Links: |
|
||||||||||||||||||||||||||||||||
| Description |
|
Issue A: Currently, ODL OpenApi generates examples for POST requests which contain all configuration children in payload. This is not correct for both XML and JSON because we cannot create multiple resources with POST request. Issue B: We can try to remove all data but the key from payload and we get working example for JSON: POST /rests/data/network-topology:network-topology/topology=topology-id
{
"topology-id": "topology-id"
}
But even this approach does not work for XML, for example: POST /rests/data/network-topology:network-topology/topology=topology-id <?xml version="1.0" encoding="UTF-8"?> <topology xmlns="urn:TBD:params:xml:ns:yang:network-topology"> <topology-id xmlns="urn:TBD:params:xml:ns:yang:network-topology">topology-id</topology-id> </topology> Because Swagger UI automatically encloses child into topology element (what's correct behavior for XML payloads). Instead we should just POST one child as follows: <?xml version="1.0" encoding="UTF-8"?> <topology-id xmlns="urn:TBD:params:xml:ns:yang:network-topology">Some topology-id</topology-id> Solution: POST payloads should contains only the key (lists with key) or empty body (lists without key or containers). Issue B will be addressed separately. |
| Comments |
| Comment by Ivan Hrasko [ 02/Aug/23 ] |
|
It has been proven that we do not need to create cumbersome separate logic to create empty containers and lists but instead we can use schema for the first child of the container/list. There are two cases:
IMO we have everything needed in BaseYangOpenApiGenerator#addPaths to easily implement all needed logic to distinguish between container and list and add child local name into schema name. This approach solves the problem with XML payloads, too. |
| Comment by Ivan Hrasko [ 02/Aug/23 ] |
|
The XML problem mentioned here is solved by |
| Comment by Ivan Hrasko [ 24/Aug/23 ] |
|
There are some problems on 5.0.x and 4.0.x branches. yaroslav.lastivka please explain/fix. |
| Comment by Yaroslav Lastivka [ 08/Sep/23 ] |
|
Since we have applied changes https://git.opendaylight.org/gerrit/c/netconf/+/107479 on 5.0.x and 4.0.x, we faced the problem of unnecessary "_post", and "_xml" prefixes for POST requests. |
| Comment by Ivan Hrasko [ 08/Sep/23 ] |
|
OK, thanks. |