summaryrefslogtreecommitdiffstats
path: root/vpp-integration/api-docs
diff options
context:
space:
mode:
Diffstat (limited to 'vpp-integration/api-docs')
-rw-r--r--vpp-integration/api-docs/core/src/main/java/io/fd/hc2vpp/docs/core/CoverageGenerator.java1
-rw-r--r--vpp-integration/api-docs/core/src/main/java/io/fd/hc2vpp/docs/core/YangTypeLinkIndex.java25
2 files changed, 25 insertions, 1 deletions
diff --git a/vpp-integration/api-docs/core/src/main/java/io/fd/hc2vpp/docs/core/CoverageGenerator.java b/vpp-integration/api-docs/core/src/main/java/io/fd/hc2vpp/docs/core/CoverageGenerator.java
index bc94a74cb..fb9e3a629 100644
--- a/vpp-integration/api-docs/core/src/main/java/io/fd/hc2vpp/docs/core/CoverageGenerator.java
+++ b/vpp-integration/api-docs/core/src/main/java/io/fd/hc2vpp/docs/core/CoverageGenerator.java
@@ -97,6 +97,7 @@ public class CoverageGenerator implements VppApiUtils {
// binds Yang types with links from pre-build index
// TODO - use deserialized yii e.g. /module:parent-node/child-node
builder.setYangTypes(handler.getHandledNodes().stream()
+ .filter(YangTypeLinkIndex::hasQname)
.map(type -> new YangType(type, yangTypeIndex.getLinkForType(type)))
.collect(Collectors.toList()));
diff --git a/vpp-integration/api-docs/core/src/main/java/io/fd/hc2vpp/docs/core/YangTypeLinkIndex.java b/vpp-integration/api-docs/core/src/main/java/io/fd/hc2vpp/docs/core/YangTypeLinkIndex.java
index b4002b636..4b0a3c1bd 100644
--- a/vpp-integration/api-docs/core/src/main/java/io/fd/hc2vpp/docs/core/YangTypeLinkIndex.java
+++ b/vpp-integration/api-docs/core/src/main/java/io/fd/hc2vpp/docs/core/YangTypeLinkIndex.java
@@ -20,10 +20,16 @@ import static java.lang.String.format;
import java.io.IOException;
import java.lang.reflect.Field;
+import java.util.Arrays;
+
import org.opendaylight.yangtools.yang.common.QName;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
public class YangTypeLinkIndex {
+ private static final Logger LOG = LoggerFactory.getLogger(YangTypeLinkIndex.class);
+
private final ModelLinkIndex modelLinkIndex;
private final ModelTypeIndex modelTypeIndex;
@@ -36,6 +42,24 @@ public class YangTypeLinkIndex {
}
}
+ // to be able to skip augments without QNAME field
+ static boolean hasQname(final String classname) {
+ final Class<?> loadedClass;
+ try {
+ loadedClass = YangTypeLinkIndex.class.getClassLoader().loadClass(classname);
+ boolean
+ hasQname = Arrays.stream(loadedClass.getFields())
+ .anyMatch(field -> field.getName().equalsIgnoreCase("QNAME"));
+ if (!hasQname) {
+ LOG.warn("Class {} does not have a QNAME field", classname);
+ }
+
+ return hasQname;
+ } catch (ClassNotFoundException e) {
+ throw new IllegalStateException(format("Unable to load classname: %s", classname), e);
+ }
+ }
+
public String getLinkForType(final String classname) {
final Class<?> loadedClass;
final QName qname;
@@ -47,7 +71,6 @@ public class YangTypeLinkIndex {
throw new IllegalStateException(format("Unable to extract QNAME from %s", classname), e);
}
-
final String namespace = qname.getNamespace().toString();
final String formattedRevision = qname.getRevision().get().toString();
final String model = modelTypeIndex.namespaceToModule(namespace, formattedRevision);