Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
public class Qt5CPPGenerator extends AbstractCppCodegen implements CodegenConfig {
public static final String CPP_NAMESPACE = "cppNamespace";
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 Set<String> foundationClasses = new HashSet<String>();
Expand All @@ -35,6 +36,7 @@ public class Qt5CPPGenerator extends AbstractCppCodegen implements CodegenConfig
protected Map<String, String> namespaces = new HashMap<String, String>();
protected Set<String> systemIncludes = new HashSet<String>();
protected String cppNamespace = "Swagger";
protected boolean optionalProjectFileFlag = true;

public Qt5CPPGenerator() {
super();
Expand Down Expand Up @@ -82,6 +84,7 @@ public Qt5CPPGenerator() {

// CLI options
addOption(CPP_NAMESPACE, CPP_NAMESPACE_DESC, this.cppNamespace);
addSwitch(CodegenConstants.OPTIONAL_PROJECT_FILE, OPTIONAL_PROJECT_FILE_DESC, this.optionalProjectFileFlag);

/*
* Additional Properties. These values can be passed to the templates and
Expand Down Expand Up @@ -114,6 +117,9 @@ public Qt5CPPGenerator() {
supportingFiles.add(new SupportingFile("HttpRequest.cpp.mustache", sourceFolder, PREFIX + "HttpRequest.cpp"));
supportingFiles.add(new SupportingFile("modelFactory.mustache", sourceFolder, PREFIX + "ModelFactory.h"));
supportingFiles.add(new SupportingFile("object.mustache", sourceFolder, PREFIX + "Object.h"));
if (optionalProjectFileFlag) {
supportingFiles.add(new SupportingFile("Project.mustache", "", "client.pri"));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you are missing the mustache file

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also check the processOpts function

}

super.typeMapping = new HashMap<String, String>();

Expand Down Expand Up @@ -160,6 +166,14 @@ protected void addOption(String key, String description, String defaultValue) {
cliOptions.add(option);
}

protected void addSwitch(String key, String description, Boolean defaultValue) {
CliOption option = CliOption.newBoolean(key, description);
if (defaultValue != null)
option.defaultValue(defaultValue.toString());
cliOptions.add(option);
}


@Override
public void processOpts() {
super.processOpts();
Expand Down Expand Up @@ -425,4 +439,8 @@ public String escapeQuotationMark(String input) {
public String escapeUnsafeCharacters(String input) {
return input.replace("*/", "*_/").replace("/*", "/_*");
}

public void setOptionalProjectFileFlag(boolean flag) {
this.optionalProjectFileFlag = flag;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ public class Qt5CPPOptionsProvider implements OptionsProvider {
public static final String ENSURE_UNIQUE_PARAMS_VALUE = "true";
public static final String ALLOW_UNICODE_IDENTIFIERS_VALUE = "false";
public static final String CPP_NAMESPACE_VALUE = "Swagger";
public static final String OPTIONAL_PROJECT_FILE_VALUE = "true";


@Override
Expand All @@ -26,6 +27,7 @@ public Map<String, String> createOptions() {
.put(CodegenConstants.ENSURE_UNIQUE_PARAMS, ENSURE_UNIQUE_PARAMS_VALUE)
.put(CodegenConstants.ALLOW_UNICODE_IDENTIFIERS, ALLOW_UNICODE_IDENTIFIERS_VALUE)
.put(Qt5CPPGenerator.CPP_NAMESPACE, CPP_NAMESPACE_VALUE)
.put(CodegenConstants.OPTIONAL_PROJECT_FILE, OPTIONAL_PROJECT_FILE_VALUE)
.build();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ protected void setExpectations() {
new Expectations(clientCodegen) {{
clientCodegen.setSortParamsByRequiredFlag(Boolean.valueOf(Qt5CPPOptionsProvider.SORT_PARAMS_VALUE));
times = 1;
clientCodegen.setOptionalProjectFileFlag(true);
times = 1;
}};
}
}