aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBenjamin, Max <max.benjamin@att.com>2020-11-30 20:08:25 -0500
committerBenjamin, Max (mb388a) <mb388a@att.com>2021-01-05 10:32:30 -0500
commit6a9bc85d041384beb5acbc0c6982f6107a4fa9f0 (patch)
treed6c29949a7917b0b924dc3988227cbd050121641
parente036ebd43a0b58eda96b2546290bba2189bb3824 (diff)
allow automatic selection of swagger file by
allow automatic selection of swagger file by LATEST Issue-ID: SO-3408 Signed-off-by: Benjamin, Max (mb388a) <mb388a@att.com> Change-Id: I879244cc0cd76cf4a5a6f9bf70598da4f6973b83
-rw-r--r--graph-inventory/aai-client/pom.xml2
-rw-r--r--graph-inventory/fluent-builder-maven-plugin/src/main/java/org/onap/graphinventory/generate/SwaggerConverter.java22
2 files changed, 23 insertions, 1 deletions
diff --git a/graph-inventory/aai-client/pom.xml b/graph-inventory/aai-client/pom.xml
index d1c9742cea..d532103c40 100644
--- a/graph-inventory/aai-client/pom.xml
+++ b/graph-inventory/aai-client/pom.xml
@@ -93,7 +93,7 @@
<destination>${project.build.directory}/generated-sources</destination>
<destinationClasspath>org.onap.aaiclient.client.generated.fluentbuilders</destinationClasspath>
<builderName>AAIFluentTypeBuilder</builderName>
- <swaggerLocation>${project.build.directory}/swagger/onap/aai_swagger_yaml/aai_swagger_v21.yaml</swaggerLocation>
+ <swaggerLocation>${project.build.directory}/swagger/onap/aai_swagger_yaml/aai_swagger_LATEST.yaml</swaggerLocation>
<singularBuilderClass>org.onap.aaiclient.client.aai.entities.uri.AAIFluentSingleType</singularBuilderClass>
<pluralBuilderClass>org.onap.aaiclient.client.aai.entities.uri.AAIFluentPluralType</pluralBuilderClass>
<topLevelBuilderClass>org.onap.aaiclient.client.aai.entities.uri.AAIFluentTopLevelType</topLevelBuilderClass>
diff --git a/graph-inventory/fluent-builder-maven-plugin/src/main/java/org/onap/graphinventory/generate/SwaggerConverter.java b/graph-inventory/fluent-builder-maven-plugin/src/main/java/org/onap/graphinventory/generate/SwaggerConverter.java
index ec09af8a4e..fc42d9ca0d 100644
--- a/graph-inventory/fluent-builder-maven-plugin/src/main/java/org/onap/graphinventory/generate/SwaggerConverter.java
+++ b/graph-inventory/fluent-builder-maven-plugin/src/main/java/org/onap/graphinventory/generate/SwaggerConverter.java
@@ -1,6 +1,10 @@
package org.onap.graphinventory.generate;
+import java.io.IOException;
+import java.nio.file.Files;
+import java.nio.file.Paths;
import java.util.ArrayList;
+import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
@@ -26,6 +30,9 @@ public class SwaggerConverter {
}
public Map<String, ObjectType> getDoc(String swaggerLocation) throws JsonProcessingException {
+
+
+ swaggerLocation = processLocation(swaggerLocation);
Swagger swagger = new SwaggerParser().read(swaggerLocation);
Map<String, Path> paths = swagger.getPaths().entrySet().stream()
@@ -168,4 +175,19 @@ public class SwaggerConverter {
return output;
}
+
+ private String processLocation(String swaggerLocation) {
+
+ java.nio.file.Path path = Paths.get(swaggerLocation);
+ try {
+ return Files.list(path.getParent())
+ .filter(it -> it.getFileName().toString()
+ .matches(path.getFileName().toString().replaceFirst("LATEST", "v\\\\\\d+")))
+ .sorted(Comparator.reverseOrder()).map(it -> it.toString()).findFirst().orElseGet(null);
+ } catch (IOException e) {
+ log.error(e);
+ }
+
+ return null;
+ }
}