mirror of
https://github.com/OpenAPITools/openapi-generator.git
synced 2026-03-18 12:39:04 +00:00
Update default value for C++ related generator (#373)
* udpate default value for cpp, remove unused imports * update cpprest template * update tizen default value * update cpp restbed default value * update qt5cpp samples * update pistache samples * regenerate restbed ignore file
This commit is contained in:
@@ -722,7 +722,6 @@ public class DefaultGenerator extends AbstractGenerator implements Generator {
|
||||
URL url = URLPathUtils.getServerURL(openAPI);
|
||||
|
||||
bundle.put("openAPI", openAPI);
|
||||
bundle.put("swagger", openAPI); // for backward compatibility
|
||||
bundle.put("basePath", basePath);
|
||||
bundle.put("basePathWithoutHost", basePathWithoutHost);
|
||||
bundle.put("scheme", URLPathUtils.getScheme(url, config));
|
||||
|
||||
@@ -20,9 +20,6 @@ package org.openapitools.codegen.languages;
|
||||
import org.openapitools.codegen.CodegenConfig;
|
||||
import org.openapitools.codegen.CodegenProperty;
|
||||
import org.openapitools.codegen.DefaultCodegen;
|
||||
import org.openapitools.codegen.utils.ModelUtils;
|
||||
import io.swagger.v3.oas.models.OpenAPI;
|
||||
import io.swagger.v3.oas.models.Operation;
|
||||
import io.swagger.v3.oas.models.media.*;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
@@ -91,7 +91,7 @@ public class Apache2ConfigCodegen extends DefaultCodegen implements CodegenConfi
|
||||
List<CodegenOperation> operationList = (List<CodegenOperation>) operations.get("operation");
|
||||
List<CodegenOperation> newOpList = new ArrayList<CodegenOperation>();
|
||||
for (CodegenOperation op : operationList) {
|
||||
String path = new String(op.path);
|
||||
String path = op.path;
|
||||
|
||||
String[] items = path.split("/", -1);
|
||||
List<String> splitPath = new ArrayList<String>();
|
||||
|
||||
@@ -62,8 +62,8 @@ public class CppPistacheServerCodegen extends AbstractCppCodegen {
|
||||
public CppPistacheServerCodegen() {
|
||||
super();
|
||||
|
||||
apiPackage = "io.swagger.server.api";
|
||||
modelPackage = "io.swagger.server.model";
|
||||
apiPackage = "org.openapitools.server.api";
|
||||
modelPackage = "org.openapitools.server.model";
|
||||
|
||||
modelTemplateFiles.put("model-header.mustache", ".h");
|
||||
modelTemplateFiles.put("model-source.mustache", ".cpp");
|
||||
@@ -374,7 +374,7 @@ public class CppPistacheServerCodegen extends AbstractCppCodegen {
|
||||
}
|
||||
|
||||
/**
|
||||
* Optional - swagger type conversion. This is used to map swagger types in
|
||||
* Optional - OpenAPI type conversion. This is used to map OpenAPI types in
|
||||
* a `Schema` into either language specific types via `typeMapping` or
|
||||
* into complex models if there is not a mapping.
|
||||
*
|
||||
|
||||
@@ -21,10 +21,7 @@ import org.apache.commons.lang3.StringUtils;
|
||||
import org.openapitools.codegen.*;
|
||||
import org.openapitools.codegen.utils.ModelUtils;
|
||||
|
||||
import io.swagger.v3.oas.models.OpenAPI;
|
||||
import io.swagger.v3.oas.models.Operation;
|
||||
import io.swagger.v3.oas.models.media.*;
|
||||
import io.swagger.v3.oas.models.responses.ApiResponse;
|
||||
import io.swagger.v3.parser.util.SchemaTypeUtil;
|
||||
|
||||
import java.io.File;
|
||||
@@ -39,14 +36,14 @@ public class CppQt5ClientCodegen extends AbstractCppCodegen implements CodegenCo
|
||||
public static final String CPP_NAMESPACE_DESC = "C++ namespace (convention: name::space::for::api).";
|
||||
public static final String OPTIONAL_PROJECT_FILE_DESC = "Generate client.pri.";
|
||||
|
||||
protected final String PREFIX = "SWG";
|
||||
protected final String PREFIX = "OAI";
|
||||
protected Set<String> foundationClasses = new HashSet<String>();
|
||||
// source folder where to write the files
|
||||
protected String sourceFolder = "client";
|
||||
protected String apiVersion = "1.0.0";
|
||||
protected Map<String, String> namespaces = new HashMap<String, String>();
|
||||
protected Set<String> systemIncludes = new HashSet<String>();
|
||||
protected String cppNamespace = "Swagger";
|
||||
protected String cppNamespace = "OpenAPI";
|
||||
protected boolean optionalProjectFileFlag = true;
|
||||
|
||||
public CppQt5ClientCodegen() {
|
||||
@@ -56,7 +53,7 @@ public class CppQt5ClientCodegen extends AbstractCppCodegen implements CodegenCo
|
||||
outputFolder = "generated-code/qt5cpp";
|
||||
|
||||
// set modelNamePrefix as default for QT5CPP
|
||||
if (modelNamePrefix == "") {
|
||||
if ("".equals(modelNamePrefix)) {
|
||||
modelNamePrefix = PREFIX;
|
||||
}
|
||||
|
||||
@@ -143,11 +140,10 @@ public class CppQt5ClientCodegen extends AbstractCppCodegen implements CodegenCo
|
||||
typeMapping.put("boolean", "bool");
|
||||
typeMapping.put("array", "QList");
|
||||
typeMapping.put("map", "QMap");
|
||||
typeMapping.put("file", "SWGHttpRequestInputFileElement");
|
||||
typeMapping.put("file", "OAIHttpRequestInputFileElement");
|
||||
typeMapping.put("object", PREFIX + "Object");
|
||||
//TODO binary should be mapped to byte array
|
||||
// mapped as "file" type for OAS 3.0
|
||||
typeMapping.put("binary", "SWGHttpRequestInputFileElement");
|
||||
typeMapping.put("binary", "OAIHttpRequestInputFileElement");
|
||||
typeMapping.put("ByteArray", "QByteArray");
|
||||
// UUID support - possible enhancement : use QUuid instead of QString.
|
||||
// beware though that Serialisation/deserialisation of QUuid does not
|
||||
@@ -157,7 +153,7 @@ public class CppQt5ClientCodegen extends AbstractCppCodegen implements CodegenCo
|
||||
|
||||
importMapping = new HashMap<String, String>();
|
||||
|
||||
importMapping.put("SWGHttpRequestInputFileElement", "#include \"" + PREFIX + "HttpRequest.h\"");
|
||||
importMapping.put("OAIHttpRequestInputFileElement", "#include \"" + PREFIX + "HttpRequest.h\"");
|
||||
|
||||
namespaces = new HashMap<String, String>();
|
||||
|
||||
@@ -354,7 +350,7 @@ public class CppQt5ClientCodegen extends AbstractCppCodegen implements CodegenCo
|
||||
}
|
||||
|
||||
/**
|
||||
* Optional - swagger type conversion. This is used to map swagger types in a `Schema` into
|
||||
* Optional - OpenAPI type conversion. This is used to map OpenAPI types in a `Schema` into
|
||||
* either language specific types via `typeMapping` or into complex models if there is not a mapping.
|
||||
*
|
||||
* @return a string value of the type or complex model for this property
|
||||
|
||||
@@ -45,7 +45,6 @@ import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
|
||||
public class CppRestClientCodegen extends AbstractCppCodegen {
|
||||
|
||||
public static final String DECLSPEC = "declspec";
|
||||
@@ -91,8 +90,8 @@ public class CppRestClientCodegen extends AbstractCppCodegen {
|
||||
public CppRestClientCodegen() {
|
||||
super();
|
||||
|
||||
apiPackage = "io.swagger.client.api";
|
||||
modelPackage = "io.swagger.client.model";
|
||||
apiPackage = "org.openapitools.client.api";
|
||||
modelPackage = "org.openapitools.client.model";
|
||||
|
||||
modelTemplateFiles.put("model-header.mustache", ".h");
|
||||
modelTemplateFiles.put("model-source.mustache", ".cpp");
|
||||
@@ -359,7 +358,7 @@ public class CppRestClientCodegen extends AbstractCppCodegen {
|
||||
}
|
||||
|
||||
/**
|
||||
* Optional - swagger type conversion. This is used to map swagger types in
|
||||
* Optional - OpenAPI type conversion. This is used to map OpenAPI types in
|
||||
* a `Schema` into either language specific types via `typeMapping` or
|
||||
* into complex models if there is not a mapping.
|
||||
*
|
||||
|
||||
@@ -26,17 +26,11 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import io.swagger.v3.parser.util.SchemaTypeUtil;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.openapitools.codegen.*;
|
||||
import org.openapitools.codegen.utils.ModelUtils;
|
||||
|
||||
import io.swagger.v3.oas.models.security.SecurityScheme;
|
||||
import io.swagger.v3.oas.models.*;
|
||||
import io.swagger.v3.oas.models.media.*;
|
||||
import io.swagger.v3.oas.models.responses.ApiResponse;
|
||||
import io.swagger.v3.oas.models.parameters.*;
|
||||
import io.swagger.v3.core.util.Yaml;
|
||||
|
||||
public class CppRestbedServerCodegen extends AbstractCppCodegen {
|
||||
|
||||
@@ -50,8 +44,8 @@ public class CppRestbedServerCodegen extends AbstractCppCodegen {
|
||||
public CppRestbedServerCodegen() {
|
||||
super();
|
||||
|
||||
apiPackage = "io.swagger.server.api";
|
||||
modelPackage = "io.swagger.server.model";
|
||||
apiPackage = "org.openapitools.server.api";
|
||||
modelPackage = "org.openapitools.server.model";
|
||||
|
||||
modelTemplateFiles.put("model-header.mustache", ".h");
|
||||
modelTemplateFiles.put("model-source.mustache", ".cpp");
|
||||
@@ -226,7 +220,7 @@ public class CppRestbedServerCodegen extends AbstractCppCodegen {
|
||||
List<CodegenOperation> operationList = (List<CodegenOperation>) operations.get("operation");
|
||||
List<CodegenOperation> newOpList = new ArrayList<CodegenOperation>();
|
||||
for (CodegenOperation op : operationList) {
|
||||
String path = new String(op.path);
|
||||
String path = op.path;
|
||||
|
||||
String[] items = path.split("/", -1);
|
||||
String resourceNameCamelCase = "";
|
||||
@@ -349,7 +343,7 @@ public class CppRestbedServerCodegen extends AbstractCppCodegen {
|
||||
}
|
||||
|
||||
/**
|
||||
* Optional - swagger type conversion. This is used to map swagger types in
|
||||
* Optional - OpenAPI type conversion. This is used to map OpenAPI types in
|
||||
* a `Schema` into either language specific types via `typeMapping` or
|
||||
* into complex models if there is not a mapping.
|
||||
*
|
||||
|
||||
@@ -24,19 +24,13 @@ import org.openapitools.codegen.DefaultCodegen;
|
||||
import org.openapitools.codegen.SupportingFile;
|
||||
import org.openapitools.codegen.utils.ModelUtils;
|
||||
|
||||
import io.swagger.v3.oas.models.OpenAPI;
|
||||
import io.swagger.v3.oas.models.Operation;
|
||||
import io.swagger.v3.oas.models.media.*;
|
||||
import io.swagger.v3.oas.models.responses.ApiResponse;
|
||||
import io.swagger.v3.parser.util.SchemaTypeUtil;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
|
||||
public class CppTizenClientCodegen extends DefaultCodegen implements CodegenConfig {
|
||||
protected static String PREFIX = "ArtikCloud";
|
||||
@@ -287,7 +281,7 @@ public class CppTizenClientCodegen extends DefaultCodegen implements CodegenConf
|
||||
@Override
|
||||
public String toOperationId(String operationId) {
|
||||
// throw exception if method name is empty
|
||||
if (operationId == "") {
|
||||
if ("".equals(operationId)) {
|
||||
throw new RuntimeException("Empty method name (operationId) not allowed");
|
||||
}
|
||||
|
||||
|
||||
@@ -23,18 +23,13 @@ import org.openapitools.codegen.CodegenConstants;
|
||||
import org.openapitools.codegen.CodegenModel;
|
||||
import org.openapitools.codegen.CodegenOperation;
|
||||
import org.openapitools.codegen.CodegenParameter;
|
||||
import org.openapitools.codegen.CodegenProperty;
|
||||
import org.openapitools.codegen.CodegenSecurity;
|
||||
import org.openapitools.codegen.CodegenType;
|
||||
import org.openapitools.codegen.DefaultCodegen;
|
||||
import org.openapitools.codegen.SupportingFile;
|
||||
import org.openapitools.codegen.utils.ModelUtils;
|
||||
|
||||
import io.swagger.v3.oas.models.OpenAPI;
|
||||
import io.swagger.v3.oas.models.Operation;
|
||||
import io.swagger.v3.oas.models.media.*;
|
||||
import io.swagger.v3.oas.models.parameters.*;
|
||||
import io.swagger.v3.parser.util.SchemaTypeUtil;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Arrays;
|
||||
@@ -373,7 +368,7 @@ public class FinchServerCodegen extends DefaultCodegen implements CodegenConfig
|
||||
private void generateScalaPath(CodegenOperation op) {
|
||||
op.httpMethod = op.httpMethod.toLowerCase();
|
||||
|
||||
String path = new String(op.path);
|
||||
String path = op.path;
|
||||
|
||||
// remove first /
|
||||
if (path.startsWith("/")) {
|
||||
|
||||
@@ -25,8 +25,6 @@ import org.openapitools.codegen.DefaultCodegen;
|
||||
import org.openapitools.codegen.SupportingFile;
|
||||
import org.openapitools.codegen.utils.ModelUtils;
|
||||
|
||||
import io.swagger.v3.oas.models.OpenAPI;
|
||||
import io.swagger.v3.oas.models.Operation;
|
||||
import io.swagger.v3.oas.models.media.*;
|
||||
|
||||
import java.io.File;
|
||||
@@ -249,7 +247,7 @@ public class PhpSilexServerCodegen extends DefaultCodegen implements CodegenConf
|
||||
Map<String, Object> operations = (Map<String, Object>) objs.get("operations");
|
||||
List<CodegenOperation> operationList = (List<CodegenOperation>) operations.get("operation");
|
||||
for (CodegenOperation op : operationList) {
|
||||
String path = new String(op.path);
|
||||
String path = op.path;
|
||||
String[] items = path.split("/", -1);
|
||||
String opsPath = "";
|
||||
int pathParamIndex = 0;
|
||||
|
||||
@@ -25,10 +25,7 @@ import org.openapitools.codegen.DefaultCodegen;
|
||||
import org.openapitools.codegen.SupportingFile;
|
||||
import org.openapitools.codegen.utils.ModelUtils;
|
||||
|
||||
import io.swagger.v3.oas.models.OpenAPI;
|
||||
import io.swagger.v3.oas.models.Operation;
|
||||
import io.swagger.v3.oas.models.media.*;
|
||||
import io.swagger.v3.core.util.Yaml;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Arrays;
|
||||
@@ -109,9 +106,7 @@ public class PhpSlimServerCodegen extends DefaultCodegen implements CodegenConfi
|
||||
typeMapping.put("array", "array");
|
||||
typeMapping.put("list", "array");
|
||||
typeMapping.put("object", "object");
|
||||
//TODO binary should be mapped to byte array
|
||||
// mapped to String as a workaround
|
||||
typeMapping.put("binary", "string");
|
||||
typeMapping.put("binary", "\\SplFileObject");
|
||||
|
||||
supportingFiles.add(new SupportingFile("README.mustache", packagePath.replace('/', File.separatorChar), "README.md"));
|
||||
supportingFiles.add(new SupportingFile("composer.json", packagePath.replace('/', File.separatorChar), "composer.json"));
|
||||
|
||||
Reference in New Issue
Block a user