Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generator tweaks #308

Merged
merged 2 commits into from
Feb 15, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.Set;
import java.util.TreeSet;
import java.util.regex.Matcher;
Expand Down Expand Up @@ -3840,12 +3841,17 @@ protected void configureDataForTestTemplate(CodegenOperation codegenOperation) {
final String pathParam = path.substring(path.indexOf("{"), path.indexOf("}") + 1);
final String paramName = pathParam.replace("{", StringUtils.EMPTY).replace("}", StringUtils.EMPTY);

final CodegenParameter codegenParameter = codegenOperation
final Optional<CodegenParameter> optionalCodegenParameter = codegenOperation
.pathParams
.stream()
.filter(codegenParam -> codegenParam.baseName.equals(paramName))
.findFirst()
.get();
.findFirst();

if (!optionalCodegenParameter.isPresent()) {
return;
}

final CodegenParameter codegenParameter = optionalCodegenParameter.get();

if (codegenParameter.testExample == null) {
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -697,7 +697,7 @@ public String toDefaultValue(Schema schema) {
}

return String.format(pattern, typeDeclaration);
} else if (schema instanceof MapSchema) {
} else if (schema instanceof MapSchema || (schema.getAdditionalProperties() != null && (schema.getAdditionalProperties() instanceof Schema))) {
final String pattern;
if (fullJavaUtil) {
pattern = "new java.util.HashMap<%s>()";
Expand Down