forked from loafle/openapi-generator-original
[cpp-qt-client] New makeOperationsVirtual
option (#19613)
* Implementation of new `makeOperationsVirtual` option * Make new parameter `true` by default * Fix default value set and regenerate samples
This commit is contained in:
parent
78f2f7010f
commit
7d8eacc197
@ -26,6 +26,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|
||||
|ensureUniqueParams|Whether to ensure parameter names are unique in an operation (rename parameters that are not).| |true|
|
||||
|enumUnknownDefaultCase|If the server adds new enum cases, that are unknown by an old spec/client, the client will fail to parse the network response.With this option enabled, each enum will have a new case, 'unknown_default_open_api', so that when the server sends an enum case that is not known by the client/spec, they can safely fallback to this case.|<dl><dt>**false**</dt><dd>No changes to the enum's are made, this is the default option.</dd><dt>**true**</dt><dd>With this option enabled, each enum will have a new case, 'unknown_default_open_api', so that when the enum case sent by the server is not known by the client/spec, can safely be decoded to this case.</dd></dl>|false|
|
||||
|legacyDiscriminatorBehavior|Set to false for generators with better support for discriminators. (Python, Java, Go, PowerShell, C# have this enabled by default).|<dl><dt>**true**</dt><dd>The mapping in the discriminator includes descendent schemas that allOf inherit from self and the discriminator mapping schemas in the OAS document.</dd><dt>**false**</dt><dd>The mapping in the discriminator includes any descendent schemas that allOf inherit from self, any oneOf schemas, any anyOf schemas, any x-discriminator-values, and the discriminator mapping schemas in the OAS document AND Codegen validates that oneOf and anyOf schemas contain the required discriminator and throws an error if the discriminator is missing.</dd></dl>|true|
|
||||
|makeOperationsVirtual|Make all operations methods virtual. This makes it easy to mock the generated API class for testing purposes.| |true|
|
||||
|modelNamePrefix|Prefix that will be prepended to all model names.| |OAI|
|
||||
|optionalProjectFile|Generate client.pri.| |true|
|
||||
|packageName|C++ package (library) name.| |QtOpenAPIClient|
|
||||
|
@ -36,11 +36,16 @@ import static org.openapitools.codegen.utils.StringUtils.*;
|
||||
public class CppQtClientCodegen extends CppQtAbstractCodegen implements CodegenConfig {
|
||||
public static final String OPTIONAL_PROJECT_FILE_DESC = "Generate client.pri.";
|
||||
public static final String DEFAULT_PACKAGE_NAME = "QtOpenAPIClient";
|
||||
public static final String MAKE_OPERATIONS_VIRTUAL_NAME = "makeOperationsVirtual";
|
||||
public static final String MAKE_OPERATIONS_VIRTUAL_DESC =
|
||||
"Make all operations methods virtual. " +
|
||||
"This makes it easy to mock the generated API class for testing purposes.";
|
||||
protected String packageName = "";
|
||||
// source folder where to write the files
|
||||
protected String sourceFolder = "client";
|
||||
@Setter protected boolean optionalProjectFileFlag = true;
|
||||
@Setter protected boolean addDownloadProgress = false;
|
||||
@Setter protected boolean makeOperationsVirtual = true;
|
||||
|
||||
public CppQtClientCodegen() {
|
||||
super();
|
||||
@ -100,6 +105,7 @@ public class CppQtClientCodegen extends CppQtAbstractCodegen implements CodegenC
|
||||
addOption(CodegenConstants.PACKAGE_NAME, "C++ package (library) name.", DEFAULT_PACKAGE_NAME);
|
||||
addSwitch(CodegenConstants.OPTIONAL_PROJECT_FILE, OPTIONAL_PROJECT_FILE_DESC, this.optionalProjectFileFlag);
|
||||
addSwitch("addDownloadProgress", "Add support for Qt download progress", this.addDownloadProgress);
|
||||
addSwitch(MAKE_OPERATIONS_VIRTUAL_NAME, MAKE_OPERATIONS_VIRTUAL_DESC, this.makeOperationsVirtual);
|
||||
|
||||
supportingFiles.add(new SupportingFile("helpers-header.mustache", sourceFolder, PREFIX + "Helpers.h"));
|
||||
supportingFiles.add(new SupportingFile("helpers-body.mustache", sourceFolder, PREFIX + "Helpers.cpp"));
|
||||
@ -140,6 +146,12 @@ public class CppQtClientCodegen extends CppQtAbstractCodegen implements CodegenC
|
||||
additionalProperties.put(CodegenConstants.OPTIONAL_PROJECT_FILE, optionalProjectFileFlag);
|
||||
}
|
||||
|
||||
if (additionalProperties.containsKey(MAKE_OPERATIONS_VIRTUAL_NAME)) {
|
||||
setMakeOperationsVirtual(convertPropertyToBooleanAndWriteBack(MAKE_OPERATIONS_VIRTUAL_NAME));
|
||||
} else {
|
||||
additionalProperties.put(MAKE_OPERATIONS_VIRTUAL_NAME, makeOperationsVirtual);
|
||||
}
|
||||
|
||||
additionalProperties.put(CodegenConstants.PACKAGE_NAME, packageName);
|
||||
|
||||
if (additionalProperties.containsKey("modelNamePrefix")) {
|
||||
|
@ -58,7 +58,7 @@ public:
|
||||
{{/required}}
|
||||
{{/allParams}}
|
||||
*/{{/hasParams}}
|
||||
{{#isDeprecated}}Q_DECL_DEPRECATED {{/isDeprecated}}void {{nickname}}({{#allParams}}{{#required}}const {{{dataType}}} &{{/required}}{{^required}}const ::{{cppNamespace}}::OptionalParam<{{{dataType}}}> &{{/required}}{{paramName}}{{^required}} = ::{{cppNamespace}}::OptionalParam<{{{dataType}}}>(){{/required}}{{^-last}}, {{/-last}}{{/allParams}});
|
||||
{{#isDeprecated}}Q_DECL_DEPRECATED {{/isDeprecated}}{{#makeOperationsVirtual}}virtual {{/makeOperationsVirtual}}void {{nickname}}({{#allParams}}{{#required}}const {{{dataType}}} &{{/required}}{{^required}}const ::{{cppNamespace}}::OptionalParam<{{{dataType}}}> &{{/required}}{{paramName}}{{^required}} = ::{{cppNamespace}}::OptionalParam<{{{dataType}}}>(){{/required}}{{^-last}}, {{/-last}}{{/allParams}});
|
||||
{{/operation}}{{/operations}}
|
||||
|
||||
private:
|
||||
|
@ -62,50 +62,50 @@ public:
|
||||
/**
|
||||
* @param[in] pfx_pet PFXPet [required]
|
||||
*/
|
||||
void addPet(const PFXPet &pfx_pet);
|
||||
virtual void addPet(const PFXPet &pfx_pet);
|
||||
|
||||
|
||||
void allPets();
|
||||
virtual void allPets();
|
||||
|
||||
/**
|
||||
* @param[in] pet_id qint64 [required]
|
||||
* @param[in] api_key QString [optional]
|
||||
*/
|
||||
void deletePet(const qint64 &pet_id, const ::test_namespace::OptionalParam<QString> &api_key = ::test_namespace::OptionalParam<QString>());
|
||||
virtual void deletePet(const qint64 &pet_id, const ::test_namespace::OptionalParam<QString> &api_key = ::test_namespace::OptionalParam<QString>());
|
||||
|
||||
/**
|
||||
* @param[in] status QList<QString> [required]
|
||||
*/
|
||||
void findPetsByStatus(const QList<QString> &status);
|
||||
virtual void findPetsByStatus(const QList<QString> &status);
|
||||
|
||||
/**
|
||||
* @param[in] tags QList<QString> [required]
|
||||
*/
|
||||
Q_DECL_DEPRECATED void findPetsByTags(const QList<QString> &tags);
|
||||
Q_DECL_DEPRECATED virtual void findPetsByTags(const QList<QString> &tags);
|
||||
|
||||
/**
|
||||
* @param[in] pet_id qint64 [required]
|
||||
*/
|
||||
void getPetById(const qint64 &pet_id);
|
||||
virtual void getPetById(const qint64 &pet_id);
|
||||
|
||||
/**
|
||||
* @param[in] pfx_pet PFXPet [required]
|
||||
*/
|
||||
void updatePet(const PFXPet &pfx_pet);
|
||||
virtual void updatePet(const PFXPet &pfx_pet);
|
||||
|
||||
/**
|
||||
* @param[in] pet_id qint64 [required]
|
||||
* @param[in] name QString [optional]
|
||||
* @param[in] status QString [optional]
|
||||
*/
|
||||
void updatePetWithForm(const qint64 &pet_id, const ::test_namespace::OptionalParam<QString> &name = ::test_namespace::OptionalParam<QString>(), const ::test_namespace::OptionalParam<QString> &status = ::test_namespace::OptionalParam<QString>());
|
||||
virtual void updatePetWithForm(const qint64 &pet_id, const ::test_namespace::OptionalParam<QString> &name = ::test_namespace::OptionalParam<QString>(), const ::test_namespace::OptionalParam<QString> &status = ::test_namespace::OptionalParam<QString>());
|
||||
|
||||
/**
|
||||
* @param[in] pet_id qint64 [required]
|
||||
* @param[in] additional_metadata QString [optional]
|
||||
* @param[in] file PFXHttpFileElement [optional]
|
||||
*/
|
||||
void uploadFile(const qint64 &pet_id, const ::test_namespace::OptionalParam<QString> &additional_metadata = ::test_namespace::OptionalParam<QString>(), const ::test_namespace::OptionalParam<PFXHttpFileElement> &file = ::test_namespace::OptionalParam<PFXHttpFileElement>());
|
||||
virtual void uploadFile(const qint64 &pet_id, const ::test_namespace::OptionalParam<QString> &additional_metadata = ::test_namespace::OptionalParam<QString>(), const ::test_namespace::OptionalParam<PFXHttpFileElement> &file = ::test_namespace::OptionalParam<PFXHttpFileElement>());
|
||||
|
||||
|
||||
private:
|
||||
|
@ -58,12 +58,12 @@ public:
|
||||
/**
|
||||
* @param[in] body qint32 [optional]
|
||||
*/
|
||||
void primitivesIntegerPost(const ::test_namespace::OptionalParam<qint32> &body = ::test_namespace::OptionalParam<qint32>());
|
||||
virtual void primitivesIntegerPost(const ::test_namespace::OptionalParam<qint32> &body = ::test_namespace::OptionalParam<qint32>());
|
||||
|
||||
/**
|
||||
* @param[in] body double [optional]
|
||||
*/
|
||||
void primitivesNumberPut(const ::test_namespace::OptionalParam<double> &body = ::test_namespace::OptionalParam<double>());
|
||||
virtual void primitivesNumberPut(const ::test_namespace::OptionalParam<double> &body = ::test_namespace::OptionalParam<double>());
|
||||
|
||||
|
||||
private:
|
||||
|
@ -60,20 +60,20 @@ public:
|
||||
/**
|
||||
* @param[in] order_id QString [required]
|
||||
*/
|
||||
void deleteOrder(const QString &order_id);
|
||||
virtual void deleteOrder(const QString &order_id);
|
||||
|
||||
|
||||
void getInventory();
|
||||
virtual void getInventory();
|
||||
|
||||
/**
|
||||
* @param[in] order_id qint64 [required]
|
||||
*/
|
||||
void getOrderById(const qint64 &order_id);
|
||||
virtual void getOrderById(const qint64 &order_id);
|
||||
|
||||
/**
|
||||
* @param[in] pfx_order PFXOrder [required]
|
||||
*/
|
||||
void placeOrder(const PFXOrder &pfx_order);
|
||||
virtual void placeOrder(const PFXOrder &pfx_order);
|
||||
|
||||
|
||||
private:
|
||||
|
@ -59,42 +59,42 @@ public:
|
||||
/**
|
||||
* @param[in] pfx_user PFXUser [required]
|
||||
*/
|
||||
void createUser(const PFXUser &pfx_user);
|
||||
virtual void createUser(const PFXUser &pfx_user);
|
||||
|
||||
/**
|
||||
* @param[in] pfx_user QList<PFXUser> [required]
|
||||
*/
|
||||
void createUsersWithArrayInput(const QList<PFXUser> &pfx_user);
|
||||
virtual void createUsersWithArrayInput(const QList<PFXUser> &pfx_user);
|
||||
|
||||
/**
|
||||
* @param[in] pfx_user QList<PFXUser> [required]
|
||||
*/
|
||||
void createUsersWithListInput(const QList<PFXUser> &pfx_user);
|
||||
virtual void createUsersWithListInput(const QList<PFXUser> &pfx_user);
|
||||
|
||||
/**
|
||||
* @param[in] username QString [required]
|
||||
*/
|
||||
void deleteUser(const QString &username);
|
||||
virtual void deleteUser(const QString &username);
|
||||
|
||||
/**
|
||||
* @param[in] username QString [required]
|
||||
*/
|
||||
void getUserByName(const QString &username);
|
||||
virtual void getUserByName(const QString &username);
|
||||
|
||||
/**
|
||||
* @param[in] username QString [required]
|
||||
* @param[in] password QString [required]
|
||||
*/
|
||||
void loginUser(const QString &username, const QString &password);
|
||||
virtual void loginUser(const QString &username, const QString &password);
|
||||
|
||||
|
||||
void logoutUser();
|
||||
virtual void logoutUser();
|
||||
|
||||
/**
|
||||
* @param[in] username QString [required]
|
||||
* @param[in] pfx_user PFXUser [required]
|
||||
*/
|
||||
void updateUser(const QString &username, const PFXUser &pfx_user);
|
||||
virtual void updateUser(const QString &username, const PFXUser &pfx_user);
|
||||
|
||||
|
||||
private:
|
||||
|
@ -62,50 +62,50 @@ public:
|
||||
/**
|
||||
* @param[in] pfx_pet PFXPet [required]
|
||||
*/
|
||||
void addPet(const PFXPet &pfx_pet);
|
||||
virtual void addPet(const PFXPet &pfx_pet);
|
||||
|
||||
|
||||
void allPets();
|
||||
virtual void allPets();
|
||||
|
||||
/**
|
||||
* @param[in] pet_id qint64 [required]
|
||||
* @param[in] api_key QString [optional]
|
||||
*/
|
||||
void deletePet(const qint64 &pet_id, const ::test_namespace::OptionalParam<QString> &api_key = ::test_namespace::OptionalParam<QString>());
|
||||
virtual void deletePet(const qint64 &pet_id, const ::test_namespace::OptionalParam<QString> &api_key = ::test_namespace::OptionalParam<QString>());
|
||||
|
||||
/**
|
||||
* @param[in] status QList<QString> [required]
|
||||
*/
|
||||
void findPetsByStatus(const QList<QString> &status);
|
||||
virtual void findPetsByStatus(const QList<QString> &status);
|
||||
|
||||
/**
|
||||
* @param[in] tags QList<QString> [required]
|
||||
*/
|
||||
Q_DECL_DEPRECATED void findPetsByTags(const QList<QString> &tags);
|
||||
Q_DECL_DEPRECATED virtual void findPetsByTags(const QList<QString> &tags);
|
||||
|
||||
/**
|
||||
* @param[in] pet_id qint64 [required]
|
||||
*/
|
||||
void getPetById(const qint64 &pet_id);
|
||||
virtual void getPetById(const qint64 &pet_id);
|
||||
|
||||
/**
|
||||
* @param[in] pfx_pet PFXPet [required]
|
||||
*/
|
||||
void updatePet(const PFXPet &pfx_pet);
|
||||
virtual void updatePet(const PFXPet &pfx_pet);
|
||||
|
||||
/**
|
||||
* @param[in] pet_id qint64 [required]
|
||||
* @param[in] name QString [optional]
|
||||
* @param[in] status QString [optional]
|
||||
*/
|
||||
void updatePetWithForm(const qint64 &pet_id, const ::test_namespace::OptionalParam<QString> &name = ::test_namespace::OptionalParam<QString>(), const ::test_namespace::OptionalParam<QString> &status = ::test_namespace::OptionalParam<QString>());
|
||||
virtual void updatePetWithForm(const qint64 &pet_id, const ::test_namespace::OptionalParam<QString> &name = ::test_namespace::OptionalParam<QString>(), const ::test_namespace::OptionalParam<QString> &status = ::test_namespace::OptionalParam<QString>());
|
||||
|
||||
/**
|
||||
* @param[in] pet_id qint64 [required]
|
||||
* @param[in] additional_metadata QString [optional]
|
||||
* @param[in] file PFXHttpFileElement [optional]
|
||||
*/
|
||||
void uploadFile(const qint64 &pet_id, const ::test_namespace::OptionalParam<QString> &additional_metadata = ::test_namespace::OptionalParam<QString>(), const ::test_namespace::OptionalParam<PFXHttpFileElement> &file = ::test_namespace::OptionalParam<PFXHttpFileElement>());
|
||||
virtual void uploadFile(const qint64 &pet_id, const ::test_namespace::OptionalParam<QString> &additional_metadata = ::test_namespace::OptionalParam<QString>(), const ::test_namespace::OptionalParam<PFXHttpFileElement> &file = ::test_namespace::OptionalParam<PFXHttpFileElement>());
|
||||
|
||||
|
||||
private:
|
||||
|
@ -58,12 +58,12 @@ public:
|
||||
/**
|
||||
* @param[in] body qint32 [optional]
|
||||
*/
|
||||
void primitivesIntegerPost(const ::test_namespace::OptionalParam<qint32> &body = ::test_namespace::OptionalParam<qint32>());
|
||||
virtual void primitivesIntegerPost(const ::test_namespace::OptionalParam<qint32> &body = ::test_namespace::OptionalParam<qint32>());
|
||||
|
||||
/**
|
||||
* @param[in] body double [optional]
|
||||
*/
|
||||
void primitivesNumberPut(const ::test_namespace::OptionalParam<double> &body = ::test_namespace::OptionalParam<double>());
|
||||
virtual void primitivesNumberPut(const ::test_namespace::OptionalParam<double> &body = ::test_namespace::OptionalParam<double>());
|
||||
|
||||
|
||||
private:
|
||||
|
@ -60,20 +60,20 @@ public:
|
||||
/**
|
||||
* @param[in] order_id QString [required]
|
||||
*/
|
||||
void deleteOrder(const QString &order_id);
|
||||
virtual void deleteOrder(const QString &order_id);
|
||||
|
||||
|
||||
void getInventory();
|
||||
virtual void getInventory();
|
||||
|
||||
/**
|
||||
* @param[in] order_id qint64 [required]
|
||||
*/
|
||||
void getOrderById(const qint64 &order_id);
|
||||
virtual void getOrderById(const qint64 &order_id);
|
||||
|
||||
/**
|
||||
* @param[in] pfx_order PFXOrder [required]
|
||||
*/
|
||||
void placeOrder(const PFXOrder &pfx_order);
|
||||
virtual void placeOrder(const PFXOrder &pfx_order);
|
||||
|
||||
|
||||
private:
|
||||
|
@ -59,42 +59,42 @@ public:
|
||||
/**
|
||||
* @param[in] pfx_user PFXUser [required]
|
||||
*/
|
||||
void createUser(const PFXUser &pfx_user);
|
||||
virtual void createUser(const PFXUser &pfx_user);
|
||||
|
||||
/**
|
||||
* @param[in] pfx_user QList<PFXUser> [required]
|
||||
*/
|
||||
void createUsersWithArrayInput(const QList<PFXUser> &pfx_user);
|
||||
virtual void createUsersWithArrayInput(const QList<PFXUser> &pfx_user);
|
||||
|
||||
/**
|
||||
* @param[in] pfx_user QList<PFXUser> [required]
|
||||
*/
|
||||
void createUsersWithListInput(const QList<PFXUser> &pfx_user);
|
||||
virtual void createUsersWithListInput(const QList<PFXUser> &pfx_user);
|
||||
|
||||
/**
|
||||
* @param[in] username QString [required]
|
||||
*/
|
||||
void deleteUser(const QString &username);
|
||||
virtual void deleteUser(const QString &username);
|
||||
|
||||
/**
|
||||
* @param[in] username QString [required]
|
||||
*/
|
||||
void getUserByName(const QString &username);
|
||||
virtual void getUserByName(const QString &username);
|
||||
|
||||
/**
|
||||
* @param[in] username QString [required]
|
||||
* @param[in] password QString [required]
|
||||
*/
|
||||
void loginUser(const QString &username, const QString &password);
|
||||
virtual void loginUser(const QString &username, const QString &password);
|
||||
|
||||
|
||||
void logoutUser();
|
||||
virtual void logoutUser();
|
||||
|
||||
/**
|
||||
* @param[in] username QString [required]
|
||||
* @param[in] pfx_user PFXUser [required]
|
||||
*/
|
||||
void updateUser(const QString &username, const PFXUser &pfx_user);
|
||||
virtual void updateUser(const QString &username, const PFXUser &pfx_user);
|
||||
|
||||
|
||||
private:
|
||||
|
Loading…
x
Reference in New Issue
Block a user