Skip to content
Merged
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 @@ -128,7 +128,7 @@ public enum RequestMappingMode {
controller("Generate the @RequestMapping annotation on the generated Api Controller Implementation."),
none("Do not add a class level @RequestMapping annotation.");

private String description;
private final String description;

RequestMappingMode(String description) {
this.description = description;
Expand Down Expand Up @@ -949,7 +949,6 @@ public void preprocessOpenAPI(OpenAPI openAPI) {

if (openAPI.getPaths() != null) {
for (final Map.Entry<String, PathItem> openAPIGetPathsEntry : openAPI.getPaths().entrySet()) {
final String pathname = openAPIGetPathsEntry.getKey();
final PathItem path = openAPIGetPathsEntry.getValue();
if (path.readOperations() != null) {
for (final Operation operation : path.readOperations()) {
Expand All @@ -960,9 +959,9 @@ public void preprocessOpenAPI(OpenAPI openAPI) {
value.put("tag", escapeText(tag));
tags.add(value);
}
if (operation.getTags().size() > 0) {
if (!operation.getTags().isEmpty()) {
final String tag = operation.getTags().get(0);
operation.setTags(Arrays.asList(tag));
operation.setTags(Collections.singletonList(tag));
}
operation.addExtension("x-tags", tags);
}
Expand Down Expand Up @@ -1065,29 +1064,28 @@ private interface DataTypeAssigner {
* fields in the model.
*/
private void doDataTypeAssignment(String returnType, DataTypeAssigner dataTypeAssigner) {
final String rt = returnType;
if (rt == null) {
if (returnType == null) {
dataTypeAssigner.setReturnType("Void");
dataTypeAssigner.setIsVoid(true);
} else if (rt.startsWith("List") || rt.startsWith("java.util.List")) {
final int start = rt.indexOf("<");
final int end = rt.lastIndexOf(">");
} else if (returnType.startsWith("List") || returnType.startsWith("java.util.List")) {
final int start = returnType.indexOf("<");
final int end = returnType.lastIndexOf(">");
if (start > 0 && end > 0) {
dataTypeAssigner.setReturnType(rt.substring(start + 1, end).trim());
dataTypeAssigner.setReturnType(returnType.substring(start + 1, end).trim());
dataTypeAssigner.setReturnContainer("List");
}
} else if (rt.startsWith("Map") || rt.startsWith("java.util.Map")) {
final int start = rt.indexOf("<");
final int end = rt.lastIndexOf(">");
} else if (returnType.startsWith("Map") || returnType.startsWith("java.util.Map")) {
final int start = returnType.indexOf("<");
final int end = returnType.lastIndexOf(">");
if (start > 0 && end > 0) {
dataTypeAssigner.setReturnType(rt.substring(start + 1, end).split(",", 2)[1].trim());
dataTypeAssigner.setReturnType(returnType.substring(start + 1, end).split(",", 2)[1].trim());
dataTypeAssigner.setReturnContainer("Map");
}
} else if (rt.startsWith("Set") || rt.startsWith("java.util.Set")) {
final int start = rt.indexOf("<");
final int end = rt.lastIndexOf(">");
} else if (returnType.startsWith("Set") || returnType.startsWith("java.util.Set")) {
final int start = returnType.indexOf("<");
final int end = returnType.lastIndexOf(">");
if (start > 0 && end > 0) {
dataTypeAssigner.setReturnType(rt.substring(start + 1, end).trim());
dataTypeAssigner.setReturnType(returnType.substring(start + 1, end).trim());
dataTypeAssigner.setReturnContainer("Set");
}
}
Expand Down Expand Up @@ -1140,7 +1138,7 @@ public Map<String, Object> postProcessSupportingFileData(Map<String, Object> obj

@Override
public String toApiName(String name) {
if (name.length() == 0) {
if (name.isEmpty()) {
return "DefaultApi";
}
name = sanitizeName(name);
Expand Down Expand Up @@ -1188,10 +1186,10 @@ public void postProcessModelProperty(CodegenModel model, CodegenProperty propert
}

// Add imports for Jackson
if (!Boolean.TRUE.equals(model.isEnum)) {
if (!model.isEnum) {
model.imports.add("JsonProperty");

if (Boolean.TRUE.equals(model.hasEnums)) {
if (model.hasEnums) {
model.imports.add("JsonValue");
}
} else { // enum class
Expand Down Expand Up @@ -1243,7 +1241,7 @@ public CodegenModel fromModel(String name, Schema model) {
}

// Only add Nullable import for non-enum models that may have nullable fields
if (!Boolean.TRUE.equals(codegenModel.isEnum)) {
if (!codegenModel.isEnum) {
addSpringNullableImport(codegenModel.imports);
}

Expand Down Expand Up @@ -1352,7 +1350,7 @@ public CodegenOperation fromOperation(String path, String httpMethod, Operation
if (schemaTypes.containsKey("array")) {
// we have a match with SSE pattern
// double check potential conflicting, multiple specs
if (schemaTypes.keySet().size() > 1) {
if (schemaTypes.size() > 1) {
throw new RuntimeException("only 1 response media type supported, when SSE is detected");
}
// double check schema format
Expand Down Expand Up @@ -1384,8 +1382,7 @@ public CodegenOperation fromOperation(String path, String httpMethod, Operation
// Run through toModelName so that schemaMappings (e.g. User → com.example.MyUser)
// are honored: the mapped name is used both in the type arg and for import resolution.
String itemType = toModelName(detected.itemSchemaName);
String newBaseType = pagedModelClassName + "<" + itemType + ">";
codegenOperation.returnType = newBaseType;
codegenOperation.returnType = pagedModelClassName + "<" + itemType + ">";
codegenOperation.returnBaseType = pagedModelClassName;
// Clear any container flag — PagedModel is not itself a List/array
codegenOperation.returnContainer = null;
Expand Down Expand Up @@ -1432,7 +1429,7 @@ private Set<String> reformatProvideArgsParams(Operation operation) {
}
}
String newArg = String.join(" ", newArgs);
LOGGER.trace("new arg {} {}", newArg);
LOGGER.trace("new arg {}", newArg);
formattedArgs.add(newArg);
}
}
Expand Down
Loading