aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBenjamin, Max <max.benjamin@att.com>2020-07-07 10:43:22 -0400
committerBenjamin, Max (mb388a) <mb388a@att.com>2020-07-07 10:43:22 -0400
commit4d7315b9e723bfde1068d94a21e7ff6c049f701e (patch)
treee99c6ac3b1ee35a0584910a3706d7e66f5cc444a
parentaf108bdcc19cdc2cf06dacdd0705ec408bfd4910 (diff)
correctly generate local fields when prefix has
correctly generate local fields when prefix has type and name Issue-ID: SO-3032 Signed-off-by: Benjamin, Max (mb388a) <mb388a@att.com> Change-Id: I0ba88949a136fae87850553dab5b4b80b32f9824
-rw-r--r--graph-inventory/fluent-builder-maven-plugin/src/main/java/org/onap/graphinventory/generate/FluentGenerator.java7
-rw-r--r--graph-inventory/fluent-builder-maven-plugin/src/main/java/org/onap/graphinventory/generate/Patterns.java2
-rw-r--r--graph-inventory/fluent-builder-maven-plugin/src/main/java/org/onap/graphinventory/generate/SwaggerConverter.java6
3 files changed, 5 insertions, 10 deletions
diff --git a/graph-inventory/fluent-builder-maven-plugin/src/main/java/org/onap/graphinventory/generate/FluentGenerator.java b/graph-inventory/fluent-builder-maven-plugin/src/main/java/org/onap/graphinventory/generate/FluentGenerator.java
index 23a1a812df..4a8b7d90c6 100644
--- a/graph-inventory/fluent-builder-maven-plugin/src/main/java/org/onap/graphinventory/generate/FluentGenerator.java
+++ b/graph-inventory/fluent-builder-maven-plugin/src/main/java/org/onap/graphinventory/generate/FluentGenerator.java
@@ -325,13 +325,8 @@ public class FluentGenerator {
String value;
String name;
- if (params.group(2) != null) {
- name = params.group(2);
- } else {
- name = params.group(1);
- }
value = params.group(1);
-
+ name = params.group(2);
name = CaseFormat.LOWER_HYPHEN.to(CaseFormat.LOWER_CAMEL, name);
classFields.add(FieldSpec.builder(String.class, name, Modifier.PUBLIC, Modifier.FINAL)
diff --git a/graph-inventory/fluent-builder-maven-plugin/src/main/java/org/onap/graphinventory/generate/Patterns.java b/graph-inventory/fluent-builder-maven-plugin/src/main/java/org/onap/graphinventory/generate/Patterns.java
index 8be22e1dcc..d27794c127 100644
--- a/graph-inventory/fluent-builder-maven-plugin/src/main/java/org/onap/graphinventory/generate/Patterns.java
+++ b/graph-inventory/fluent-builder-maven-plugin/src/main/java/org/onap/graphinventory/generate/Patterns.java
@@ -7,5 +7,5 @@ public class Patterns {
public static final Pattern pluralPattern = Pattern.compile(".*(?<partial>/(?<name>[^{]*$))");
public static final Pattern singularPattern = Pattern.compile(".*(?<partial>/(?<name>[^/{}]*)/\\{.*$)");
public static final Pattern topLevelPattern = Pattern.compile("^/([^/]+)/.*");
- public static final Pattern urlTemplatePattern = Pattern.compile("\\{([^}.]+(?:\\.([^}]+))?)\\}");
+ public static final Pattern urlTemplatePattern = Pattern.compile("\\{((?:.+\\.)?([^}.]+))\\}");
}
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 42305488bc..ec09af8a4e 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
@@ -125,8 +125,6 @@ public class SwaggerConverter {
}
}
- log.debug(mapper.writerWithDefaultPrettyPrinter().writeValueAsString(output));
-
for (Map.Entry<String, ObjectType> item : output.entrySet()) {
if (item.getValue().getType().equals("plural")) {
@@ -156,7 +154,7 @@ public class SwaggerConverter {
Matcher templates = Patterns.urlTemplatePattern.matcher(item.getValue().getPartialUri());
List<String> localFields = new ArrayList<>();
while (templates.find()) {
- localFields.add(templates.group(1));
+ localFields.add(templates.group(2));
}
item.getValue().setFields(item.getValue().getFields().stream()
.filter(f -> localFields.contains(f.getName())).collect(Collectors.toList()));
@@ -166,6 +164,8 @@ public class SwaggerConverter {
output.values().stream().filter(item -> item.getType().equals("plural"))
.forEach(item -> item.getChildren().clear());
+ log.debug(mapper.writerWithDefaultPrettyPrinter().writeValueAsString(output));
+
return output;
}
}