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

Enhancement of merging algorithm. #3298

Merged
merged 4 commits into from
May 3, 2020
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
import springfox.documentation.spi.schema.EnumTypeDeterminer;
import springfox.documentation.spi.schema.contexts.ModelContext;

import java.util.HashMap;
import java.util.Collections;
import java.util.Map;
import java.util.Optional;
import java.util.function.Function;
Expand All @@ -50,7 +50,7 @@ class ModelReferenceProvider implements Function<ResolvedType, ModelReference> {
this.typeNameExtractor = typeNameExtractor;
this.enumTypeDeterminer = enumTypeDeterminer;
this.parentContext = parentContext;
this.knownNames = new HashMap<>(knownNames);
this.knownNames = Collections.unmodifiableMap(knownNames);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import org.slf4j.LoggerFactory;
import springfox.documentation.spi.schema.UniqueTypeNameAdapter;

import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import java.util.Optional;
Expand All @@ -35,7 +36,7 @@ public class TypeNameIndexingAdapter implements UniqueTypeNameAdapter {

@Override
public Map<String, String> getNames() {
return new HashMap<>(knownNames);
return Collections.unmodifiableMap(knownNames);
}

@Override
Expand Down Expand Up @@ -87,10 +88,10 @@ public void registerUniqueType(
String tempName = typeName;
while (knownNames.values().contains(tempName)) {
++nameIndex;
tempName = String.format(
"%s_%s",
typeName,
nameIndex);
tempName = new StringBuilder(typeName)
.append("_")
.append(nameIndex).
toString();
}
knownNames.put(
modelId,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,10 @@ private ModelContext(
this.view = view;
this.validationGroups = new HashSet<>(validationGroups);
this.modelBuilder =
new ModelBuilder(String.format(
"%s_%s",
parameterId,
type.getBriefDescription()));
new ModelBuilder(new StringBuilder(parameterId)
.append("_")
.append(type.getBriefDescription()).
toString());
}

@SuppressWarnings("ParameterNumber")
Expand All @@ -99,10 +99,10 @@ private ModelContext(
this.registeredTypes = parentContext.registeredTypes;
this.genericNamingStrategy = parentContext.getGenericNamingStrategy();
this.modelBuilder =
new ModelBuilder(String.format(
"%s_%s",
parameterId,
input.getBriefDescription()));
new ModelBuilder(new StringBuilder(parameterId)
.append("_")
.append(type.getBriefDescription()).
toString());
}

/**
Expand All @@ -123,10 +123,10 @@ public String getParameterId() {
* @return type id behind this context
*/
public String getTypeId() {
return String.format(
"%s_%s",
parameterId,
type.getBriefDescription());
return new StringBuilder(parameterId)
.append("_")
.append(type.getBriefDescription()).
toString();
}

/**
Expand Down Expand Up @@ -359,7 +359,7 @@ public String description() {
.append("{")
.append("groupName=").append(this.getGroupName()).append(", ")
.append("type=").append(this.getType()).append(", ")
.append("isReturnType=").append(this.isReturnType())
.append("isReturnType=").append(this.isReturnType()).append(", ")
.append("view=").append(this.getView())
.append("}").toString();
}
Expand Down