This commit is contained in:
William Cheng 2019-07-25 15:30:30 +08:00
commit 2c9bfdf29a
4 changed files with 9 additions and 7 deletions

View File

@ -12,5 +12,5 @@ sidebar_label: cpp-qt5-client
|allowUnicodeIdentifiers|boolean, toggles whether unicode identifiers are allowed in names or not, default is false| |false|
|prependFormOrBodyParameters|Add form or body parameters to the beginning of the parameter list.| |false|
|cppNamespace|C++ namespace (convention: name::space::for::api).| |OpenAPI|
|cppNamespace|C++ namespace (convention: name::space::for::api).| |OpenAPI|
|modelNamePrefix|Prefix that will be prepended to all model names.| |OAI|
|optionalProjectFile|Generate client.pri.| |true|

View File

@ -12,4 +12,4 @@ sidebar_label: cpp-qt5-qhttpengine-server
|allowUnicodeIdentifiers|boolean, toggles whether unicode identifiers are allowed in names or not, default is false| |false|
|prependFormOrBodyParameters|Add form or body parameters to the beginning of the parameter list.| |false|
|cppNamespace|C++ namespace (convention: name::space::for::api).| |OpenAPI|
|cppNamespace|C++ namespace (convention: name::space::for::api).| |OpenAPI|
|modelNamePrefix|Prefix that will be prepended to all model names.| |OAI|

View File

@ -203,10 +203,10 @@ public class CodegenConstants {
public static final String ENUM_PROPERTY_NAMING_DESC = "Naming convention for enum properties: 'camelCase', 'PascalCase', 'snake_case', 'UPPERCASE', and 'original'";
public static final String MODEL_NAME_PREFIX = "modelNamePrefix";
public static final String MODEL_NAME_PREFIX_DESC = "Prefix that will be prepended to all model names. Default is the empty string.";
public static final String MODEL_NAME_PREFIX_DESC = "Prefix that will be prepended to all model names.";
public static final String MODEL_NAME_SUFFIX = "modelNameSuffix";
public static final String MODEL_NAME_SUFFIX_DESC = "Suffix that will be appended to all model names. Default is the empty string.";
public static final String MODEL_NAME_SUFFIX_DESC = "Suffix that will be appended to all model names.";
public static final String GIT_USER_ID = "gitUserId";
public static final String GIT_USER_ID_DESC = "Git user ID, e.g. openapitools.";

View File

@ -5,6 +5,7 @@ import io.swagger.v3.oas.models.media.Schema;
import io.swagger.v3.parser.util.SchemaTypeUtil;
import org.apache.commons.lang3.StringUtils;
import org.openapitools.codegen.CodegenConfig;
import org.openapitools.codegen.CodegenConstants;
import org.openapitools.codegen.CodegenModel;
import org.openapitools.codegen.CodegenOperation;
import org.openapitools.codegen.CodegenParameter;
@ -34,6 +35,7 @@ public class CppQt5AbstractCodegen extends AbstractCppCodegen implements Codegen
}
// CLI options
addOption(CPP_NAMESPACE, CPP_NAMESPACE_DESC, this.cppNamespace);
addOption(CodegenConstants.MODEL_NAME_PREFIX, CodegenConstants.MODEL_NAME_PREFIX_DESC, this.modelNamePrefix);
/*
* Additional Properties. These values can be passed to the templates and
@ -46,8 +48,6 @@ public class CppQt5AbstractCodegen extends AbstractCppCodegen implements Codegen
// At this point command line has not been parsed so if value is given
// in command line it will supersede this content
additionalProperties.put("cppNamespace", cppNamespace);
// CLI options
addOption(CPP_NAMESPACE, CPP_NAMESPACE_DESC, this.cppNamespace);
/*
* Language Specific Primitives. These types will not trigger imports by
* the client generator
@ -112,7 +112,9 @@ public class CppQt5AbstractCodegen extends AbstractCppCodegen implements Codegen
}
additionalProperties.put("cppNamespaceDeclarations", cppNamespace.split("\\::"));
if (additionalProperties.containsKey("modelNamePrefix")) {
modelNamePrefix = (String) additionalProperties.get("modelNamePrefix");
typeMapping.put("object", modelNamePrefix + "Object");
additionalProperties().put("prefix", modelNamePrefix);
}