mirror of
https://github.com/OpenAPITools/openapi-generator.git
synced 2025-06-28 19:50:49 +00:00
fix
This commit is contained in:
parent
ef50215438
commit
f362ff1e88
@ -361,7 +361,4 @@ public interface CodegenConfig {
|
||||
boolean getUseOpenapiNormalizer();
|
||||
|
||||
Set<String> getOpenapiGeneratorIgnoreList();
|
||||
|
||||
void setApplyCamelizeFix(boolean applyCamelizeFix);
|
||||
|
||||
}
|
||||
|
@ -316,9 +316,6 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
// Whether to automatically hardcode params that are considered Constants by OpenAPI Spec
|
||||
protected boolean autosetConstants = false;
|
||||
|
||||
// when set to true, apply camelization fix
|
||||
protected boolean applyCamelizeFix = false;
|
||||
|
||||
public boolean getAddSuffixToDuplicateOperationNicknames() {
|
||||
return addSuffixToDuplicateOperationNicknames;
|
||||
}
|
||||
@ -6185,22 +6182,6 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
* @return camelized string
|
||||
*/
|
||||
protected String removeNonNameElementToCamelCase(final String name, final String nonNameElementPattern) {
|
||||
if (Boolean.parseBoolean(System.getProperty("openapi.generator.fix.camelize"))) {
|
||||
// new behaviour with fix
|
||||
String[] splitString = name.split(nonNameElementPattern);
|
||||
|
||||
if (splitString.length > 0) {
|
||||
splitString[0] = camelize(splitString[0], CamelizeOption.LOWERCASE_FIRST_CHAR);
|
||||
}
|
||||
|
||||
String result = Arrays.stream(splitString)
|
||||
.map(StringUtils::capitalize)
|
||||
.collect(Collectors.joining(""));
|
||||
if (result.length() > 0) {
|
||||
result = result.substring(0, 1).toLowerCase(Locale.ROOT) + result.substring(1);
|
||||
}
|
||||
return result;
|
||||
} else { // old behaviour with bug
|
||||
String result = Arrays.stream(name.split(nonNameElementPattern))
|
||||
.map(StringUtils::capitalize)
|
||||
.collect(Collectors.joining(""));
|
||||
@ -6209,7 +6190,6 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String apiFilename(String templateName, String tag) {
|
||||
@ -8552,8 +8532,6 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
this.autosetConstants = autosetConstants;
|
||||
}
|
||||
|
||||
public void setApplyCamelizeFix(boolean applyCamelizeFix) { this.applyCamelizeFix = applyCamelizeFix; }
|
||||
|
||||
/**
|
||||
* This method removes all constant Query, Header and Cookie Params from allParams and sets them as constantParams in the CodegenOperation.
|
||||
* The definition of constant is single valued required enum params.
|
||||
|
@ -17,7 +17,6 @@
|
||||
|
||||
package org.openapitools.codegen;
|
||||
|
||||
import com.fasterxml.jackson.databind.annotation.JsonAppend;
|
||||
import io.swagger.v3.core.util.Json;
|
||||
import io.swagger.v3.oas.models.OpenAPI;
|
||||
import io.swagger.v3.oas.models.Operation;
|
||||
@ -262,7 +261,6 @@ public class DefaultGenerator implements Generator {
|
||||
if (config.additionalProperties().containsKey("applyCamelizeFix")) {
|
||||
org.openapitools.codegen.utils.StringUtils.applyCamelizeFix =
|
||||
Boolean.parseBoolean(String.valueOf(config.additionalProperties().get("applyCamelizeFix")));
|
||||
config.setApplyCamelizeFix(true);
|
||||
}
|
||||
|
||||
config.processOpts();
|
||||
|
@ -41,9 +41,6 @@ public class StringUtils {
|
||||
|
||||
// A cache of escaped words, used to optimize the performance of the escape() method.
|
||||
private static Cache<EscapedNameOptions, String> escapedWordsCache;
|
||||
|
||||
|
||||
|
||||
static {
|
||||
int cacheSize = Integer.parseInt(GlobalSettings.getProperty(NAME_CACHE_SIZE_PROPERTY, "200"));
|
||||
int cacheExpiry = Integer.parseInt(GlobalSettings.getProperty(NAME_CACHE_EXPIRY_PROPERTY, "5"));
|
||||
@ -64,7 +61,6 @@ public class StringUtils {
|
||||
.expireAfterAccess(cacheExpiry, TimeUnit.SECONDS)
|
||||
.ticker(Ticker.systemTicker())
|
||||
.build();
|
||||
|
||||
}
|
||||
|
||||
private static Pattern capitalLetterPattern = Pattern.compile("([A-Z]+)([A-Z][a-z][a-z]+)");
|
||||
|
@ -4915,6 +4915,7 @@ public class DefaultCodegenTest {
|
||||
|
||||
public void testRemoveNonNameElementToCamelCase() {
|
||||
final DefaultCodegen codegen = new DefaultCodegen();
|
||||
Assert.assertFalse(org.openapitools.codegen.utils.StringUtils.applyCamelizeFix);
|
||||
|
||||
final String alreadyCamelCase = "aVATRate";
|
||||
Assert.assertEquals(codegen.removeNonNameElementToCamelCase(alreadyCamelCase), alreadyCamelCase);
|
||||
|
Loading…
x
Reference in New Issue
Block a user