[NETCONF-976] The required fields are created, but they are not populate in the Swagger API Created: 15/Mar/23  Updated: 14/Jul/23  Resolved: 14/Jul/23

Status: Resolved
Project: netconf
Component/s: restconf-openapi
Affects Version/s: 5.0.0, 4.0.3
Fix Version/s: 6.0.0, 5.0.7, 4.0.9

Type: Bug Priority: Medium
Reporter: Peter Suna Assignee: Peter Suna
Resolution: Done Votes: 0
Labels: pt, regression
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified


 Description   

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



 Comments   
Comment by Ivan Hrasko [ 15/Mar/23 ]

https://www.rfc-editor.org/rfc/rfc7950#page-14 says that mandatory attribute can be used with: leaf, choice, anydata, anyxml, list (under some conditions), leaf-list (under some conditions) and container (under some conditions).

Comment by Ivan Hrasko [ 15/Mar/23 ]

The mandatory attribute is no more written since fix of NETCONF-883.

Comment by Ivan Hrasko [ 15/Mar/23 ]

In addition, we are missing implementation of logic for lists, leaf-lists and containers.

Comment by Ivan Hrasko [ 27/Jun/23 ]

Unfortunately, branches 4.0.x and 5.0.x don't contain https://git.opendaylight.org/gerrit/c/netconf/+/105042. Thus we have to add mandatory logic into _xml and _post schemas to make fix complete on those branches.

Generated at Wed Feb 07 20:16:23 UTC 2024 using Jira 8.20.10#820010-sha1:ace47f9899e9ee25d7157d59aa17ab06aee30d3d.