Skip to content

Commit

Permalink
Merge branch 'bugfix/model-enhancement'
Browse files Browse the repository at this point in the history
  • Loading branch information
dilipkrish committed May 3, 2020
2 parents 34246cf + 1e96ab7 commit 4c181b6
Show file tree
Hide file tree
Showing 26 changed files with 1,836 additions and 361 deletions.
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

0 comments on commit 4c181b6

Please sign in to comment.