[cpp-pistache] Fix compilation of petstore for Pistache (#497)

* Fix compilation of petstore for Pistache
Add Map support

* Add support for ByteArray

* Add Support for ByteArray in cpprest

* Implement TODOs
This commit is contained in:
sunn
2018-07-20 16:04:25 +02:00
committed by William Cheng
parent 1b2d12286f
commit 97d6b71460
29 changed files with 284 additions and 68 deletions

View File

@@ -59,11 +59,14 @@ void UserApi::setupRoutes() {
void UserApi::create_user_handler(const Pistache::Rest::Request &request, Pistache::Http::ResponseWriter response) {
// Getting the body param
User user;
try {
nlohmann::json request_body = nlohmann::json::parse(request.body());
user.fromJson(request_body);
this->create_user(user, response);
} catch (std::runtime_error & e) {
//send a 400 error
@@ -75,11 +78,11 @@ void UserApi::create_user_handler(const Pistache::Rest::Request &request, Pistac
void UserApi::create_users_with_array_input_handler(const Pistache::Rest::Request &request, Pistache::Http::ResponseWriter response) {
// Getting the body param
std::vector user;
std::vector<User> user;
try {
nlohmann::json request_body = nlohmann::json::parse(request.body());
user.fromJson(request_body);
user = ModelArrayHelper::fromJson<User>(request_body);
this->create_users_with_array_input(user, response);
} catch (std::runtime_error & e) {
//send a 400 error
@@ -91,11 +94,11 @@ void UserApi::create_users_with_array_input_handler(const Pistache::Rest::Reques
void UserApi::create_users_with_list_input_handler(const Pistache::Rest::Request &request, Pistache::Http::ResponseWriter response) {
// Getting the body param
std::vector user;
std::vector<User> user;
try {
nlohmann::json request_body = nlohmann::json::parse(request.body());
user.fromJson(request_body);
user = ModelArrayHelper::fromJson<User>(request_body);
this->create_users_with_list_input(user, response);
} catch (std::runtime_error & e) {
//send a 400 error
@@ -161,11 +164,14 @@ void UserApi::update_user_handler(const Pistache::Rest::Request &request, Pistac
auto username = request.param(":username").as<std::string>();
// Getting the body param
User user;
try {
nlohmann::json request_body = nlohmann::json::parse(request.body());
user.fromJson(request_body);
this->update_user(username, user, response);
} catch (std::runtime_error & e) {
//send a 400 error