forked from loafle/openapi-generator-original
[cpp-pistache] add the option to fetch dependencies (#495)
* Add the Possibility to fetch dependencies needed by the generated code * Fix typo * Make External Libraries default to false * Add parameter string to the javadoc comment
This commit is contained in:
@@ -27,6 +27,6 @@ fi
|
||||
|
||||
# if you've executed sbt assembly previously it will use that instead.
|
||||
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
|
||||
ags="generate -g cpp-pistache-server -i modules/openapi-generator/src/test/resources/2_0/petstore.yaml -o samples/server/petstore/cpp-pistache $@"
|
||||
ags="generate -g cpp-pistache-server -t modules/openapi-generator/src/main/resources/cpp-pistache-server -i modules/openapi-generator/src/test/resources/2_0/petstore.yaml -o samples/server/petstore/cpp-pistache $@"
|
||||
|
||||
java $JAVA_OPTS -jar $executable $ags
|
||||
|
||||
@@ -27,6 +27,6 @@ fi
|
||||
|
||||
# if you've executed sbt assembly previously it will use that instead.
|
||||
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
|
||||
ags="generate -g cpp-pistache-server -i modules/openapi-generator/src/test/resources/3_0/petstore.yaml -o samples/server/petstore/cpp-pistache $@"
|
||||
ags="generate -g cpp-pistache-server -t modules/openapi-generator/src/main/resources/cpp-pistache-server -i modules/openapi-generator/src/test/resources/3_0/petstore.yaml -o samples/server/petstore/cpp-pistache $@"
|
||||
|
||||
java $JAVA_OPTS -jar $executable $ags
|
||||
|
||||
@@ -43,7 +43,9 @@ import java.util.Set;
|
||||
|
||||
public class CppPistacheServerCodegen extends AbstractCppCodegen {
|
||||
protected String implFolder = "impl";
|
||||
|
||||
protected boolean isAddExternalLibs = false;
|
||||
public static final String OPTIONAL_EXTERNAL_LIB = "addExternalLibs";
|
||||
public static final String OPTIONAL_EXTERNAL_LIB_DESC = "Add the Possibility to fetch and compile external Libraries needed by this Framework.";
|
||||
@Override
|
||||
public CodegenType getTag() {
|
||||
return CodegenType.SERVER;
|
||||
@@ -77,6 +79,7 @@ public class CppPistacheServerCodegen extends AbstractCppCodegen {
|
||||
embeddedTemplateDir = templateDir = "cpp-pistache-server";
|
||||
|
||||
cliOptions.clear();
|
||||
addSwitch(OPTIONAL_EXTERNAL_LIB, OPTIONAL_EXTERNAL_LIB_DESC, this.isAddExternalLibs);
|
||||
|
||||
reservedWords = new HashSet<>();
|
||||
|
||||
@@ -118,7 +121,12 @@ public class CppPistacheServerCodegen extends AbstractCppCodegen {
|
||||
additionalProperties.put("modelNamespaceDeclarations", modelPackage.split("\\."));
|
||||
additionalProperties.put("modelNamespace", modelPackage.replaceAll("\\.", "::"));
|
||||
additionalProperties.put("apiNamespaceDeclarations", apiPackage.split("\\."));
|
||||
additionalProperties.put("apiNamespace", apiPackage.replaceAll("\\.", "::"));
|
||||
additionalProperties.put("apiNamespace", apiPackage.replaceAll("\\.", "::"));
|
||||
if (additionalProperties.containsKey(OPTIONAL_EXTERNAL_LIB)) {
|
||||
setAddExternalLibs(convertPropertyToBooleanAndWriteBack(OPTIONAL_EXTERNAL_LIB));
|
||||
} else {
|
||||
additionalProperties.put(OPTIONAL_EXTERNAL_LIB, isAddExternalLibs);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -410,9 +418,17 @@ public class CppPistacheServerCodegen extends AbstractCppCodegen {
|
||||
public String escapeUnsafeCharacters(String input) {
|
||||
return input.replace("*/", "*_/").replace("/*", "/_*");
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String getTypeDeclaration(String str) {
|
||||
return toModelName(str);
|
||||
}
|
||||
|
||||
/**
|
||||
* Specify whether external libraries will be added during the generation
|
||||
* @param value the value to be set
|
||||
*/
|
||||
public void setAddExternalLibs(boolean value){
|
||||
isAddExternalLibs = value;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,6 +4,26 @@ project(server)
|
||||
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -pg -g3" )
|
||||
|
||||
{{#addExternalLibs}}
|
||||
include(ExternalProject)
|
||||
|
||||
set(EXTERNAL_INSTALL_LOCATION ${CMAKE_CURRENT_SOURCE_DIR}/external)
|
||||
|
||||
ExternalProject_Add(PISTACHE
|
||||
GIT_REPOSITORY https://github.com/oktal/pistache.git
|
||||
CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${EXTERNAL_INSTALL_LOCATION}
|
||||
)
|
||||
|
||||
ExternalProject_Add(NLOHMANN
|
||||
GIT_REPOSITORY https://github.com/nlohmann/json.git
|
||||
CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${EXTERNAL_INSTALL_LOCATION}
|
||||
|
||||
)
|
||||
include_directories(${EXTERNAL_INSTALL_LOCATION}/include)
|
||||
include_directories(${EXTERNAL_INSTALL_LOCATION}/include/nlohmann)
|
||||
link_directories(${EXTERNAL_INSTALL_LOCATION}/lib)
|
||||
{{/addExternalLibs}}
|
||||
|
||||
link_directories(/usr/local/lib/)
|
||||
|
||||
aux_source_directory(model MODEL_SOURCES)
|
||||
|
||||
@@ -4,6 +4,7 @@ project(server)
|
||||
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -pg -g3" )
|
||||
|
||||
|
||||
link_directories(/usr/local/lib/)
|
||||
|
||||
aux_source_directory(model MODEL_SOURCES)
|
||||
|
||||
Reference in New Issue
Block a user