diff options
author | Steve Smokowski <ss835w@att.com> | 2020-07-09 14:54:20 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@onap.org> | 2020-07-09 14:54:20 +0000 |
commit | 76c3b4dd5af216b9c598063868cae98f883d90de (patch) | |
tree | f6867b72884f59dd83ec51e357afbfa2c25931d5 | |
parent | bcac6e2bb3067d8566b7228539a387aa893daa92 (diff) | |
parent | 4d7315b9e723bfde1068d94a21e7ff6c049f701e (diff) |
Merge "correctly generate local fields when prefix has"
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; } } |