Uploaded image for project: 'netconf'
  1. netconf
  2. NETCONF-1164

OpenAPI POST request generates incorrect XML example payload

XMLWordPrintable

      Provided model create wrong XML payload for POST request:

      curl -X 'POST' \
        'http://localhost:8181/rests/data/network-topology:network-topology/topology=topology-netconf/node=36001-sim-device/yang-ext:mount/toaster-example:toaster' \
        -H 'accept: */*' \
        -H 'Content-Type: application/xml' \
        -d '<?xml version="1.0" encoding="UTF-8"?>
      <toaster xmlns="http://netconfcentral.org/ns/toaster/example">
      	<darknessFactor>0</darknessFactor>
      </toaster>' 

      The correct request should be:

      curl -X 'POST' \
        'http://localhost:8181/rests/data/network-topology:network-topology/topology=topology-netconf/node=36001-sim-device/yang-ext:mount/toaster-example:toaster' \
        -H 'accept: */*' \
        -H 'Content-Type: application/xml' \
        -d '<?xml version="1.0" encoding="UTF-8"?>
      <darknessFactor xmlns="http://netconfcentral.org/ns/toaster/example">0</darknessFactor>' 

      This issue arises because OpenAPI generates a virtual XML wrapper for all XML objects, which, in this specific case, is incorrect.

        "toaster-example_toaster": {
          "properties": {
            "darknessFactor": {
              "default": 1000,
              "description": "The darkness factor. Basically, the number of ms to multiple the doneness value by.",
              "type": "integer",
              "example": 0,
              "format": "int64",
              "uniqueItems": false
            }
          },
          "xml": {
            "name": "toaster",
            "namespace": "http://netconfcentral.org/ns/toaster/example",
            "attribute": false,
            "wrapped": false
          },
          "description": "Top-level container for all toaster database objects.",
          "title": "toaster-example_toaster",
          "type": "object"
        }

            SamoSchneider Samuel Schneider
            PeterSuna Peter Suna
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: