Fix error in example return value for certain containers

Signed-off-by: tim.quinn@oracle.com <tim.quinn@oracle.com>
This commit is contained in:
tim.quinn@oracle.com
2022-10-14 10:16:51 -05:00
parent 715bbfab56
commit cec28261e1

View File

@@ -19,8 +19,10 @@ package org.openapitools.codegen.languages;
import java.nio.file.Paths;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Set;
import java.util.stream.Collectors;
@@ -64,6 +66,14 @@ public abstract class JavaHelidonCommonCodegen extends AbstractJavaCodegen
private static final String VALIDATION_ARTIFACT_PREFIX_JAVAX = "";
private static final String VALIDATION_ARTIFACT_PREFIX_JAKARTA = MICROPROFILE_ROOT_PACKAGE_JAKARTA + ".";
private static final Map<String, String> EXAMPLE_RETURN_VALUES = new HashMap<String, String>() {
{
put("set", "Set");
put("array", "List");
put("map", "Map");
}
};
// for generated doc
static final String MICROPROFILE_ROOT_PACKAGE_DEFAULT =
"Helidon 2.x and earlier: " + MICROPROFILE_ROOT_PACKAGE_JAVAX
@@ -273,15 +283,13 @@ public abstract class JavaHelidonCommonCodegen extends AbstractJavaCodegen
private String chooseExampleReturnTypeValue(CodegenOperation op) {
// See DefaultCodegen#handleMethodResponse to see how the various op fields related to the return type are set.
if (op.returnType == null) {
return ""; // won't be used anyway in the templates
}
if (op.isMap) {
return "java.util.Collections.emptyMap()";
}
if (op.isArray) {
return "java.util.Collections.emptyList()";
if (op.returnContainer != null) {
return "java.util.Collections.empty" + EXAMPLE_RETURN_VALUES.get(op.returnContainer) + "()";
}
switch (op.returnType) {
case "Integer":