OpenApi: Add missing required elements to JSON 75/104975/27
authorPeter Suna <peter.suna@pantheon.tech>
Mon, 20 Mar 2023 07:38:30 +0000 (08:38 +0100)
committerIvan Hrasko <ivan.hrasko@pantheon.tech>
Wed, 21 Jun 2023 13:32:42 +0000 (13:32 +0000)
commit08d93cab539d7abbe045a87ba415a8a1b81637e7
tree63a35a5592895df6032d806a3980504bd643b9c5
parent52b73cfc518933890db7e3f11cb1cbf014f6663d
OpenApi: Add missing required elements to JSON

This commit adds missing mandatory nodes to the required
field of the JSON OpenApi data. According to RFC-7950, a node
is mandatory if it is:
A leaf, choice, anydata, or anyxml node with a "mandatory"
statement with the value "true".

See:
https://www.rfc-editor.org/rfc/rfc7950#page-14

The only exception for this patch is the 'choice' node.
If the 'choice' node is mandatory, we cannot require the
'choice' or 'case' name in the body.

Additionally, nodes inside the 'case' should only be required
if they are mandatory.

JIRA: NETCONF-976
Change-Id: I3d1220737a582b27163a9ff8f33ceee1edb94c87
Signed-off-by: Peter Suna <peter.suna@pantheon.tech>
Signed-off-by: Ivan Hrasko <ivan.hrasko@pantheon.tech>
restconf/restconf-openapi/src/main/java/org/opendaylight/restconf/openapi/impl/DefinitionGenerator.java
restconf/restconf-openapi/src/test/java/org/opendaylight/restconf/openapi/impl/OpenApiGeneratorRFC8040Test.java
restconf/restconf-openapi/src/test/java/org/opendaylight/restconf/openapi/mountpoints/MountPointOpenApiTest.java
restconf/restconf-openapi/src/test/resources/yang/mandatory-test.yang [new file with mode: 0644]