forked from loafle/openapi-generator-original
Merge branch 'master' of https://github.com/OpenAPITools/openapi-generator
This commit is contained in:
commit
d57009d14d
@ -875,23 +875,6 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
throw new RuntimeException("reserved word " + name + " not allowed");
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the name with escaped characters.
|
||||
*
|
||||
* @param name the name to be escaped
|
||||
* @param charactersToAllow characters that are not escaped
|
||||
* @param appdendixToReplacement String to append to replaced characters.
|
||||
* @return the escaped word
|
||||
* <p>
|
||||
* throws Runtime exception as word is not escaped properly.
|
||||
* @see org.openapitools.codegen.utils.StringUtils#escape directly instead
|
||||
* @deprecated since version 3.2.3, may be removed with the next major release (4.0)
|
||||
*/
|
||||
@Deprecated
|
||||
public String escapeSpecialCharacters(String name, List<String> charactersToAllow, String appdendixToReplacement) {
|
||||
return escape(name, specialCharReplacements, charactersToAllow, appdendixToReplacement);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the fully-qualified "Model" name for import
|
||||
*
|
||||
@ -1788,7 +1771,7 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
if (name == null || name.length() == 0) {
|
||||
return name;
|
||||
}
|
||||
return org.openapitools.codegen.utils.StringUtils.camelize(toVarName(name));
|
||||
return camelize(toVarName(name));
|
||||
}
|
||||
|
||||
|
||||
@ -1812,7 +1795,7 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
CodegenProperty property = CodegenModelFactory.newInstance(CodegenModelType.PROPERTY);
|
||||
property.name = toVarName(name);
|
||||
property.baseName = name;
|
||||
property.nameInCamelCase = org.openapitools.codegen.utils.StringUtils.camelize(property.name, false);
|
||||
property.nameInCamelCase = camelize(property.name, false);
|
||||
property.nameInSnakeCase = CaseFormat.UPPER_CAMEL.to(CaseFormat.UPPER_UNDERSCORE, property.nameInCamelCase);
|
||||
property.description = escapeText(p.getDescription());
|
||||
property.unescapedDescription = p.getDescription();
|
||||
@ -3309,8 +3292,8 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
}
|
||||
co.operationId = uniqueName;
|
||||
co.operationIdLowerCase = uniqueName.toLowerCase(Locale.ROOT);
|
||||
co.operationIdCamelCase = org.openapitools.codegen.utils.StringUtils.camelize(uniqueName);
|
||||
co.operationIdSnakeCase = org.openapitools.codegen.utils.StringUtils.underscore(uniqueName);
|
||||
co.operationIdCamelCase = camelize(uniqueName);
|
||||
co.operationIdSnakeCase = underscore(uniqueName);
|
||||
opList.add(co);
|
||||
co.baseName = tag;
|
||||
}
|
||||
@ -3332,35 +3315,6 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Underscore the given word.
|
||||
* Copied from Twitter elephant bird
|
||||
* https://github.com/twitter/elephant-bird/blob/master/core/src/main/java/com/twitter/elephantbird/util/Strings.java
|
||||
*
|
||||
* @param word The word
|
||||
* @return The underscored version of the word
|
||||
* @see org.openapitools.codegen.utils.StringUtils#underscore
|
||||
* @deprecated since version 3.2.3, may be removed with the next major release (4.0)
|
||||
*/
|
||||
@Deprecated
|
||||
public static String underscore(String word) {
|
||||
return org.openapitools.codegen.utils.StringUtils.underscore(word);
|
||||
}
|
||||
|
||||
/**
|
||||
* Dashize the given word.
|
||||
*
|
||||
* @param word The word
|
||||
* @return The dashized version of the word, e.g. "my-name"
|
||||
* @see org.openapitools.codegen.utils.StringUtils#dashize
|
||||
* @deprecated since version 3.2.3, may be removed with the next major release (4.0)
|
||||
*/
|
||||
@SuppressWarnings("static-method")
|
||||
@Deprecated
|
||||
protected String dashize(String word) {
|
||||
return org.openapitools.codegen.utils.StringUtils.dashize(word);
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate the next name for the given name, i.e. append "2" to the base name if not ending with a number,
|
||||
* otherwise increase the number by 1. For example:
|
||||
@ -3560,37 +3514,6 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Camelize name (parameter, property, method, etc) with upper case for first letter
|
||||
* copied from Twitter elephant bird
|
||||
* https://github.com/twitter/elephant-bird/blob/master/core/src/main/java/com/twitter/elephantbird/util/Strings.java
|
||||
*
|
||||
* @param word string to be camelize
|
||||
* @return camelized string
|
||||
* @see org.openapitools.codegen.utils.StringUtils#camelize(String)
|
||||
* @deprecated since version 3.2.3, may be removed with the next major release (4.0)
|
||||
*/
|
||||
@Deprecated
|
||||
public static String camelize(String word) {
|
||||
return org.openapitools.codegen.utils.StringUtils.camelize(word);
|
||||
}
|
||||
|
||||
/**
|
||||
* Camelize name (parameter, property, method, etc)
|
||||
*
|
||||
* @param word string to be camelize
|
||||
* @param lowercaseFirstLetter lower case for first letter if set to true
|
||||
* @return camelized string
|
||||
* @see org.openapitools.codegen.utils.StringUtils#camelize(String, boolean)
|
||||
* @deprecated since version 3.2.3, may be removed with the next major release (4.0)
|
||||
*/
|
||||
@Deprecated
|
||||
public static String camelize(String word, boolean lowercaseFirstLetter) {
|
||||
return org.openapitools.codegen.utils.StringUtils.camelize(word, lowercaseFirstLetter);
|
||||
}
|
||||
|
||||
|
||||
public String apiFilename(String templateName, String tag) {
|
||||
String suffix = apiTemplateFiles().get(templateName);
|
||||
return apiFileFolder() + File.separator + toApiFilename(tag) + suffix;
|
||||
|
@ -46,6 +46,7 @@ import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
|
||||
import static org.openapitools.codegen.utils.StringUtils.camelize;
|
||||
|
||||
abstract public class AbstractAdaCodegen extends DefaultCodegen implements CodegenConfig {
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(AbstractAdaCodegen.class);
|
||||
@ -666,7 +667,7 @@ abstract public class AbstractAdaCodegen extends DefaultCodegen implements Codeg
|
||||
// method with only the scope that it requires. We have to create a new auth method
|
||||
// instance because the original object must not be modified.
|
||||
List<String> opScopes = (scopes == null) ? null : scopes.get(authMethod.name);
|
||||
authMethod.name = org.openapitools.codegen.utils.StringUtils.camelize(sanitizeName(authMethod.name), true);
|
||||
authMethod.name = camelize(sanitizeName(authMethod.name), true);
|
||||
if (opScopes != null) {
|
||||
CodegenSecurity opSecurity = new CodegenSecurity();
|
||||
opSecurity.name = authMethod.name;
|
||||
|
@ -36,6 +36,8 @@ import io.swagger.v3.oas.models.responses.ApiResponse;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import static org.openapitools.codegen.utils.StringUtils.camelize;
|
||||
|
||||
public abstract class AbstractApexCodegen extends DefaultCodegen implements CodegenConfig {
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(AbstractApexCodegen.class);
|
||||
|
||||
@ -112,7 +114,7 @@ public abstract class AbstractApexCodegen extends DefaultCodegen implements Code
|
||||
|
||||
// camelize (lower first character) the variable name
|
||||
// pet_id => petId
|
||||
name = org.openapitools.codegen.utils.StringUtils.camelize(name, true);
|
||||
name = camelize(name, true);
|
||||
|
||||
// for reserved word or word starting with number, append _
|
||||
if (isReservedWord(name) || name.matches("^\\d.*")) {
|
||||
@ -159,7 +161,7 @@ public abstract class AbstractApexCodegen extends DefaultCodegen implements Code
|
||||
|
||||
// camelize the model name
|
||||
// phone_number => PhoneNumber
|
||||
final String camelizedName = org.openapitools.codegen.utils.StringUtils.camelize(nameWithPrefixSuffix);
|
||||
final String camelizedName = camelize(nameWithPrefixSuffix);
|
||||
|
||||
// model name cannot use reserved keyword, e.g. return
|
||||
if (isReservedWord(camelizedName)) {
|
||||
@ -422,11 +424,11 @@ public abstract class AbstractApexCodegen extends DefaultCodegen implements Code
|
||||
throw new RuntimeException("Empty method/operation name (operationId) not allowed");
|
||||
}
|
||||
|
||||
operationId = org.openapitools.codegen.utils.StringUtils.camelize(sanitizeName(operationId), true);
|
||||
operationId = camelize(sanitizeName(operationId), true);
|
||||
|
||||
// method name cannot use reserved keyword, e.g. return
|
||||
if (isReservedWord(operationId)) {
|
||||
String newOperationId = org.openapitools.codegen.utils.StringUtils.camelize("call_" + operationId, true);
|
||||
String newOperationId = camelize("call_" + operationId, true);
|
||||
LOGGER.warn(operationId + " (reserved word) cannot be used as method name. Renamed to " + newOperationId);
|
||||
return newOperationId;
|
||||
}
|
||||
@ -515,7 +517,7 @@ public abstract class AbstractApexCodegen extends DefaultCodegen implements Code
|
||||
|
||||
@Override
|
||||
public String toEnumName(CodegenProperty property) {
|
||||
return sanitizeName(org.openapitools.codegen.utils.StringUtils.camelize(property.name)) + "Enum";
|
||||
return sanitizeName(camelize(property.name)) + "Enum";
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -669,7 +671,7 @@ public abstract class AbstractApexCodegen extends DefaultCodegen implements Code
|
||||
|
||||
@Override
|
||||
public String sanitizeTag(String tag) {
|
||||
return org.openapitools.codegen.utils.StringUtils.camelize(sanitizeName(tag));
|
||||
return camelize(sanitizeName(tag));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -40,6 +40,7 @@ import org.slf4j.LoggerFactory;
|
||||
import java.io.File;
|
||||
import java.util.*;
|
||||
|
||||
import static org.openapitools.codegen.utils.StringUtils.camelize;
|
||||
|
||||
public abstract class AbstractCSharpCodegen extends DefaultCodegen implements CodegenConfig {
|
||||
|
||||
@ -635,17 +636,17 @@ public abstract class AbstractCSharpCodegen extends DefaultCodegen implements Co
|
||||
|
||||
// method name cannot use reserved keyword, e.g. return
|
||||
if (isReservedWord(operationId)) {
|
||||
LOGGER.warn(operationId + " (reserved word) cannot be used as method name. Renamed to " + org.openapitools.codegen.utils.StringUtils.camelize(sanitizeName("call_" + operationId)));
|
||||
LOGGER.warn(operationId + " (reserved word) cannot be used as method name. Renamed to " + camelize(sanitizeName("call_" + operationId)));
|
||||
operationId = "call_" + operationId;
|
||||
}
|
||||
|
||||
// operationId starts with a number
|
||||
if (operationId.matches("^\\d.*")) {
|
||||
LOGGER.warn(operationId + " (starting with a number) cannot be used as method name. Renamed to " + org.openapitools.codegen.utils.StringUtils.camelize(sanitizeName("call_" + operationId)));
|
||||
LOGGER.warn(operationId + " (starting with a number) cannot be used as method name. Renamed to " + camelize(sanitizeName("call_" + operationId)));
|
||||
operationId = "call_" + operationId;
|
||||
}
|
||||
|
||||
return org.openapitools.codegen.utils.StringUtils.camelize(sanitizeName(operationId));
|
||||
return camelize(sanitizeName(operationId));
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -660,7 +661,7 @@ public abstract class AbstractCSharpCodegen extends DefaultCodegen implements Co
|
||||
|
||||
// camelize the variable name
|
||||
// pet_id => PetId
|
||||
name = org.openapitools.codegen.utils.StringUtils.camelize(name);
|
||||
name = camelize(name);
|
||||
|
||||
// for reserved word or word starting with number, append _
|
||||
if (isReservedWord(name) || name.matches("^\\d.*")) {
|
||||
@ -683,9 +684,9 @@ public abstract class AbstractCSharpCodegen extends DefaultCodegen implements Co
|
||||
return name;
|
||||
}
|
||||
|
||||
// org.openapitools.codegen.utils.StringUtils.camelize(lower) the variable name
|
||||
// camelize(lower) the variable name
|
||||
// pet_id => petId
|
||||
name = org.openapitools.codegen.utils.StringUtils.camelize(name, true);
|
||||
name = camelize(name, true);
|
||||
|
||||
// for reserved word or word starting with number, append _
|
||||
if (isReservedWord(name) || name.matches("^\\d.*")) {
|
||||
@ -870,19 +871,19 @@ public abstract class AbstractCSharpCodegen extends DefaultCodegen implements Co
|
||||
|
||||
// model name cannot use reserved keyword, e.g. return
|
||||
if (isReservedWord(name)) {
|
||||
LOGGER.warn(name + " (reserved word) cannot be used as model name. Renamed to " + org.openapitools.codegen.utils.StringUtils.camelize("model_" + name));
|
||||
LOGGER.warn(name + " (reserved word) cannot be used as model name. Renamed to " + camelize("model_" + name));
|
||||
name = "model_" + name; // e.g. return => ModelReturn (after camelize)
|
||||
}
|
||||
|
||||
// model name starts with number
|
||||
if (name.matches("^\\d.*")) {
|
||||
LOGGER.warn(name + " (model name starts with number) cannot be used as model name. Renamed to " + org.openapitools.codegen.utils.StringUtils.camelize("model_" + name));
|
||||
LOGGER.warn(name + " (model name starts with number) cannot be used as model name. Renamed to " + camelize("model_" + name));
|
||||
name = "model_" + name; // e.g. 200Response => Model200Response (after camelize)
|
||||
}
|
||||
|
||||
// camelize the model name
|
||||
// phone_number => PhoneNumber
|
||||
return org.openapitools.codegen.utils.StringUtils.camelize(name);
|
||||
return camelize(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -970,7 +971,7 @@ public abstract class AbstractCSharpCodegen extends DefaultCodegen implements Co
|
||||
|
||||
// for symbol, e.g. $, #
|
||||
if (getSymbolName(name) != null) {
|
||||
return org.openapitools.codegen.utils.StringUtils.camelize(getSymbolName(name));
|
||||
return camelize(getSymbolName(name));
|
||||
}
|
||||
|
||||
String enumName = sanitizeName(name);
|
||||
@ -978,7 +979,7 @@ public abstract class AbstractCSharpCodegen extends DefaultCodegen implements Co
|
||||
enumName = enumName.replaceFirst("^_", "");
|
||||
enumName = enumName.replaceFirst("_$", "");
|
||||
|
||||
enumName = org.openapitools.codegen.utils.StringUtils.camelize(enumName) + "Enum";
|
||||
enumName = camelize(enumName) + "Enum";
|
||||
|
||||
if (enumName.matches("\\d.*")) { // starts with number
|
||||
return "_" + enumName;
|
||||
@ -989,7 +990,7 @@ public abstract class AbstractCSharpCodegen extends DefaultCodegen implements Co
|
||||
|
||||
@Override
|
||||
public String toEnumName(CodegenProperty property) {
|
||||
return sanitizeName(org.openapitools.codegen.utils.StringUtils.camelize(property.name)) + "Enum";
|
||||
return sanitizeName(camelize(property.name)) + "Enum";
|
||||
}
|
||||
|
||||
public String testPackageName() {
|
||||
|
@ -49,6 +49,8 @@ import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import static com.google.common.base.Strings.isNullOrEmpty;
|
||||
import static org.openapitools.codegen.utils.StringUtils.camelize;
|
||||
import static org.openapitools.codegen.utils.StringUtils.underscore;
|
||||
|
||||
public abstract class AbstractEiffelCodegen extends DefaultCodegen implements CodegenConfig {
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(AbstractEiffelCodegen.class);
|
||||
@ -206,7 +208,7 @@ public abstract class AbstractEiffelCodegen extends DefaultCodegen implements Co
|
||||
// (after camelize)
|
||||
}
|
||||
|
||||
return org.openapitools.codegen.utils.StringUtils.underscore(name);
|
||||
return underscore(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -217,7 +219,7 @@ public abstract class AbstractEiffelCodegen extends DefaultCodegen implements Co
|
||||
// methods parameters as 'final'.
|
||||
|
||||
// e.g. PetApi.go => pet_api.go
|
||||
return org.openapitools.codegen.utils.StringUtils.underscore(name) + "_api";
|
||||
return underscore(name) + "_api";
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -335,7 +337,7 @@ public abstract class AbstractEiffelCodegen extends DefaultCodegen implements Co
|
||||
// method name cannot use reserved keyword, e.g. return
|
||||
if (isReservedWord(sanitizedOperationId)) {
|
||||
LOGGER.warn(operationId + " (reserved word) cannot be used as method name. Renamed to "
|
||||
+ org.openapitools.codegen.utils.StringUtils.camelize("call_" + operationId));
|
||||
+ camelize("call_" + operationId));
|
||||
sanitizedOperationId = "call_" + sanitizedOperationId;
|
||||
}
|
||||
// method name from updateSomething to update_Something.
|
||||
@ -353,7 +355,7 @@ public abstract class AbstractEiffelCodegen extends DefaultCodegen implements Co
|
||||
for (CodegenOperation operation : operations) {
|
||||
// http method verb conversion (e.g. PUT => Put)
|
||||
|
||||
operation.httpMethod = org.openapitools.codegen.utils.StringUtils.camelize(operation.httpMethod.toLowerCase(Locale.ROOT));
|
||||
operation.httpMethod = camelize(operation.httpMethod.toLowerCase(Locale.ROOT));
|
||||
}
|
||||
|
||||
// remove model imports to avoid error
|
||||
|
@ -30,6 +30,9 @@ import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.*;
|
||||
|
||||
import static org.openapitools.codegen.utils.StringUtils.camelize;
|
||||
import static org.openapitools.codegen.utils.StringUtils.underscore;
|
||||
|
||||
public abstract class AbstractGoCodegen extends DefaultCodegen implements CodegenConfig {
|
||||
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(AbstractGoCodegen.class);
|
||||
@ -147,7 +150,7 @@ public abstract class AbstractGoCodegen extends DefaultCodegen implements Codege
|
||||
if (this.reservedWordsMappings().containsKey(name)) {
|
||||
return this.reservedWordsMappings().get(name);
|
||||
}
|
||||
return org.openapitools.codegen.utils.StringUtils.camelize(name) + '_';
|
||||
return camelize(name) + '_';
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -162,7 +165,7 @@ public abstract class AbstractGoCodegen extends DefaultCodegen implements Codege
|
||||
|
||||
// camelize (lower first character) the variable name
|
||||
// pet_id => PetId
|
||||
name = org.openapitools.codegen.utils.StringUtils.camelize(name);
|
||||
name = camelize(name);
|
||||
|
||||
// for reserved word append _
|
||||
if (isReservedWord(name)) {
|
||||
@ -187,7 +190,7 @@ public abstract class AbstractGoCodegen extends DefaultCodegen implements Codege
|
||||
// params should be lowerCamelCase. E.g. "person Person", instead of
|
||||
// "Person Person".
|
||||
//
|
||||
name = org.openapitools.codegen.utils.StringUtils.camelize(toVarName(name), true);
|
||||
name = camelize(toVarName(name), true);
|
||||
|
||||
// REVISIT: Actually, for idiomatic go, the param name should
|
||||
// really should just be a letter, e.g. "p Person"), but we'll get
|
||||
@ -204,7 +207,7 @@ public abstract class AbstractGoCodegen extends DefaultCodegen implements Codege
|
||||
public String toModelName(String name) {
|
||||
// camelize the model name
|
||||
// phone_number => PhoneNumber
|
||||
return org.openapitools.codegen.utils.StringUtils.camelize(toModel(name));
|
||||
return camelize(toModel(name));
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -241,7 +244,7 @@ public abstract class AbstractGoCodegen extends DefaultCodegen implements Codege
|
||||
name = "model_" + name; // e.g. 200Response => Model200Response (after camelize)
|
||||
}
|
||||
|
||||
return org.openapitools.codegen.utils.StringUtils.underscore(name);
|
||||
return underscore(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -250,7 +253,7 @@ public abstract class AbstractGoCodegen extends DefaultCodegen implements Codege
|
||||
name = name.replaceAll("-", "_"); // FIXME: a parameter should not be assigned. Also declare the methods parameters as 'final'.
|
||||
|
||||
// e.g. PetApi.go => pet_api.go
|
||||
name = "api_" + org.openapitools.codegen.utils.StringUtils.underscore(name);
|
||||
name = "api_" + underscore(name);
|
||||
if (name.endsWith("_test")) {
|
||||
LOGGER.warn(name + ".go with `_test.go` suffix (reserved word) cannot be used as filename. Renamed to " + name + "_.go");
|
||||
name += "_";
|
||||
@ -321,17 +324,17 @@ public abstract class AbstractGoCodegen extends DefaultCodegen implements Codege
|
||||
// method name cannot use reserved keyword, e.g. return
|
||||
if (isReservedWord(sanitizedOperationId)) {
|
||||
LOGGER.warn(operationId + " (reserved word) cannot be used as method name. Renamed to "
|
||||
+ org.openapitools.codegen.utils.StringUtils.camelize("call_" + sanitizedOperationId));
|
||||
+ camelize("call_" + sanitizedOperationId));
|
||||
sanitizedOperationId = "call_" + sanitizedOperationId;
|
||||
}
|
||||
|
||||
// operationId starts with a number
|
||||
if (sanitizedOperationId.matches("^\\d.*")) {
|
||||
LOGGER.warn(operationId + " (starting with a number) cannot be used as method name. Renamed to " + org.openapitools.codegen.utils.StringUtils.camelize("call_" + sanitizedOperationId));
|
||||
LOGGER.warn(operationId + " (starting with a number) cannot be used as method name. Renamed to " + camelize("call_" + sanitizedOperationId));
|
||||
sanitizedOperationId = "call_" + sanitizedOperationId;
|
||||
}
|
||||
|
||||
return org.openapitools.codegen.utils.StringUtils.camelize(sanitizedOperationId);
|
||||
return camelize(sanitizedOperationId);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -342,7 +345,7 @@ public abstract class AbstractGoCodegen extends DefaultCodegen implements Codege
|
||||
List<CodegenOperation> operations = (List<CodegenOperation>) objectMap.get("operation");
|
||||
for (CodegenOperation operation : operations) {
|
||||
// http method verb conversion (e.g. PUT => Put)
|
||||
operation.httpMethod = org.openapitools.codegen.utils.StringUtils.camelize(operation.httpMethod.toLowerCase(Locale.ROOT));
|
||||
operation.httpMethod = camelize(operation.httpMethod.toLowerCase(Locale.ROOT));
|
||||
}
|
||||
|
||||
// remove model imports to avoid error
|
||||
@ -573,7 +576,7 @@ public abstract class AbstractGoCodegen extends DefaultCodegen implements Codege
|
||||
}
|
||||
|
||||
// string
|
||||
String enumName = sanitizeName(org.openapitools.codegen.utils.StringUtils.underscore(name).toUpperCase(Locale.ROOT));
|
||||
String enumName = sanitizeName(underscore(name).toUpperCase(Locale.ROOT));
|
||||
enumName = enumName.replaceFirst("^_", "");
|
||||
enumName = enumName.replaceFirst("_$", "");
|
||||
|
||||
@ -588,7 +591,7 @@ public abstract class AbstractGoCodegen extends DefaultCodegen implements Codege
|
||||
|
||||
@Override
|
||||
public String toEnumName(CodegenProperty property) {
|
||||
String enumName = org.openapitools.codegen.utils.StringUtils.underscore(toModelName(property.name)).toUpperCase(Locale.ROOT);
|
||||
String enumName = underscore(toModelName(property.name)).toUpperCase(Locale.ROOT);
|
||||
|
||||
// remove [] for array or map of enum
|
||||
enumName = enumName.replace("[]", "");
|
||||
|
@ -27,6 +27,9 @@ import org.slf4j.LoggerFactory;
|
||||
import java.io.File;
|
||||
import java.util.*;
|
||||
|
||||
import static org.openapitools.codegen.utils.StringUtils.camelize;
|
||||
import static org.openapitools.codegen.utils.StringUtils.underscore;
|
||||
|
||||
public abstract class AbstractGraphQLCodegen extends DefaultCodegen implements CodegenConfig {
|
||||
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(AbstractGraphQLCodegen.class);
|
||||
|
@ -55,7 +55,8 @@ import java.util.Map;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import static org.openapitools.codegen.utils.StringUtils.escape;
|
||||
|
||||
import static org.openapitools.codegen.utils.StringUtils.camelize;
|
||||
import static org.openapitools.codegen.utils.StringUtils.underscore;
|
||||
|
||||
public abstract class AbstractJavaCodegen extends DefaultCodegen implements CodegenConfig {
|
||||
|
||||
@ -584,7 +585,7 @@ public abstract class AbstractJavaCodegen extends DefaultCodegen implements Code
|
||||
if (name.length() == 0) {
|
||||
return "DefaultApi";
|
||||
}
|
||||
return org.openapitools.codegen.utils.StringUtils.camelize(name) + "Api";
|
||||
return camelize(name) + "Api";
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -624,7 +625,7 @@ public abstract class AbstractJavaCodegen extends DefaultCodegen implements Code
|
||||
|
||||
// camelize (lower first character) the variable name
|
||||
// pet_id => petId
|
||||
name = org.openapitools.codegen.utils.StringUtils.camelize(name, true);
|
||||
name = camelize(name, true);
|
||||
|
||||
// for reserved word or word starting with number, append _
|
||||
if (isReservedWord(name) || name.matches("^\\d.*")) {
|
||||
@ -676,7 +677,7 @@ public abstract class AbstractJavaCodegen extends DefaultCodegen implements Code
|
||||
|
||||
// camelize the model name
|
||||
// phone_number => PhoneNumber
|
||||
final String camelizedName = org.openapitools.codegen.utils.StringUtils.camelize(nameWithPrefixSuffix);
|
||||
final String camelizedName = camelize(nameWithPrefixSuffix);
|
||||
|
||||
// model name cannot use reserved keyword, e.g. return
|
||||
if (isReservedWord(camelizedName)) {
|
||||
@ -919,19 +920,19 @@ public abstract class AbstractJavaCodegen extends DefaultCodegen implements Code
|
||||
throw new RuntimeException("Empty method/operation name (operationId) not allowed");
|
||||
}
|
||||
|
||||
operationId = org.openapitools.codegen.utils.StringUtils.camelize(sanitizeName(operationId), true);
|
||||
operationId = camelize(sanitizeName(operationId), true);
|
||||
|
||||
// method name cannot use reserved keyword, e.g. return
|
||||
if (isReservedWord(operationId)) {
|
||||
String newOperationId = org.openapitools.codegen.utils.StringUtils.camelize("call_" + operationId, true);
|
||||
String newOperationId = camelize("call_" + operationId, true);
|
||||
LOGGER.warn(operationId + " (reserved word) cannot be used as method name. Renamed to " + newOperationId);
|
||||
return newOperationId;
|
||||
}
|
||||
|
||||
// operationId starts with a number
|
||||
if (operationId.matches("^\\d.*")) {
|
||||
LOGGER.warn(operationId + " (starting with a number) cannot be used as method sname. Renamed to " + org.openapitools.codegen.utils.StringUtils.camelize("call_" + operationId), true);
|
||||
operationId = org.openapitools.codegen.utils.StringUtils.camelize("call_" + operationId, true);
|
||||
LOGGER.warn(operationId + " (starting with a number) cannot be used as method sname. Renamed to " + camelize("call_" + operationId), true);
|
||||
operationId = camelize("call_" + operationId, true);
|
||||
}
|
||||
|
||||
return operationId;
|
||||
@ -1082,7 +1083,7 @@ public abstract class AbstractJavaCodegen extends DefaultCodegen implements Code
|
||||
|
||||
@Override
|
||||
public String toEnumName(CodegenProperty property) {
|
||||
return sanitizeName(org.openapitools.codegen.utils.StringUtils.camelize(property.name)) + "Enum";
|
||||
return sanitizeName(camelize(property.name)) + "Enum";
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -1378,7 +1379,7 @@ public abstract class AbstractJavaCodegen extends DefaultCodegen implements Code
|
||||
|
||||
@Override
|
||||
public String sanitizeTag(String tag) {
|
||||
tag = org.openapitools.codegen.utils.StringUtils.camelize(org.openapitools.codegen.utils.StringUtils.underscore(sanitizeName(tag)));
|
||||
tag = camelize(underscore(sanitizeName(tag)));
|
||||
|
||||
// tag starts with numbers
|
||||
if (tag.matches("^\\d.*")) {
|
||||
|
@ -40,6 +40,7 @@ import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import static org.openapitools.codegen.utils.StringUtils.camelize;
|
||||
|
||||
public abstract class AbstractJavaJAXRSServerCodegen extends AbstractJavaCodegen implements BeanValidationFeatures {
|
||||
public static final String SERVER_PORT = "serverPort";
|
||||
@ -251,7 +252,7 @@ public abstract class AbstractJavaJAXRSServerCodegen extends AbstractJavaCodegen
|
||||
return "DefaultApi";
|
||||
}
|
||||
computed = sanitizeName(computed);
|
||||
return org.openapitools.codegen.utils.StringUtils.camelize(computed) + "Api";
|
||||
return camelize(computed) + "Api";
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -32,6 +32,9 @@ import org.slf4j.LoggerFactory;
|
||||
import java.io.File;
|
||||
import java.util.*;
|
||||
|
||||
import static org.openapitools.codegen.utils.StringUtils.camelize;
|
||||
import static org.openapitools.codegen.utils.StringUtils.escape;
|
||||
import static org.openapitools.codegen.utils.StringUtils.underscore;
|
||||
|
||||
public abstract class AbstractKotlinCodegen extends DefaultCodegen implements CodegenConfig {
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(AbstractKotlinCodegen.class);
|
||||
@ -431,16 +434,16 @@ public abstract class AbstractKotlinCodegen extends DefaultCodegen implements Co
|
||||
break;
|
||||
case camelCase:
|
||||
// NOTE: Removes hyphens and underscores
|
||||
modified = org.openapitools.codegen.utils.StringUtils.camelize(modified, true);
|
||||
modified = camelize(modified, true);
|
||||
break;
|
||||
case PascalCase:
|
||||
// NOTE: Removes hyphens and underscores
|
||||
String result = org.openapitools.codegen.utils.StringUtils.camelize(modified);
|
||||
String result = camelize(modified);
|
||||
modified = titleCase(result);
|
||||
break;
|
||||
case snake_case:
|
||||
// NOTE: Removes hyphens
|
||||
modified = org.openapitools.codegen.utils.StringUtils.underscore(modified);
|
||||
modified = underscore(modified);
|
||||
break;
|
||||
case UPPERCASE:
|
||||
modified = modified.toUpperCase(Locale.ROOT);
|
||||
@ -502,7 +505,7 @@ public abstract class AbstractKotlinCodegen extends DefaultCodegen implements Co
|
||||
modifiedName = sanitizeKotlinSpecificNames(modifiedName);
|
||||
|
||||
// Camelize name of nested properties
|
||||
modifiedName = org.openapitools.codegen.utils.StringUtils.camelize(modifiedName);
|
||||
modifiedName = camelize(modifiedName);
|
||||
|
||||
// model name cannot use reserved keyword, e.g. return
|
||||
if (isReservedWord(modifiedName)) {
|
||||
@ -687,7 +690,7 @@ public abstract class AbstractKotlinCodegen extends DefaultCodegen implements Co
|
||||
List<String> allowedCharacters = new ArrayList<>();
|
||||
allowedCharacters.add("_");
|
||||
allowedCharacters.add("$");
|
||||
name = escapeSpecialCharacters(name, allowedCharacters, "_");
|
||||
name = escape(name, specialCharReplacements, allowedCharacters, "_");
|
||||
}
|
||||
|
||||
// camelize (lower first character) the variable name
|
||||
|
@ -41,6 +41,13 @@ import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.regex.Matcher;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import static org.openapitools.codegen.utils.StringUtils.camelize;
|
||||
import static org.openapitools.codegen.utils.StringUtils.underscore;
|
||||
|
||||
public abstract class AbstractPhpCodegen extends DefaultCodegen implements CodegenConfig {
|
||||
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(AbstractPhpCodegen.class);
|
||||
@ -425,11 +432,11 @@ public abstract class AbstractPhpCodegen extends DefaultCodegen implements Codeg
|
||||
if ("camelCase".equals(variableNamingConvention)) {
|
||||
// return the name in camelCase style
|
||||
// phone_number => phoneNumber
|
||||
name = org.openapitools.codegen.utils.StringUtils.camelize(name, true);
|
||||
name = camelize(name, true);
|
||||
} else { // default to snake case
|
||||
// return the name in underscore style
|
||||
// PhoneNumber => phone_number
|
||||
name = org.openapitools.codegen.utils.StringUtils.underscore(name);
|
||||
name = underscore(name);
|
||||
}
|
||||
|
||||
// parameter name starting with number won't compile
|
||||
@ -460,13 +467,13 @@ public abstract class AbstractPhpCodegen extends DefaultCodegen implements Codeg
|
||||
|
||||
// model name cannot use reserved keyword
|
||||
if (isReservedWord(name)) {
|
||||
LOGGER.warn(name + " (reserved word) cannot be used as model name. Renamed to " + org.openapitools.codegen.utils.StringUtils.camelize("model_" + name));
|
||||
LOGGER.warn(name + " (reserved word) cannot be used as model name. Renamed to " + camelize("model_" + name));
|
||||
name = "model_" + name; // e.g. return => ModelReturn (after camelize)
|
||||
}
|
||||
|
||||
// model name starts with number
|
||||
if (name.matches("^\\d.*")) {
|
||||
LOGGER.warn(name + " (model name starts with number) cannot be used as model name. Renamed to " + org.openapitools.codegen.utils.StringUtils.camelize("model_" + name));
|
||||
LOGGER.warn(name + " (model name starts with number) cannot be used as model name. Renamed to " + camelize("model_" + name));
|
||||
name = "model_" + name; // e.g. 200Response => Model200Response (after camelize)
|
||||
}
|
||||
|
||||
@ -483,7 +490,7 @@ public abstract class AbstractPhpCodegen extends DefaultCodegen implements Codeg
|
||||
|
||||
// camelize the model name
|
||||
// phone_number => PhoneNumber
|
||||
return org.openapitools.codegen.utils.StringUtils.camelize(name);
|
||||
return camelize(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -505,7 +512,7 @@ public abstract class AbstractPhpCodegen extends DefaultCodegen implements Codeg
|
||||
* @return capitalized model name
|
||||
*/
|
||||
public String toInterfaceName(final String name) {
|
||||
return org.openapitools.codegen.utils.StringUtils.camelize(interfaceNamePrefix + name + interfaceNameSuffix);
|
||||
return camelize(interfaceNamePrefix + name + interfaceNameSuffix);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -515,7 +522,7 @@ public abstract class AbstractPhpCodegen extends DefaultCodegen implements Codeg
|
||||
* @return capitalized abstract class name
|
||||
*/
|
||||
public String toAbstractName(final String name) {
|
||||
return org.openapitools.codegen.utils.StringUtils.camelize(abstractNamePrefix + name + abstractNameSuffix);
|
||||
return camelize(abstractNamePrefix + name + abstractNameSuffix);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -525,7 +532,7 @@ public abstract class AbstractPhpCodegen extends DefaultCodegen implements Codeg
|
||||
* @return capitalized trait name
|
||||
*/
|
||||
public String toTraitName(final String name) {
|
||||
return org.openapitools.codegen.utils.StringUtils.camelize(traitNamePrefix + name + traitNameSuffix);
|
||||
return camelize(traitNamePrefix + name + traitNameSuffix);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -537,17 +544,17 @@ public abstract class AbstractPhpCodegen extends DefaultCodegen implements Codeg
|
||||
|
||||
// method name cannot use reserved keyword, e.g. return
|
||||
if (isReservedWord(operationId)) {
|
||||
LOGGER.warn(operationId + " (reserved word) cannot be used as method name. Renamed to " + org.openapitools.codegen.utils.StringUtils.camelize(sanitizeName("call_" + operationId), true));
|
||||
LOGGER.warn(operationId + " (reserved word) cannot be used as method name. Renamed to " + camelize(sanitizeName("call_" + operationId), true));
|
||||
operationId = "call_" + operationId;
|
||||
}
|
||||
|
||||
// operationId starts with a number
|
||||
if (operationId.matches("^\\d.*")) {
|
||||
LOGGER.warn(operationId + " (starting with a number) cannot be used as method name. Renamed to " + org.openapitools.codegen.utils.StringUtils.camelize(sanitizeName("call_" + operationId), true));
|
||||
LOGGER.warn(operationId + " (starting with a number) cannot be used as method name. Renamed to " + camelize(sanitizeName("call_" + operationId), true));
|
||||
operationId = "call_" + operationId;
|
||||
}
|
||||
|
||||
return org.openapitools.codegen.utils.StringUtils.camelize(sanitizeName(operationId), true);
|
||||
return camelize(sanitizeName(operationId), true);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -685,7 +692,7 @@ public abstract class AbstractPhpCodegen extends DefaultCodegen implements Codeg
|
||||
}
|
||||
|
||||
// string
|
||||
String enumName = sanitizeName(org.openapitools.codegen.utils.StringUtils.underscore(name).toUpperCase(Locale.ROOT));
|
||||
String enumName = sanitizeName(underscore(name).toUpperCase(Locale.ROOT));
|
||||
enumName = enumName.replaceFirst("^_", "");
|
||||
enumName = enumName.replaceFirst("_$", "");
|
||||
|
||||
@ -698,7 +705,7 @@ public abstract class AbstractPhpCodegen extends DefaultCodegen implements Codeg
|
||||
|
||||
@Override
|
||||
public String toEnumName(CodegenProperty property) {
|
||||
String enumName = org.openapitools.codegen.utils.StringUtils.underscore(toModelName(property.name)).toUpperCase(Locale.ROOT);
|
||||
String enumName = underscore(toModelName(property.name)).toUpperCase(Locale.ROOT);
|
||||
|
||||
// remove [] for array or map of enum
|
||||
enumName = enumName.replace("[]", "");
|
||||
@ -723,7 +730,7 @@ public abstract class AbstractPhpCodegen extends DefaultCodegen implements Codeg
|
||||
for (CodegenOperation op : operationList) {
|
||||
// for API test method name
|
||||
// e.g. public function test{{vendorExtensions.x-testOperationId}}()
|
||||
op.vendorExtensions.put("x-testOperationId", org.openapitools.codegen.utils.StringUtils.camelize(op.operationId));
|
||||
op.vendorExtensions.put("x-testOperationId", camelize(op.operationId));
|
||||
}
|
||||
return objs;
|
||||
}
|
||||
|
@ -31,6 +31,7 @@ import java.io.File;
|
||||
import java.util.Arrays;
|
||||
import java.util.Locale;
|
||||
|
||||
import static org.openapitools.codegen.utils.StringUtils.underscore;
|
||||
|
||||
abstract class AbstractRubyCodegen extends DefaultCodegen implements CodegenConfig {
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(AbstractRubyCodegen.class);
|
||||
@ -136,7 +137,7 @@ abstract class AbstractRubyCodegen extends DefaultCodegen implements CodegenConf
|
||||
|
||||
// camelize (lower first character) the variable name
|
||||
// petId => pet_id
|
||||
name = org.openapitools.codegen.utils.StringUtils.underscore(name);
|
||||
name = underscore(name);
|
||||
|
||||
// for reserved word or word starting with number, append _
|
||||
if (isReservedWord(name) || name.matches("^\\d.*")) {
|
||||
@ -160,12 +161,12 @@ abstract class AbstractRubyCodegen extends DefaultCodegen implements CodegenConf
|
||||
public String toOperationId(String operationId) {
|
||||
// method name cannot use reserved keyword, e.g. return
|
||||
if (isReservedWord(operationId)) {
|
||||
String newOperationId = org.openapitools.codegen.utils.StringUtils.underscore("call_" + operationId);
|
||||
String newOperationId = underscore("call_" + operationId);
|
||||
LOGGER.warn(operationId + " (reserved word) cannot be used as method name. Renamed to " + newOperationId);
|
||||
return newOperationId;
|
||||
}
|
||||
|
||||
return org.openapitools.codegen.utils.StringUtils.underscore(operationId);
|
||||
return underscore(operationId);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -36,6 +36,7 @@ import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import static org.openapitools.codegen.utils.StringUtils.camelize;
|
||||
|
||||
public abstract class AbstractScalaCodegen extends DefaultCodegen {
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(AbstractScalaCodegen.class);
|
||||
@ -280,7 +281,7 @@ public abstract class AbstractScalaCodegen extends DefaultCodegen {
|
||||
}
|
||||
|
||||
protected String formatIdentifier(String name, boolean capitalized) {
|
||||
String identifier = org.openapitools.codegen.utils.StringUtils.camelize(sanitizeName(name), true);
|
||||
String identifier = camelize(sanitizeName(name), true);
|
||||
if (capitalized) {
|
||||
identifier = StringUtils.capitalize(identifier);
|
||||
}
|
||||
|
@ -32,6 +32,8 @@ import java.util.*;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import static org.openapitools.codegen.utils.StringUtils.camelize;
|
||||
import static org.openapitools.codegen.utils.StringUtils.underscore;
|
||||
|
||||
public abstract class AbstractTypeScriptClientCodegen extends DefaultCodegen implements CodegenConfig {
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(AbstractTypeScriptClientCodegen.class);
|
||||
@ -159,7 +161,7 @@ public abstract class AbstractTypeScriptClientCodegen extends DefaultCodegen imp
|
||||
@Override
|
||||
public String toParamName(String name) {
|
||||
// sanitize name
|
||||
name = sanitizeName(name, "\\W-[\\$]");
|
||||
name = sanitizeName(name, "[^\\w$]");
|
||||
|
||||
if ("_".equals(name)) {
|
||||
name = "_u";
|
||||
@ -221,27 +223,27 @@ public abstract class AbstractTypeScriptClientCodegen extends DefaultCodegen imp
|
||||
|
||||
// model name cannot use reserved keyword, e.g. return
|
||||
if (isReservedWord(name)) {
|
||||
String modelName = org.openapitools.codegen.utils.StringUtils.camelize("model_" + name);
|
||||
String modelName = camelize("model_" + name);
|
||||
LOGGER.warn(name + " (reserved word) cannot be used as model name. Renamed to " + modelName);
|
||||
return modelName;
|
||||
}
|
||||
|
||||
// model name starts with number
|
||||
if (name.matches("^\\d.*")) {
|
||||
String modelName = org.openapitools.codegen.utils.StringUtils.camelize("model_" + name); // e.g. 200Response => Model200Response (after camelize)
|
||||
String modelName = camelize("model_" + name); // e.g. 200Response => Model200Response (after camelize)
|
||||
LOGGER.warn(name + " (model name starts with number) cannot be used as model name. Renamed to " + modelName);
|
||||
return modelName;
|
||||
}
|
||||
|
||||
if (languageSpecificPrimitives.contains(name)) {
|
||||
String modelName = org.openapitools.codegen.utils.StringUtils.camelize("model_" + name);
|
||||
String modelName = camelize("model_" + name);
|
||||
LOGGER.warn(name + " (model name matches existing language type) cannot be used as a model name. Renamed to " + modelName);
|
||||
return modelName;
|
||||
}
|
||||
|
||||
// camelize the model name
|
||||
// phone_number => PhoneNumber
|
||||
return org.openapitools.codegen.utils.StringUtils.camelize(name);
|
||||
return camelize(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -405,10 +407,10 @@ public abstract class AbstractTypeScriptClientCodegen extends DefaultCodegen imp
|
||||
// method name cannot use reserved keyword, e.g. return
|
||||
// append _ at the beginning, e.g. _return
|
||||
if (isReservedWord(operationId)) {
|
||||
return escapeReservedWord(org.openapitools.codegen.utils.StringUtils.camelize(sanitizeName(operationId), true));
|
||||
return escapeReservedWord(camelize(sanitizeName(operationId), true));
|
||||
}
|
||||
|
||||
return org.openapitools.codegen.utils.StringUtils.camelize(sanitizeName(operationId), true);
|
||||
return camelize(sanitizeName(operationId), true);
|
||||
}
|
||||
|
||||
public void setModelPropertyNaming(String naming) {
|
||||
@ -431,11 +433,11 @@ public abstract class AbstractTypeScriptClientCodegen extends DefaultCodegen imp
|
||||
case original:
|
||||
return name;
|
||||
case camelCase:
|
||||
return org.openapitools.codegen.utils.StringUtils.camelize(name, true);
|
||||
return camelize(name, true);
|
||||
case PascalCase:
|
||||
return org.openapitools.codegen.utils.StringUtils.camelize(name);
|
||||
return camelize(name);
|
||||
case snake_case:
|
||||
return org.openapitools.codegen.utils.StringUtils.underscore(name);
|
||||
return underscore(name);
|
||||
default:
|
||||
throw new IllegalArgumentException("Invalid model property naming '" +
|
||||
name + "'. Must be 'original', 'camelCase', " +
|
||||
@ -466,7 +468,7 @@ public abstract class AbstractTypeScriptClientCodegen extends DefaultCodegen imp
|
||||
|
||||
// for symbol, e.g. $, #
|
||||
if (getSymbolName(name) != null) {
|
||||
return org.openapitools.codegen.utils.StringUtils.camelize(getSymbolName(name));
|
||||
return camelize(getSymbolName(name));
|
||||
}
|
||||
|
||||
// number
|
||||
@ -486,7 +488,7 @@ public abstract class AbstractTypeScriptClientCodegen extends DefaultCodegen imp
|
||||
|
||||
// camelize the enum variable name
|
||||
// ref: https://basarat.gitbooks.io/typescript/content/docs/enums.html
|
||||
enumName = org.openapitools.codegen.utils.StringUtils.camelize(enumName);
|
||||
enumName = camelize(enumName);
|
||||
|
||||
if (enumName.matches("\\d.*")) { // starts with number
|
||||
return "_" + enumName;
|
||||
|
@ -36,6 +36,7 @@ import java.io.File;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashSet;
|
||||
|
||||
import static org.openapitools.codegen.utils.StringUtils.camelize;
|
||||
|
||||
public class AndroidClientCodegen extends DefaultCodegen implements CodegenConfig {
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(AndroidClientCodegen.class);
|
||||
@ -229,7 +230,7 @@ public class AndroidClientCodegen extends DefaultCodegen implements CodegenConfi
|
||||
|
||||
// camelize (lower first character) the variable name
|
||||
// pet_id => petId
|
||||
name = org.openapitools.codegen.utils.StringUtils.camelize(name, true);
|
||||
name = camelize(name, true);
|
||||
|
||||
// for reserved word or word starting with number, append _
|
||||
if (isReservedWord(name) || name.matches("^\\d.*")) {
|
||||
@ -258,7 +259,7 @@ public class AndroidClientCodegen extends DefaultCodegen implements CodegenConfi
|
||||
|
||||
// camelize the model name
|
||||
// phone_number => PhoneNumber
|
||||
name = org.openapitools.codegen.utils.StringUtils.camelize(sanitizeName(name));
|
||||
name = camelize(sanitizeName(name));
|
||||
|
||||
// model name cannot use reserved keyword, e.g. return
|
||||
if (isReservedWord(name)) {
|
||||
@ -355,11 +356,11 @@ public class AndroidClientCodegen extends DefaultCodegen implements CodegenConfi
|
||||
throw new RuntimeException("Empty method name (operationId) not allowed");
|
||||
}
|
||||
|
||||
operationId = org.openapitools.codegen.utils.StringUtils.camelize(sanitizeName(operationId), true);
|
||||
operationId = camelize(sanitizeName(operationId), true);
|
||||
|
||||
// method name cannot use reserved keyword, e.g. return
|
||||
if (isReservedWord(operationId)) {
|
||||
String newOperationId = org.openapitools.codegen.utils.StringUtils.camelize("call_" + operationId, true);
|
||||
String newOperationId = camelize("call_" + operationId, true);
|
||||
LOGGER.warn(operationId + " (reserved word) cannot be used as method name. Renamed to " + newOperationId);
|
||||
return newOperationId;
|
||||
}
|
||||
|
@ -30,6 +30,7 @@ import org.slf4j.LoggerFactory;
|
||||
import java.io.File;
|
||||
import java.util.*;
|
||||
|
||||
import static org.openapitools.codegen.utils.StringUtils.camelize;
|
||||
|
||||
public class ApexClientCodegen extends AbstractApexCodegen {
|
||||
|
||||
@ -193,7 +194,7 @@ public class ApexClientCodegen extends AbstractApexCodegen {
|
||||
|
||||
@Override
|
||||
public String toApiName(String name) {
|
||||
return org.openapitools.codegen.utils.StringUtils.camelize(classPrefix + super.toApiName(name));
|
||||
return camelize(classPrefix + super.toApiName(name));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -16,7 +16,6 @@
|
||||
|
||||
package org.openapitools.codegen.languages;
|
||||
|
||||
import io.swagger.v3.oas.models.media.ArraySchema;
|
||||
import io.swagger.v3.oas.models.media.Schema;
|
||||
import io.swagger.v3.oas.models.OpenAPI;
|
||||
import io.swagger.v3.oas.models.info.Info;
|
||||
@ -26,7 +25,6 @@ import org.openapitools.codegen.utils.ModelUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.commons.io.FilenameUtils;
|
||||
|
||||
import java.io.File;
|
||||
@ -37,6 +35,9 @@ import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import static org.openapitools.codegen.utils.StringUtils.camelize;
|
||||
import static org.openapitools.codegen.utils.StringUtils.underscore;
|
||||
|
||||
public class CLibcurlClientCodegen extends DefaultCodegen implements CodegenConfig {
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(CLibcurlClientCodegen.class);
|
||||
|
||||
|
@ -42,6 +42,8 @@ import java.util.Locale;
|
||||
import java.util.Map;
|
||||
|
||||
import static org.apache.commons.lang3.StringUtils.isEmpty;
|
||||
import static org.openapitools.codegen.utils.StringUtils.camelize;
|
||||
import static org.openapitools.codegen.utils.StringUtils.underscore;
|
||||
|
||||
public class CSharpClientCodegen extends AbstractCSharpCodegen {
|
||||
@SuppressWarnings({"hiding"})
|
||||
@ -704,7 +706,7 @@ public class CSharpClientCodegen extends AbstractCSharpCodegen {
|
||||
|
||||
// for symbol, e.g. $, #
|
||||
if (getSymbolName(value) != null) {
|
||||
return org.openapitools.codegen.utils.StringUtils.camelize(getSymbolName(value));
|
||||
return camelize(getSymbolName(value));
|
||||
}
|
||||
|
||||
// number
|
||||
@ -720,7 +722,7 @@ public class CSharpClientCodegen extends AbstractCSharpCodegen {
|
||||
// string
|
||||
String var = value.replaceAll("_", " ");
|
||||
//var = WordUtils.capitalizeFully(var);
|
||||
var = org.openapitools.codegen.utils.StringUtils.camelize(var);
|
||||
var = camelize(var);
|
||||
var = var.replaceAll("\\W+", "");
|
||||
|
||||
if (var.matches("\\d.*")) {
|
||||
@ -755,11 +757,11 @@ public class CSharpClientCodegen extends AbstractCSharpCodegen {
|
||||
case original:
|
||||
return name;
|
||||
case camelCase:
|
||||
return org.openapitools.codegen.utils.StringUtils.camelize(name, true);
|
||||
return camelize(name, true);
|
||||
case PascalCase:
|
||||
return org.openapitools.codegen.utils.StringUtils.camelize(name);
|
||||
return camelize(name);
|
||||
case snake_case:
|
||||
return org.openapitools.codegen.utils.StringUtils.underscore(name);
|
||||
return underscore(name);
|
||||
default:
|
||||
throw new IllegalArgumentException("Invalid model property naming '" +
|
||||
name + "'. Must be 'original', 'camelCase', " +
|
||||
|
@ -36,7 +36,6 @@ import org.openapitools.codegen.utils.URLPathUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
|
||||
import java.io.File;
|
||||
import java.net.URL;
|
||||
import java.util.ArrayList;
|
||||
@ -72,6 +71,7 @@ import static org.openapitools.codegen.CodegenConstants.USE_COLLECTION_DESC;
|
||||
import static org.openapitools.codegen.CodegenConstants.USE_DATETIME_OFFSET;
|
||||
import static org.openapitools.codegen.CodegenConstants.USE_DATETIME_OFFSET_DESC;
|
||||
import static org.openapitools.codegen.CodegenType.SERVER;
|
||||
import static org.openapitools.codegen.utils.StringUtils.camelize;
|
||||
|
||||
public class CSharpNancyFXServerCodegen extends AbstractCSharpCodegen {
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(CSharpNancyFXServerCodegen.class);
|
||||
@ -335,7 +335,7 @@ public class CSharpNancyFXServerCodegen extends AbstractCSharpCodegen {
|
||||
return "Empty";
|
||||
}
|
||||
|
||||
final String enumName = org.openapitools.codegen.utils.StringUtils.camelize(
|
||||
final String enumName = camelize(
|
||||
sanitizeName(name)
|
||||
.replaceFirst("^_", "")
|
||||
.replaceFirst("_$", "")
|
||||
@ -402,7 +402,7 @@ public class CSharpNancyFXServerCodegen extends AbstractCSharpCodegen {
|
||||
|
||||
@Override
|
||||
public String toEnumName(final CodegenProperty property) {
|
||||
return sanitizeName(org.openapitools.codegen.utils.StringUtils.camelize(property.name)) + "Enum";
|
||||
return sanitizeName(camelize(property.name)) + "Enum";
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -43,6 +43,9 @@ import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
|
||||
import static org.openapitools.codegen.utils.StringUtils.camelize;
|
||||
import static org.openapitools.codegen.utils.StringUtils.underscore;
|
||||
|
||||
public class CSharpRefactorClientCodegen extends AbstractCSharpCodegen {
|
||||
@SuppressWarnings({"hiding"})
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(CSharpClientCodegen.class);
|
||||
|
@ -28,6 +28,8 @@ import org.openapitools.codegen.utils.ModelUtils;
|
||||
import java.io.File;
|
||||
import java.util.*;
|
||||
|
||||
import static org.openapitools.codegen.utils.StringUtils.dashize;
|
||||
import static org.openapitools.codegen.utils.StringUtils.underscore;
|
||||
|
||||
public class ClojureClientCodegen extends DefaultCodegen implements CodegenConfig {
|
||||
private static final String PROJECT_NAME = "projectName";
|
||||
@ -215,7 +217,7 @@ public class ClojureClientCodegen extends DefaultCodegen implements CodegenConfi
|
||||
Info info = openAPI.getInfo();
|
||||
if (projectName == null && info.getTitle() != null) {
|
||||
// when projectName is not specified, generate it from info.title
|
||||
projectName = org.openapitools.codegen.utils.StringUtils.dashize(info.getTitle());
|
||||
projectName = dashize(info.getTitle());
|
||||
}
|
||||
if (projectVersion == null) {
|
||||
// when projectVersion is not specified, use info.version
|
||||
@ -254,7 +256,7 @@ public class ClojureClientCodegen extends DefaultCodegen implements CodegenConfi
|
||||
projectDescription = "Client library of " + projectName;
|
||||
}
|
||||
if (baseNamespace == null) {
|
||||
baseNamespace = org.openapitools.codegen.utils.StringUtils.dashize(projectName);
|
||||
baseNamespace = dashize(projectName);
|
||||
}
|
||||
apiPackage = baseNamespace + ".api";
|
||||
modelPackage = baseNamespace + ".specs";
|
||||
@ -295,12 +297,12 @@ public class ClojureClientCodegen extends DefaultCodegen implements CodegenConfi
|
||||
throw new RuntimeException("Empty method/operation name (operationId) not allowed");
|
||||
}
|
||||
|
||||
return org.openapitools.codegen.utils.StringUtils.dashize(sanitizeName(operationId));
|
||||
return dashize(sanitizeName(operationId));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toApiFilename(String name) {
|
||||
return org.openapitools.codegen.utils.StringUtils.underscore(toApiName(name));
|
||||
return underscore(toApiName(name));
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -310,7 +312,7 @@ public class ClojureClientCodegen extends DefaultCodegen implements CodegenConfi
|
||||
|
||||
@Override
|
||||
public String toApiName(String name) {
|
||||
return org.openapitools.codegen.utils.StringUtils.dashize(name);
|
||||
return dashize(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -41,6 +41,7 @@ import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import static org.openapitools.codegen.utils.StringUtils.underscore;
|
||||
|
||||
public class CppPistacheServerCodegen extends AbstractCppCodegen {
|
||||
protected String implFolder = "impl";
|
||||
@ -214,8 +215,8 @@ public class CppPistacheServerCodegen extends AbstractCppCodegen {
|
||||
public Map<String, Object> postProcessOperationsWithModels(Map<String, Object> objs, List<Object> allModels) {
|
||||
Map<String, Object> operations = (Map<String, Object>) objs.get("operations");
|
||||
String classname = (String) operations.get("classname");
|
||||
operations.put("classnameSnakeUpperCase", org.openapitools.codegen.utils.StringUtils.underscore(classname).toUpperCase(Locale.ROOT));
|
||||
operations.put("classnameSnakeLowerCase", org.openapitools.codegen.utils.StringUtils.underscore(classname).toLowerCase(Locale.ROOT));
|
||||
operations.put("classnameSnakeUpperCase", underscore(classname).toUpperCase(Locale.ROOT));
|
||||
operations.put("classnameSnakeLowerCase", underscore(classname).toLowerCase(Locale.ROOT));
|
||||
|
||||
List<CodegenOperation> operationList = (List<CodegenOperation>) operations.get("operation");
|
||||
for (CodegenOperation op : operationList) {
|
||||
|
@ -23,6 +23,14 @@ import org.openapitools.codegen.CodegenType;
|
||||
import org.openapitools.codegen.SupportingFile;
|
||||
import java.io.File;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import static org.openapitools.codegen.utils.StringUtils.underscore;
|
||||
|
||||
public class CppQt5ClientCodegen extends CppQt5AbstractCodegen implements CodegenConfig {
|
||||
public static final String OPTIONAL_PROJECT_FILE_DESC = "Generate client.pri.";
|
||||
|
@ -22,6 +22,16 @@ import org.openapitools.codegen.CodegenType;
|
||||
import org.openapitools.codegen.SupportingFile;
|
||||
import java.io.File;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import static org.openapitools.codegen.utils.StringUtils.underscore;
|
||||
|
||||
public class CppQt5QHttpEngineServerCodegen extends CppQt5AbstractCodegen implements CodegenConfig {
|
||||
|
||||
|
@ -32,6 +32,7 @@ import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
|
||||
import static org.openapitools.codegen.utils.StringUtils.camelize;
|
||||
|
||||
public class CppTizenClientCodegen extends AbstractCppCodegen implements CodegenConfig {
|
||||
protected static String PREFIX = "ArtikCloud";
|
||||
@ -284,7 +285,7 @@ public class CppTizenClientCodegen extends AbstractCppCodegen implements Codegen
|
||||
}
|
||||
|
||||
// add_pet_by_id => addPetById
|
||||
return org.openapitools.codegen.utils.StringUtils.camelize(operationId, true);
|
||||
return camelize(operationId, true);
|
||||
}
|
||||
/**
|
||||
* Output the Getter name for boolean property, e.g. getActive
|
||||
|
@ -42,6 +42,9 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import static org.openapitools.codegen.utils.StringUtils.camelize;
|
||||
import static org.openapitools.codegen.utils.StringUtils.underscore;
|
||||
|
||||
public class DartClientCodegen extends DefaultCodegen implements CodegenConfig {
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(DartClientCodegen.class);
|
||||
|
||||
@ -263,7 +266,7 @@ public class DartClientCodegen extends DefaultCodegen implements CodegenConfig {
|
||||
|
||||
// camelize (lower first character) the variable name
|
||||
// pet_id => petId
|
||||
name = org.openapitools.codegen.utils.StringUtils.camelize(name, true);
|
||||
name = camelize(name, true);
|
||||
|
||||
if (name.matches("^\\d.*")) {
|
||||
name = "n" + name;
|
||||
@ -286,23 +289,23 @@ public class DartClientCodegen extends DefaultCodegen implements CodegenConfig {
|
||||
public String toModelName(String name) {
|
||||
// model name cannot use reserved keyword, e.g. return
|
||||
if (isReservedWord(name)) {
|
||||
LOGGER.warn(name + " (reserved word) cannot be used as model filename. Renamed to " + org.openapitools.codegen.utils.StringUtils.camelize("model_" + name));
|
||||
LOGGER.warn(name + " (reserved word) cannot be used as model filename. Renamed to " + camelize("model_" + name));
|
||||
name = "model_" + name; // e.g. return => ModelReturn (after camelize)
|
||||
}
|
||||
|
||||
// camelize the model name
|
||||
// phone_number => PhoneNumber
|
||||
return org.openapitools.codegen.utils.StringUtils.camelize(name);
|
||||
return camelize(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toModelFilename(String name) {
|
||||
return org.openapitools.codegen.utils.StringUtils.underscore(toModelName(name));
|
||||
return underscore(toModelName(name));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toApiFilename(String name) {
|
||||
return org.openapitools.codegen.utils.StringUtils.underscore(toApiName(name));
|
||||
return underscore(toApiName(name));
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -424,7 +427,7 @@ public class DartClientCodegen extends DefaultCodegen implements CodegenConfig {
|
||||
new ArrayList<Map<String, String>>();
|
||||
for (Map<String, Object> value : values) {
|
||||
Map<String, String> enumVar = new HashMap<String, String>();
|
||||
String name = org.openapitools.codegen.utils.StringUtils.camelize((String) value.get("identifier"), true);
|
||||
String name = camelize((String) value.get("identifier"), true);
|
||||
if (isReservedWord(name)) {
|
||||
name = escapeReservedWord(name);
|
||||
}
|
||||
@ -450,7 +453,7 @@ public class DartClientCodegen extends DefaultCodegen implements CodegenConfig {
|
||||
"int".equalsIgnoreCase(datatype)) {
|
||||
var = "Number" + var;
|
||||
}
|
||||
return escapeReservedWord(org.openapitools.codegen.utils.StringUtils.camelize(var, true));
|
||||
return escapeReservedWord(camelize(var, true));
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -467,12 +470,12 @@ public class DartClientCodegen extends DefaultCodegen implements CodegenConfig {
|
||||
public String toOperationId(String operationId) {
|
||||
// method name cannot use reserved keyword, e.g. return
|
||||
if (isReservedWord(operationId)) {
|
||||
String newOperationId = org.openapitools.codegen.utils.StringUtils.camelize("call_" + operationId, true);
|
||||
String newOperationId = camelize("call_" + operationId, true);
|
||||
LOGGER.warn(operationId + " (reserved word) cannot be used as method name. Renamed to " + newOperationId);
|
||||
return newOperationId;
|
||||
}
|
||||
|
||||
return org.openapitools.codegen.utils.StringUtils.camelize(operationId, true);
|
||||
return camelize(operationId, true);
|
||||
}
|
||||
|
||||
public void setBrowserClient(boolean browserClient) {
|
||||
|
@ -33,6 +33,8 @@ import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import static org.openapitools.codegen.utils.StringUtils.underscore;
|
||||
|
||||
public class DartJaguarClientCodegen extends DartClientCodegen {
|
||||
private static Set<String> modelToIgnore = new HashSet<>();
|
||||
|
||||
|
@ -37,6 +37,8 @@ import java.util.*;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import static org.openapitools.codegen.utils.StringUtils.underscore;
|
||||
import static org.openapitools.codegen.utils.StringUtils.camelize;
|
||||
|
||||
public class ElixirClientCodegen extends DefaultCodegen implements CodegenConfig {
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(ElixirClientCodegen.class);
|
||||
@ -276,7 +278,7 @@ public class ElixirClientCodegen extends DefaultCodegen implements CodegenConfig
|
||||
StringBuffer buffer = new StringBuffer();
|
||||
while (matcher.find()) {
|
||||
String pathTemplateName = matcher.group(1);
|
||||
matcher.appendReplacement(buffer, "#{" + org.openapitools.codegen.utils.StringUtils.underscore(pathTemplateName) + "}" + "$2");
|
||||
matcher.appendReplacement(buffer, "#{" + underscore(pathTemplateName) + "}" + "$2");
|
||||
pathTemplateNames.add(pathTemplateName);
|
||||
}
|
||||
ExtendedCodegenOperation eco = new ExtendedCodegenOperation(o);
|
||||
@ -324,7 +326,7 @@ public class ElixirClientCodegen extends DefaultCodegen implements CodegenConfig
|
||||
String underscored(String words) {
|
||||
ArrayList<String> underscoredWords = new ArrayList<String>();
|
||||
for (String word : words.split(" ")) {
|
||||
underscoredWords.add(org.openapitools.codegen.utils.StringUtils.underscore(word));
|
||||
underscoredWords.add(underscore(word));
|
||||
}
|
||||
return join("_", underscoredWords);
|
||||
}
|
||||
@ -332,7 +334,7 @@ public class ElixirClientCodegen extends DefaultCodegen implements CodegenConfig
|
||||
String modulized(String words) {
|
||||
ArrayList<String> modulizedWords = new ArrayList<String>();
|
||||
for (String word : words.split(" ")) {
|
||||
modulizedWords.add(org.openapitools.codegen.utils.StringUtils.camelize(word));
|
||||
modulizedWords.add(camelize(word));
|
||||
}
|
||||
return join("", modulizedWords);
|
||||
}
|
||||
@ -351,7 +353,7 @@ public class ElixirClientCodegen extends DefaultCodegen implements CodegenConfig
|
||||
private String sourceFolder() {
|
||||
ArrayList<String> underscoredWords = new ArrayList<String>();
|
||||
for (String word : moduleName.split("\\.")) {
|
||||
underscoredWords.add(org.openapitools.codegen.utils.StringUtils.underscore(word));
|
||||
underscoredWords.add(underscore(word));
|
||||
}
|
||||
return ("lib/" + join("/", underscoredWords)).replace('/', File.separatorChar);
|
||||
}
|
||||
@ -378,7 +380,7 @@ public class ElixirClientCodegen extends DefaultCodegen implements CodegenConfig
|
||||
if (name.length() == 0) {
|
||||
return "Default";
|
||||
}
|
||||
return org.openapitools.codegen.utils.StringUtils.camelize(name);
|
||||
return camelize(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -387,14 +389,14 @@ public class ElixirClientCodegen extends DefaultCodegen implements CodegenConfig
|
||||
name = name.replaceAll("-", "_");
|
||||
|
||||
// e.g. PetApi.go => pet_api.go
|
||||
return org.openapitools.codegen.utils.StringUtils.underscore(name);
|
||||
return underscore(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toModelName(String name) {
|
||||
// camelize the model name
|
||||
// phone_number => PhoneNumber
|
||||
return org.openapitools.codegen.utils.StringUtils.camelize(toModelFilename(name));
|
||||
return camelize(toModelFilename(name));
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -421,7 +423,7 @@ public class ElixirClientCodegen extends DefaultCodegen implements CodegenConfig
|
||||
name = "model_" + name; // e.g. 200Response => Model200Response (after camelize)
|
||||
}
|
||||
|
||||
return org.openapitools.codegen.utils.StringUtils.underscore(name);
|
||||
return underscore(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -433,17 +435,17 @@ public class ElixirClientCodegen extends DefaultCodegen implements CodegenConfig
|
||||
|
||||
// method name cannot use reserved keyword, e.g. return
|
||||
if (isReservedWord(operationId)) {
|
||||
LOGGER.warn(operationId + " (reserved word) cannot be used as method name. Renamed to " + org.openapitools.codegen.utils.StringUtils.underscore(sanitizeName("call_" + operationId)));
|
||||
return org.openapitools.codegen.utils.StringUtils.underscore(sanitizeName("call_" + operationId));
|
||||
LOGGER.warn(operationId + " (reserved word) cannot be used as method name. Renamed to " + underscore(sanitizeName("call_" + operationId)));
|
||||
return underscore(sanitizeName("call_" + operationId));
|
||||
}
|
||||
|
||||
// operationId starts with a number
|
||||
if (operationId.matches("^\\d.*")) {
|
||||
LOGGER.warn(operationId + " (starting with a number) cannot be used as method name. Renamed to " + org.openapitools.codegen.utils.StringUtils.underscore(sanitizeName("call_" + operationId)));
|
||||
LOGGER.warn(operationId + " (starting with a number) cannot be used as method name. Renamed to " + underscore(sanitizeName("call_" + operationId)));
|
||||
operationId = "call_" + operationId;
|
||||
}
|
||||
|
||||
return org.openapitools.codegen.utils.StringUtils.underscore(sanitizeName(operationId));
|
||||
return underscore(sanitizeName(operationId));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -596,7 +598,7 @@ public class ElixirClientCodegen extends DefaultCodegen implements CodegenConfig
|
||||
|
||||
public String typespec() {
|
||||
StringBuilder sb = new StringBuilder("@spec ");
|
||||
sb.append(org.openapitools.codegen.utils.StringUtils.underscore(operationId));
|
||||
sb.append(underscore(operationId));
|
||||
sb.append("(Tesla.Env.client, ");
|
||||
|
||||
for (CodegenParameter param : allParams) {
|
||||
|
@ -19,7 +19,6 @@ package org.openapitools.codegen.languages;
|
||||
|
||||
import io.swagger.v3.oas.models.OpenAPI;
|
||||
import io.swagger.v3.oas.models.media.ArraySchema;
|
||||
import io.swagger.v3.oas.models.media.NumberSchema;
|
||||
import io.swagger.v3.oas.models.media.Schema;
|
||||
import io.swagger.v3.oas.models.responses.ApiResponse;
|
||||
import org.openapitools.codegen.CliOption;
|
||||
@ -55,6 +54,8 @@ import java.util.Set;
|
||||
import java.util.TreeSet;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static org.openapitools.codegen.utils.StringUtils.camelize;
|
||||
|
||||
public class ElmClientCodegen extends DefaultCodegen implements CodegenConfig {
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(ElmClientCodegen.class);
|
||||
private Set<String> customPrimitives = new HashSet<String>();
|
||||
@ -252,7 +253,7 @@ public class ElmClientCodegen extends DefaultCodegen implements CodegenConfig {
|
||||
|
||||
@Override
|
||||
public String toModelName(String name) {
|
||||
final String modelName = org.openapitools.codegen.utils.StringUtils.camelize(name);
|
||||
final String modelName = camelize(name);
|
||||
return defaultIncludes.contains(modelName) ? modelName + "_" : modelName;
|
||||
}
|
||||
|
||||
@ -268,13 +269,13 @@ public class ElmClientCodegen extends DefaultCodegen implements CodegenConfig {
|
||||
|
||||
@Override
|
||||
public String toVarName(String name) {
|
||||
final String varName = org.openapitools.codegen.utils.StringUtils.camelize(name, true);
|
||||
final String varName = camelize(name, true);
|
||||
return isReservedWord(varName) ? escapeReservedWord(name) : varName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toEnumVarName(String value, String datatype) {
|
||||
String camelized = org.openapitools.codegen.utils.StringUtils.camelize(value.replace(" ", "_").replace("(", "_").replace(")", "")); // TODO FIXME escape properly
|
||||
String camelized = camelize(value.replace(" ", "_").replace("(", "_").replace(")", "")); // TODO FIXME escape properly
|
||||
|
||||
if (camelized.length() == 0) {
|
||||
LOGGER.error("Unable to determine enum variable name (name: {}, datatype: {}) from empty string. Default to UnknownEnumVariableName", value, datatype);
|
||||
@ -584,7 +585,7 @@ public class ElmClientCodegen extends DefaultCodegen implements CodegenConfig {
|
||||
if (mapFn == null) {
|
||||
throw new RuntimeException("Parameter '" + param.paramName + "' cannot be converted to a string. Please report the issue.");
|
||||
}
|
||||
|
||||
|
||||
if (param.isListContainer) {
|
||||
if (!param.required) {
|
||||
mapFn = "(" + mapFn + ")";
|
||||
|
@ -33,7 +33,8 @@ import java.util.regex.Pattern;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import static org.openapitools.codegen.utils.StringUtils.camelize;
|
||||
import static org.openapitools.codegen.utils.StringUtils.underscore;
|
||||
|
||||
public class ErlangClientCodegen extends DefaultCodegen implements CodegenConfig {
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(ErlangClientCodegen.class);
|
||||
@ -204,7 +205,7 @@ public class ErlangClientCodegen extends DefaultCodegen implements CodegenConfig
|
||||
if (this.reservedWordsMappings().containsKey(name)) {
|
||||
return this.reservedWordsMappings().get(name);
|
||||
}
|
||||
return org.openapitools.codegen.utils.StringUtils.camelize(name) + '_';
|
||||
return camelize(name) + '_';
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -230,7 +231,7 @@ public class ErlangClientCodegen extends DefaultCodegen implements CodegenConfig
|
||||
|
||||
@Override
|
||||
public String toParamName(String name) {
|
||||
return org.openapitools.codegen.utils.StringUtils.camelize(toVarName(name));
|
||||
return camelize(toVarName(name));
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -249,17 +250,17 @@ public class ErlangClientCodegen extends DefaultCodegen implements CodegenConfig
|
||||
|
||||
@Override
|
||||
public String toModelName(String name) {
|
||||
return this.packageName + "_" + org.openapitools.codegen.utils.StringUtils.underscore(name.replaceAll("-", "_").replaceAll("\\.", "_"));
|
||||
return this.packageName + "_" + underscore(name.replaceAll("-", "_").replaceAll("\\.", "_"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toApiName(String name) {
|
||||
return this.packageName + "_" + org.openapitools.codegen.utils.StringUtils.underscore(name.replaceAll("-", "_").replaceAll("\\.", "_"));
|
||||
return this.packageName + "_" + underscore(name.replaceAll("-", "_").replaceAll("\\.", "_"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toModelFilename(String name) {
|
||||
return this.packageName + "_" + org.openapitools.codegen.utils.StringUtils.underscore(name.replaceAll("\\.", "_"));
|
||||
return this.packageName + "_" + underscore(name.replaceAll("\\.", "_"));
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -269,18 +270,18 @@ public class ErlangClientCodegen extends DefaultCodegen implements CodegenConfig
|
||||
name = name.replaceAll("-", "_").replaceAll("\\.", "_");
|
||||
|
||||
// e.g. PetApi.erl => pet_api.erl
|
||||
return this.packageName + "_" + org.openapitools.codegen.utils.StringUtils.underscore(name) + "_api";
|
||||
return this.packageName + "_" + underscore(name) + "_api";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toOperationId(String operationId) {
|
||||
// method name cannot use reserved keyword, e.g. return
|
||||
if (isReservedWord(operationId)) {
|
||||
LOGGER.warn(operationId + " (reserved word) cannot be used as method name. Renamed to " + org.openapitools.codegen.utils.StringUtils.underscore(sanitizeName("call_" + operationId)).replaceAll("\\.", "_"));
|
||||
LOGGER.warn(operationId + " (reserved word) cannot be used as method name. Renamed to " + underscore(sanitizeName("call_" + operationId)).replaceAll("\\.", "_"));
|
||||
operationId = "call_" + operationId;
|
||||
}
|
||||
|
||||
return org.openapitools.codegen.utils.StringUtils.underscore(operationId.replaceAll("\\.", "_"));
|
||||
return underscore(operationId.replaceAll("\\.", "_"));
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -302,7 +303,7 @@ public class ErlangClientCodegen extends DefaultCodegen implements CodegenConfig
|
||||
StringBuffer buffer = new StringBuffer();
|
||||
while (matcher.find()) {
|
||||
String pathTemplateName = matcher.group(1);
|
||||
matcher.appendReplacement(buffer, "\", " + org.openapitools.codegen.utils.StringUtils.camelize(pathTemplateName) + ", \"");
|
||||
matcher.appendReplacement(buffer, "\", " + camelize(pathTemplateName) + ", \"");
|
||||
pathTemplateNames.add(pathTemplateName);
|
||||
}
|
||||
matcher.appendTail(buffer);
|
||||
|
@ -33,6 +33,9 @@ import java.util.*;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import static org.openapitools.codegen.utils.StringUtils.camelize;
|
||||
import static org.openapitools.codegen.utils.StringUtils.underscore;
|
||||
|
||||
public class ErlangProperCodegen extends DefaultCodegen implements CodegenConfig {
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(ErlangProperCodegen.class);
|
||||
|
||||
|
@ -32,6 +32,8 @@ import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import static org.openapitools.codegen.utils.StringUtils.camelize;
|
||||
import static org.openapitools.codegen.utils.StringUtils.underscore;
|
||||
|
||||
public class ErlangServerCodegen extends DefaultCodegen implements CodegenConfig {
|
||||
|
||||
@ -200,7 +202,7 @@ public class ErlangServerCodegen extends DefaultCodegen implements CodegenConfig
|
||||
if (name.length() == 0) {
|
||||
return this.packageName + "_default_handler";
|
||||
}
|
||||
return this.packageName + "_" + org.openapitools.codegen.utils.StringUtils.underscore(name) + "_handler";
|
||||
return this.packageName + "_" + underscore(name) + "_handler";
|
||||
}
|
||||
|
||||
/**
|
||||
@ -228,18 +230,18 @@ public class ErlangServerCodegen extends DefaultCodegen implements CodegenConfig
|
||||
|
||||
@Override
|
||||
public String toModelName(String name) {
|
||||
return org.openapitools.codegen.utils.StringUtils.camelize(toModelFilename(name));
|
||||
return camelize(toModelFilename(name));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toOperationId(String operationId) {
|
||||
// method name cannot use reserved keyword, e.g. return
|
||||
if (isReservedWord(operationId)) {
|
||||
LOGGER.warn(operationId + " (reserved word) cannot be used as method name. Renamed to " + org.openapitools.codegen.utils.StringUtils.camelize(sanitizeName("call_" + operationId)));
|
||||
LOGGER.warn(operationId + " (reserved word) cannot be used as method name. Renamed to " + camelize(sanitizeName("call_" + operationId)));
|
||||
operationId = "call_" + operationId;
|
||||
}
|
||||
|
||||
return org.openapitools.codegen.utils.StringUtils.camelize(operationId);
|
||||
return camelize(operationId);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -278,7 +280,7 @@ public class ErlangServerCodegen extends DefaultCodegen implements CodegenConfig
|
||||
}
|
||||
|
||||
protected String toModuleName(String name) {
|
||||
return this.packageName + "_" + org.openapitools.codegen.utils.StringUtils.underscore(name.replaceAll("-", "_"));
|
||||
return this.packageName + "_" + underscore(name.replaceAll("-", "_"));
|
||||
}
|
||||
|
||||
protected String toSourceFilePath(String name, String extension) {
|
||||
|
@ -29,6 +29,8 @@ import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.Locale;
|
||||
|
||||
import static org.openapitools.codegen.utils.StringUtils.camelize;
|
||||
import static org.openapitools.codegen.utils.StringUtils.underscore;
|
||||
|
||||
public class FlashClientCodegen extends DefaultCodegen implements CodegenConfig {
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(FlashClientCodegen.class);
|
||||
@ -265,7 +267,7 @@ public class FlashClientCodegen extends DefaultCodegen implements CodegenConfig
|
||||
|
||||
// underscore the variable name
|
||||
// petId => pet_id
|
||||
name = org.openapitools.codegen.utils.StringUtils.camelize(dropDots(name), true);
|
||||
name = camelize(dropDots(name), true);
|
||||
|
||||
// for reserved word or word starting with number, append _
|
||||
if (isReservedWord(name) || name.matches("^\\d.*")) {
|
||||
@ -295,13 +297,13 @@ public class FlashClientCodegen extends DefaultCodegen implements CodegenConfig
|
||||
|
||||
// model name cannot use reserved keyword, e.g. return
|
||||
if (isReservedWord(name)) {
|
||||
LOGGER.warn(name + " (reserved word) cannot be used as model name. Renamed to " + org.openapitools.codegen.utils.StringUtils.camelize("model_" + name));
|
||||
LOGGER.warn(name + " (reserved word) cannot be used as model name. Renamed to " + camelize("model_" + name));
|
||||
name = "model_" + name; // e.g. return => ModelReturn (after camelize)
|
||||
}
|
||||
|
||||
// camelize the model name
|
||||
// phone_number => PhoneNumber
|
||||
return org.openapitools.codegen.utils.StringUtils.camelize(name);
|
||||
return camelize(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -316,7 +318,7 @@ public class FlashClientCodegen extends DefaultCodegen implements CodegenConfig
|
||||
name = name.replaceAll("-", "_"); // FIXME: a parameter should not be assigned. Also declare the methods parameters as 'final'.
|
||||
|
||||
// e.g. PhoneNumberApi.rb => phone_number_api.rb
|
||||
return org.openapitools.codegen.utils.StringUtils.camelize(name) + "Api";
|
||||
return camelize(name) + "Api";
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -325,7 +327,7 @@ public class FlashClientCodegen extends DefaultCodegen implements CodegenConfig
|
||||
return "DefaultApi";
|
||||
}
|
||||
// e.g. phone_number_api => PhoneNumberApi
|
||||
return org.openapitools.codegen.utils.StringUtils.camelize(name) + "Api";
|
||||
return camelize(name) + "Api";
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -333,7 +335,7 @@ public class FlashClientCodegen extends DefaultCodegen implements CodegenConfig
|
||||
if (name.length() == 0) {
|
||||
return "DefaultApi";
|
||||
}
|
||||
return org.openapitools.codegen.utils.StringUtils.camelize(name) + "Api";
|
||||
return camelize(name) + "Api";
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -345,11 +347,11 @@ public class FlashClientCodegen extends DefaultCodegen implements CodegenConfig
|
||||
|
||||
// method name cannot use reserved keyword, e.g. return
|
||||
if (isReservedWord(operationId)) {
|
||||
LOGGER.warn(operationId + " (reserved word) cannot be used as method name. Renamed to " + org.openapitools.codegen.utils.StringUtils.underscore(sanitizeName("call_" + operationId)));
|
||||
LOGGER.warn(operationId + " (reserved word) cannot be used as method name. Renamed to " + underscore(sanitizeName("call_" + operationId)));
|
||||
operationId = "call_" + operationId;
|
||||
}
|
||||
|
||||
return org.openapitools.codegen.utils.StringUtils.underscore(operationId);
|
||||
return underscore(operationId);
|
||||
}
|
||||
|
||||
public void setPackageName(String packageName) {
|
||||
|
@ -20,6 +20,7 @@ package org.openapitools.codegen.languages;
|
||||
import org.openapitools.codegen.*;
|
||||
|
||||
import java.io.File;
|
||||
import static org.openapitools.codegen.utils.StringUtils.camelize;
|
||||
|
||||
|
||||
public class GroovyClientCodegen extends AbstractJavaCodegen {
|
||||
@ -99,7 +100,7 @@ public class GroovyClientCodegen extends AbstractJavaCodegen {
|
||||
return "DefaultApi";
|
||||
}
|
||||
name = sanitizeName(name);
|
||||
return org.openapitools.codegen.utils.StringUtils.camelize(name) + "Api";
|
||||
return camelize(name) + "Api";
|
||||
}
|
||||
|
||||
public void setConfigPackage(String configPackage) {
|
||||
|
@ -36,6 +36,8 @@ import java.util.*;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import static org.openapitools.codegen.utils.StringUtils.camelize;
|
||||
import static org.openapitools.codegen.utils.StringUtils.underscore;
|
||||
|
||||
public class HaskellHttpClientCodegen extends DefaultCodegen implements CodegenConfig {
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(HaskellHttpClientCodegen.class);
|
||||
@ -622,8 +624,8 @@ public class HaskellHttpClientCodegen extends DefaultCodegen implements CodegenC
|
||||
}
|
||||
op.operationId = uniqueName;
|
||||
op.operationIdLowerCase = uniqueName.toLowerCase(Locale.ROOT);
|
||||
op.operationIdCamelCase = org.openapitools.codegen.utils.StringUtils.camelize(uniqueName);
|
||||
op.operationIdSnakeCase = org.openapitools.codegen.utils.StringUtils.underscore(uniqueName);
|
||||
op.operationIdCamelCase = camelize(uniqueName);
|
||||
op.operationIdSnakeCase = underscore(uniqueName);
|
||||
opList.add(op);
|
||||
op.baseName = tag;
|
||||
|
||||
@ -1083,8 +1085,8 @@ public class HaskellHttpClientCodegen extends DefaultCodegen implements CodegenC
|
||||
|
||||
public String toVarName(String prefix, String name) {
|
||||
Boolean hasPrefix = !StringUtils.isBlank(prefix);
|
||||
name = org.openapitools.codegen.utils.StringUtils.underscore(sanitizeName(name.replaceAll("-", "_")));
|
||||
name = org.openapitools.codegen.utils.StringUtils.camelize(name, !hasPrefix);
|
||||
name = underscore(sanitizeName(name.replaceAll("-", "_")));
|
||||
name = camelize(name, !hasPrefix);
|
||||
if (hasPrefix) {
|
||||
return prefix + name;
|
||||
} else {
|
||||
@ -1129,7 +1131,7 @@ public class HaskellHttpClientCodegen extends DefaultCodegen implements CodegenC
|
||||
}
|
||||
|
||||
public String toTypeName(String prefix, String name) {
|
||||
name = escapeIdentifier(prefix, org.openapitools.codegen.utils.StringUtils.camelize(sanitizeName(name)));
|
||||
name = escapeIdentifier(prefix, camelize(sanitizeName(name)));
|
||||
return name;
|
||||
}
|
||||
|
||||
@ -1138,7 +1140,7 @@ public class HaskellHttpClientCodegen extends DefaultCodegen implements CodegenC
|
||||
if (StringUtils.isEmpty(operationId)) {
|
||||
throw new RuntimeException("Empty method/operation name (operationId) not allowed");
|
||||
}
|
||||
operationId = escapeIdentifier("op", org.openapitools.codegen.utils.StringUtils.camelize(sanitizeName(operationId), true));
|
||||
operationId = escapeIdentifier("op", camelize(sanitizeName(operationId), true));
|
||||
return operationId;
|
||||
}
|
||||
|
||||
|
@ -47,6 +47,7 @@ import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import static org.openapitools.codegen.utils.StringUtils.camelize;
|
||||
|
||||
public class HaskellServantCodegen extends DefaultCodegen implements CodegenConfig {
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(HaskellServantCodegen.class);
|
||||
@ -502,7 +503,7 @@ public class HaskellServantCodegen extends DefaultCodegen implements CodegenConf
|
||||
}
|
||||
} else if (op.getHasFormParams()) {
|
||||
// Use the FormX data type, where X is the conglomerate of all things being passed
|
||||
String formName = "Form" + org.openapitools.codegen.utils.StringUtils.camelize(op.operationId);
|
||||
String formName = "Form" + camelize(op.operationId);
|
||||
bodyType = formName;
|
||||
path.add("ReqBody '[FormUrlEncoded] " + formName);
|
||||
}
|
||||
@ -527,7 +528,7 @@ public class HaskellServantCodegen extends DefaultCodegen implements CodegenConf
|
||||
|
||||
// store form parameter name in the vendor extensions
|
||||
for (CodegenParameter param : op.formParams) {
|
||||
param.vendorExtensions.put("x-formParamName", org.openapitools.codegen.utils.StringUtils.camelize(param.baseName));
|
||||
param.vendorExtensions.put("x-formParamName", camelize(param.baseName));
|
||||
}
|
||||
|
||||
// Add the HTTP method and return type
|
||||
@ -543,9 +544,9 @@ public class HaskellServantCodegen extends DefaultCodegen implements CodegenConf
|
||||
|
||||
op.vendorExtensions.put("x-routeType", joinStrings(" :> ", path));
|
||||
op.vendorExtensions.put("x-clientType", joinStrings(" -> ", type));
|
||||
op.vendorExtensions.put("x-formName", "Form" + org.openapitools.codegen.utils.StringUtils.camelize(op.operationId));
|
||||
op.vendorExtensions.put("x-formName", "Form" + camelize(op.operationId));
|
||||
for (CodegenParameter param : op.formParams) {
|
||||
param.vendorExtensions.put("x-formPrefix", org.openapitools.codegen.utils.StringUtils.camelize(op.operationId, true));
|
||||
param.vendorExtensions.put("x-formPrefix", camelize(op.operationId, true));
|
||||
}
|
||||
return op;
|
||||
}
|
||||
@ -610,9 +611,9 @@ public class HaskellServantCodegen extends DefaultCodegen implements CodegenConf
|
||||
}
|
||||
|
||||
// From the model name, compute the prefix for the fields.
|
||||
String prefix = org.openapitools.codegen.utils.StringUtils.camelize(model.classname, true);
|
||||
String prefix = camelize(model.classname, true);
|
||||
for (CodegenProperty prop : model.vars) {
|
||||
prop.name = toVarName(prefix + org.openapitools.codegen.utils.StringUtils.camelize(fixOperatorChars(prop.name)));
|
||||
prop.name = toVarName(prefix + camelize(fixOperatorChars(prop.name)));
|
||||
}
|
||||
|
||||
// Create newtypes for things with non-object types
|
||||
|
@ -46,6 +46,7 @@ import java.util.regex.Pattern;
|
||||
import static com.google.common.base.CaseFormat.LOWER_CAMEL;
|
||||
import static com.google.common.base.CaseFormat.UPPER_UNDERSCORE;
|
||||
import static java.util.Collections.sort;
|
||||
import static org.openapitools.codegen.utils.StringUtils.camelize;
|
||||
|
||||
public class JavaClientCodegen extends AbstractJavaCodegen
|
||||
implements BeanValidationFeatures, PerformBeanValidationFeatures,
|
||||
@ -466,7 +467,7 @@ public class JavaClientCodegen extends AbstractJavaCodegen
|
||||
for (int i = 0; i < items.length; ++i) {
|
||||
if (items[i].matches("^\\{(.*)\\}$")) { // wrap in {}
|
||||
// camelize path variable
|
||||
items[i] = "{" + org.openapitools.codegen.utils.StringUtils.camelize(items[i].substring(1, items[i].length() - 1), true) + "}";
|
||||
items[i] = "{" + camelize(items[i].substring(1, items[i].length() - 1), true) + "}";
|
||||
}
|
||||
}
|
||||
op.path = StringUtils.join(items, "/");
|
||||
|
@ -33,6 +33,7 @@ import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import static org.openapitools.codegen.utils.StringUtils.camelize;
|
||||
|
||||
|
||||
public class JavaInflectorServerCodegen extends AbstractJavaCodegen {
|
||||
@ -227,6 +228,6 @@ public class JavaInflectorServerCodegen extends AbstractJavaCodegen {
|
||||
return "DefaultController";
|
||||
}
|
||||
name = name.replaceAll("[^a-zA-Z0-9]+", "_");
|
||||
return org.openapitools.codegen.utils.StringUtils.camelize(name) + "Controller";
|
||||
return camelize(name) + "Controller";
|
||||
}
|
||||
}
|
||||
|
@ -33,6 +33,7 @@ import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import static org.openapitools.codegen.utils.StringUtils.camelize;
|
||||
|
||||
public class JavaJAXRSSpecServerCodegen extends AbstractJavaJAXRSServerCodegen {
|
||||
|
||||
@ -222,6 +223,6 @@ public class JavaJAXRSSpecServerCodegen extends AbstractJavaJAXRSServerCodegen {
|
||||
return primaryResourceName + "Api";
|
||||
}
|
||||
computed = sanitizeName(computed);
|
||||
return org.openapitools.codegen.utils.StringUtils.camelize(computed) + "Api";
|
||||
return camelize(computed) + "Api";
|
||||
}
|
||||
}
|
||||
|
@ -41,6 +41,7 @@ import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
|
||||
import static org.openapitools.codegen.utils.StringUtils.camelize;
|
||||
|
||||
/**
|
||||
* Created by prokarma on 04/09/17.
|
||||
@ -546,7 +547,7 @@ public class JavaPKMSTServerCodegen extends AbstractJavaCodegen {
|
||||
title = title.substring(0, title.length() - 3);
|
||||
}
|
||||
|
||||
this.title = org.openapitools.codegen.utils.StringUtils.camelize(sanitizeName(title), true);
|
||||
this.title = camelize(sanitizeName(title), true);
|
||||
}
|
||||
additionalProperties.put(TITLE, this.title);
|
||||
}
|
||||
@ -595,7 +596,7 @@ public class JavaPKMSTServerCodegen extends AbstractJavaCodegen {
|
||||
return "DefaultApi";
|
||||
}
|
||||
name = sanitizeName(name);
|
||||
return org.openapitools.codegen.utils.StringUtils.camelize(name) + "Api";
|
||||
return camelize(name) + "Api";
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -35,6 +35,7 @@ import java.util.Map;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import static org.openapitools.codegen.utils.StringUtils.camelize;
|
||||
|
||||
public class JavaPlayFrameworkCodegen extends AbstractJavaCodegen implements BeanValidationFeatures {
|
||||
|
||||
@ -302,7 +303,7 @@ public class JavaPlayFrameworkCodegen extends AbstractJavaCodegen implements Bea
|
||||
Matcher match = pathVariableMatcher.matcher(operation.path);
|
||||
while (match.find()) {
|
||||
String completeMatch = match.group();
|
||||
String replacement = ":" + org.openapitools.codegen.utils.StringUtils.camelize(match.group(1), true);
|
||||
String replacement = ":" + camelize(match.group(1), true);
|
||||
operation.path = operation.path.replace(completeMatch, replacement);
|
||||
}
|
||||
|
||||
|
@ -29,6 +29,7 @@ import org.slf4j.LoggerFactory;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import static org.openapitools.codegen.utils.StringUtils.camelize;
|
||||
|
||||
|
||||
public class JavaUndertowServerCodegen extends AbstractJavaCodegen {
|
||||
@ -202,6 +203,6 @@ public class JavaUndertowServerCodegen extends AbstractJavaCodegen {
|
||||
return "DefaultHandler";
|
||||
}
|
||||
name = name.replaceAll("[^a-zA-Z0-9]+", "_"); // FIXME: a parameter should not be assigned. Also declare the methods parameters as 'final'.
|
||||
return org.openapitools.codegen.utils.StringUtils.camelize(name) + "Handler";
|
||||
return camelize(name) + "Handler";
|
||||
}
|
||||
}
|
||||
|
@ -48,6 +48,10 @@ import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
|
||||
import static org.openapitools.codegen.utils.StringUtils.camelize;
|
||||
import static org.openapitools.codegen.utils.StringUtils.dashize;
|
||||
import static org.openapitools.codegen.utils.StringUtils.underscore;
|
||||
|
||||
public class JavascriptClientCodegen extends DefaultCodegen implements CodegenConfig {
|
||||
@SuppressWarnings("hiding")
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(JavascriptClientCodegen.class);
|
||||
@ -289,7 +293,7 @@ public class JavascriptClientCodegen extends DefaultCodegen implements CodegenCo
|
||||
Info info = openAPI.getInfo();
|
||||
if (StringUtils.isBlank(projectName) && info.getTitle() != null) {
|
||||
// when projectName is not specified, generate it from info.title
|
||||
projectName = sanitizeName(org.openapitools.codegen.utils.StringUtils.dashize(info.getTitle()));
|
||||
projectName = sanitizeName(dashize(info.getTitle()));
|
||||
}
|
||||
if (StringUtils.isBlank(projectVersion)) {
|
||||
// when projectVersion is not specified, use info.version
|
||||
@ -316,7 +320,7 @@ public class JavascriptClientCodegen extends DefaultCodegen implements CodegenCo
|
||||
projectName = "openapi-js-client";
|
||||
}
|
||||
if (StringUtils.isBlank(moduleName)) {
|
||||
moduleName = org.openapitools.codegen.utils.StringUtils.camelize(org.openapitools.codegen.utils.StringUtils.underscore(projectName));
|
||||
moduleName = camelize(underscore(projectName));
|
||||
}
|
||||
if (StringUtils.isBlank(projectVersion)) {
|
||||
projectVersion = "1.0.0";
|
||||
@ -513,11 +517,11 @@ public class JavascriptClientCodegen extends DefaultCodegen implements CodegenCo
|
||||
case original:
|
||||
return name;
|
||||
case camelCase:
|
||||
return org.openapitools.codegen.utils.StringUtils.camelize(name, true);
|
||||
return camelize(name, true);
|
||||
case PascalCase:
|
||||
return org.openapitools.codegen.utils.StringUtils.camelize(name);
|
||||
return camelize(name);
|
||||
case snake_case:
|
||||
return org.openapitools.codegen.utils.StringUtils.underscore(name);
|
||||
return underscore(name);
|
||||
default:
|
||||
throw new IllegalArgumentException("Invalid model property naming '" +
|
||||
name + "'. Must be 'original', 'camelCase', " +
|
||||
@ -571,7 +575,7 @@ public class JavascriptClientCodegen extends DefaultCodegen implements CodegenCo
|
||||
|
||||
// camelize the model name
|
||||
// phone_number => PhoneNumber
|
||||
name = org.openapitools.codegen.utils.StringUtils.camelize(name);
|
||||
name = camelize(name);
|
||||
|
||||
// model name cannot use reserved keyword, e.g. return
|
||||
if (isReservedWord(name)) {
|
||||
@ -840,18 +844,18 @@ public class JavascriptClientCodegen extends DefaultCodegen implements CodegenCo
|
||||
throw new RuntimeException("Empty method/operation name (operationId) not allowed");
|
||||
}
|
||||
|
||||
operationId = org.openapitools.codegen.utils.StringUtils.camelize(sanitizeName(operationId), true);
|
||||
operationId = camelize(sanitizeName(operationId), true);
|
||||
|
||||
// method name cannot use reserved keyword, e.g. return
|
||||
if (isReservedWord(operationId)) {
|
||||
String newOperationId = org.openapitools.codegen.utils.StringUtils.camelize("call_" + operationId, true);
|
||||
String newOperationId = camelize("call_" + operationId, true);
|
||||
LOGGER.warn(operationId + " (reserved word) cannot be used as method name. Renamed to " + newOperationId);
|
||||
return newOperationId;
|
||||
}
|
||||
|
||||
// operationId starts with a number
|
||||
if (operationId.matches("^\\d.*")) {
|
||||
String newOperationId = org.openapitools.codegen.utils.StringUtils.camelize("call_" + operationId, true);
|
||||
String newOperationId = camelize("call_" + operationId, true);
|
||||
LOGGER.warn(operationId + " (starting with a number) cannot be used as method name. Renamed to " + newOperationId);
|
||||
return newOperationId;
|
||||
}
|
||||
@ -1133,7 +1137,7 @@ public class JavascriptClientCodegen extends DefaultCodegen implements CodegenCo
|
||||
|
||||
@Override
|
||||
public String toEnumName(CodegenProperty property) {
|
||||
return sanitizeName(org.openapitools.codegen.utils.StringUtils.camelize(property.name)) + "Enum";
|
||||
return sanitizeName(camelize(property.name)) + "Enum";
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -41,7 +41,7 @@ import java.util.*;
|
||||
import java.io.File;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import static org.openapitools.codegen.utils.StringUtils.camelize;
|
||||
|
||||
public class JavascriptClosureAngularClientCodegen extends DefaultCodegen implements CodegenConfig {
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(JavascriptClosureAngularClientCodegen.class);
|
||||
@ -188,7 +188,7 @@ public class JavascriptClosureAngularClientCodegen extends DefaultCodegen implem
|
||||
|
||||
// camelize the variable name
|
||||
// pet_id => PetId
|
||||
name = org.openapitools.codegen.utils.StringUtils.camelize(name, true);
|
||||
name = camelize(name, true);
|
||||
|
||||
// for reserved word or word starting with number, append _
|
||||
if (isReservedWord(name) || name.matches("^\\d.*"))
|
||||
@ -215,13 +215,13 @@ public class JavascriptClosureAngularClientCodegen extends DefaultCodegen implem
|
||||
|
||||
// model name cannot use reserved keyword, e.g. return
|
||||
if (isReservedWord(name)) {
|
||||
LOGGER.warn(name + " (reserved word) cannot be used as model name. Renamed to " + org.openapitools.codegen.utils.StringUtils.camelize("model_" + name));
|
||||
LOGGER.warn(name + " (reserved word) cannot be used as model name. Renamed to " + camelize("model_" + name));
|
||||
name = "model_" + name; // e.g. return => ModelReturn (after camelize)
|
||||
}
|
||||
|
||||
// camelize the model name
|
||||
// phone_number => PhoneNumber
|
||||
return org.openapitools.codegen.utils.StringUtils.camelize(name);
|
||||
return camelize(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -305,11 +305,11 @@ public class JavascriptClosureAngularClientCodegen extends DefaultCodegen implem
|
||||
throw new RuntimeException("Empty method/operation name (operationId) not allowed");
|
||||
}
|
||||
|
||||
operationId = org.openapitools.codegen.utils.StringUtils.camelize(sanitizeName(operationId), true);
|
||||
operationId = camelize(sanitizeName(operationId), true);
|
||||
|
||||
// method name cannot use reserved keyword, e.g. return
|
||||
if (isReservedWord(operationId)) {
|
||||
String newOperationId = org.openapitools.codegen.utils.StringUtils.camelize("call_" + operationId, true);
|
||||
String newOperationId = camelize("call_" + operationId, true);
|
||||
LOGGER.warn(operationId + " (reserved word) cannot be used as method name. Renamed to " + newOperationId);
|
||||
return newOperationId;
|
||||
}
|
||||
|
@ -29,6 +29,7 @@ import org.openapitools.codegen.utils.ModelUtils;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.*;
|
||||
|
||||
import static org.openapitools.codegen.utils.StringUtils.dashize;
|
||||
|
||||
public class JavascriptFlowtypedClientCodegen extends AbstractTypeScriptClientCodegen {
|
||||
private static final SimpleDateFormat SNAPSHOT_SUFFIX_FORMAT = new SimpleDateFormat("yyyyMMddHHmm", Locale.ROOT);
|
||||
@ -186,7 +187,7 @@ public class JavascriptFlowtypedClientCodegen extends AbstractTypeScriptClientCo
|
||||
Info info = openAPI.getInfo();
|
||||
if (StringUtils.isBlank(npmName) && info.getTitle() != null) {
|
||||
// when projectName is not specified, generate it from info.title
|
||||
npmName = sanitizeName(org.openapitools.codegen.utils.StringUtils.dashize(info.getTitle()));
|
||||
npmName = sanitizeName(dashize(info.getTitle()));
|
||||
}
|
||||
if (StringUtils.isBlank(npmVersion)) {
|
||||
// when projectVersion is not specified, use info.version
|
||||
|
@ -35,6 +35,7 @@ import java.util.*;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static org.openapitools.codegen.utils.StringUtils.camelize;
|
||||
|
||||
public class KotlinSpringServerCodegen extends AbstractKotlinCodegen
|
||||
implements BeanValidationFeatures {
|
||||
|
@ -43,6 +43,8 @@ import java.util.ListIterator;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
|
||||
import static org.openapitools.codegen.utils.StringUtils.camelize;
|
||||
import static org.openapitools.codegen.utils.StringUtils.underscore;
|
||||
|
||||
public class LuaClientCodegen extends DefaultCodegen implements CodegenConfig {
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(LuaClientCodegen.class);
|
||||
@ -203,7 +205,7 @@ public class LuaClientCodegen extends DefaultCodegen implements CodegenConfig {
|
||||
if (this.reservedWordsMappings().containsKey(name)) {
|
||||
return this.reservedWordsMappings().get(name);
|
||||
}
|
||||
return org.openapitools.codegen.utils.StringUtils.camelize(name) + '_';
|
||||
return camelize(name) + '_';
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -226,7 +228,7 @@ public class LuaClientCodegen extends DefaultCodegen implements CodegenConfig {
|
||||
|
||||
// convert variable name to snake case
|
||||
// PetId => pet_id
|
||||
name = org.openapitools.codegen.utils.StringUtils.underscore(name);
|
||||
name = underscore(name);
|
||||
|
||||
// for reserved word or word starting with number, append _
|
||||
if (isReservedWord(name))
|
||||
@ -273,7 +275,7 @@ public class LuaClientCodegen extends DefaultCodegen implements CodegenConfig {
|
||||
name = "model_" + name; // e.g. 200Response => Model200Response (after camelize)
|
||||
}
|
||||
|
||||
return org.openapitools.codegen.utils.StringUtils.underscore(name);
|
||||
return underscore(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -282,7 +284,7 @@ public class LuaClientCodegen extends DefaultCodegen implements CodegenConfig {
|
||||
name = name.replaceAll("-", "_"); // FIXME: a parameter should not be assigned. Also declare the methods parameters as 'final'.
|
||||
|
||||
// e.g. PetApi.lua => pet_api.lua
|
||||
return org.openapitools.codegen.utils.StringUtils.underscore(name) + "_api";
|
||||
return underscore(name) + "_api";
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -339,7 +341,7 @@ public class LuaClientCodegen extends DefaultCodegen implements CodegenConfig {
|
||||
|
||||
@Override
|
||||
public String toApiName(String name) {
|
||||
return org.openapitools.codegen.utils.StringUtils.underscore(super.toApiName(name));
|
||||
return underscore(super.toApiName(name));
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -391,11 +393,11 @@ public class LuaClientCodegen extends DefaultCodegen implements CodegenConfig {
|
||||
|
||||
// method name cannot use reserved keyword, e.g. return
|
||||
if (isReservedWord(sanitizedOperationId)) {
|
||||
LOGGER.warn(operationId + " (reserved word) cannot be used as method name. Renamed to " + org.openapitools.codegen.utils.StringUtils.underscore("call_" + operationId));
|
||||
LOGGER.warn(operationId + " (reserved word) cannot be used as method name. Renamed to " + underscore("call_" + operationId));
|
||||
sanitizedOperationId = "call_" + sanitizedOperationId;
|
||||
}
|
||||
|
||||
return org.openapitools.codegen.utils.StringUtils.underscore(sanitizedOperationId);
|
||||
return underscore(sanitizedOperationId);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -530,7 +532,7 @@ public class LuaClientCodegen extends DefaultCodegen implements CodegenConfig {
|
||||
}
|
||||
|
||||
// string
|
||||
String enumName = sanitizeName(org.openapitools.codegen.utils.StringUtils.underscore(name).toUpperCase(Locale.ROOT));
|
||||
String enumName = sanitizeName(underscore(name).toUpperCase(Locale.ROOT));
|
||||
enumName = enumName.replaceFirst("^_", "");
|
||||
enumName = enumName.replaceFirst("_$", "");
|
||||
|
||||
@ -543,7 +545,7 @@ public class LuaClientCodegen extends DefaultCodegen implements CodegenConfig {
|
||||
|
||||
@Override
|
||||
public String toEnumName(CodegenProperty property) {
|
||||
String enumName = org.openapitools.codegen.utils.StringUtils.underscore(toModelName(property.name)).toUpperCase(Locale.ROOT);
|
||||
String enumName = underscore(toModelName(property.name)).toUpperCase(Locale.ROOT);
|
||||
|
||||
// remove [] for array or map of enum
|
||||
enumName = enumName.replace("[]", "");
|
||||
|
@ -44,7 +44,7 @@ import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import static org.openapitools.codegen.utils.StringUtils.camelize;
|
||||
|
||||
public class ObjcClientCodegen extends DefaultCodegen implements CodegenConfig {
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(ObjcClientCodegen.class);
|
||||
@ -432,7 +432,7 @@ public class ObjcClientCodegen extends DefaultCodegen implements CodegenConfig {
|
||||
// model name starts with number
|
||||
/* no need for the fix below as objc model starts with prefix (e.g. SWG)
|
||||
if (type.matches("^\\d.*")) {
|
||||
LOGGER.warn(type + " (model name starts with number) cannot be used as model name. Renamed to " + org.openapitools.codegen.utils.StringUtils.camelize("model_" + type));
|
||||
LOGGER.warn(type + " (model name starts with number) cannot be used as model name. Renamed to " + camelize("model_" + type));
|
||||
type = "model_" + type; // e.g. 200Response => Model200Response (after camelize)
|
||||
}
|
||||
*/
|
||||
@ -456,7 +456,7 @@ public class ObjcClientCodegen extends DefaultCodegen implements CodegenConfig {
|
||||
importMapping.values().contains(type) ||
|
||||
defaultIncludes.contains(type) ||
|
||||
languageSpecificPrimitives.contains(type)) {
|
||||
return org.openapitools.codegen.utils.StringUtils.camelize(type);
|
||||
return camelize(type);
|
||||
}
|
||||
// custom classes
|
||||
else {
|
||||
@ -468,7 +468,7 @@ public class ObjcClientCodegen extends DefaultCodegen implements CodegenConfig {
|
||||
type = modelNamePrefix + "_" + type;
|
||||
}
|
||||
|
||||
return classPrefix + org.openapitools.codegen.utils.StringUtils.camelize(type); // add class prefix
|
||||
return classPrefix + camelize(type); // add class prefix
|
||||
}
|
||||
}
|
||||
|
||||
@ -529,12 +529,12 @@ public class ObjcClientCodegen extends DefaultCodegen implements CodegenConfig {
|
||||
|
||||
@Override
|
||||
public String toApiName(String name) {
|
||||
return classPrefix + org.openapitools.codegen.utils.StringUtils.camelize(name) + "Api";
|
||||
return classPrefix + camelize(name) + "Api";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toApiFilename(String name) {
|
||||
return classPrefix + org.openapitools.codegen.utils.StringUtils.camelize(name) + "Api";
|
||||
return classPrefix + camelize(name) + "Api";
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -559,7 +559,7 @@ public class ObjcClientCodegen extends DefaultCodegen implements CodegenConfig {
|
||||
|
||||
// camelize (lower first character) the variable name
|
||||
// e.g. `pet_id` to `petId`
|
||||
name = org.openapitools.codegen.utils.StringUtils.camelize(name, true);
|
||||
name = camelize(name, true);
|
||||
|
||||
// for reserved word or word starting with number, prepend `_`
|
||||
if (isReservedWord(name) || name.matches("^\\d.*")) {
|
||||
@ -604,11 +604,11 @@ public class ObjcClientCodegen extends DefaultCodegen implements CodegenConfig {
|
||||
|
||||
// method name cannot use reserved keyword, e.g. return
|
||||
if (isReservedWord(operationId)) {
|
||||
LOGGER.warn(operationId + " (reserved word) cannot be used as method name. Renamed to " + org.openapitools.codegen.utils.StringUtils.camelize(sanitizeName("call_" + operationId), true));
|
||||
LOGGER.warn(operationId + " (reserved word) cannot be used as method name. Renamed to " + camelize(sanitizeName("call_" + operationId), true));
|
||||
operationId = "call_" + operationId;
|
||||
}
|
||||
|
||||
return org.openapitools.codegen.utils.StringUtils.camelize(sanitizeName(operationId), true);
|
||||
return camelize(sanitizeName(operationId), true);
|
||||
}
|
||||
|
||||
public void setClassPrefix(String classPrefix) {
|
||||
@ -647,7 +647,7 @@ public class ObjcClientCodegen extends DefaultCodegen implements CodegenConfig {
|
||||
for (CodegenOperation operation : ops) {
|
||||
if (!operation.allParams.isEmpty()) {
|
||||
String firstParamName = operation.allParams.get(0).paramName;
|
||||
operation.vendorExtensions.put("firstParamAltName", org.openapitools.codegen.utils.StringUtils.camelize(firstParamName));
|
||||
operation.vendorExtensions.put("firstParamAltName", camelize(firstParamName));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -657,7 +657,7 @@ public class ObjcClientCodegen extends DefaultCodegen implements CodegenConfig {
|
||||
@Override
|
||||
public void postProcessModelProperty(CodegenModel model, CodegenProperty schema) {
|
||||
super.postProcessModelProperty(model, schema);
|
||||
schema.vendorExtensions.put("x-uppercaseName", org.openapitools.codegen.utils.StringUtils.camelize(schema.name));
|
||||
schema.vendorExtensions.put("x-uppercaseName", camelize(schema.name));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -34,6 +34,9 @@ import java.util.regex.Matcher;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.commons.io.FilenameUtils;
|
||||
|
||||
import static org.openapitools.codegen.utils.StringUtils.camelize;
|
||||
import static org.openapitools.codegen.utils.StringUtils.underscore;
|
||||
|
||||
public class PerlClientCodegen extends DefaultCodegen implements CodegenConfig {
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(PerlClientCodegen.class);
|
||||
|
||||
@ -282,7 +285,7 @@ public class PerlClientCodegen extends DefaultCodegen implements CodegenConfig {
|
||||
public String toVarName(String name) {
|
||||
// return the name in underscore style
|
||||
// PhoneNumber => phone_number
|
||||
name = org.openapitools.codegen.utils.StringUtils.underscore(name); // FIXME: a parameter should not be assigned. Also declare the methods parameters as 'final'.
|
||||
name = underscore(name); // FIXME: a parameter should not be assigned. Also declare the methods parameters as 'final'.
|
||||
|
||||
// parameter name starting with number won't compile
|
||||
// need to escape it by appending _ at the beginning
|
||||
@ -304,13 +307,13 @@ public class PerlClientCodegen extends DefaultCodegen implements CodegenConfig {
|
||||
|
||||
// model name cannot use reserved keyword
|
||||
if (isReservedWord(name)) {
|
||||
LOGGER.warn(name + " (reserved word) cannot be used as model name. Renamed to " + org.openapitools.codegen.utils.StringUtils.camelize("model_" + name));
|
||||
LOGGER.warn(name + " (reserved word) cannot be used as model name. Renamed to " + camelize("model_" + name));
|
||||
name = "model_" + name;
|
||||
}
|
||||
|
||||
// model name starts with number
|
||||
if (name.matches("^\\d.*")) {
|
||||
LOGGER.warn(name + " (model name starts with number) cannot be used as model name. Renamed to " + org.openapitools.codegen.utils.StringUtils.camelize("model_" + name));
|
||||
LOGGER.warn(name + " (model name starts with number) cannot be used as model name. Renamed to " + camelize("model_" + name));
|
||||
name = "model_" + name; // e.g. 200Response => Model200Response (after camelize)
|
||||
}
|
||||
|
||||
@ -325,7 +328,7 @@ public class PerlClientCodegen extends DefaultCodegen implements CodegenConfig {
|
||||
|
||||
// camelize the model name
|
||||
// phone_number => PhoneNumber
|
||||
return org.openapitools.codegen.utils.StringUtils.camelize(name);
|
||||
return camelize(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -360,7 +363,7 @@ public class PerlClientCodegen extends DefaultCodegen implements CodegenConfig {
|
||||
name = name.replaceAll("-", "_"); // FIXME: a parameter should not be assigned. Also declare the methods parameters as 'final'.
|
||||
|
||||
// e.g. phone_number_api.rb => PhoneNumberApi.rb
|
||||
return org.openapitools.codegen.utils.StringUtils.camelize(name) + "Api";
|
||||
return camelize(name) + "Api";
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -369,32 +372,32 @@ public class PerlClientCodegen extends DefaultCodegen implements CodegenConfig {
|
||||
return "DefaultApi";
|
||||
}
|
||||
// e.g. phone_number_api => PhoneNumberApi
|
||||
return org.openapitools.codegen.utils.StringUtils.camelize(name) + "Api";
|
||||
return camelize(name) + "Api";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toOperationId(String operationId) {
|
||||
//rename to empty_function_name_1 (e.g.) if method name is empty
|
||||
if (StringUtils.isEmpty(operationId)) {
|
||||
operationId = org.openapitools.codegen.utils.StringUtils.underscore("empty_function_name_" + emptyFunctionNameCounter++);
|
||||
operationId = underscore("empty_function_name_" + emptyFunctionNameCounter++);
|
||||
LOGGER.warn("Empty method name (operationId) found. Renamed to " + operationId);
|
||||
return operationId;
|
||||
}
|
||||
|
||||
// method name cannot use reserved keyword, e.g. return
|
||||
if (isReservedWord(operationId)) {
|
||||
LOGGER.warn(operationId + " (reserved word) cannot be used as method name. Renamed to " + org.openapitools.codegen.utils.StringUtils.underscore(sanitizeName("call_" + operationId)));
|
||||
return org.openapitools.codegen.utils.StringUtils.underscore(sanitizeName("call_" + operationId));
|
||||
LOGGER.warn(operationId + " (reserved word) cannot be used as method name. Renamed to " + underscore(sanitizeName("call_" + operationId)));
|
||||
return underscore(sanitizeName("call_" + operationId));
|
||||
}
|
||||
|
||||
// operationId starts with a number
|
||||
if (operationId.matches("^\\d.*")) {
|
||||
LOGGER.warn(operationId + " (starting with a number) cannot be used as method name. Renamed to " + org.openapitools.codegen.utils.StringUtils.underscore(sanitizeName("call_" + operationId)));
|
||||
LOGGER.warn(operationId + " (starting with a number) cannot be used as method name. Renamed to " + underscore(sanitizeName("call_" + operationId)));
|
||||
operationId = "call_" + operationId;
|
||||
}
|
||||
|
||||
//return org.openapitools.codegen.utils.StringUtils.underscore(operationId).replaceAll("[^A-Za-z0-9_]", "");
|
||||
return org.openapitools.codegen.utils.StringUtils.underscore(sanitizeName(operationId));
|
||||
//return underscore(operationId).replaceAll("[^A-Za-z0-9_]", "");
|
||||
return underscore(sanitizeName(operationId));
|
||||
}
|
||||
|
||||
public void setModuleName(String moduleName) {
|
||||
|
@ -22,6 +22,7 @@ import org.openapitools.codegen.*;
|
||||
import java.io.File;
|
||||
import java.util.*;
|
||||
|
||||
import static org.openapitools.codegen.utils.StringUtils.camelize;
|
||||
|
||||
public class PhpLaravelServerCodegen extends AbstractPhpCodegen {
|
||||
protected String apiVersion = "1.0.0";
|
||||
@ -241,7 +242,7 @@ public class PhpLaravelServerCodegen extends AbstractPhpCodegen {
|
||||
return "DefaultController";
|
||||
}
|
||||
|
||||
return org.openapitools.codegen.utils.StringUtils.camelize(name, false) + "Controller";
|
||||
return camelize(name, false) + "Controller";
|
||||
}
|
||||
|
||||
protected String controllerFileFolder() {
|
||||
@ -263,6 +264,6 @@ public class PhpLaravelServerCodegen extends AbstractPhpCodegen {
|
||||
return "DefaultController";
|
||||
}
|
||||
|
||||
return org.openapitools.codegen.utils.StringUtils.camelize(name, false) + "Controller";
|
||||
return camelize(name, false) + "Controller";
|
||||
}
|
||||
}
|
||||
|
@ -36,6 +36,8 @@ import java.util.Map;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import static org.openapitools.codegen.utils.StringUtils.camelize;
|
||||
import static org.openapitools.codegen.utils.StringUtils.underscore;
|
||||
|
||||
public class PhpSilexServerCodegen extends DefaultCodegen implements CodegenConfig {
|
||||
protected String invokerPackage;
|
||||
@ -46,7 +48,7 @@ public class PhpSilexServerCodegen extends DefaultCodegen implements CodegenConf
|
||||
public PhpSilexServerCodegen() {
|
||||
super();
|
||||
|
||||
invokerPackage = org.openapitools.codegen.utils.StringUtils.camelize("OpenAPIServer");
|
||||
invokerPackage = camelize("OpenAPIServer");
|
||||
String packageName = "OpenAPIServer";
|
||||
modelPackage = "lib" + File.separator + "models";
|
||||
apiPackage = "lib";
|
||||
@ -200,7 +202,7 @@ public class PhpSilexServerCodegen extends DefaultCodegen implements CodegenConf
|
||||
public String toVarName(String name) {
|
||||
// return the name in underscore style
|
||||
// PhoneNumber => phone_number
|
||||
name = org.openapitools.codegen.utils.StringUtils.underscore(name); // FIXME: a parameter should not be assigned. Also declare the methods parameters as 'final'.
|
||||
name = underscore(name); // FIXME: a parameter should not be assigned. Also declare the methods parameters as 'final'.
|
||||
|
||||
// parameter name starting with number won't compile
|
||||
// need to escape it by appending _ at the beginning
|
||||
@ -226,7 +228,7 @@ public class PhpSilexServerCodegen extends DefaultCodegen implements CodegenConf
|
||||
|
||||
// camelize the model name
|
||||
// phone_number => PhoneNumber
|
||||
return org.openapitools.codegen.utils.StringUtils.camelize(name);
|
||||
return camelize(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -259,7 +261,7 @@ public class PhpSilexServerCodegen extends DefaultCodegen implements CodegenConf
|
||||
for (int i = 0; i < items.length; ++i) {
|
||||
if (items[i].matches("^\\{(.*)\\}$")) { // wrap in {}
|
||||
// camelize path variable
|
||||
items[i] = "{" + org.openapitools.codegen.utils.StringUtils.camelize(items[i].substring(1, items[i].length() - 1), true) + "}";
|
||||
items[i] = "{" + camelize(items[i].substring(1, items[i].length() - 1), true) + "}";
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -28,6 +28,7 @@ import org.slf4j.LoggerFactory;
|
||||
import java.io.File;
|
||||
import java.util.*;
|
||||
|
||||
import static org.openapitools.codegen.utils.StringUtils.camelize;
|
||||
|
||||
public class PhpSymfonyServerCodegen extends AbstractPhpCodegen implements CodegenConfig {
|
||||
@SuppressWarnings("hiding")
|
||||
@ -568,14 +569,14 @@ public class PhpSymfonyServerCodegen extends AbstractPhpCodegen implements Codeg
|
||||
if (name.isEmpty()) {
|
||||
return "DefaultApiInterface";
|
||||
}
|
||||
return org.openapitools.codegen.utils.StringUtils.camelize(name, false) + "ApiInterface";
|
||||
return camelize(name, false) + "ApiInterface";
|
||||
}
|
||||
|
||||
protected String toControllerName(String name) {
|
||||
if (name.isEmpty()) {
|
||||
return "DefaultController";
|
||||
}
|
||||
return org.openapitools.codegen.utils.StringUtils.camelize(name, false) + "Controller";
|
||||
return camelize(name, false) + "Controller";
|
||||
}
|
||||
|
||||
protected String toSymfonyService(String name) {
|
||||
|
@ -41,6 +41,7 @@ import java.util.Locale;
|
||||
import java.util.Map;
|
||||
|
||||
import static java.util.UUID.randomUUID;
|
||||
import static org.openapitools.codegen.utils.StringUtils.camelize;
|
||||
|
||||
public class PowerShellClientCodegen extends DefaultCodegen implements CodegenConfig {
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(PowerShellClientCodegen.class);
|
||||
@ -329,19 +330,19 @@ public class PowerShellClientCodegen extends DefaultCodegen implements CodegenCo
|
||||
|
||||
// model name cannot use reserved keyword, e.g. return
|
||||
if (isReservedWord(name)) {
|
||||
LOGGER.warn(name + " (reserved word) cannot be used as model name. Renamed to " + org.openapitools.codegen.utils.StringUtils.camelize("model_" + name));
|
||||
LOGGER.warn(name + " (reserved word) cannot be used as model name. Renamed to " + camelize("model_" + name));
|
||||
name = "model_" + name; // e.g. return => ModelReturn (after camelize)
|
||||
}
|
||||
|
||||
// model name starts with number
|
||||
if (name.matches("^\\d.*")) {
|
||||
LOGGER.warn(name + " (model name starts with number) cannot be used as model name. Renamed to " + org.openapitools.codegen.utils.StringUtils.camelize("model_" + name));
|
||||
LOGGER.warn(name + " (model name starts with number) cannot be used as model name. Renamed to " + camelize("model_" + name));
|
||||
name = "model_" + name; // e.g. 200Response => Model200Response (after camelize)
|
||||
}
|
||||
|
||||
// camelize the model name
|
||||
// phone_number => PhoneNumber
|
||||
return org.openapitools.codegen.utils.StringUtils.camelize(name);
|
||||
return camelize(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -406,11 +407,11 @@ public class PowerShellClientCodegen extends DefaultCodegen implements CodegenCo
|
||||
|
||||
// method name cannot use reserved keyword, e.g. return
|
||||
if (isReservedWord(operationId)) {
|
||||
LOGGER.warn(operationId + " (reserved word) cannot be used as method name. Renamed to " + org.openapitools.codegen.utils.StringUtils.camelize(sanitizeName("call_" + operationId)));
|
||||
LOGGER.warn(operationId + " (reserved word) cannot be used as method name. Renamed to " + camelize(sanitizeName("call_" + operationId)));
|
||||
operationId = "call_" + operationId;
|
||||
}
|
||||
|
||||
return org.openapitools.codegen.utils.StringUtils.camelize(sanitizeName(operationId));
|
||||
return camelize(sanitizeName(operationId));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -43,6 +43,8 @@ import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import static org.openapitools.codegen.utils.StringUtils.camelize;
|
||||
import static org.openapitools.codegen.utils.StringUtils.underscore;
|
||||
|
||||
public class PythonClientCodegen extends DefaultCodegen implements CodegenConfig {
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(PythonClientCodegen.class);
|
||||
@ -444,7 +446,7 @@ public class PythonClientCodegen extends DefaultCodegen implements CodegenConfig
|
||||
|
||||
// underscore the variable name
|
||||
// petId => pet_id
|
||||
name = org.openapitools.codegen.utils.StringUtils.underscore(name);
|
||||
name = underscore(name);
|
||||
|
||||
// remove leading underscore
|
||||
name = name.replaceAll("^_*", "");
|
||||
@ -476,13 +478,13 @@ public class PythonClientCodegen extends DefaultCodegen implements CodegenConfig
|
||||
|
||||
// model name cannot use reserved keyword, e.g. return
|
||||
if (isReservedWord(name)) {
|
||||
LOGGER.warn(name + " (reserved word) cannot be used as model name. Renamed to " + org.openapitools.codegen.utils.StringUtils.camelize("model_" + name));
|
||||
LOGGER.warn(name + " (reserved word) cannot be used as model name. Renamed to " + camelize("model_" + name));
|
||||
name = "model_" + name; // e.g. return => ModelReturn (after camelize)
|
||||
}
|
||||
|
||||
// model name starts with number
|
||||
if (name.matches("^\\d.*")) {
|
||||
LOGGER.warn(name + " (model name starts with number) cannot be used as model name. Renamed to " + org.openapitools.codegen.utils.StringUtils.camelize("model_" + name));
|
||||
LOGGER.warn(name + " (model name starts with number) cannot be used as model name. Renamed to " + camelize("model_" + name));
|
||||
name = "model_" + name; // e.g. 200Response => Model200Response (after camelize)
|
||||
}
|
||||
|
||||
@ -496,14 +498,14 @@ public class PythonClientCodegen extends DefaultCodegen implements CodegenConfig
|
||||
|
||||
// camelize the model name
|
||||
// phone_number => PhoneNumber
|
||||
return org.openapitools.codegen.utils.StringUtils.camelize(name);
|
||||
return camelize(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toModelFilename(String name) {
|
||||
// underscore the model file name
|
||||
// PhoneNumber => phone_number
|
||||
return org.openapitools.codegen.utils.StringUtils.underscore(dropDots(toModelName(name)));
|
||||
return underscore(dropDots(toModelName(name)));
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -517,7 +519,7 @@ public class PythonClientCodegen extends DefaultCodegen implements CodegenConfig
|
||||
name = name.replaceAll("-", "_");
|
||||
|
||||
// e.g. PhoneNumberApi.py => phone_number_api.py
|
||||
return org.openapitools.codegen.utils.StringUtils.underscore(name) + "_api";
|
||||
return underscore(name) + "_api";
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -531,7 +533,7 @@ public class PythonClientCodegen extends DefaultCodegen implements CodegenConfig
|
||||
return "DefaultApi";
|
||||
}
|
||||
// e.g. phone_number_api => PhoneNumberApi
|
||||
return org.openapitools.codegen.utils.StringUtils.camelize(name) + "Api";
|
||||
return camelize(name) + "Api";
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -539,7 +541,7 @@ public class PythonClientCodegen extends DefaultCodegen implements CodegenConfig
|
||||
if (name.length() == 0) {
|
||||
return "default_api";
|
||||
}
|
||||
return org.openapitools.codegen.utils.StringUtils.underscore(name) + "_api";
|
||||
return underscore(name) + "_api";
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -551,17 +553,17 @@ public class PythonClientCodegen extends DefaultCodegen implements CodegenConfig
|
||||
|
||||
// method name cannot use reserved keyword, e.g. return
|
||||
if (isReservedWord(operationId)) {
|
||||
LOGGER.warn(operationId + " (reserved word) cannot be used as method name. Renamed to " + org.openapitools.codegen.utils.StringUtils.underscore(sanitizeName("call_" + operationId)));
|
||||
LOGGER.warn(operationId + " (reserved word) cannot be used as method name. Renamed to " + underscore(sanitizeName("call_" + operationId)));
|
||||
operationId = "call_" + operationId;
|
||||
}
|
||||
|
||||
// operationId starts with a number
|
||||
if (operationId.matches("^\\d.*")) {
|
||||
LOGGER.warn(operationId + " (starting with a number) cannot be used as method name. Renamed to " + org.openapitools.codegen.utils.StringUtils.underscore(sanitizeName("call_" + operationId)));
|
||||
LOGGER.warn(operationId + " (starting with a number) cannot be used as method name. Renamed to " + underscore(sanitizeName("call_" + operationId)));
|
||||
operationId = "call_" + operationId;
|
||||
}
|
||||
|
||||
return org.openapitools.codegen.utils.StringUtils.underscore(sanitizeName(operationId));
|
||||
return underscore(sanitizeName(operationId));
|
||||
}
|
||||
|
||||
public void setPackageName(String packageName) {
|
||||
@ -591,7 +593,7 @@ public class PythonClientCodegen extends DefaultCodegen implements CodegenConfig
|
||||
*/
|
||||
@SuppressWarnings("static-method")
|
||||
public String generatePackageName(String packageName) {
|
||||
return org.openapitools.codegen.utils.StringUtils.underscore(packageName.replaceAll("[^\\w]+", ""));
|
||||
return underscore(packageName.replaceAll("[^\\w]+", ""));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -35,6 +35,8 @@ import org.slf4j.LoggerFactory;
|
||||
import java.io.File;
|
||||
import java.util.*;
|
||||
|
||||
import static org.openapitools.codegen.utils.StringUtils.camelize;
|
||||
import static org.openapitools.codegen.utils.StringUtils.underscore;
|
||||
|
||||
public class PythonFlaskConnexionServerCodegen extends DefaultCodegen implements CodegenConfig {
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(PythonFlaskConnexionServerCodegen.class);
|
||||
@ -253,12 +255,12 @@ public class PythonFlaskConnexionServerCodegen extends DefaultCodegen implements
|
||||
if (name == null || name.length() == 0) {
|
||||
return "DefaultController";
|
||||
}
|
||||
return org.openapitools.codegen.utils.StringUtils.camelize(name, false) + "Controller";
|
||||
return camelize(name, false) + "Controller";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toApiFilename(String name) {
|
||||
return org.openapitools.codegen.utils.StringUtils.underscore(toApiName(name));
|
||||
return underscore(toApiName(name));
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -412,7 +414,7 @@ public class PythonFlaskConnexionServerCodegen extends DefaultCodegen implements
|
||||
|
||||
// underscore the variable name
|
||||
// petId => pet_id
|
||||
name = org.openapitools.codegen.utils.StringUtils.underscore(name);
|
||||
name = underscore(name);
|
||||
|
||||
// remove leading underscore
|
||||
name = name.replaceAll("^_*", "");
|
||||
@ -440,7 +442,7 @@ public class PythonFlaskConnexionServerCodegen extends DefaultCodegen implements
|
||||
public String toModelFilename(String name) {
|
||||
// underscore the model file name
|
||||
// PhoneNumber => phone_number
|
||||
return org.openapitools.codegen.utils.StringUtils.underscore(dropDots(toModelName(name)));
|
||||
return underscore(dropDots(toModelName(name)));
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -451,13 +453,13 @@ public class PythonFlaskConnexionServerCodegen extends DefaultCodegen implements
|
||||
|
||||
// model name cannot use reserved keyword, e.g. return
|
||||
if (isReservedWord(name)) {
|
||||
LOGGER.warn(name + " (reserved word) cannot be used as model name. Renamed to " + org.openapitools.codegen.utils.StringUtils.camelize("model_" + name));
|
||||
LOGGER.warn(name + " (reserved word) cannot be used as model name. Renamed to " + camelize("model_" + name));
|
||||
name = "model_" + name; // e.g. return => ModelReturn (after camelize)
|
||||
}
|
||||
|
||||
// model name starts with number
|
||||
if (name.matches("^\\d.*")) {
|
||||
LOGGER.warn(name + " (model name starts with number) cannot be used as model name. Renamed to " + org.openapitools.codegen.utils.StringUtils.camelize("model_" + name));
|
||||
LOGGER.warn(name + " (model name starts with number) cannot be used as model name. Renamed to " + camelize("model_" + name));
|
||||
name = "model_" + name; // e.g. 200Response => Model200Response (after camelize)
|
||||
}
|
||||
|
||||
@ -471,7 +473,7 @@ public class PythonFlaskConnexionServerCodegen extends DefaultCodegen implements
|
||||
|
||||
// camelize the model name
|
||||
// phone_number => PhoneNumber
|
||||
return org.openapitools.codegen.utils.StringUtils.camelize(name);
|
||||
return camelize(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -483,11 +485,11 @@ public class PythonFlaskConnexionServerCodegen extends DefaultCodegen implements
|
||||
|
||||
// method name cannot use reserved keyword, e.g. return
|
||||
if (isReservedWord(operationId)) {
|
||||
LOGGER.warn(operationId + " (reserved word) cannot be used as method name. Renamed to " + org.openapitools.codegen.utils.StringUtils.underscore(sanitizeName("call_" + operationId)));
|
||||
LOGGER.warn(operationId + " (reserved word) cannot be used as method name. Renamed to " + underscore(sanitizeName("call_" + operationId)));
|
||||
operationId = "call_" + operationId;
|
||||
}
|
||||
|
||||
return org.openapitools.codegen.utils.StringUtils.underscore(sanitizeName(operationId));
|
||||
return underscore(sanitizeName(operationId));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -28,6 +28,8 @@ import org.slf4j.LoggerFactory;
|
||||
import java.io.File;
|
||||
import java.util.*;
|
||||
|
||||
import static org.openapitools.codegen.utils.StringUtils.camelize;
|
||||
import static org.openapitools.codegen.utils.StringUtils.underscore;
|
||||
|
||||
public class RClientCodegen extends DefaultCodegen implements CodegenConfig {
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(RClientCodegen.class);
|
||||
@ -173,7 +175,7 @@ public class RClientCodegen extends DefaultCodegen implements CodegenConfig {
|
||||
if (this.reservedWordsMappings().containsKey(name)) {
|
||||
return this.reservedWordsMappings().get(name);
|
||||
}
|
||||
return org.openapitools.codegen.utils.StringUtils.camelize(name) + '_';
|
||||
return camelize(name) + '_';
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -196,7 +198,7 @@ public class RClientCodegen extends DefaultCodegen implements CodegenConfig {
|
||||
|
||||
// convert variable name to snake case
|
||||
// PetId => pet_id
|
||||
name = org.openapitools.codegen.utils.StringUtils.underscore(name);
|
||||
name = underscore(name);
|
||||
|
||||
// for reserved word or word starting with number, append _
|
||||
if (isReservedWord(name))
|
||||
@ -233,17 +235,17 @@ public class RClientCodegen extends DefaultCodegen implements CodegenConfig {
|
||||
|
||||
// model name cannot use reserved keyword, e.g. return
|
||||
if (isReservedWord(name)) {
|
||||
LOGGER.warn(name + " (reserved word) cannot be used as model name. Renamed to " + org.openapitools.codegen.utils.StringUtils.camelize("model_" + name));
|
||||
LOGGER.warn(name + " (reserved word) cannot be used as model name. Renamed to " + camelize("model_" + name));
|
||||
name = "model_" + name; // e.g. return => ModelReturn (after camelize)
|
||||
}
|
||||
|
||||
// model name starts with number
|
||||
if (name.matches("^\\d.*")) {
|
||||
LOGGER.warn(name + " (model name starts with number) cannot be used as model name. Renamed to " + org.openapitools.codegen.utils.StringUtils.camelize("model_" + name));
|
||||
LOGGER.warn(name + " (model name starts with number) cannot be used as model name. Renamed to " + camelize("model_" + name));
|
||||
name = "model_" + name; // e.g. 200Response => Model200Response (after camelize)
|
||||
}
|
||||
|
||||
return org.openapitools.codegen.utils.StringUtils.camelize(name);
|
||||
return camelize(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -252,7 +254,7 @@ public class RClientCodegen extends DefaultCodegen implements CodegenConfig {
|
||||
name = name.replaceAll("-", "_"); // FIXME: a parameter should not be assigned. Also declare the methods parameters as 'final'.
|
||||
|
||||
// e.g. PetApi.r => pet_api.r
|
||||
return org.openapitools.codegen.utils.StringUtils.camelize(name + "_api");
|
||||
return camelize(name + "_api");
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -277,7 +279,7 @@ public class RClientCodegen extends DefaultCodegen implements CodegenConfig {
|
||||
|
||||
@Override
|
||||
public String toApiName(String name) {
|
||||
return org.openapitools.codegen.utils.StringUtils.camelize(super.toApiName(name));
|
||||
return camelize(super.toApiName(name));
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -329,11 +331,11 @@ public class RClientCodegen extends DefaultCodegen implements CodegenConfig {
|
||||
|
||||
// method name cannot use reserved keyword, e.g. return
|
||||
if (isReservedWord(sanitizedOperationId)) {
|
||||
LOGGER.warn(operationId + " (reserved word) cannot be used as method name. Renamed to " + org.openapitools.codegen.utils.StringUtils.underscore("call_" + operationId));
|
||||
LOGGER.warn(operationId + " (reserved word) cannot be used as method name. Renamed to " + underscore("call_" + operationId));
|
||||
sanitizedOperationId = "call_" + sanitizedOperationId;
|
||||
}
|
||||
|
||||
return org.openapitools.codegen.utils.StringUtils.underscore(sanitizedOperationId);
|
||||
return underscore(sanitizedOperationId);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -433,7 +435,7 @@ public class RClientCodegen extends DefaultCodegen implements CodegenConfig {
|
||||
}
|
||||
|
||||
// string
|
||||
String enumName = sanitizeName(org.openapitools.codegen.utils.StringUtils.underscore(name).toUpperCase(Locale.ROOT));
|
||||
String enumName = sanitizeName(underscore(name).toUpperCase(Locale.ROOT));
|
||||
enumName = enumName.replaceFirst("^_", "");
|
||||
enumName = enumName.replaceFirst("_$", "");
|
||||
|
||||
@ -446,7 +448,7 @@ public class RClientCodegen extends DefaultCodegen implements CodegenConfig {
|
||||
|
||||
@Override
|
||||
public String toEnumName(CodegenProperty property) {
|
||||
String enumName = org.openapitools.codegen.utils.StringUtils.underscore(toModelName(property.name)).toUpperCase(Locale.ROOT);
|
||||
String enumName = underscore(toModelName(property.name)).toUpperCase(Locale.ROOT);
|
||||
|
||||
// remove [] for array or map of enum
|
||||
enumName = enumName.replace("[]", "");
|
||||
|
@ -31,6 +31,9 @@ import java.util.Iterator;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
|
||||
import static org.openapitools.codegen.utils.StringUtils.camelize;
|
||||
import static org.openapitools.codegen.utils.StringUtils.underscore;
|
||||
|
||||
public class RubyClientCodegen extends AbstractRubyCodegen {
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(RubyClientCodegen.class);
|
||||
public static final String GEM_NAME = "gemName";
|
||||
@ -252,7 +255,7 @@ public class RubyClientCodegen extends AbstractRubyCodegen {
|
||||
*/
|
||||
@SuppressWarnings("static-method")
|
||||
public String generateModuleName(String gemName) {
|
||||
return org.openapitools.codegen.utils.StringUtils.camelize(gemName.replaceAll("[^\\w]+", "_"));
|
||||
return camelize(gemName.replaceAll("[^\\w]+", "_"));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -263,7 +266,7 @@ public class RubyClientCodegen extends AbstractRubyCodegen {
|
||||
*/
|
||||
@SuppressWarnings("static-method")
|
||||
public String generateGemName(String moduleName) {
|
||||
return org.openapitools.codegen.utils.StringUtils.underscore(moduleName.replaceAll("[^\\w]+", ""));
|
||||
return underscore(moduleName.replaceAll("[^\\w]+", ""));
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -330,25 +333,25 @@ public class RubyClientCodegen extends AbstractRubyCodegen {
|
||||
|
||||
// model name cannot use reserved keyword, e.g. return
|
||||
if (isReservedWord(name)) {
|
||||
String modelName = org.openapitools.codegen.utils.StringUtils.camelize("Model" + name);
|
||||
String modelName = camelize("Model" + name);
|
||||
LOGGER.warn(name + " (reserved word) cannot be used as model name. Renamed to " + modelName);
|
||||
return modelName;
|
||||
}
|
||||
|
||||
// model name starts with number
|
||||
if (name.matches("^\\d.*")) {
|
||||
LOGGER.warn(name + " (model name starts with number) cannot be used as model name. Renamed to " + org.openapitools.codegen.utils.StringUtils.camelize("model_" + name));
|
||||
LOGGER.warn(name + " (model name starts with number) cannot be used as model name. Renamed to " + camelize("model_" + name));
|
||||
name = "model_" + name; // e.g. 200Response => Model200Response (after camelize)
|
||||
}
|
||||
|
||||
// camelize the model name
|
||||
// phone_number => PhoneNumber
|
||||
return org.openapitools.codegen.utils.StringUtils.camelize(name);
|
||||
return camelize(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toModelFilename(String name) {
|
||||
return org.openapitools.codegen.utils.StringUtils.underscore(toModelName(name));
|
||||
return underscore(toModelName(name));
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -362,7 +365,7 @@ public class RubyClientCodegen extends AbstractRubyCodegen {
|
||||
name = name.replaceAll("-", "_"); // FIXME: a parameter should not be assigned. Also declare the methods parameters as 'final'.
|
||||
|
||||
// e.g. PhoneNumberApi.rb => phone_number_api.rb
|
||||
return org.openapitools.codegen.utils.StringUtils.underscore(name) + "_api";
|
||||
return underscore(name) + "_api";
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -386,7 +389,7 @@ public class RubyClientCodegen extends AbstractRubyCodegen {
|
||||
return "DefaultApi";
|
||||
}
|
||||
// e.g. phone_number_api => PhoneNumberApi
|
||||
return org.openapitools.codegen.utils.StringUtils.camelize(name) + "Api";
|
||||
return camelize(name) + "Api";
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -414,7 +417,7 @@ public class RubyClientCodegen extends AbstractRubyCodegen {
|
||||
}
|
||||
|
||||
// string
|
||||
String enumName = sanitizeName(org.openapitools.codegen.utils.StringUtils.underscore(name).toUpperCase(Locale.ROOT));
|
||||
String enumName = sanitizeName(underscore(name).toUpperCase(Locale.ROOT));
|
||||
enumName = enumName.replaceFirst("^_", "");
|
||||
enumName = enumName.replaceFirst("_$", "");
|
||||
|
||||
@ -427,7 +430,7 @@ public class RubyClientCodegen extends AbstractRubyCodegen {
|
||||
|
||||
@Override
|
||||
public String toEnumName(CodegenProperty property) {
|
||||
String enumName = org.openapitools.codegen.utils.StringUtils.underscore(toModelName(property.name)).toUpperCase(Locale.ROOT);
|
||||
String enumName = underscore(toModelName(property.name)).toUpperCase(Locale.ROOT);
|
||||
enumName = enumName.replaceFirst("^_", "");
|
||||
enumName = enumName.replaceFirst("_$", "");
|
||||
|
||||
@ -448,25 +451,25 @@ public class RubyClientCodegen extends AbstractRubyCodegen {
|
||||
public String toOperationId(String operationId) {
|
||||
// rename to empty_method_name_1 (e.g.) if method name is empty
|
||||
if (StringUtils.isEmpty(operationId)) {
|
||||
operationId = org.openapitools.codegen.utils.StringUtils.underscore("empty_method_name_" + emptyMethodNameCounter++);
|
||||
operationId = underscore("empty_method_name_" + emptyMethodNameCounter++);
|
||||
LOGGER.warn("Empty method name (operationId) found. Renamed to " + operationId);
|
||||
return operationId;
|
||||
}
|
||||
|
||||
// method name cannot use reserved keyword, e.g. return
|
||||
if (isReservedWord(operationId)) {
|
||||
String newOperationId = org.openapitools.codegen.utils.StringUtils.underscore("call_" + operationId);
|
||||
String newOperationId = underscore("call_" + operationId);
|
||||
LOGGER.warn(operationId + " (reserved word) cannot be used as method name. Renamed to " + newOperationId);
|
||||
return newOperationId;
|
||||
}
|
||||
|
||||
// operationId starts with a number
|
||||
if (operationId.matches("^\\d.*")) {
|
||||
LOGGER.warn(operationId + " (starting with a number) cannot be used as method name. Renamed to " + org.openapitools.codegen.utils.StringUtils.underscore(sanitizeName("call_" + operationId)));
|
||||
LOGGER.warn(operationId + " (starting with a number) cannot be used as method name. Renamed to " + underscore(sanitizeName("call_" + operationId)));
|
||||
operationId = "call_" + operationId;
|
||||
}
|
||||
|
||||
return org.openapitools.codegen.utils.StringUtils.underscore(sanitizeName(operationId));
|
||||
return underscore(sanitizeName(operationId));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -19,7 +19,6 @@ package org.openapitools.codegen.languages;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
|
||||
|
||||
import org.openapitools.codegen.CliOption;
|
||||
import org.openapitools.codegen.CodegenType;
|
||||
import org.openapitools.codegen.CodegenConstants;
|
||||
@ -34,6 +33,8 @@ import java.util.Map;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import static org.openapitools.codegen.utils.StringUtils.camelize;
|
||||
import static org.openapitools.codegen.utils.StringUtils.underscore;
|
||||
|
||||
public class RubyOnRailsServerCodegen extends AbstractRubyCodegen {
|
||||
|
||||
@ -221,28 +222,28 @@ public class RubyOnRailsServerCodegen extends AbstractRubyCodegen {
|
||||
public String toModelName(String name) {
|
||||
// model name cannot use reserved keyword, e.g. return
|
||||
if (isReservedWord(name)) {
|
||||
String modelName = org.openapitools.codegen.utils.StringUtils.camelize("Model" + name);
|
||||
String modelName = camelize("Model" + name);
|
||||
LOGGER.warn(name + " (reserved word) cannot be used as model name. Renamed to " + modelName);
|
||||
return modelName;
|
||||
}
|
||||
|
||||
// camelize the model name
|
||||
// phone_number => PhoneNumber
|
||||
return org.openapitools.codegen.utils.StringUtils.camelize(name);
|
||||
return camelize(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toModelFilename(String name) {
|
||||
// model name cannot use reserved keyword, e.g. return
|
||||
if (isReservedWord(name)) {
|
||||
String filename = org.openapitools.codegen.utils.StringUtils.underscore("model_" + name);
|
||||
String filename = underscore("model_" + name);
|
||||
LOGGER.warn(name + " (reserved word) cannot be used as model filename. Renamed to " + filename);
|
||||
return filename;
|
||||
}
|
||||
|
||||
// underscore the model file name
|
||||
// PhoneNumber.rb => phone_number.rb
|
||||
return org.openapitools.codegen.utils.StringUtils.underscore(name);
|
||||
return underscore(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -251,7 +252,7 @@ public class RubyOnRailsServerCodegen extends AbstractRubyCodegen {
|
||||
name = name.replaceAll("-", "_"); // FIXME: a parameter should not be assigned. Also declare the methods parameters as 'final'.
|
||||
|
||||
// e.g. DefaultController => defaults_controller.rb
|
||||
return org.openapitools.codegen.utils.StringUtils.underscore(name) + "_controller";
|
||||
return underscore(name) + "_controller";
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -261,7 +262,7 @@ public class RubyOnRailsServerCodegen extends AbstractRubyCodegen {
|
||||
}
|
||||
|
||||
// e.g. PhoneNumber => phone_number
|
||||
return org.openapitools.codegen.utils.StringUtils.underscore(sanitizeName(name));
|
||||
return underscore(sanitizeName(name));
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -270,7 +271,7 @@ public class RubyOnRailsServerCodegen extends AbstractRubyCodegen {
|
||||
return "ApiController";
|
||||
}
|
||||
// e.g. phone_number_controller => PhoneNumberController
|
||||
return org.openapitools.codegen.utils.StringUtils.camelize(name) + "Controller";
|
||||
return camelize(name) + "Controller";
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -28,6 +28,8 @@ import java.util.Map;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import static org.openapitools.codegen.utils.StringUtils.camelize;
|
||||
import static org.openapitools.codegen.utils.StringUtils.underscore;
|
||||
|
||||
public class RubySinatraServerCodegen extends AbstractRubyCodegen {
|
||||
|
||||
@ -110,26 +112,26 @@ public class RubySinatraServerCodegen extends AbstractRubyCodegen {
|
||||
public String toModelName(String name) {
|
||||
// model name cannot use reserved keyword, e.g. return
|
||||
if (isReservedWord(name)) {
|
||||
LOGGER.warn(name + " (reserved word) cannot be used as model filename. Renamed to " + org.openapitools.codegen.utils.StringUtils.camelize("model_" + name));
|
||||
LOGGER.warn(name + " (reserved word) cannot be used as model filename. Renamed to " + camelize("model_" + name));
|
||||
name = "model_" + name; // e.g. return => ModelReturn (after camelize)
|
||||
}
|
||||
|
||||
// camelize the model name
|
||||
// phone_number => PhoneNumber
|
||||
return org.openapitools.codegen.utils.StringUtils.camelize(name);
|
||||
return camelize(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toModelFilename(String name) {
|
||||
// model name cannot use reserved keyword, e.g. return
|
||||
if (isReservedWord(name)) {
|
||||
LOGGER.warn(name + " (reserved word) cannot be used as model filename. Renamed to " + org.openapitools.codegen.utils.StringUtils.underscore("model_" + name));
|
||||
LOGGER.warn(name + " (reserved word) cannot be used as model filename. Renamed to " + underscore("model_" + name));
|
||||
name = "model_" + name; // e.g. return => ModelReturn (after camelize)
|
||||
}
|
||||
|
||||
// underscore the model file name
|
||||
// PhoneNumber.rb => phone_number.rb
|
||||
return org.openapitools.codegen.utils.StringUtils.underscore(name);
|
||||
return underscore(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -138,7 +140,7 @@ public class RubySinatraServerCodegen extends AbstractRubyCodegen {
|
||||
name = name.replaceAll("-", "_"); // FIXME: a parameter should not be assigned. Also declare the methods parameters as 'final'.
|
||||
|
||||
// e.g. PhoneNumberApi.rb => phone_number_api.rb
|
||||
return org.openapitools.codegen.utils.StringUtils.underscore(name) + "_api";
|
||||
return underscore(name) + "_api";
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -147,7 +149,7 @@ public class RubySinatraServerCodegen extends AbstractRubyCodegen {
|
||||
return "DefaultApi";
|
||||
}
|
||||
// e.g. phone_number_api => PhoneNumberApi
|
||||
return org.openapitools.codegen.utils.StringUtils.camelize(name) + "Api";
|
||||
return camelize(name) + "Api";
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -30,6 +30,8 @@ import org.slf4j.LoggerFactory;
|
||||
import java.io.File;
|
||||
import java.util.*;
|
||||
|
||||
import static org.openapitools.codegen.utils.StringUtils.camelize;
|
||||
import static org.openapitools.codegen.utils.StringUtils.underscore;
|
||||
|
||||
public class RustClientCodegen extends DefaultCodegen implements CodegenConfig {
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(RustClientCodegen.class);
|
||||
@ -224,7 +226,7 @@ public class RustClientCodegen extends DefaultCodegen implements CodegenConfig {
|
||||
return name;
|
||||
|
||||
// snake_case, e.g. PetId => pet_id
|
||||
name = StringUtils.underscore(name);
|
||||
name = underscore(name);
|
||||
|
||||
// for reserved word or word starting with number, append _
|
||||
if (isReservedWord(name))
|
||||
@ -246,7 +248,7 @@ public class RustClientCodegen extends DefaultCodegen implements CodegenConfig {
|
||||
public String toModelName(String name) {
|
||||
// camelize the model name
|
||||
// phone_number => PhoneNumber
|
||||
return StringUtils.camelize(toModelFilename(name));
|
||||
return camelize(toModelFilename(name));
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -274,7 +276,7 @@ public class RustClientCodegen extends DefaultCodegen implements CodegenConfig {
|
||||
name = "model_" + name; // e.g. 200Response => Model200Response (after camelize)
|
||||
}
|
||||
|
||||
return StringUtils.underscore(name);
|
||||
return underscore(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -283,7 +285,7 @@ public class RustClientCodegen extends DefaultCodegen implements CodegenConfig {
|
||||
name = name.replaceAll("-", "_"); // FIXME: a parameter should not be assigned. Also declare the methods parameters as 'final'.
|
||||
|
||||
// e.g. PetApi.rs => pet_api.rs
|
||||
return StringUtils.underscore(name) + "_api";
|
||||
return underscore(name) + "_api";
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -504,7 +506,7 @@ public class RustClientCodegen extends DefaultCodegen implements CodegenConfig {
|
||||
}
|
||||
|
||||
// string
|
||||
String enumName = sanitizeName(org.openapitools.codegen.utils.StringUtils.underscore(name).toUpperCase(Locale.ROOT));
|
||||
String enumName = sanitizeName(underscore(name).toUpperCase(Locale.ROOT));
|
||||
enumName = enumName.replaceFirst("^_", "");
|
||||
enumName = enumName.replaceFirst("_$", "");
|
||||
|
||||
@ -517,7 +519,7 @@ public class RustClientCodegen extends DefaultCodegen implements CodegenConfig {
|
||||
|
||||
@Override
|
||||
public String toEnumName(CodegenProperty property) {
|
||||
String enumName = org.openapitools.codegen.utils.StringUtils.underscore(toModelName(property.name)).toUpperCase(Locale.ROOT);
|
||||
String enumName = underscore(toModelName(property.name)).toUpperCase(Locale.ROOT);
|
||||
|
||||
// remove [] for array or map of enum
|
||||
enumName = enumName.replace("[]", "");
|
||||
|
@ -55,7 +55,8 @@ import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Set;
|
||||
|
||||
import static org.openapitools.codegen.utils.StringUtils.camelize;
|
||||
import static org.openapitools.codegen.utils.StringUtils.underscore;
|
||||
|
||||
public class RustServerCodegen extends DefaultCodegen implements CodegenConfig {
|
||||
|
||||
@ -301,7 +302,7 @@ public class RustServerCodegen extends DefaultCodegen implements CodegenConfig {
|
||||
if (name.length() == 0) {
|
||||
return "default";
|
||||
}
|
||||
return org.openapitools.codegen.utils.StringUtils.underscore(name);
|
||||
return underscore(name);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -331,7 +332,7 @@ public class RustServerCodegen extends DefaultCodegen implements CodegenConfig {
|
||||
public String toModelName(String name) {
|
||||
// camelize the model name
|
||||
// phone_number => PhoneNumber
|
||||
String camelizedName = org.openapitools.codegen.utils.StringUtils.camelize(toModelFilename(name));
|
||||
String camelizedName = camelize(toModelFilename(name));
|
||||
|
||||
// model name cannot use reserved keyword, e.g. return
|
||||
if (isReservedWord(camelizedName)) {
|
||||
@ -364,18 +365,18 @@ public class RustServerCodegen extends DefaultCodegen implements CodegenConfig {
|
||||
sanitizedName = escapeReservedWord(sanitizedName);
|
||||
}
|
||||
|
||||
return org.openapitools.codegen.utils.StringUtils.underscore(sanitizedName);
|
||||
return underscore(sanitizedName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toOperationId(String operationId) {
|
||||
// method name cannot use reserved keyword, e.g. return
|
||||
if (isReservedWord(operationId)) {
|
||||
LOGGER.warn(operationId + " (reserved word) cannot be used as method name. Renamed to " + org.openapitools.codegen.utils.StringUtils.camelize(sanitizeName("call_" + operationId)));
|
||||
LOGGER.warn(operationId + " (reserved word) cannot be used as method name. Renamed to " + camelize(sanitizeName("call_" + operationId)));
|
||||
operationId = "call_" + operationId;
|
||||
}
|
||||
|
||||
return org.openapitools.codegen.utils.StringUtils.camelize(operationId);
|
||||
return camelize(operationId);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -392,16 +393,16 @@ public class RustServerCodegen extends DefaultCodegen implements CodegenConfig {
|
||||
|
||||
// model name cannot use reserved keyword, e.g. return
|
||||
if (isReservedWord(name)) {
|
||||
LOGGER.warn(name + " (reserved word) cannot be used as model name. Renamed to " + org.openapitools.codegen.utils.StringUtils.camelize("model_" + name));
|
||||
LOGGER.warn(name + " (reserved word) cannot be used as model name. Renamed to " + camelize("model_" + name));
|
||||
name = "model_" + name; // e.g. return => ModelReturn (after camelize)
|
||||
}
|
||||
|
||||
return org.openapitools.codegen.utils.StringUtils.underscore(name);
|
||||
return underscore(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toEnumName(CodegenProperty property) {
|
||||
return sanitizeName(org.openapitools.codegen.utils.StringUtils.camelize(property.name)) + "Enum";
|
||||
return sanitizeName(camelize(property.name)) + "Enum";
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -452,7 +453,7 @@ public class RustServerCodegen extends DefaultCodegen implements CodegenConfig {
|
||||
name = name.replaceAll("-", "_"); // FIXME: a parameter should not be assigned. Also declare the methods parameters as 'final'.
|
||||
|
||||
// e.g. PetApi.go => pet_api.go
|
||||
return org.openapitools.codegen.utils.StringUtils.underscore(name);
|
||||
return underscore(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -522,8 +523,8 @@ public class RustServerCodegen extends DefaultCodegen implements CodegenConfig {
|
||||
pathSetMap.put(pathId, pathSetEntry);
|
||||
}
|
||||
|
||||
op.vendorExtensions.put("operation_id", org.openapitools.codegen.utils.StringUtils.underscore(op.operationId));
|
||||
op.vendorExtensions.put("uppercase_operation_id", org.openapitools.codegen.utils.StringUtils.underscore(op.operationId).toUpperCase(Locale.ROOT));
|
||||
op.vendorExtensions.put("operation_id", underscore(op.operationId));
|
||||
op.vendorExtensions.put("uppercase_operation_id", underscore(op.operationId).toUpperCase(Locale.ROOT));
|
||||
op.vendorExtensions.put("path", op.path.replace("{", ":").replace("}", ""));
|
||||
op.vendorExtensions.put("PATH_ID", pathId);
|
||||
op.vendorExtensions.put("hasPathParams", !op.pathParams.isEmpty());
|
||||
@ -604,13 +605,13 @@ public class RustServerCodegen extends DefaultCodegen implements CodegenConfig {
|
||||
if (rsp.vendorExtensions.containsKey("x-responseId")) {
|
||||
responseId = (String) rsp.vendorExtensions.get("x-responseId");
|
||||
} else if (words.length != 0) {
|
||||
responseId = org.openapitools.codegen.utils.StringUtils.camelize(words[0].replace(" ", "_"));
|
||||
responseId = camelize(words[0].replace(" ", "_"));
|
||||
} else {
|
||||
responseId = "Status" + rsp.code;
|
||||
}
|
||||
rsp.vendorExtensions.put("x-responseId", responseId);
|
||||
rsp.vendorExtensions.put("x-uppercaseResponseId", org.openapitools.codegen.utils.StringUtils.underscore(responseId).toUpperCase(Locale.ROOT));
|
||||
rsp.vendorExtensions.put("uppercase_operation_id", org.openapitools.codegen.utils.StringUtils.underscore(op.operationId).toUpperCase(Locale.ROOT));
|
||||
rsp.vendorExtensions.put("x-uppercaseResponseId", underscore(responseId).toUpperCase(Locale.ROOT));
|
||||
rsp.vendorExtensions.put("uppercase_operation_id", underscore(op.operationId).toUpperCase(Locale.ROOT));
|
||||
if (rsp.dataType != null) {
|
||||
rsp.vendorExtensions.put("uppercase_data_type", (rsp.dataType.replace("models::", "")).toUpperCase(Locale.ROOT));
|
||||
|
||||
@ -687,7 +688,7 @@ public class RustServerCodegen extends DefaultCodegen implements CodegenConfig {
|
||||
|
||||
if (op.bodyParam != null) {
|
||||
// Default to consuming json
|
||||
op.bodyParam.vendorExtensions.put("uppercase_operation_id", org.openapitools.codegen.utils.StringUtils.underscore(op.operationId).toUpperCase(Locale.ROOT));
|
||||
op.bodyParam.vendorExtensions.put("uppercase_operation_id", underscore(op.operationId).toUpperCase(Locale.ROOT));
|
||||
if (consumesXml) {
|
||||
op.bodyParam.vendorExtensions.put("consumesXml", true);
|
||||
} else if (consumesPlainText) {
|
||||
@ -700,7 +701,7 @@ public class RustServerCodegen extends DefaultCodegen implements CodegenConfig {
|
||||
for (CodegenParameter param : op.bodyParams) {
|
||||
processParam(param, op);
|
||||
|
||||
param.vendorExtensions.put("uppercase_operation_id", org.openapitools.codegen.utils.StringUtils.underscore(op.operationId).toUpperCase(Locale.ROOT));
|
||||
param.vendorExtensions.put("uppercase_operation_id", underscore(op.operationId).toUpperCase(Locale.ROOT));
|
||||
|
||||
// Default to producing json if nothing else is specified
|
||||
if (consumesXml) {
|
||||
@ -938,9 +939,9 @@ public class RustServerCodegen extends DefaultCodegen implements CodegenConfig {
|
||||
// If we use a more qualified model name, then only camelize the actual type, not the qualifier.
|
||||
if (property.dataType.contains(":")) {
|
||||
int position = property.dataType.lastIndexOf(":");
|
||||
property.dataType = property.dataType.substring(0, position) + org.openapitools.codegen.utils.StringUtils.camelize(property.dataType.substring(position));
|
||||
property.dataType = property.dataType.substring(0, position) + camelize(property.dataType.substring(position));
|
||||
} else {
|
||||
property.dataType = org.openapitools.codegen.utils.StringUtils.camelize(property.dataType, false);
|
||||
property.dataType = camelize(property.dataType, false);
|
||||
}
|
||||
}
|
||||
|
||||
@ -988,7 +989,7 @@ public class RustServerCodegen extends DefaultCodegen implements CodegenConfig {
|
||||
}
|
||||
}
|
||||
|
||||
property.name = org.openapitools.codegen.utils.StringUtils.underscore(property.name);
|
||||
property.name = underscore(property.name);
|
||||
|
||||
if (!property.required) {
|
||||
property.defaultValue = (property.defaultValue != null) ? "Some(" + property.defaultValue + ")" : "None";
|
||||
|
@ -35,6 +35,7 @@ import java.io.StringWriter;
|
||||
import java.io.Writer;
|
||||
import java.util.*;
|
||||
|
||||
import static org.openapitools.codegen.utils.StringUtils.camelize;
|
||||
|
||||
public class ScalaAkkaClientCodegen extends AbstractScalaCodegen implements CodegenConfig {
|
||||
protected String mainPackage = "org.openapitools.client";
|
||||
@ -336,7 +337,7 @@ public class ScalaAkkaClientCodegen extends AbstractScalaCodegen implements Code
|
||||
|
||||
@Override
|
||||
public String formatFragment(String fragment) {
|
||||
return org.openapitools.codegen.utils.StringUtils.camelize(fragment, !capitalizeFirst);
|
||||
return camelize(fragment, !capitalizeFirst);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -26,6 +26,8 @@ import java.io.File;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
|
||||
import static org.openapitools.codegen.utils.StringUtils.camelize;
|
||||
import static org.openapitools.codegen.utils.StringUtils.underscore;
|
||||
|
||||
public class ScalaHttpClientCodegen extends AbstractScalaCodegen implements CodegenConfig {
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(ScalaHttpClientCodegen.class);
|
||||
@ -185,11 +187,11 @@ public class ScalaHttpClientCodegen extends AbstractScalaCodegen implements Code
|
||||
case original:
|
||||
return name;
|
||||
case camelCase:
|
||||
return org.openapitools.codegen.utils.StringUtils.camelize(name, true);
|
||||
return camelize(name, true);
|
||||
case PascalCase:
|
||||
return org.openapitools.codegen.utils.StringUtils.camelize(name);
|
||||
return camelize(name);
|
||||
case snake_case:
|
||||
return org.openapitools.codegen.utils.StringUtils.underscore(name);
|
||||
return underscore(name);
|
||||
default:
|
||||
throw new IllegalArgumentException("Invalid model property naming '" +
|
||||
name + "'. Must be 'original', 'camelCase', " +
|
||||
@ -227,7 +229,7 @@ public class ScalaHttpClientCodegen extends AbstractScalaCodegen implements Code
|
||||
throw new RuntimeException(operationId + " (reserved word) cannot be used as method name");
|
||||
}
|
||||
|
||||
return org.openapitools.codegen.utils.StringUtils.camelize(operationId, true);
|
||||
return camelize(operationId, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -236,7 +238,7 @@ public class ScalaHttpClientCodegen extends AbstractScalaCodegen implements Code
|
||||
|
||||
// camelize the model name
|
||||
// phone_number => PhoneNumber
|
||||
final String camelizedName = org.openapitools.codegen.utils.StringUtils.camelize(sanitizedName);
|
||||
final String camelizedName = camelize(sanitizedName);
|
||||
|
||||
// model name cannot use reserved keyword, e.g. return
|
||||
if (isReservedWord(camelizedName)) {
|
||||
|
@ -23,7 +23,8 @@ import org.apache.commons.lang3.StringUtils;
|
||||
import java.util.*;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import static org.openapitools.codegen.utils.StringUtils.camelize;
|
||||
import static org.openapitools.codegen.utils.StringUtils.underscore;
|
||||
|
||||
public class ScalaLagomServerCodegen extends AbstractScalaCodegen implements CodegenConfig {
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(ScalaLagomServerCodegen.class);
|
||||
@ -167,11 +168,11 @@ public class ScalaLagomServerCodegen extends AbstractScalaCodegen implements Cod
|
||||
case original:
|
||||
return name;
|
||||
case camelCase:
|
||||
return org.openapitools.codegen.utils.StringUtils.camelize(name, true);
|
||||
return camelize(name, true);
|
||||
case PascalCase:
|
||||
return org.openapitools.codegen.utils.StringUtils.camelize(name);
|
||||
return camelize(name);
|
||||
case snake_case:
|
||||
return org.openapitools.codegen.utils.StringUtils.underscore(name);
|
||||
return underscore(name);
|
||||
default:
|
||||
throw new IllegalArgumentException("Invalid model property naming '" +
|
||||
name + "'. Must be 'original', 'camelCase', " +
|
||||
@ -207,7 +208,7 @@ public class ScalaLagomServerCodegen extends AbstractScalaCodegen implements Cod
|
||||
throw new RuntimeException(operationId + " (reserved word) cannot be used as method name");
|
||||
}
|
||||
|
||||
return org.openapitools.codegen.utils.StringUtils.camelize(operationId, true);
|
||||
return camelize(operationId, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -216,7 +217,7 @@ public class ScalaLagomServerCodegen extends AbstractScalaCodegen implements Cod
|
||||
|
||||
// camelize the model name
|
||||
// phone_number => PhoneNumber
|
||||
final String camelizedName = org.openapitools.codegen.utils.StringUtils.camelize(sanitizedName);
|
||||
final String camelizedName = camelize(sanitizedName);
|
||||
|
||||
// model name cannot use reserved keyword, e.g. return
|
||||
if (isReservedWord(camelizedName)) {
|
||||
|
@ -31,6 +31,8 @@ import java.io.Writer;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
|
||||
import static org.openapitools.codegen.utils.StringUtils.camelize;
|
||||
import static org.openapitools.codegen.utils.StringUtils.underscore;
|
||||
|
||||
public class ScalazClientCodegen extends AbstractScalaCodegen implements CodegenConfig {
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(ScalazClientCodegen.class);
|
||||
@ -164,11 +166,11 @@ public class ScalazClientCodegen extends AbstractScalaCodegen implements Codegen
|
||||
case original:
|
||||
return name;
|
||||
case camelCase:
|
||||
return org.openapitools.codegen.utils.StringUtils.camelize(name, true);
|
||||
return camelize(name, true);
|
||||
case PascalCase:
|
||||
return org.openapitools.codegen.utils.StringUtils.camelize(name);
|
||||
return camelize(name);
|
||||
case snake_case:
|
||||
return org.openapitools.codegen.utils.StringUtils.underscore(name);
|
||||
return underscore(name);
|
||||
default:
|
||||
throw new IllegalArgumentException("Invalid model property naming '" +
|
||||
name + "'. Must be 'original', 'camelCase', " +
|
||||
@ -204,7 +206,7 @@ public class ScalazClientCodegen extends AbstractScalaCodegen implements Codegen
|
||||
throw new RuntimeException(operationId + " (reserved word) cannot be used as method name");
|
||||
}
|
||||
|
||||
return org.openapitools.codegen.utils.StringUtils.camelize(operationId, true);
|
||||
return camelize(operationId, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -213,7 +215,7 @@ public class ScalazClientCodegen extends AbstractScalaCodegen implements Codegen
|
||||
|
||||
// camelize the model name
|
||||
// phone_number => PhoneNumber
|
||||
final String camelizedName = org.openapitools.codegen.utils.StringUtils.camelize(sanitizedName);
|
||||
final String camelizedName = camelize(sanitizedName);
|
||||
|
||||
// model name cannot use reserved keyword, e.g. return
|
||||
if (isReservedWord(camelizedName)) {
|
||||
|
@ -50,6 +50,7 @@ import java.util.Map;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static org.openapitools.codegen.utils.StringUtils.camelize;
|
||||
|
||||
public class SpringCodegen extends AbstractJavaCodegen
|
||||
implements BeanValidationFeatures, PerformBeanValidationFeatures,
|
||||
@ -478,7 +479,7 @@ public class SpringCodegen extends AbstractJavaCodegen
|
||||
title = title.substring(0, title.length() - 3);
|
||||
}
|
||||
|
||||
this.title = org.openapitools.codegen.utils.StringUtils.camelize(sanitizeName(title), true);
|
||||
this.title = camelize(sanitizeName(title), true);
|
||||
}
|
||||
additionalProperties.put(TITLE, this.title);
|
||||
}
|
||||
@ -628,7 +629,7 @@ public class SpringCodegen extends AbstractJavaCodegen
|
||||
List<CodegenSecurity> authMethods = (List<CodegenSecurity>) objs.get("authMethods");
|
||||
if (authMethods != null) {
|
||||
for (CodegenSecurity authMethod : authMethods) {
|
||||
authMethod.name = org.openapitools.codegen.utils.StringUtils.camelize(sanitizeName(authMethod.name), true);
|
||||
authMethod.name = camelize(sanitizeName(authMethod.name), true);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -641,7 +642,7 @@ public class SpringCodegen extends AbstractJavaCodegen
|
||||
return "DefaultApi";
|
||||
}
|
||||
name = sanitizeName(name);
|
||||
return org.openapitools.codegen.utils.StringUtils.camelize(name) + "Api";
|
||||
return camelize(name) + "Api";
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -45,6 +45,9 @@ import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
|
||||
import static org.openapitools.codegen.utils.StringUtils.dashize;
|
||||
import static org.openapitools.codegen.utils.StringUtils.camelize;
|
||||
import static org.openapitools.codegen.utils.StringUtils.underscore;
|
||||
|
||||
public class StaticHtml2Generator extends DefaultCodegen implements CodegenConfig {
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(StaticHtml2Generator.class);
|
||||
@ -162,7 +165,7 @@ public class StaticHtml2Generator extends DefaultCodegen implements CodegenConfi
|
||||
Info info = openAPI.getInfo();
|
||||
if (StringUtils.isBlank(jsProjectName) && info.getTitle() != null) {
|
||||
// when jsProjectName is not specified, generate it from info.title
|
||||
jsProjectName = sanitizeName(org.openapitools.codegen.utils.StringUtils.dashize(info.getTitle()));
|
||||
jsProjectName = sanitizeName(dashize(info.getTitle()));
|
||||
}
|
||||
}
|
||||
|
||||
@ -171,7 +174,7 @@ public class StaticHtml2Generator extends DefaultCodegen implements CodegenConfi
|
||||
jsProjectName = "openapi-js-client";
|
||||
}
|
||||
if (StringUtils.isBlank(jsModuleName)) {
|
||||
jsModuleName = org.openapitools.codegen.utils.StringUtils.camelize(org.openapitools.codegen.utils.StringUtils.underscore(jsProjectName));
|
||||
jsModuleName = camelize(underscore(jsProjectName));
|
||||
}
|
||||
|
||||
additionalProperties.put("jsProjectName", jsProjectName);
|
||||
|
@ -33,6 +33,7 @@ import java.util.*;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import static org.openapitools.codegen.utils.StringUtils.camelize;
|
||||
|
||||
public class Swift3Codegen extends DefaultCodegen implements CodegenConfig {
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(Swift3Codegen.class);
|
||||
@ -389,7 +390,7 @@ public class Swift3Codegen extends DefaultCodegen implements CodegenConfig {
|
||||
|
||||
// camelize the model name
|
||||
// phone_number => PhoneNumber
|
||||
name = org.openapitools.codegen.utils.StringUtils.camelize(name);
|
||||
name = camelize(name);
|
||||
|
||||
// model name cannot use reserved keyword, e.g. return
|
||||
if (isReservedWord(name)) {
|
||||
@ -447,7 +448,7 @@ public class Swift3Codegen extends DefaultCodegen implements CodegenConfig {
|
||||
|
||||
@Override
|
||||
public String toOperationId(String operationId) {
|
||||
operationId = org.openapitools.codegen.utils.StringUtils.camelize(sanitizeName(operationId), true);
|
||||
operationId = camelize(sanitizeName(operationId), true);
|
||||
|
||||
// throw exception if method name is empty. This should not happen but keep the check just in case
|
||||
if (StringUtils.isEmpty(operationId)) {
|
||||
@ -456,15 +457,15 @@ public class Swift3Codegen extends DefaultCodegen implements CodegenConfig {
|
||||
|
||||
// method name cannot use reserved keyword, e.g. return
|
||||
if (isReservedWord(operationId)) {
|
||||
String newOperationId = org.openapitools.codegen.utils.StringUtils.camelize(("call_" + operationId), true);
|
||||
String newOperationId = camelize(("call_" + operationId), true);
|
||||
LOGGER.warn(operationId + " (reserved word) cannot be used as method name. Renamed to " + newOperationId);
|
||||
return newOperationId;
|
||||
}
|
||||
|
||||
// operationId starts with a number
|
||||
if (operationId.matches("^\\d.*")) {
|
||||
LOGGER.warn(operationId + " (starting with a number) cannot be used as method name. Renamed to " + org.openapitools.codegen.utils.StringUtils.camelize(sanitizeName("call_" + operationId), true));
|
||||
operationId = org.openapitools.codegen.utils.StringUtils.camelize(sanitizeName("call_" + operationId), true);
|
||||
LOGGER.warn(operationId + " (starting with a number) cannot be used as method name. Renamed to " + camelize(sanitizeName("call_" + operationId), true));
|
||||
operationId = camelize(sanitizeName("call_" + operationId), true);
|
||||
}
|
||||
|
||||
return operationId;
|
||||
@ -482,7 +483,7 @@ public class Swift3Codegen extends DefaultCodegen implements CodegenConfig {
|
||||
|
||||
// camelize the variable name
|
||||
// pet_id => petId
|
||||
name = org.openapitools.codegen.utils.StringUtils.camelize(name, true);
|
||||
name = camelize(name, true);
|
||||
|
||||
// for reserved word or word starting with number, append _
|
||||
if (isReservedWord(name) || name.matches("^\\d.*")) {
|
||||
@ -505,9 +506,9 @@ public class Swift3Codegen extends DefaultCodegen implements CodegenConfig {
|
||||
return name;
|
||||
}
|
||||
|
||||
// org.openapitools.codegen.utils.StringUtils.camelize(lower) the variable name
|
||||
// camelize(lower) the variable name
|
||||
// pet_id => petId
|
||||
name = org.openapitools.codegen.utils.StringUtils.camelize(name, true);
|
||||
name = camelize(name, true);
|
||||
|
||||
// for reserved word or word starting with number, append _
|
||||
if (isReservedWord(name) || name.matches("^\\d.*")) {
|
||||
@ -586,18 +587,18 @@ public class Swift3Codegen extends DefaultCodegen implements CodegenConfig {
|
||||
String startingNumbers = startWithNumberMatcher.group(0);
|
||||
String nameWithoutStartingNumbers = name.substring(startingNumbers.length());
|
||||
|
||||
return "_" + startingNumbers + org.openapitools.codegen.utils.StringUtils.camelize(nameWithoutStartingNumbers, true);
|
||||
return "_" + startingNumbers + camelize(nameWithoutStartingNumbers, true);
|
||||
}
|
||||
|
||||
// for symbol, e.g. $, #
|
||||
if (getSymbolName(name) != null) {
|
||||
return org.openapitools.codegen.utils.StringUtils.camelize(WordUtils.capitalizeFully(getSymbolName(name).toUpperCase(Locale.ROOT)), true);
|
||||
return camelize(WordUtils.capitalizeFully(getSymbolName(name).toUpperCase(Locale.ROOT)), true);
|
||||
}
|
||||
|
||||
// Camelize only when we have a structure defined below
|
||||
Boolean camelized = false;
|
||||
if (name.matches("[A-Z][a-z0-9]+[a-zA-Z0-9]*")) {
|
||||
name = org.openapitools.codegen.utils.StringUtils.camelize(name, true);
|
||||
name = camelize(name, true);
|
||||
camelized = true;
|
||||
}
|
||||
|
||||
@ -610,7 +611,7 @@ public class Swift3Codegen extends DefaultCodegen implements CodegenConfig {
|
||||
// Check for numerical conversions
|
||||
if ("Int".equals(datatype) || "Int32".equals(datatype) || "Int64".equals(datatype) ||
|
||||
"Float".equals(datatype) || "Double".equals(datatype)) {
|
||||
String varName = "number" + org.openapitools.codegen.utils.StringUtils.camelize(name);
|
||||
String varName = "number" + camelize(name);
|
||||
varName = varName.replaceAll("-", "minus");
|
||||
varName = varName.replaceAll("\\+", "plus");
|
||||
varName = varName.replaceAll("\\.", "dot");
|
||||
@ -624,7 +625,7 @@ public class Swift3Codegen extends DefaultCodegen implements CodegenConfig {
|
||||
}
|
||||
|
||||
char[] separators = {'-', '_', ' ', ':', '(', ')'};
|
||||
return org.openapitools.codegen.utils.StringUtils.camelize(WordUtils.capitalizeFully(StringUtils.lowerCase(name), separators).replaceAll("[-_ :\\(\\)]", ""), true);
|
||||
return camelize(WordUtils.capitalizeFully(StringUtils.lowerCase(name), separators).replaceAll("[-_ :\\(\\)]", ""), true);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -33,6 +33,7 @@ import java.io.File;
|
||||
import java.util.*;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
import static org.openapitools.codegen.utils.StringUtils.camelize;
|
||||
|
||||
|
||||
public class Swift4Codegen extends DefaultCodegen implements CodegenConfig {
|
||||
@ -480,7 +481,7 @@ public class Swift4Codegen extends DefaultCodegen implements CodegenConfig {
|
||||
|
||||
// camelize the model name
|
||||
// phone_number => PhoneNumber
|
||||
name = org.openapitools.codegen.utils.StringUtils.camelize(name);
|
||||
name = camelize(name);
|
||||
|
||||
// model name cannot use reserved keyword, e.g. return
|
||||
if (isReservedWord(name)) {
|
||||
@ -556,7 +557,7 @@ public class Swift4Codegen extends DefaultCodegen implements CodegenConfig {
|
||||
|
||||
@Override
|
||||
public String toOperationId(String operationId) {
|
||||
operationId = org.openapitools.codegen.utils.StringUtils.camelize(sanitizeName(operationId), true);
|
||||
operationId = camelize(sanitizeName(operationId), true);
|
||||
|
||||
// Throw exception if method name is empty.
|
||||
// This should not happen but keep the check just in case
|
||||
@ -566,7 +567,7 @@ public class Swift4Codegen extends DefaultCodegen implements CodegenConfig {
|
||||
|
||||
// method name cannot use reserved keyword, e.g. return
|
||||
if (isReservedWord(operationId)) {
|
||||
String newOperationId = org.openapitools.codegen.utils.StringUtils.camelize(("call_" + operationId), true);
|
||||
String newOperationId = camelize(("call_" + operationId), true);
|
||||
LOGGER.warn(operationId + " (reserved word) cannot be used as method name."
|
||||
+ " Renamed to " + newOperationId);
|
||||
return newOperationId;
|
||||
@ -574,8 +575,8 @@ public class Swift4Codegen extends DefaultCodegen implements CodegenConfig {
|
||||
|
||||
// operationId starts with a number
|
||||
if (operationId.matches("^\\d.*")) {
|
||||
LOGGER.warn(operationId + " (starting with a number) cannot be used as method name. Renamed to " + org.openapitools.codegen.utils.StringUtils.camelize(sanitizeName("call_" + operationId), true));
|
||||
operationId = org.openapitools.codegen.utils.StringUtils.camelize(sanitizeName("call_" + operationId), true);
|
||||
LOGGER.warn(operationId + " (starting with a number) cannot be used as method name. Renamed to " + camelize(sanitizeName("call_" + operationId), true));
|
||||
operationId = camelize(sanitizeName("call_" + operationId), true);
|
||||
}
|
||||
|
||||
|
||||
@ -594,7 +595,7 @@ public class Swift4Codegen extends DefaultCodegen implements CodegenConfig {
|
||||
|
||||
// camelize the variable name
|
||||
// pet_id => petId
|
||||
name = org.openapitools.codegen.utils.StringUtils.camelize(name, true);
|
||||
name = camelize(name, true);
|
||||
|
||||
// for reserved word or word starting with number, append _
|
||||
if (isReservedWord(name) || name.matches("^\\d.*")) {
|
||||
@ -617,9 +618,9 @@ public class Swift4Codegen extends DefaultCodegen implements CodegenConfig {
|
||||
return name;
|
||||
}
|
||||
|
||||
// org.openapitools.codegen.utils.StringUtils.camelize(lower) the variable name
|
||||
// camelize(lower) the variable name
|
||||
// pet_id => petId
|
||||
name = org.openapitools.codegen.utils.StringUtils.camelize(name, true);
|
||||
name = camelize(name, true);
|
||||
|
||||
// for reserved word or word starting with number, append _
|
||||
if (isReservedWord(name) || name.matches("^\\d.*")) {
|
||||
@ -705,18 +706,18 @@ public class Swift4Codegen extends DefaultCodegen implements CodegenConfig {
|
||||
String startingNumbers = startWithNumberMatcher.group(0);
|
||||
String nameWithoutStartingNumbers = name.substring(startingNumbers.length());
|
||||
|
||||
return "_" + startingNumbers + org.openapitools.codegen.utils.StringUtils.camelize(nameWithoutStartingNumbers, true);
|
||||
return "_" + startingNumbers + camelize(nameWithoutStartingNumbers, true);
|
||||
}
|
||||
|
||||
// for symbol, e.g. $, #
|
||||
if (getSymbolName(name) != null) {
|
||||
return org.openapitools.codegen.utils.StringUtils.camelize(WordUtils.capitalizeFully(getSymbolName(name).toUpperCase(Locale.ROOT)), true);
|
||||
return camelize(WordUtils.capitalizeFully(getSymbolName(name).toUpperCase(Locale.ROOT)), true);
|
||||
}
|
||||
|
||||
// Camelize only when we have a structure defined below
|
||||
Boolean camelized = false;
|
||||
if (name.matches("[A-Z][a-z0-9]+[a-zA-Z0-9]*")) {
|
||||
name = org.openapitools.codegen.utils.StringUtils.camelize(name, true);
|
||||
name = camelize(name, true);
|
||||
camelized = true;
|
||||
}
|
||||
|
||||
@ -729,7 +730,7 @@ public class Swift4Codegen extends DefaultCodegen implements CodegenConfig {
|
||||
// Check for numerical conversions
|
||||
if ("Int".equals(datatype) || "Int32".equals(datatype) || "Int64".equals(datatype)
|
||||
|| "Float".equals(datatype) || "Double".equals(datatype)) {
|
||||
String varName = "number" + org.openapitools.codegen.utils.StringUtils.camelize(name);
|
||||
String varName = "number" + camelize(name);
|
||||
varName = varName.replaceAll("-", "minus");
|
||||
varName = varName.replaceAll("\\+", "plus");
|
||||
varName = varName.replaceAll("\\.", "dot");
|
||||
@ -743,7 +744,7 @@ public class Swift4Codegen extends DefaultCodegen implements CodegenConfig {
|
||||
}
|
||||
|
||||
char[] separators = {'-', '_', ' ', ':', '(', ')'};
|
||||
return org.openapitools.codegen.utils.StringUtils.camelize(WordUtils.capitalizeFully(StringUtils.lowerCase(name), separators)
|
||||
return camelize(WordUtils.capitalizeFully(StringUtils.lowerCase(name), separators)
|
||||
.replaceAll("[-_ :\\(\\)]", ""),
|
||||
true);
|
||||
}
|
||||
|
@ -34,6 +34,8 @@ import java.util.*;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import static org.openapitools.codegen.utils.StringUtils.camelize;
|
||||
import static org.openapitools.codegen.utils.StringUtils.underscore;
|
||||
|
||||
/**
|
||||
* Swift (2.x) generator is no longer actively maintained. Please use
|
||||
@ -320,7 +322,7 @@ public class SwiftClientCodegen extends DefaultCodegen implements CodegenConfig
|
||||
|
||||
// camelize the model name
|
||||
// phone_number => PhoneNumber
|
||||
name = org.openapitools.codegen.utils.StringUtils.camelize(name);
|
||||
name = camelize(name);
|
||||
|
||||
// model name cannot use reserved keyword, e.g. return
|
||||
if (isReservedWord(name)) {
|
||||
@ -437,7 +439,7 @@ public class SwiftClientCodegen extends DefaultCodegen implements CodegenConfig
|
||||
|
||||
@Override
|
||||
public String toOperationId(String operationId) {
|
||||
operationId = org.openapitools.codegen.utils.StringUtils.camelize(sanitizeName(operationId), true);
|
||||
operationId = camelize(sanitizeName(operationId), true);
|
||||
|
||||
// throw exception if method name is empty. This should not happen but keep the check just in case
|
||||
if (StringUtils.isEmpty(operationId)) {
|
||||
@ -446,15 +448,15 @@ public class SwiftClientCodegen extends DefaultCodegen implements CodegenConfig
|
||||
|
||||
// method name cannot use reserved keyword, e.g. return
|
||||
if (isReservedWord(operationId)) {
|
||||
String newOperationId = org.openapitools.codegen.utils.StringUtils.camelize(("call_" + operationId), true);
|
||||
String newOperationId = camelize(("call_" + operationId), true);
|
||||
LOGGER.warn(operationId + " (reserved word) cannot be used as method name. Renamed to " + newOperationId);
|
||||
return newOperationId;
|
||||
}
|
||||
|
||||
// operationId starts with a number
|
||||
if (operationId.matches("^\\d.*")) {
|
||||
LOGGER.warn(operationId + " (starting with a number) cannot be used as method name. Renamed to " + org.openapitools.codegen.utils.StringUtils.camelize(sanitizeName("call_" + operationId), true));
|
||||
operationId = org.openapitools.codegen.utils.StringUtils.camelize(sanitizeName("call_" + operationId), true);
|
||||
LOGGER.warn(operationId + " (starting with a number) cannot be used as method name. Renamed to " + camelize(sanitizeName("call_" + operationId), true));
|
||||
operationId = camelize(sanitizeName("call_" + operationId), true);
|
||||
}
|
||||
|
||||
return operationId;
|
||||
@ -472,7 +474,7 @@ public class SwiftClientCodegen extends DefaultCodegen implements CodegenConfig
|
||||
|
||||
// camelize the variable name
|
||||
// pet_id => petId
|
||||
name = org.openapitools.codegen.utils.StringUtils.camelize(name, true);
|
||||
name = camelize(name, true);
|
||||
|
||||
// for reserved word or word starting with number, append _
|
||||
if (isReservedWord(name) || name.matches("^\\d.*")) {
|
||||
@ -495,9 +497,9 @@ public class SwiftClientCodegen extends DefaultCodegen implements CodegenConfig
|
||||
return name;
|
||||
}
|
||||
|
||||
// org.openapitools.codegen.utils.StringUtils.camelize(lower) the variable name
|
||||
// camelize(lower) the variable name
|
||||
// pet_id => petId
|
||||
name = org.openapitools.codegen.utils.StringUtils.camelize(name, true);
|
||||
name = camelize(name, true);
|
||||
|
||||
// for reserved word or word starting with number, append _
|
||||
if (isReservedWord(name) || name.matches("^\\d.*")) {
|
||||
@ -525,7 +527,7 @@ public class SwiftClientCodegen extends DefaultCodegen implements CodegenConfig
|
||||
builder.append(stringBeforeMatch);
|
||||
|
||||
String group = matcher.group().substring(1, matcher.group().length() - 1);
|
||||
group = org.openapitools.codegen.utils.StringUtils.camelize(group, true);
|
||||
group = camelize(group, true);
|
||||
builder
|
||||
.append("{")
|
||||
.append(group)
|
||||
@ -584,7 +586,7 @@ public class SwiftClientCodegen extends DefaultCodegen implements CodegenConfig
|
||||
}
|
||||
|
||||
// string
|
||||
String enumName = sanitizeName(org.openapitools.codegen.utils.StringUtils.underscore(name).toUpperCase(Locale.ROOT));
|
||||
String enumName = sanitizeName(underscore(name).toUpperCase(Locale.ROOT));
|
||||
enumName = enumName.replaceFirst("^_", "");
|
||||
enumName = enumName.replaceFirst("_$", "");
|
||||
|
||||
|
@ -29,6 +29,9 @@ import java.io.File;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.*;
|
||||
|
||||
import static org.openapitools.codegen.utils.StringUtils.camelize;
|
||||
import static org.openapitools.codegen.utils.StringUtils.underscore;
|
||||
import static org.openapitools.codegen.utils.StringUtils.dashize;
|
||||
|
||||
public class TypeScriptAngularClientCodegen extends AbstractTypeScriptClientCodegen {
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(TypeScriptAngularClientCodegen.class);
|
||||
@ -571,7 +574,7 @@ public class TypeScriptAngularClientCodegen extends AbstractTypeScriptClientCode
|
||||
if (modelFileSuffix.length() > 0) {
|
||||
name = name.substring(0, name.length() - modelFileSuffix.length());
|
||||
}
|
||||
return org.openapitools.codegen.utils.StringUtils.camelize(name) + modelSuffix;
|
||||
return camelize(name) + modelSuffix;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -28,7 +28,7 @@ import java.io.File;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.*;
|
||||
|
||||
|
||||
import static org.openapitools.codegen.utils.StringUtils.camelize;
|
||||
|
||||
public class TypeScriptInversifyClientCodegen extends AbstractTypeScriptClientCodegen {
|
||||
private static final SimpleDateFormat SNAPSHOT_SUFFIX_FORMAT = new SimpleDateFormat("yyyyMMddHHmm", Locale.ROOT);
|
||||
@ -327,7 +327,7 @@ public class TypeScriptInversifyClientCodegen extends AbstractTypeScriptClientCo
|
||||
if (name.length() == 0) {
|
||||
return "default.service";
|
||||
}
|
||||
return org.openapitools.codegen.utils.StringUtils.camelize(name, true) + ".service";
|
||||
return camelize(name, true) + ".service";
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -337,7 +337,7 @@ public class TypeScriptInversifyClientCodegen extends AbstractTypeScriptClientCo
|
||||
|
||||
@Override
|
||||
public String toModelFilename(String name) {
|
||||
return org.openapitools.codegen.utils.StringUtils.camelize(toModelName(name), true);
|
||||
return camelize(toModelName(name), true);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -376,7 +376,7 @@ public class TypeScriptInversifyClientCodegen extends AbstractTypeScriptClientCo
|
||||
|
||||
private String getModelnameFromModelFilename(String filename) {
|
||||
String name = filename.substring((modelPackage() + "/").length());
|
||||
return org.openapitools.codegen.utils.StringUtils.camelize(name);
|
||||
return camelize(name);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -29,6 +29,7 @@ import java.io.File;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.*;
|
||||
|
||||
import static org.openapitools.codegen.utils.StringUtils.camelize;
|
||||
|
||||
public class TypeScriptNodeClientCodegen extends AbstractTypeScriptClientCodegen {
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(TypeScriptNodeClientCodegen.class);
|
||||
@ -107,7 +108,7 @@ public class TypeScriptNodeClientCodegen extends AbstractTypeScriptClientCodegen
|
||||
if (name.length() == 0) {
|
||||
return "default" + apiSuffix;
|
||||
}
|
||||
return org.openapitools.codegen.utils.StringUtils.camelize(name, true) + apiSuffix;
|
||||
return camelize(name, true) + apiSuffix;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -117,7 +118,7 @@ public class TypeScriptNodeClientCodegen extends AbstractTypeScriptClientCodegen
|
||||
|
||||
@Override
|
||||
public String toModelFilename(String name) {
|
||||
return org.openapitools.codegen.utils.StringUtils.camelize(toModelName(name), true);
|
||||
return camelize(toModelName(name), true);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -296,6 +297,6 @@ public class TypeScriptNodeClientCodegen extends AbstractTypeScriptClientCodegen
|
||||
|
||||
private String getModelnameFromModelFilename(String filename) {
|
||||
String name = filename.substring((modelPackage() + File.separator).length());
|
||||
return org.openapitools.codegen.utils.StringUtils.camelize(name);
|
||||
return camelize(name);
|
||||
}
|
||||
}
|
||||
|
@ -26,7 +26,6 @@ import java.io.Writer;
|
||||
|
||||
import static org.openapitools.codegen.utils.StringUtils.camelize;
|
||||
|
||||
|
||||
/**
|
||||
* Converts text in a fragment to camelCase.
|
||||
*
|
||||
|
@ -192,13 +192,13 @@ export class {{classname}} {
|
||||
// authentication ({{name}}) required
|
||||
{{#isApiKey}}
|
||||
{{#isKeyInHeader}}
|
||||
if (this.configuration.apiKeys["{{keyParamName}}"]) {
|
||||
if (this.configuration.apiKeys && this.configuration.apiKeys["{{keyParamName}}"]) {
|
||||
{{#useHttpClient}}headers = {{/useHttpClient}}headers.set('{{keyParamName}}', this.configuration.apiKeys["{{keyParamName}}"]);
|
||||
}
|
||||
|
||||
{{/isKeyInHeader}}
|
||||
{{#isKeyInQuery}}
|
||||
if (this.configuration.apiKeys["{{keyParamName}}"]) {
|
||||
if (this.configuration.apiKeys && this.configuration.apiKeys["{{keyParamName}}"]) {
|
||||
{{#useHttpClient}}queryParameters = {{/useHttpClient}}queryParameters.set('{{keyParamName}}', this.configuration.apiKeys["{{keyParamName}}"]);
|
||||
}
|
||||
|
||||
|
@ -106,12 +106,12 @@ export class {{classname}} {
|
||||
// authentication ({{name}}) required
|
||||
{{#isApiKey}}
|
||||
{{#isKeyInHeader}}
|
||||
if (this.APIConfiguration.apiKeys["{{keyParamName}}"]) {
|
||||
if (this.APIConfiguration.apiKeys && this.APIConfiguration.apiKeys["{{keyParamName}}"]) {
|
||||
headers['{{keyParamName}}'] = this.APIConfiguration.apiKeys["{{keyParamName}}"];
|
||||
}
|
||||
{{/isKeyInHeader}}
|
||||
{{#isKeyInQuery}}
|
||||
if (this.APIConfiguration.apiKeys["{{keyParamName}}"]) {
|
||||
if (this.APIConfiguration.apiKeys && this.APIConfiguration.apiKeys["{{keyParamName}}"]) {
|
||||
queryParameters.push("{{paramName}}="+encodeURIComponent(String(this.APIConfiguration.apiKeys["{{keyParamName}}"])));
|
||||
}
|
||||
{{/isKeyInQuery}}
|
||||
|
@ -15,5 +15,6 @@ public class TypeScriptNodeClientCodegenTest {
|
||||
Assert.assertEquals(codegen.toVarName("user-name"), "userName");
|
||||
Assert.assertEquals(codegen.toVarName("user_name"), "userName");
|
||||
Assert.assertEquals(codegen.toVarName("user|name"), "userName");
|
||||
Assert.assertEquals(codegen.toVarName("user !\"#$%&'()*+,-./:;<=>?@[\\]^_`{|}~name"), "user$Name");
|
||||
}
|
||||
}
|
||||
|
@ -28,7 +28,7 @@ paths:
|
||||
description: To test code injection */ ' " =end -- \r\n \n \r
|
||||
operationId: testCodeInject */ ' " =end -- \r\n \n \r
|
||||
consumes:
|
||||
- application/json
|
||||
- application/x-www-form-urlencoded
|
||||
- "*/ ' \" =end -- \r\n \n \r"
|
||||
produces:
|
||||
- application/json
|
||||
|
@ -1 +1 @@
|
||||
2.4.0-SNAPSHOT
|
||||
4.0.0-SNAPSHOT
|
@ -2,7 +2,7 @@
|
||||
|
||||
### Building
|
||||
|
||||
To build an compile the typescript sources to javascript use:
|
||||
To install the required dependencies and to build the typescript sources run:
|
||||
```
|
||||
npm install
|
||||
npm run build
|
||||
@ -10,11 +10,11 @@ npm run build
|
||||
|
||||
### publishing
|
||||
|
||||
First build the package than run ```npm publish```
|
||||
First build the package then run ```npm publish```
|
||||
|
||||
### consuming
|
||||
|
||||
navigate to the folder of your consuming project and run one of next commando's.
|
||||
Navigate to the folder of your consuming project and run one of next commands.
|
||||
|
||||
_published:_
|
||||
|
||||
@ -22,7 +22,7 @@ _published:_
|
||||
npm install @ --save
|
||||
```
|
||||
|
||||
_unPublished (not recommended):_
|
||||
_without publishing (not recommended):_
|
||||
|
||||
```
|
||||
npm install PATH_TO_GENERATED_PACKAGE --save
|
||||
@ -37,9 +37,16 @@ npm link
|
||||
|
||||
In your project:
|
||||
```
|
||||
npm link @
|
||||
npm link
|
||||
```
|
||||
|
||||
__Note for Windows users:__ The Angular CLI has troubles to use linked npm packages.
|
||||
Please refer to this issue https://github.com/angular/angular-cli/issues/8284 for a solution / workaround.
|
||||
Published packages are not effected by this issue.
|
||||
|
||||
|
||||
#### General usage
|
||||
|
||||
In your Angular project:
|
||||
|
||||
|
||||
@ -94,8 +101,8 @@ export class AppComponent {
|
||||
Note: The ApiModule is restricted to being instantiated once app wide.
|
||||
This is to ensure that all services are treated as singletons.
|
||||
|
||||
#### Using multiple swagger files / APIs / ApiModules
|
||||
In order to use multiple `ApiModules` generated from different swagger files,
|
||||
#### Using multiple OpenAPI files / APIs / ApiModules
|
||||
In order to use multiple `ApiModules` generated from different OpenAPI files,
|
||||
you can create an alias name when importing the modules
|
||||
in order to avoid naming conflicts:
|
||||
```
|
||||
@ -168,4 +175,4 @@ import { environment } from '../environments/environment';
|
||||
bootstrap: [ AppComponent ]
|
||||
})
|
||||
export class AppModule { }
|
||||
```
|
||||
```
|
||||
|
@ -17,7 +17,7 @@ export class ApiModule {
|
||||
return {
|
||||
ngModule: ApiModule,
|
||||
providers: [ { provide: Configuration, useFactory: configurationFactory } ]
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
constructor( @Optional() @SkipSelf() parentModule: ApiModule,
|
||||
|
@ -1,12 +1,12 @@
|
||||
/**
|
||||
* Swagger Petstore *_/ ' \" =end -- \\r\\n \\n \\r
|
||||
* OpenAPI Petstore *_/ ' \" =end -- \\r\\n \\n \\r
|
||||
* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ *_/ ' \" =end --
|
||||
*
|
||||
* OpenAPI spec version: 1.0.0 *_/ ' \" =end -- \\r\\n \\n \\r
|
||||
* Contact: apiteam@swagger.io *_/ ' \" =end -- \\r\\n \\n \\r
|
||||
* Contact: something@something.abc *_/ ' \" =end -- \\r\\n \\n \\r
|
||||
*
|
||||
* NOTE: This class is auto generated by the swagger code generator program.
|
||||
* https://github.com/swagger-api/swagger-codegen.git
|
||||
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
||||
* https://openapi-generator.tech
|
||||
* Do not edit the class manually.
|
||||
*/
|
||||
/* tslint:disable:no-unused-variable member-ordering */
|
||||
@ -26,17 +26,18 @@ import { Configuration } from '../configurat
|
||||
@Injectable()
|
||||
export class FakeService {
|
||||
|
||||
protected basePath = 'https://petstore.swagger.io *_/ ' \" =end -- \\r\\n \\n \\r/v2 *_/ ' \" =end -- \\r\\n \\n \\r';
|
||||
protected basePath = 'http://petstore.swagger.io *_/ ' \" =end -- \\r\\n \\n \\r/v2 *_/ ' \" =end -- \\r\\n \\n \\r';
|
||||
public defaultHeaders = new HttpHeaders();
|
||||
public configuration = new Configuration();
|
||||
|
||||
constructor(protected httpClient: HttpClient, @Optional()@Inject(BASE_PATH) basePath: string, @Optional() configuration: Configuration) {
|
||||
if (basePath) {
|
||||
this.basePath = basePath;
|
||||
}
|
||||
|
||||
if (configuration) {
|
||||
this.configuration = configuration;
|
||||
this.basePath = basePath || configuration.basePath || this.basePath;
|
||||
this.configuration.basePath = configuration.basePath || basePath || this.basePath;
|
||||
|
||||
} else {
|
||||
this.configuration.basePath = basePath || this.basePath;
|
||||
}
|
||||
}
|
||||
|
||||
@ -46,7 +47,7 @@ export class FakeService {
|
||||
*/
|
||||
private canConsumeForm(consumes: string[]): boolean {
|
||||
const form = 'multipart/form-data';
|
||||
for (let consume of consumes) {
|
||||
for (const consume of consumes) {
|
||||
if (form === consume) {
|
||||
return true;
|
||||
}
|
||||
@ -57,8 +58,8 @@ export class FakeService {
|
||||
|
||||
/**
|
||||
* To test code injection *_/ ' \" =end -- \\r\\n \\n \\r
|
||||
*
|
||||
* @param testCodeInjectEndRnNR To test code injection *_/ ' \" =end -- \\r\\n \\n \\r
|
||||
* To test code injection *_/ ' \" =end -- \\r\\n \\n \\r
|
||||
* @param testCodeInjectEndRnNR To test code injection *_/ ' \\\" =end -- \\\\r\\\\n \\\\n \\\\r
|
||||
* @param observe set whether or not to return the data Observable as the body, response or events. defaults to returning the body.
|
||||
* @param reportProgress flag to report request and response progress.
|
||||
*/
|
||||
@ -71,23 +72,21 @@ export class FakeService {
|
||||
|
||||
// to determine the Accept header
|
||||
let httpHeaderAccepts: string[] = [
|
||||
'application/json',
|
||||
'*_/ =end -- '
|
||||
];
|
||||
let httpHeaderAcceptSelected: string | undefined = this.configuration.selectHeaderAccept(httpHeaderAccepts);
|
||||
if (httpHeaderAcceptSelected != undefined) {
|
||||
headers = headers.set("Accept", httpHeaderAcceptSelected);
|
||||
const httpHeaderAcceptSelected: string | undefined = this.configuration.selectHeaderAccept(httpHeaderAccepts);
|
||||
if (httpHeaderAcceptSelected !== undefined) {
|
||||
headers = headers.set('Accept', httpHeaderAcceptSelected);
|
||||
}
|
||||
|
||||
// to determine the Content-Type header
|
||||
let consumes: string[] = [
|
||||
'application/json',
|
||||
const consumes: string[] = [
|
||||
'application/x-www-form-urlencoded',
|
||||
'*_/ =end -- '
|
||||
];
|
||||
|
||||
const canConsumeForm = this.canConsumeForm(consumes);
|
||||
|
||||
let formParams: { append(param: string, value: any): void; };
|
||||
let formParams: { append(param: string, value: any): any; };
|
||||
let useForm = false;
|
||||
let convertFormParamsToString = false;
|
||||
if (useForm) {
|
||||
@ -100,7 +99,7 @@ export class FakeService {
|
||||
formParams = formParams.append('test code inject */ ' " =end -- \r\n \n \r', <any>testCodeInjectEndRnNR) || formParams;
|
||||
}
|
||||
|
||||
return this.httpClient.put<any>(`${this.basePath}/fake`,
|
||||
return this.httpClient.put<any>(`${this.configuration.basePath}/fake`,
|
||||
convertFormParamsToString ? formParams.toString() : formParams,
|
||||
{
|
||||
withCredentials: this.configuration.withCredentials,
|
||||
|
@ -28,11 +28,11 @@ export class Configuration {
|
||||
* Select the correct content-type to use for a request.
|
||||
* Uses {@link Configuration#isJsonMime} to determine the correct content-type.
|
||||
* If no content type is found return the first found type if the contentTypes is not empty
|
||||
* @param {string[]} contentTypes - the array of content types that are available for selection
|
||||
* @returns {string} the selected content-type or <code>undefined</code> if no selection could be made.
|
||||
* @param contentTypes - the array of content types that are available for selection
|
||||
* @returns the selected content-type or <code>undefined</code> if no selection could be made.
|
||||
*/
|
||||
public selectHeaderContentType (contentTypes: string[]): string | undefined {
|
||||
if (contentTypes.length == 0) {
|
||||
if (contentTypes.length === 0) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
@ -47,11 +47,11 @@ export class Configuration {
|
||||
* Select the correct accept content-type to use for a request.
|
||||
* Uses {@link Configuration#isJsonMime} to determine the correct accept content-type.
|
||||
* If no content type is found return the first found type if the contentTypes is not empty
|
||||
* @param {string[]} accepts - the array of content types that are available for selection.
|
||||
* @returns {string} the selected content-type or <code>undefined</code> if no selection could be made.
|
||||
* @param accepts - the array of content types that are available for selection.
|
||||
* @returns the selected content-type or <code>undefined</code> if no selection could be made.
|
||||
*/
|
||||
public selectHeaderAccept(accepts: string[]): string | undefined {
|
||||
if (accepts.length == 0) {
|
||||
if (accepts.length === 0) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
@ -69,11 +69,11 @@ export class Configuration {
|
||||
* application/json; charset=UTF8
|
||||
* APPLICATION/JSON
|
||||
* application/vnd.company+json
|
||||
* @param {string} mime - MIME (Multipurpose Internet Mail Extensions)
|
||||
* @return {boolean} True if the given MIME is JSON, false otherwise.
|
||||
* @param mime - MIME (Multipurpose Internet Mail Extensions)
|
||||
* @return True if the given MIME is JSON, false otherwise.
|
||||
*/
|
||||
public isJsonMime(mime: string): boolean {
|
||||
const jsonMime: RegExp = new RegExp('^(application\/json|[^;/ \t]+\/[^;/ \t]+[+]json)[ \t]*(;.*)?$', 'i');
|
||||
return mime != null && (jsonMime.test(mime) || mime.toLowerCase() === 'application/json-patch+json');
|
||||
return mime !== null && (jsonMime.test(mime) || mime.toLowerCase() === 'application/json-patch+json');
|
||||
}
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
#!/bin/sh
|
||||
# ref: https://help.github.com/articles/adding-an-existing-project-to-github-using-the-command-line/
|
||||
#
|
||||
# Usage example: /bin/sh ./git_push.sh wing328 swagger-petstore-perl "minor update"
|
||||
# Usage example: /bin/sh ./git_push.sh wing328 openapi-pestore-perl "minor update"
|
||||
|
||||
git_user_id=$1
|
||||
git_repo_id=$2
|
||||
|
@ -1 +1 @@
|
||||
export * from './modelReturn';
|
||||
export * from './return';
|
||||
|
@ -0,0 +1,22 @@
|
||||
/**
|
||||
* OpenAPI Petstore *_/ ' \" =end -- \\r\\n \\n \\r
|
||||
* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ *_/ ' \" =end --
|
||||
*
|
||||
* OpenAPI spec version: 1.0.0 *_/ ' \" =end -- \\r\\n \\n \\r
|
||||
* Contact: something@something.abc *_/ ' \" =end -- \\r\\n \\n \\r
|
||||
*
|
||||
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
||||
* https://openapi-generator.tech
|
||||
* Do not edit the class manually.
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* Model for testing reserved words *_/ ' \" =end -- \\r\\n \\n \\r
|
||||
*/
|
||||
export interface Return {
|
||||
/**
|
||||
* property description *_/ ' \" =end -- \\r\\n \\n \\r
|
||||
*/
|
||||
_return?: number;
|
||||
}
|
@ -1 +1 @@
|
||||
2.4.0-SNAPSHOT
|
||||
4.0.0-SNAPSHOT
|
@ -2,7 +2,7 @@
|
||||
|
||||
### Building
|
||||
|
||||
To build an compile the typescript sources to javascript use:
|
||||
To install the required dependencies and to build the typescript sources run:
|
||||
```
|
||||
npm install
|
||||
npm run build
|
||||
@ -10,11 +10,11 @@ npm run build
|
||||
|
||||
### publishing
|
||||
|
||||
First build the package than run ```npm publish```
|
||||
First build the package then run ```npm publish```
|
||||
|
||||
### consuming
|
||||
|
||||
navigate to the folder of your consuming project and run one of next commando's.
|
||||
Navigate to the folder of your consuming project and run one of next commands.
|
||||
|
||||
_published:_
|
||||
|
||||
@ -22,7 +22,7 @@ _published:_
|
||||
npm install @ --save
|
||||
```
|
||||
|
||||
_unPublished (not recommended):_
|
||||
_without publishing (not recommended):_
|
||||
|
||||
```
|
||||
npm install PATH_TO_GENERATED_PACKAGE --save
|
||||
@ -37,9 +37,16 @@ npm link
|
||||
|
||||
In your project:
|
||||
```
|
||||
npm link @
|
||||
npm link
|
||||
```
|
||||
|
||||
__Note for Windows users:__ The Angular CLI has troubles to use linked npm packages.
|
||||
Please refer to this issue https://github.com/angular/angular-cli/issues/8284 for a solution / workaround.
|
||||
Published packages are not effected by this issue.
|
||||
|
||||
|
||||
#### General usage
|
||||
|
||||
In your Angular project:
|
||||
|
||||
|
||||
@ -94,8 +101,8 @@ export class AppComponent {
|
||||
Note: The ApiModule is restricted to being instantiated once app wide.
|
||||
This is to ensure that all services are treated as singletons.
|
||||
|
||||
#### Using multiple swagger files / APIs / ApiModules
|
||||
In order to use multiple `ApiModules` generated from different swagger files,
|
||||
#### Using multiple OpenAPI files / APIs / ApiModules
|
||||
In order to use multiple `ApiModules` generated from different OpenAPI files,
|
||||
you can create an alias name when importing the modules
|
||||
in order to avoid naming conflicts:
|
||||
```
|
||||
@ -168,4 +175,4 @@ import { environment } from '../environments/environment';
|
||||
bootstrap: [ AppComponent ]
|
||||
})
|
||||
export class AppModule { }
|
||||
```
|
||||
```
|
||||
|
@ -17,7 +17,7 @@ export class ApiModule {
|
||||
return {
|
||||
ngModule: ApiModule,
|
||||
providers: [ { provide: Configuration, useFactory: configurationFactory } ]
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
constructor( @Optional() @SkipSelf() parentModule: ApiModule,
|
||||
|
@ -1,12 +1,12 @@
|
||||
/**
|
||||
* Swagger Petstore *_/ ' \" =end -- \\r\\n \\n \\r
|
||||
* OpenAPI Petstore *_/ ' \" =end -- \\r\\n \\n \\r
|
||||
* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ *_/ ' \" =end --
|
||||
*
|
||||
* OpenAPI spec version: 1.0.0 *_/ ' \" =end -- \\r\\n \\n \\r
|
||||
* Contact: apiteam@swagger.io *_/ ' \" =end -- \\r\\n \\n \\r
|
||||
* Contact: something@something.abc *_/ ' \" =end -- \\r\\n \\n \\r
|
||||
*
|
||||
* NOTE: This class is auto generated by the swagger code generator program.
|
||||
* https://github.com/swagger-api/swagger-codegen.git
|
||||
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
||||
* https://openapi-generator.tech
|
||||
* Do not edit the class manually.
|
||||
*/
|
||||
/* tslint:disable:no-unused-variable member-ordering */
|
||||
@ -26,17 +26,18 @@ import { Configuration } from '../configurat
|
||||
@Injectable()
|
||||
export class FakeService {
|
||||
|
||||
protected basePath = 'https://petstore.swagger.io *_/ ' \" =end -- \\r\\n \\n \\r/v2 *_/ ' \" =end -- \\r\\n \\n \\r';
|
||||
protected basePath = 'http://petstore.swagger.io *_/ ' \" =end -- \\r\\n \\n \\r/v2 *_/ ' \" =end -- \\r\\n \\n \\r';
|
||||
public defaultHeaders = new HttpHeaders();
|
||||
public configuration = new Configuration();
|
||||
|
||||
constructor(protected httpClient: HttpClient, @Optional()@Inject(BASE_PATH) basePath: string, @Optional() configuration: Configuration) {
|
||||
if (basePath) {
|
||||
this.basePath = basePath;
|
||||
}
|
||||
|
||||
if (configuration) {
|
||||
this.configuration = configuration;
|
||||
this.basePath = basePath || configuration.basePath || this.basePath;
|
||||
this.configuration.basePath = configuration.basePath || basePath || this.basePath;
|
||||
|
||||
} else {
|
||||
this.configuration.basePath = basePath || this.basePath;
|
||||
}
|
||||
}
|
||||
|
||||
@ -46,7 +47,7 @@ export class FakeService {
|
||||
*/
|
||||
private canConsumeForm(consumes: string[]): boolean {
|
||||
const form = 'multipart/form-data';
|
||||
for (let consume of consumes) {
|
||||
for (const consume of consumes) {
|
||||
if (form === consume) {
|
||||
return true;
|
||||
}
|
||||
@ -57,8 +58,8 @@ export class FakeService {
|
||||
|
||||
/**
|
||||
* To test code injection *_/ ' \" =end -- \\r\\n \\n \\r
|
||||
*
|
||||
* @param testCodeInjectEndRnNR To test code injection *_/ ' \" =end -- \\r\\n \\n \\r
|
||||
* To test code injection *_/ ' \" =end -- \\r\\n \\n \\r
|
||||
* @param testCodeInjectEndRnNR To test code injection *_/ ' \\\" =end -- \\\\r\\\\n \\\\n \\\\r
|
||||
* @param observe set whether or not to return the data Observable as the body, response or events. defaults to returning the body.
|
||||
* @param reportProgress flag to report request and response progress.
|
||||
*/
|
||||
@ -71,23 +72,21 @@ export class FakeService {
|
||||
|
||||
// to determine the Accept header
|
||||
let httpHeaderAccepts: string[] = [
|
||||
'application/json',
|
||||
'*_/ =end -- '
|
||||
];
|
||||
let httpHeaderAcceptSelected: string | undefined = this.configuration.selectHeaderAccept(httpHeaderAccepts);
|
||||
if (httpHeaderAcceptSelected != undefined) {
|
||||
headers = headers.set("Accept", httpHeaderAcceptSelected);
|
||||
const httpHeaderAcceptSelected: string | undefined = this.configuration.selectHeaderAccept(httpHeaderAccepts);
|
||||
if (httpHeaderAcceptSelected !== undefined) {
|
||||
headers = headers.set('Accept', httpHeaderAcceptSelected);
|
||||
}
|
||||
|
||||
// to determine the Content-Type header
|
||||
let consumes: string[] = [
|
||||
'application/json',
|
||||
const consumes: string[] = [
|
||||
'application/x-www-form-urlencoded',
|
||||
'*_/ =end -- '
|
||||
];
|
||||
|
||||
const canConsumeForm = this.canConsumeForm(consumes);
|
||||
|
||||
let formParams: { append(param: string, value: any): void; };
|
||||
let formParams: { append(param: string, value: any): any; };
|
||||
let useForm = false;
|
||||
let convertFormParamsToString = false;
|
||||
if (useForm) {
|
||||
@ -100,7 +99,7 @@ export class FakeService {
|
||||
formParams = formParams.append('test code inject */ ' " =end -- \r\n \n \r', <any>testCodeInjectEndRnNR) || formParams;
|
||||
}
|
||||
|
||||
return this.httpClient.put<any>(`${this.basePath}/fake`,
|
||||
return this.httpClient.put<any>(`${this.configuration.basePath}/fake`,
|
||||
convertFormParamsToString ? formParams.toString() : formParams,
|
||||
{
|
||||
withCredentials: this.configuration.withCredentials,
|
||||
|
@ -28,11 +28,11 @@ export class Configuration {
|
||||
* Select the correct content-type to use for a request.
|
||||
* Uses {@link Configuration#isJsonMime} to determine the correct content-type.
|
||||
* If no content type is found return the first found type if the contentTypes is not empty
|
||||
* @param {string[]} contentTypes - the array of content types that are available for selection
|
||||
* @returns {string} the selected content-type or <code>undefined</code> if no selection could be made.
|
||||
* @param contentTypes - the array of content types that are available for selection
|
||||
* @returns the selected content-type or <code>undefined</code> if no selection could be made.
|
||||
*/
|
||||
public selectHeaderContentType (contentTypes: string[]): string | undefined {
|
||||
if (contentTypes.length == 0) {
|
||||
if (contentTypes.length === 0) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
@ -47,11 +47,11 @@ export class Configuration {
|
||||
* Select the correct accept content-type to use for a request.
|
||||
* Uses {@link Configuration#isJsonMime} to determine the correct accept content-type.
|
||||
* If no content type is found return the first found type if the contentTypes is not empty
|
||||
* @param {string[]} accepts - the array of content types that are available for selection.
|
||||
* @returns {string} the selected content-type or <code>undefined</code> if no selection could be made.
|
||||
* @param accepts - the array of content types that are available for selection.
|
||||
* @returns the selected content-type or <code>undefined</code> if no selection could be made.
|
||||
*/
|
||||
public selectHeaderAccept(accepts: string[]): string | undefined {
|
||||
if (accepts.length == 0) {
|
||||
if (accepts.length === 0) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
@ -69,11 +69,11 @@ export class Configuration {
|
||||
* application/json; charset=UTF8
|
||||
* APPLICATION/JSON
|
||||
* application/vnd.company+json
|
||||
* @param {string} mime - MIME (Multipurpose Internet Mail Extensions)
|
||||
* @return {boolean} True if the given MIME is JSON, false otherwise.
|
||||
* @param mime - MIME (Multipurpose Internet Mail Extensions)
|
||||
* @return True if the given MIME is JSON, false otherwise.
|
||||
*/
|
||||
public isJsonMime(mime: string): boolean {
|
||||
const jsonMime: RegExp = new RegExp('^(application\/json|[^;/ \t]+\/[^;/ \t]+[+]json)[ \t]*(;.*)?$', 'i');
|
||||
return mime != null && (jsonMime.test(mime) || mime.toLowerCase() === 'application/json-patch+json');
|
||||
return mime !== null && (jsonMime.test(mime) || mime.toLowerCase() === 'application/json-patch+json');
|
||||
}
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
#!/bin/sh
|
||||
# ref: https://help.github.com/articles/adding-an-existing-project-to-github-using-the-command-line/
|
||||
#
|
||||
# Usage example: /bin/sh ./git_push.sh wing328 swagger-petstore-perl "minor update"
|
||||
# Usage example: /bin/sh ./git_push.sh wing328 openapi-pestore-perl "minor update"
|
||||
|
||||
git_user_id=$1
|
||||
git_repo_id=$2
|
||||
|
@ -1 +1 @@
|
||||
export * from './modelReturn';
|
||||
export * from './return';
|
||||
|
@ -0,0 +1,22 @@
|
||||
/**
|
||||
* OpenAPI Petstore *_/ ' \" =end -- \\r\\n \\n \\r
|
||||
* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ *_/ ' \" =end --
|
||||
*
|
||||
* OpenAPI spec version: 1.0.0 *_/ ' \" =end -- \\r\\n \\n \\r
|
||||
* Contact: something@something.abc *_/ ' \" =end -- \\r\\n \\n \\r
|
||||
*
|
||||
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
||||
* https://openapi-generator.tech
|
||||
* Do not edit the class manually.
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* Model for testing reserved words *_/ ' \" =end -- \\r\\n \\n \\r
|
||||
*/
|
||||
export interface Return {
|
||||
/**
|
||||
* property description *_/ ' \" =end -- \\r\\n \\n \\r
|
||||
*/
|
||||
_return?: number;
|
||||
}
|
@ -13,14 +13,9 @@
|
||||
|
||||
|
||||
import * as runtime from '../runtime';
|
||||
import {
|
||||
UNKNOWN_BASE_TYPE,
|
||||
UNKNOWN_BASE_TYPEFromJSON,
|
||||
UNKNOWN_BASE_TYPEToJSON,
|
||||
} from '../models';
|
||||
|
||||
export interface TestCodeInjectEndRnNRRequest {
|
||||
UNKNOWN_BASE_TYPE?: UNKNOWN_BASE_TYPE;
|
||||
testCodeInjectEndRnNR?: string;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -37,14 +32,17 @@ export class FakeApi extends runtime.BaseAPI {
|
||||
|
||||
const headerParameters: runtime.HTTPHeaders = {};
|
||||
|
||||
headerParameters['Content-Type'] = 'application/json';
|
||||
const formData = new FormData();
|
||||
if (requestParameters.testCodeInjectEndRnNR !== undefined) {
|
||||
formData.append('test code inject */ ' " =end -- \r\n \n \r', requestParameters.testCodeInjectEndRnNR as any);
|
||||
}
|
||||
|
||||
const response = await this.request({
|
||||
path: `/fake`,
|
||||
method: 'PUT',
|
||||
headers: headerParameters,
|
||||
query: queryParameters,
|
||||
body: UNKNOWN_BASE_TYPEToJSON(requestParameters.UNKNOWN_BASE_TYPE),
|
||||
body: formData,
|
||||
});
|
||||
|
||||
return new runtime.VoidApiResponse(response);
|
||||
|
@ -1 +1 @@
|
||||
2.4.0-SNAPSHOT
|
||||
4.0.0-SNAPSHOT
|
@ -1,12 +1,12 @@
|
||||
/**
|
||||
* Swagger Petstore *_/ ' \" =end -- \\r\\n \\n \\r
|
||||
* OpenAPI Petstore *_/ ' \" =end -- \\r\\n \\n \\r
|
||||
* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ *_/ ' \" =end --
|
||||
*
|
||||
* OpenAPI spec version: 1.0.0 *_/ ' \" =end -- \\r\\n \\n \\r
|
||||
* Contact: apiteam@swagger.io *_/ ' \" =end -- \\r\\n \\n \\r
|
||||
* Contact: something@something.abc *_/ ' \" =end -- \\r\\n \\n \\r
|
||||
*
|
||||
* NOTE: This class is auto generated by the swagger code generator program.
|
||||
* https://github.com/swagger-api/swagger-codegen.git
|
||||
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
||||
* https://openapi-generator.tech
|
||||
* Do not edit the class manually.
|
||||
*/
|
||||
/* tslint:disable:no-unused-variable member-ordering */
|
||||
@ -27,7 +27,7 @@ import { COLLECTION_FORMATS } from '../variables';
|
||||
|
||||
@injectable()
|
||||
export class FakeService {
|
||||
private basePath: string = 'https://petstore.swagger.io *_/ ' \" =end -- \\r\\n \\n \\r/v2 *_/ ' \" =end -- \\r\\n \\n \\r';
|
||||
private basePath: string = 'http://petstore.swagger.io *_/ ' \" =end -- \\r\\n \\n \\r/v2 *_/ ' \" =end -- \\r\\n \\n \\r';
|
||||
|
||||
constructor(@inject("IApiHttpClient") private httpClient: IHttpClient,
|
||||
@inject("IAPIConfiguration") private APIConfiguration: IAPIConfiguration ) {
|
||||
@ -37,8 +37,8 @@ export class FakeService {
|
||||
|
||||
/**
|
||||
* To test code injection *_/ ' \" =end -- \\r\\n \\n \\r
|
||||
*
|
||||
* @param testCodeInjectEndRnNR To test code injection *_/ ' \" =end -- \\r\\n \\n \\r
|
||||
* To test code injection *_/ ' \" =end -- \\r\\n \\n \\r
|
||||
* @param testCodeInjectEndRnNR To test code injection *_/ ' \\\" =end -- \\\\r\\\\n \\\\n \\\\r
|
||||
|
||||
*/
|
||||
public testCodeInjectEndRnNR(testCodeInjectEndRnNR?: string, observe?: 'body', headers?: Headers): Observable<any>;
|
||||
|
@ -0,0 +1,22 @@
|
||||
/**
|
||||
* OpenAPI Petstore *_/ ' \" =end -- \\r\\n \\n \\r
|
||||
* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ *_/ ' \" =end --
|
||||
*
|
||||
* OpenAPI spec version: 1.0.0 *_/ ' \" =end -- \\r\\n \\n \\r
|
||||
* Contact: something@something.abc *_/ ' \" =end -- \\r\\n \\n \\r
|
||||
*
|
||||
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
||||
* https://openapi-generator.tech
|
||||
* Do not edit the class manually.
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* Model for testing reserved words *_/ ' \" =end -- \\r\\n \\n \\r
|
||||
*/
|
||||
export interface Return {
|
||||
/**
|
||||
* property description *_/ ' \" =end -- \\r\\n \\n \\r
|
||||
*/
|
||||
_return?: number;
|
||||
}
|
@ -1 +1 @@
|
||||
3.0.3-SNAPSHOT
|
||||
4.0.0-SNAPSHOT
|
@ -18,7 +18,7 @@ import Promise = require('bluebird');
|
||||
|
||||
import { ObjectSerializer, Authentication, HttpBasicAuth, ApiKeyAuth, OAuth, VoidAuth } from '../model/models';
|
||||
|
||||
let defaultBasePath = 'petstore.swagger.io *_/ ' \" =end -- \\r\\n \\n \\r/v2 *_/ ' \" =end -- \\r\\n \\n \\r';
|
||||
let defaultBasePath = 'http://petstore.swagger.io *_/ ' \" =end -- \\r\\n \\n \\r/v2 *_/ ' \" =end -- \\r\\n \\n \\r';
|
||||
|
||||
// ===============================================
|
||||
// This file is autogenerated - Please do not edit
|
||||
@ -70,11 +70,11 @@ export class FakeApi {
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* To test code injection *_/ ' \" =end -- \\r\\n \\n \\r
|
||||
* @summary To test code injection *_/ ' \" =end -- \\r\\n \\n \\r
|
||||
* @param UNKNOWN_BASE_TYPE
|
||||
* @param testCodeInjectEndRnNR To test code injection *_/ ' \\\" =end -- \\\\r\\\\n \\\\n \\\\r
|
||||
*/
|
||||
public testCodeInjectEndRnNR (UNKNOWN_BASE_TYPE?: any) : Promise<{ response: http.ClientResponse; body?: any; }> {
|
||||
public testCodeInjectEndRnNR (testCodeInjectEndRnNR?: string) : Promise<{ response: http.ClientResponse; body?: any; }> {
|
||||
const localVarPath = this.basePath + '/fake';
|
||||
let localVarQueryParameters: any = {};
|
||||
let localVarHeaderParams: any = (<any>Object).assign({}, this.defaultHeaders);
|
||||
@ -83,6 +83,10 @@ export class FakeApi {
|
||||
|
||||
let localVarUseFormData = false;
|
||||
|
||||
if (testCodeInjectEndRnNR !== undefined) {
|
||||
localVarFormParams['test code inject */ ' " =end -- \r\n \n \r'] = ObjectSerializer.serialize(testCodeInjectEndRnNR, "string");
|
||||
}
|
||||
|
||||
let localVarRequestOptions: localVarRequest.Options = {
|
||||
method: 'PUT',
|
||||
qs: localVarQueryParameters,
|
||||
@ -90,7 +94,6 @@ export class FakeApi {
|
||||
uri: localVarPath,
|
||||
useQuerystring: this._useQuerystring,
|
||||
json: true,
|
||||
body: ObjectSerializer.serialize(UNKNOWN_BASE_TYPE, "any")
|
||||
};
|
||||
|
||||
this.authentications.default.applyToRequest(localVarRequestOptions);
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user