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

The required fields are created, but they are not populate in the Swagger API

XMLWordPrintable

      During the processing of container nodes in the DefinitionGenerator, required fields are not being populated. While an array for required fields is created in this method, it is not being passed to the processChildNode method.

       

              final ArrayNode required = JsonNodeFactory.instance.arrayNode();
              for (final DataSchemaNode node : nodes) {
                  if (!isConfig || node.isConfiguration()) {
                      processChildNode(node, parentName, definitions, definitionNames, isConfig, stack, properties,
                              oaversion);
                  }
              }
              parentNode.set(PROPERTIES_KEY, properties);
              setRequiredIfNotEmpty(parentNode, required);

      https://github.com/opendaylight/netconf/blob/master/restconf/sal-rest-docgen/src/main/java/org/opendaylight/netconf/sal/rest/doc/impl/DefinitionGenerator.java#L476

       

      Instead of using the `ArrayNode required` inside the `processChildNode` method, a new ArrayNode is being used to populate the required fields, which is then never stored.

       

              if (node instanceof LeafSchemaNode leaf) {
                  processLeafNode(leaf, name, properties, JsonNodeFactory.instance.arrayNode(), stack, definitions,
                          definitionNames, oaversion);
              } else if (node instanceof AnyxmlSchemaNode anyxml) {
                  processAnyXMLNode(anyxml, name, properties, JsonNodeFactory.instance.arrayNode());
              } else if (node instanceof AnydataSchemaNode anydata) {
                  processAnydataNode(anydata, name, properties, JsonNodeFactory.instance.arrayNode());
              }
      

       

      https://github.com/opendaylight/netconf/blob/master/restconf/sal-rest-docgen/src/main/java/org/opendaylight/netconf/sal/rest/doc/impl/DefinitionGenerator.java#L507

            PeterSuna Peter Suna
            PeterSuna Peter Suna
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: