Skip to content

Commit 7af5117

Browse files
mowijoKRJ-RTX
authored andcommitted
[cpp][pistache-server] Add new file api-base-source.mustache
`api-base-source.mustache` contain implementations of security related methods and also the empty constructor.
1 parent ebeed21 commit 7af5117

3 files changed

Lines changed: 28 additions & 13 deletions

File tree

modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/CppPistacheServerCodegen.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,7 @@ public CppPistacheServerCodegen() {
191191
private void setupSupportingFiles() {
192192
supportingFiles.clear();
193193
supportingFiles.add(new SupportingFile("api-base-header.mustache", "api", "ApiBase.h"));
194+
supportingFiles.add(new SupportingFile("api-base-source.mustache", "api", "ApiBase.cpp"));
194195
supportingFiles.add(new SupportingFile("helpers-header.mustache", "model", modelNamePrefix + "Helpers.h"));
195196
supportingFiles.add(new SupportingFile("helpers-source.mustache", "model", modelNamePrefix + "Helpers.cpp"));
196197
supportingFiles.add(new SupportingFile("main-api-server.mustache", "", modelNamePrefix + "main-api-server.cpp"));

modules/openapi-generator/src/main/resources/cpp-pistache-server/api-base-header.mustache

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -41,22 +41,12 @@ namespace {{apiNamespace}}
4141

4242
class ApiBase {
4343
public:
44-
explicit ApiBase(const std::shared_ptr<Pistache::Rest::Router>& rtr) : router(rtr) {};
44+
explicit ApiBase(const std::shared_ptr<Pistache::Rest::Router>& rtr);
4545
virtual ~ApiBase() = default;
4646
virtual void init() = 0;
4747
48-
{{#authMethods}}{{#isBasicBasic}}
49-
void setBasicCredentialsAuthenticator( const BasicCredentialsAuthenticator &newBasicCredentialsAuthenticator)
50-
{
51-
basicCredentialsAuthenticator = newBasicCredentialsAuthenticator;
52-
}
53-
{{/isBasicBasic}}
54-
{{#isBasicBearer}}
55-
void setBearerTokenAuthenticator( const BearerTokenAuthenticator &newbearerTokenAuthenticator)
56-
{
57-
bearerTokenAuthenticator = newbearerTokenAuthenticator;
58-
}
59-
{{/isBasicBearer}}{{/authMethods}}
48+
{{#authMethods}}{{#isBasicBasic}}void setBasicCredentialsAuthenticator( const BasicCredentialsAuthenticator &newBasicCredentialsAuthenticator);{{/isBasicBasic}}{{/authMethods}}
49+
{{#authMethods}}{{#isBasicBearer}}void setBearerTokenAuthenticator( const BearerTokenAuthenticator &newbearerTokenAuthenticator);{{/isBasicBearer}}{{/authMethods}}
6050

6151

6252
protected:
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
{{>licenseInfo}}
2+
#include "ApiBase.h"
3+
4+
namespace {{apiNamespace}}
5+
{
6+
7+
ApiBase::ApiBase(const std::shared_ptr<Pistache::Rest::Router>& rtr) : router(rtr)
8+
{
9+
}
10+
11+
{{#authMethods}}{{#isBasicBasic}}
12+
void ApiBase::setBasicCredentialsAuthenticator( const BasicCredentialsAuthenticator &newBasicCredentialsAuthenticator)
13+
{
14+
basicCredentialsAuthenticator = newBasicCredentialsAuthenticator;
15+
}
16+
{{/isBasicBasic}}
17+
{{#isBasicBearer}}
18+
void ApiBase::setBearerTokenAuthenticator( const BearerTokenAuthenticator &newbearerTokenAuthenticator)
19+
{
20+
bearerTokenAuthenticator = newbearerTokenAuthenticator;
21+
}
22+
{{/isBasicBearer}}{{/authMethods}}
23+
24+
} // Namespace {{apiNamespace}}

0 commit comments

Comments
 (0)