Skip to content

Commit 0b4bb41

Browse files
mowijoKRJ-RTX
authored andcommitted
[cpp][pistache-server] Add re-generated samples.
1 parent 7af5117 commit 0b4bb41

30 files changed

Lines changed: 989 additions & 91 deletions

File tree

samples/server/petstore/cpp-pistache-everything/.openapi-generator/FILES

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
CMakeLists.txt
22
README.md
3+
api/ApiBase.cpp
34
api/ApiBase.h
45
api/PetApi.cpp
56
api/PetApi.h
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
/**
2+
* OpenAPI Petstore
3+
* This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
4+
*
5+
* The version of the OpenAPI document: 1.0.0
6+
*
7+
*
8+
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
9+
* https://openapi-generator.tech
10+
* Do not edit the class manually.
11+
*/
12+
#include "ApiBase.h"
13+
14+
namespace org::openapitools::server::api
15+
{
16+
17+
ApiBase::ApiBase(const std::shared_ptr<Pistache::Rest::Router>& rtr) : router(rtr)
18+
{
19+
}
20+
21+
22+
23+
} // Namespace org::openapitools::server::api

samples/server/petstore/cpp-pistache-everything/api/ApiBase.h

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,28 @@
2424
namespace org::openapitools::server::api
2525
{
2626

27+
28+
29+
30+
31+
32+
2733
class ApiBase {
2834
public:
29-
explicit ApiBase(const std::shared_ptr<Pistache::Rest::Router>& rtr) : router(rtr) {};
35+
explicit ApiBase(const std::shared_ptr<Pistache::Rest::Router>& rtr);
3036
virtual ~ApiBase() = default;
3137
virtual void init() = 0;
3238

39+
40+
41+
42+
3343
protected:
3444
const std::shared_ptr<Pistache::Rest::Router> router;
45+
46+
47+
48+
3549
};
3650

3751
} // namespace org::openapitools::server::api

samples/server/petstore/cpp-pistache-everything/api/PetApi.cpp

Lines changed: 181 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,7 @@ const std::string PetApi::base = "/v2";
2323

2424
PetApi::PetApi(const std::shared_ptr<Pistache::Rest::Router>& rtr)
2525
: ApiBase(rtr)
26-
{
27-
}
26+
{}
2827

2928
void PetApi::init() {
3029
setupRoutes();
@@ -93,7 +92,22 @@ void PetApi::add_pet_handler(const Pistache::Rest::Request &request, Pistache::H
9392
}
9493

9594
try {
96-
this->add_pet(pet, response);
95+
96+
97+
#ifndef HTTP_BASIC_AUTH_DEFINED
98+
#define HTTP_BASIC_AUTH_DEFINED 0
99+
#endif
100+
#ifndef HTTP_BEARER_AUTH_DEFINED
101+
#define HTTP_BEARER_AUTH_DEFINED 0
102+
#endif
103+
104+
105+
106+
107+
108+
109+
110+
this->add_pet(pet, response);
97111
} catch (Pistache::Http::HttpError &e) {
98112
response.send(static_cast<Pistache::Http::Code>(e.code()), e.what());
99113
return;
@@ -106,6 +120,17 @@ void PetApi::add_pet_handler(const Pistache::Rest::Request &request, Pistache::H
106120
response.send(Pistache::Http::Code::Internal_Server_Error, e.what());
107121
}
108122

123+
#define REST_PATH "/pet"
124+
static_assert(HTTP_BASIC_AUTH_DEFINED + HTTP_BEARER_AUTH_DEFINED < 2, "Path '" REST_PATH "' has more than one security scheme specified, and the Pistache server generator does not support that." );
125+
#undef REST_PATH
126+
127+
#ifdef HTTP_BEARER_AUTH_DEFINED
128+
#undef HTTP_BEARER_AUTH_DEFINED
129+
#endif
130+
#ifdef HTTP_BASIC_AUTH_DEFINED
131+
#undef HTTP_BASIC_AUTH_DEFINED
132+
#endif
133+
109134
}
110135
void PetApi::delete_pet_handler(const Pistache::Rest::Request &request, Pistache::Http::ResponseWriter response) {
111136
try {
@@ -117,7 +142,21 @@ void PetApi::delete_pet_handler(const Pistache::Rest::Request &request, Pistache
117142
auto apiKey = request.headers().tryGetRaw("api_key");
118143

119144
try {
120-
this->delete_pet(petId, apiKey, response);
145+
146+
#ifndef HTTP_BASIC_AUTH_DEFINED
147+
#define HTTP_BASIC_AUTH_DEFINED 0
148+
#endif
149+
#ifndef HTTP_BEARER_AUTH_DEFINED
150+
#define HTTP_BEARER_AUTH_DEFINED 0
151+
#endif
152+
153+
154+
155+
156+
157+
158+
159+
this->delete_pet(petId, apiKey, response);
121160
} catch (Pistache::Http::HttpError &e) {
122161
response.send(static_cast<Pistache::Http::Code>(e.code()), e.what());
123162
return;
@@ -130,6 +169,17 @@ void PetApi::delete_pet_handler(const Pistache::Rest::Request &request, Pistache
130169
response.send(Pistache::Http::Code::Internal_Server_Error, e.what());
131170
}
132171

172+
#define REST_PATH "/pet/:petId"
173+
static_assert(HTTP_BASIC_AUTH_DEFINED + HTTP_BEARER_AUTH_DEFINED < 2, "Path '" REST_PATH "' has more than one security scheme specified, and the Pistache server generator does not support that." );
174+
#undef REST_PATH
175+
176+
#ifdef HTTP_BEARER_AUTH_DEFINED
177+
#undef HTTP_BEARER_AUTH_DEFINED
178+
#endif
179+
#ifdef HTTP_BASIC_AUTH_DEFINED
180+
#undef HTTP_BASIC_AUTH_DEFINED
181+
#endif
182+
133183
}
134184
void PetApi::find_pets_by_status_handler(const Pistache::Rest::Request &request, Pistache::Http::ResponseWriter response) {
135185
try {
@@ -146,7 +196,21 @@ void PetApi::find_pets_by_status_handler(const Pistache::Rest::Request &request,
146196
}
147197

148198
try {
149-
this->find_pets_by_status(status, response);
199+
200+
#ifndef HTTP_BASIC_AUTH_DEFINED
201+
#define HTTP_BASIC_AUTH_DEFINED 0
202+
#endif
203+
#ifndef HTTP_BEARER_AUTH_DEFINED
204+
#define HTTP_BEARER_AUTH_DEFINED 0
205+
#endif
206+
207+
208+
209+
210+
211+
212+
213+
this->find_pets_by_status(status, response);
150214
} catch (Pistache::Http::HttpError &e) {
151215
response.send(static_cast<Pistache::Http::Code>(e.code()), e.what());
152216
return;
@@ -159,6 +223,17 @@ void PetApi::find_pets_by_status_handler(const Pistache::Rest::Request &request,
159223
response.send(Pistache::Http::Code::Internal_Server_Error, e.what());
160224
}
161225

226+
#define REST_PATH "/pet/findByStatus"
227+
static_assert(HTTP_BASIC_AUTH_DEFINED + HTTP_BEARER_AUTH_DEFINED < 2, "Path '" REST_PATH "' has more than one security scheme specified, and the Pistache server generator does not support that." );
228+
#undef REST_PATH
229+
230+
#ifdef HTTP_BEARER_AUTH_DEFINED
231+
#undef HTTP_BEARER_AUTH_DEFINED
232+
#endif
233+
#ifdef HTTP_BASIC_AUTH_DEFINED
234+
#undef HTTP_BASIC_AUTH_DEFINED
235+
#endif
236+
162237
}
163238
void PetApi::find_pets_by_tags_handler(const Pistache::Rest::Request &request, Pistache::Http::ResponseWriter response) {
164239
try {
@@ -175,7 +250,21 @@ void PetApi::find_pets_by_tags_handler(const Pistache::Rest::Request &request, P
175250
}
176251

177252
try {
178-
this->find_pets_by_tags(tags, response);
253+
254+
#ifndef HTTP_BASIC_AUTH_DEFINED
255+
#define HTTP_BASIC_AUTH_DEFINED 0
256+
#endif
257+
#ifndef HTTP_BEARER_AUTH_DEFINED
258+
#define HTTP_BEARER_AUTH_DEFINED 0
259+
#endif
260+
261+
262+
263+
264+
265+
266+
267+
this->find_pets_by_tags(tags, response);
179268
} catch (Pistache::Http::HttpError &e) {
180269
response.send(static_cast<Pistache::Http::Code>(e.code()), e.what());
181270
return;
@@ -188,6 +277,17 @@ void PetApi::find_pets_by_tags_handler(const Pistache::Rest::Request &request, P
188277
response.send(Pistache::Http::Code::Internal_Server_Error, e.what());
189278
}
190279

280+
#define REST_PATH "/pet/findByTags"
281+
static_assert(HTTP_BASIC_AUTH_DEFINED + HTTP_BEARER_AUTH_DEFINED < 2, "Path '" REST_PATH "' has more than one security scheme specified, and the Pistache server generator does not support that." );
282+
#undef REST_PATH
283+
284+
#ifdef HTTP_BEARER_AUTH_DEFINED
285+
#undef HTTP_BEARER_AUTH_DEFINED
286+
#endif
287+
#ifdef HTTP_BASIC_AUTH_DEFINED
288+
#undef HTTP_BASIC_AUTH_DEFINED
289+
#endif
290+
191291
}
192292
void PetApi::get_pet_by_id_handler(const Pistache::Rest::Request &request, Pistache::Http::ResponseWriter response) {
193293
try {
@@ -196,7 +296,21 @@ void PetApi::get_pet_by_id_handler(const Pistache::Rest::Request &request, Pista
196296
auto petId = request.param(":petId").as<int64_t>();
197297

198298
try {
199-
this->get_pet_by_id(petId, response);
299+
300+
#ifndef HTTP_BASIC_AUTH_DEFINED
301+
#define HTTP_BASIC_AUTH_DEFINED 0
302+
#endif
303+
#ifndef HTTP_BEARER_AUTH_DEFINED
304+
#define HTTP_BEARER_AUTH_DEFINED 0
305+
#endif
306+
307+
308+
309+
310+
311+
312+
313+
this->get_pet_by_id(petId, response);
200314
} catch (Pistache::Http::HttpError &e) {
201315
response.send(static_cast<Pistache::Http::Code>(e.code()), e.what());
202316
return;
@@ -209,6 +323,17 @@ void PetApi::get_pet_by_id_handler(const Pistache::Rest::Request &request, Pista
209323
response.send(Pistache::Http::Code::Internal_Server_Error, e.what());
210324
}
211325

326+
#define REST_PATH "/pet/:petId"
327+
static_assert(HTTP_BASIC_AUTH_DEFINED + HTTP_BEARER_AUTH_DEFINED < 2, "Path '" REST_PATH "' has more than one security scheme specified, and the Pistache server generator does not support that." );
328+
#undef REST_PATH
329+
330+
#ifdef HTTP_BEARER_AUTH_DEFINED
331+
#undef HTTP_BEARER_AUTH_DEFINED
332+
#endif
333+
#ifdef HTTP_BASIC_AUTH_DEFINED
334+
#undef HTTP_BASIC_AUTH_DEFINED
335+
#endif
336+
212337
}
213338
void PetApi::update_pet_handler(const Pistache::Rest::Request &request, Pistache::Http::ResponseWriter response) {
214339
try {
@@ -227,7 +352,22 @@ void PetApi::update_pet_handler(const Pistache::Rest::Request &request, Pistache
227352
}
228353

229354
try {
230-
this->update_pet(pet, response);
355+
356+
357+
#ifndef HTTP_BASIC_AUTH_DEFINED
358+
#define HTTP_BASIC_AUTH_DEFINED 0
359+
#endif
360+
#ifndef HTTP_BEARER_AUTH_DEFINED
361+
#define HTTP_BEARER_AUTH_DEFINED 0
362+
#endif
363+
364+
365+
366+
367+
368+
369+
370+
this->update_pet(pet, response);
231371
} catch (Pistache::Http::HttpError &e) {
232372
response.send(static_cast<Pistache::Http::Code>(e.code()), e.what());
233373
return;
@@ -240,6 +380,17 @@ void PetApi::update_pet_handler(const Pistache::Rest::Request &request, Pistache
240380
response.send(Pistache::Http::Code::Internal_Server_Error, e.what());
241381
}
242382

383+
#define REST_PATH "/pet"
384+
static_assert(HTTP_BASIC_AUTH_DEFINED + HTTP_BEARER_AUTH_DEFINED < 2, "Path '" REST_PATH "' has more than one security scheme specified, and the Pistache server generator does not support that." );
385+
#undef REST_PATH
386+
387+
#ifdef HTTP_BEARER_AUTH_DEFINED
388+
#undef HTTP_BEARER_AUTH_DEFINED
389+
#endif
390+
#ifdef HTTP_BASIC_AUTH_DEFINED
391+
#undef HTTP_BASIC_AUTH_DEFINED
392+
#endif
393+
243394
}
244395
void PetApi::update_pet_with_form_handler(const Pistache::Rest::Request &request, Pistache::Http::ResponseWriter response) {
245396
try {
@@ -258,6 +409,17 @@ void PetApi::update_pet_with_form_handler(const Pistache::Rest::Request &request
258409
response.send(Pistache::Http::Code::Internal_Server_Error, e.what());
259410
}
260411

412+
#define REST_PATH "/pet/:petId"
413+
static_assert(HTTP_BASIC_AUTH_DEFINED + HTTP_BEARER_AUTH_DEFINED < 2, "Path '" REST_PATH "' has more than one security scheme specified, and the Pistache server generator does not support that." );
414+
#undef REST_PATH
415+
416+
#ifdef HTTP_BEARER_AUTH_DEFINED
417+
#undef HTTP_BEARER_AUTH_DEFINED
418+
#endif
419+
#ifdef HTTP_BASIC_AUTH_DEFINED
420+
#undef HTTP_BASIC_AUTH_DEFINED
421+
#endif
422+
261423
}
262424
void PetApi::upload_file_handler(const Pistache::Rest::Request &request, Pistache::Http::ResponseWriter response) {
263425
try {
@@ -276,6 +438,17 @@ void PetApi::upload_file_handler(const Pistache::Rest::Request &request, Pistach
276438
response.send(Pistache::Http::Code::Internal_Server_Error, e.what());
277439
}
278440

441+
#define REST_PATH "/pet/:petId/uploadImage"
442+
static_assert(HTTP_BASIC_AUTH_DEFINED + HTTP_BEARER_AUTH_DEFINED < 2, "Path '" REST_PATH "' has more than one security scheme specified, and the Pistache server generator does not support that." );
443+
#undef REST_PATH
444+
445+
#ifdef HTTP_BEARER_AUTH_DEFINED
446+
#undef HTTP_BEARER_AUTH_DEFINED
447+
#endif
448+
#ifdef HTTP_BASIC_AUTH_DEFINED
449+
#undef HTTP_BASIC_AUTH_DEFINED
450+
#endif
451+
279452
}
280453

281454
void PetApi::pet_api_default_handler(const Pistache::Rest::Request &, Pistache::Http::ResponseWriter response) {

0 commit comments

Comments
 (0)