Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
/*
* Copyright 2018 OpenAPI-Generator Contributors (https://openapi-generator.tech)
* Copyright 2018 SmartBear Software
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.openapitools.codegen.languages;
import com.google.common.collect.ArrayListMultimap;
import com.google.common.collect.Multimap;
import io.swagger.v3.oas.models.Operation;
import io.swagger.v3.oas.models.media.Schema;
import io.swagger.v3.oas.models.responses.ApiResponse;
import io.swagger.v3.oas.models.servers.Server;
import org.apache.commons.lang3.StringUtils;
import org.openapitools.codegen.*;
import org.openapitools.codegen.meta.features.*;
import org.openapitools.codegen.model.ModelMap;
import org.openapitools.codegen.model.ModelsMap;
import org.openapitools.codegen.model.OperationMap;
import org.openapitools.codegen.model.OperationsMap;
import org.openapitools.codegen.utils.ModelUtils;
import java.util.*;
import static com.google.common.base.Strings.isNullOrEmpty;
public class CppRestSdkClientCodegen extends AbstractCppCodegen {
public static final String DECLSPEC = "declspec";
public static final String DEFAULT_INCLUDE = "defaultInclude";
public static final String GENERATE_GMOCKS_FOR_APIS = "generateGMocksForApis";
public static final String DEFAULT_PACKAGE_NAME = "CppRestOpenAPIClient";
protected String packageName = "";
protected String packageVersion = "1.0.0";
protected String declspec = "";
protected String defaultInclude = "";
protected String apiDirName = "api";
protected String modelDirName = "model";
private final Set parentModels = new HashSet<>();
private final Multimap childrenByParent = ArrayListMultimap.create();
/**
* Configures the type of generator.
*
* @return the CodegenType for this generator
* @see org.openapitools.codegen.CodegenType
*/
@Override
public CodegenType getTag() {
return CodegenType.CLIENT;
}
/**
* Configures a friendly name for the generator. This will be used by the
* generator to select the library with the -g flag.
*
* @return the friendly name for the generator
*/
@Override
public String getName() {
return "cpp-restsdk";
}
/**
* Returns human-friendly help for the generator. Provide the consumer with
* help tips, parameters here
*
* @return A string value for the help message
*/
@Override
public String getHelp() {
return "Generates a C++ API client with C++ REST SDK (https://github.com/Microsoft/cpprestsdk).";
}
public CppRestSdkClientCodegen() {
super();
// TODO: cpp-restsdk maintainer review
modifyFeatureSet(features -> features
.includeDocumentationFeatures(DocumentationFeature.Readme)
.securityFeatures(EnumSet.of(
SecurityFeature.BasicAuth,
SecurityFeature.OAuth2_Implicit,
SecurityFeature.ApiKey
))
.excludeGlobalFeatures(
GlobalFeature.XMLStructureDefinitions,
GlobalFeature.Callbacks,
GlobalFeature.LinkObjects,
GlobalFeature.ParameterStyling,
GlobalFeature.MultiServer
)
.includeSchemaSupportFeatures(
SchemaSupportFeature.Polymorphism,
SchemaSupportFeature.oneOf
)
.excludeParameterFeatures(
ParameterFeature.Cookie
)
.includeDataTypeFeatures(
DataTypeFeature.AnyType)
);
apiPackage = "org.openapitools.client.api";
modelPackage = "org.openapitools.client.model";
modelTemplateFiles.put("model-header.mustache", ".h");
modelTemplateFiles.put("model-source.mustache", ".cpp");
apiTemplateFiles.put("api-header.mustache", ".h");
apiTemplateFiles.put("api-source.mustache", ".cpp");
embeddedTemplateDir = templateDir = "cpp-rest-sdk-client";
cliOptions.clear();
// CLI options
addOption(CodegenConstants.PACKAGE_NAME, "C++ package (library) name.", DEFAULT_PACKAGE_NAME);
addOption(CodegenConstants.MODEL_PACKAGE, "C++ namespace for models (convention: name.space.model).",
this.modelPackage);
addOption(CodegenConstants.API_PACKAGE, "C++ namespace for apis (convention: name.space.api).",
this.apiPackage);
addOption(CodegenConstants.PACKAGE_VERSION, "C++ package version.", this.packageVersion);
addOption(DECLSPEC, "C++ preprocessor to place before the class name for handling dllexport/dllimport.",
this.declspec);
addOption(DEFAULT_INCLUDE,
"The default include statement that should be placed in all headers for including things like the declspec (convention: #include \"Commons.h\" ",
this.defaultInclude);
addOption(GENERATE_GMOCKS_FOR_APIS,
"Generate Google Mock classes for APIs.",
null);
addOption(RESERVED_WORD_PREFIX_OPTION,
RESERVED_WORD_PREFIX_DESC,
this.reservedWordPrefix);
addOption(VARIABLE_NAME_FIRST_CHARACTER_UPPERCASE_OPTION,
VARIABLE_NAME_FIRST_CHARACTER_UPPERCASE_DESC,
Boolean.toString(this.variableNameFirstCharacterUppercase));
languageSpecificPrimitives = new HashSet<>(
Arrays.asList("int", "char", "bool", "long", "float", "double", "int32_t", "int64_t"));
typeMapping = new HashMap<>();
typeMapping.put("date", "utility::datetime");
typeMapping.put("DateTime", "utility::datetime");
typeMapping.put("string", "utility::string_t");
typeMapping.put("integer", "int32_t");
typeMapping.put("long", "int64_t");
typeMapping.put("boolean", "bool");
typeMapping.put("array", "std::vector");
typeMapping.put("set", "std::set");
typeMapping.put("map", "std::map");
typeMapping.put("file", "HttpContent");
typeMapping.put("object", "Object");
typeMapping.put("binary", "HttpContent");
typeMapping.put("number", "double");
typeMapping.put("UUID", "utility::string_t");
typeMapping.put("URI", "utility::string_t");
typeMapping.put("ByteArray", "utility::string_t");
super.importMapping = new HashMap<>();
importMapping.put("std::vector", "#include ");
importMapping.put("std::map", "#include