-
-
Notifications
You must be signed in to change notification settings - Fork 6.7k
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
[cpp-restsdk] Generate mockable APIs #595
Merged
wing328
merged 9 commits into
OpenAPITools:master
from
zooxco:daniel/gmock_apis_master_rebase
Jul 24, 2018
Merged
Changes from 3 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
054c5c6
Port GMock feature from NativeInstruments
Peaches491 d2eb7b6
Update petstore for Mockable APIs
Peaches491 4fdbc73
Fix shared_ptr in templates for File params
Peaches491 0fcee54
Add guards in templates for GMock APIs
Peaches491 37220f8
Regenerate samples without GMocks
Peaches491 9f4b0d1
Add useful constructors for GMock APIs
Peaches491 714de1c
Add constructors to API header interface
Peaches491 961e342
Update samples with explicit monadic constructors
Peaches491 6b20a5a
Add default implementations for destructors
Peaches491 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 35 additions & 0 deletions
35
modules/openapi-generator/src/main/resources/cpp-rest-sdk-client/api-gmock.mustache
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
{{>licenseInfo}} | ||
{{#operations}} | ||
#ifndef {{apiHeaderGuardPrefix}}_{{classname}}GMock_H_ | ||
#define {{apiHeaderGuardPrefix}}_{{classname}}GMock_H_ | ||
|
||
#include <gmock/gmock.h> | ||
|
||
#include "{{classname}}.h" | ||
|
||
{{#apiNamespaceDeclarations}} | ||
namespace {{this}} { | ||
{{/apiNamespaceDeclarations}} | ||
|
||
using namespace {{modelNamespace}}; | ||
|
||
|
||
class {{declspec}} {{classname}}Mock : public I{{classname}} | ||
{ | ||
public: | ||
{{#operation}} | ||
MOCK_METHOD{{allParams.size}}( {{operationId}}, pplx::task<{{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}void{{/returnType}}> ( | ||
{{#allParams}} | ||
{{^required}}boost::optional<{{/required}}{{#isFile}}std::shared_ptr<{{/isFile}}{{{dataType}}}{{#isFile}}>{{/isFile}}{{^required}}>{{/required}} {{paramName}}{{#hasMore}},{{/hasMore}} | ||
{{/allParams}} | ||
) ); | ||
{{/operation}} | ||
}; | ||
|
||
{{#apiNamespaceDeclarations}} | ||
} | ||
{{/apiNamespaceDeclarations}} | ||
|
||
#endif /* {{apiHeaderGuardPrefix}}_{{classname}}GMock_H_ */ | ||
|
||
{{/operations}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,11 +22,24 @@ namespace {{this}} { | |
|
||
using namespace {{modelNamespace}}; | ||
|
||
class {{declspec}} {{classname}} | ||
class {{declspec}} I{{classname}} | ||
{ | ||
public: | ||
virtual ~I{{classname}}() = default; | ||
{{#operation}} | ||
virtual pplx::task<{{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}void{{/returnType}}> {{operationId}}( | ||
{{#allParams}} | ||
{{^required}}boost::optional<{{/required}}{{#isFile}}std::shared_ptr<{{/isFile}}{{{dataType}}}{{#isFile}}>{{/isFile}}{{^required}}>{{/required}} {{paramName}}{{#hasMore}},{{/hasMore}} | ||
{{/allParams}} | ||
) = 0; | ||
{{/operation}} | ||
}; | ||
|
||
class {{declspec}} {{classname}} : public I{{classname}} | ||
{ | ||
public: | ||
{{classname}}( std::shared_ptr<ApiClient> apiClient ); | ||
virtual ~{{classname}}(); | ||
~{{classname}}() override; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Here as well |
||
{{#operation}} | ||
/// <summary> | ||
/// {{summary}} | ||
|
@@ -41,7 +54,7 @@ public: | |
{{#allParams}} | ||
{{^required}}boost::optional<{{/required}}{{#isFile}}std::shared_ptr<{{/isFile}}{{{dataType}}}{{#isFile}}>{{/isFile}}{{^required}}>{{/required}} {{paramName}}{{#hasMore}},{{/hasMore}} | ||
{{/allParams}} | ||
); | ||
) override; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. And here. |
||
{{/operation}} | ||
|
||
protected: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this part should be encapsulated with the new mustache variable, so that current users are not impacted