forked from loafle/openapi-generator-original
Cpp restbed server improvements (#13030)
* Keep old implementation of cpp-restbed generator as cpp-restbed-server-deprecated * Refactor operation path processing * Restructure samples directory to better allow writing tests * Improve templates for cpp-restbed-server Improve templates * Add integration tests * Improvement in templates for cpp-restbed-server * Fix tests * Improve cpp-restbed generator * Improve cpp-restbed-server * Add more tests * Add suppoert for arrays of enums in query params * Generate CMakeLists.txt * Small improvements and example in Readme * Add integration tests to maven project * Update doc
This commit is contained in:
29
samples/server/petstore/cpp-restbed-deprecated/.gitignore
vendored
Normal file
29
samples/server/petstore/cpp-restbed-deprecated/.gitignore
vendored
Normal file
@@ -0,0 +1,29 @@
|
||||
# Compiled Object files
|
||||
*.slo
|
||||
*.lo
|
||||
*.o
|
||||
*.obj
|
||||
|
||||
# Precompiled Headers
|
||||
*.gch
|
||||
*.pch
|
||||
|
||||
# Compiled Dynamic libraries
|
||||
*.so
|
||||
*.dylib
|
||||
*.dll
|
||||
|
||||
# Fortran module files
|
||||
*.mod
|
||||
*.smod
|
||||
|
||||
# Compiled Static libraries
|
||||
*.lai
|
||||
*.la
|
||||
*.a
|
||||
*.lib
|
||||
|
||||
# Executables
|
||||
*.exe
|
||||
*.out
|
||||
*.app
|
||||
@@ -0,0 +1,23 @@
|
||||
# OpenAPI Generator Ignore
|
||||
# Generated by openapi-generator https://github.com/openapitools/openapi-generator
|
||||
|
||||
# Use this file to prevent files from being overwritten by the generator.
|
||||
# The patterns follow closely to .gitignore or .dockerignore.
|
||||
|
||||
# As an example, the C# client generator defines ApiClient.cs.
|
||||
# You can make changes and tell OpenAPI Generator to ignore just this file by uncommenting the following line:
|
||||
#ApiClient.cs
|
||||
|
||||
# You can match any string of characters against a directory, file or extension with a single asterisk (*):
|
||||
#foo/*/qux
|
||||
# The above matches foo/bar/qux and foo/baz/qux, but not foo/bar/baz/qux
|
||||
|
||||
# You can recursively match patterns against a directory, file or extension with a double asterisk (**):
|
||||
#foo/**/qux
|
||||
# This matches foo/bar/qux, foo/baz/qux, and foo/bar/baz/qux
|
||||
|
||||
# You can also negate patterns with an exclamation (!).
|
||||
# For example, you can ignore all files in a docs folder with the file extension .md:
|
||||
#docs/*.md
|
||||
# Then explicitly reverse the ignore rule for a single file:
|
||||
#!docs/README.md
|
||||
@@ -0,0 +1,22 @@
|
||||
.gitignore
|
||||
.openapi-generator-ignore
|
||||
README.md
|
||||
api/PetApi.cpp
|
||||
api/PetApi.h
|
||||
api/StoreApi.cpp
|
||||
api/StoreApi.h
|
||||
api/UserApi.cpp
|
||||
api/UserApi.h
|
||||
git_push.sh
|
||||
model/ApiResponse.cpp
|
||||
model/ApiResponse.h
|
||||
model/Category.cpp
|
||||
model/Category.h
|
||||
model/Order.cpp
|
||||
model/Order.h
|
||||
model/Pet.cpp
|
||||
model/Pet.h
|
||||
model/Tag.cpp
|
||||
model/Tag.h
|
||||
model/User.cpp
|
||||
model/User.h
|
||||
@@ -0,0 +1 @@
|
||||
unset
|
||||
23
samples/server/petstore/cpp-restbed-deprecated/README.md
Normal file
23
samples/server/petstore/cpp-restbed-deprecated/README.md
Normal file
@@ -0,0 +1,23 @@
|
||||
# REST API Server for OpenAPI Petstore
|
||||
|
||||
## Overview
|
||||
This API Server was generated by the [OpenAPI Generator](https://openapi-generator.tech) project.
|
||||
It uses the [Restbed](https://github.com/Corvusoft/restbed) Framework.
|
||||
|
||||
|
||||
## Installation
|
||||
Put the package under your project folder and import the API stubs.
|
||||
You need to complete the server stub, as it needs to be connected to a source.
|
||||
|
||||
|
||||
## Libraries required
|
||||
boost_system
|
||||
ssl (if Restbed was built with SSL Support)
|
||||
crypto
|
||||
pthread
|
||||
restbed
|
||||
|
||||
|
||||
## Namespaces
|
||||
org.openapitools.server.api
|
||||
org.openapitools.server.model
|
||||
819
samples/server/petstore/cpp-restbed-deprecated/api/PetApi.cpp
Normal file
819
samples/server/petstore/cpp-restbed-deprecated/api/PetApi.cpp
Normal file
@@ -0,0 +1,819 @@
|
||||
/**
|
||||
* OpenAPI Petstore
|
||||
* This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
|
||||
*
|
||||
* The version of the OpenAPI document: 1.0.0
|
||||
*
|
||||
*
|
||||
* NOTE: This class is auto generated by OpenAPI-Generator unset.
|
||||
* https://openapi-generator.tech
|
||||
* Do not edit the class manually.
|
||||
*/
|
||||
|
||||
|
||||
#include <corvusoft/restbed/byte.hpp>
|
||||
#include <corvusoft/restbed/string.hpp>
|
||||
#include <corvusoft/restbed/settings.hpp>
|
||||
#include <corvusoft/restbed/request.hpp>
|
||||
#include <corvusoft/restbed/uri.hpp>
|
||||
#include <boost/property_tree/ptree.hpp>
|
||||
#include <boost/property_tree/json_parser.hpp>
|
||||
#include <boost/lexical_cast.hpp>
|
||||
#include <boost/algorithm/string.hpp>
|
||||
|
||||
#include "PetApi.h"
|
||||
|
||||
namespace org {
|
||||
namespace openapitools {
|
||||
namespace server {
|
||||
namespace api {
|
||||
|
||||
using namespace org::openapitools::server::model;
|
||||
|
||||
PetApiException::PetApiException(int status_code, std::string what)
|
||||
: m_status(status_code),
|
||||
m_what(what)
|
||||
{
|
||||
|
||||
}
|
||||
int PetApiException::getStatus() const
|
||||
{
|
||||
return m_status;
|
||||
}
|
||||
const char* PetApiException::what() const noexcept
|
||||
{
|
||||
return m_what.c_str();
|
||||
}
|
||||
|
||||
|
||||
template<class MODEL_T>
|
||||
std::shared_ptr<MODEL_T> extractJsonModelBodyParam(const std::string& bodyContent)
|
||||
{
|
||||
std::stringstream sstream(bodyContent);
|
||||
boost::property_tree::ptree pt;
|
||||
boost::property_tree::json_parser::read_json(sstream, pt);
|
||||
|
||||
auto model = std::make_shared<MODEL_T>(pt);
|
||||
return model;
|
||||
}
|
||||
|
||||
template<class MODEL_T>
|
||||
std::vector<std::shared_ptr<MODEL_T>> extractJsonArrayBodyParam(const std::string& bodyContent)
|
||||
{
|
||||
std::stringstream sstream(bodyContent);
|
||||
boost::property_tree::ptree pt;
|
||||
boost::property_tree::json_parser::read_json(sstream, pt);
|
||||
|
||||
auto arrayRet = std::vector<std::shared_ptr<MODEL_T>>();
|
||||
for (const auto& child: pt) {
|
||||
arrayRet.emplace_back(std::make_shared<MODEL_T>(child.second));
|
||||
}
|
||||
return arrayRet;
|
||||
}
|
||||
|
||||
template <class KEY_T, class VAL_T>
|
||||
std::string convertMapResponse(const std::map<KEY_T, VAL_T>& map)
|
||||
{
|
||||
boost::property_tree::ptree pt;
|
||||
for(const auto &kv: map) {
|
||||
pt.push_back(boost::property_tree::ptree::value_type(
|
||||
boost::lexical_cast<std::string>(kv.first),
|
||||
boost::property_tree::ptree(
|
||||
boost::lexical_cast<std::string>(kv.second))));
|
||||
}
|
||||
std::stringstream sstream;
|
||||
write_json(sstream, pt);
|
||||
std::string result = sstream.str();
|
||||
return result;
|
||||
}
|
||||
|
||||
PetApiPetResource::PetApiPetResource(const std::string& context /* = "/v2" */)
|
||||
{
|
||||
this->set_path(context + "/pet/");
|
||||
this->set_method_handler("POST",
|
||||
std::bind(&PetApiPetResource::handler_POST_internal, this,
|
||||
std::placeholders::_1));
|
||||
this->set_method_handler("PUT",
|
||||
std::bind(&PetApiPetResource::handler_PUT_internal, this,
|
||||
std::placeholders::_1));
|
||||
}
|
||||
|
||||
PetApiPetResource::~PetApiPetResource()
|
||||
{
|
||||
}
|
||||
|
||||
std::pair<int, std::string> PetApiPetResource::handlePetApiException(const PetApiException& e)
|
||||
{
|
||||
return std::make_pair<int, std::string>(e.getStatus(), e.what());
|
||||
}
|
||||
|
||||
std::pair<int, std::string> PetApiPetResource::handleStdException(const std::exception& e)
|
||||
{
|
||||
return std::make_pair<int, std::string>(500, e.what());
|
||||
}
|
||||
|
||||
std::pair<int, std::string> PetApiPetResource::handleUnspecifiedException()
|
||||
{
|
||||
return std::make_pair<int, std::string>(500, "Unknown exception occurred");
|
||||
}
|
||||
|
||||
void PetApiPetResource::setResponseHeader(const std::shared_ptr<restbed::Session>& session, const std::string& header)
|
||||
{
|
||||
session->set_header(header, "");
|
||||
}
|
||||
|
||||
void PetApiPetResource::returnResponse(const std::shared_ptr<restbed::Session>& session, const int status, const std::string& result, const std::string& contentType)
|
||||
{
|
||||
session->close(status, result, { {"Connection", "close"}, {"Content-Type", contentType} });
|
||||
}
|
||||
|
||||
void PetApiPetResource::defaultSessionClose(const std::shared_ptr<restbed::Session>& session, const int status, const std::string& result)
|
||||
{
|
||||
session->close(status, result, { {"Connection", "close"} });
|
||||
}
|
||||
|
||||
void PetApiPetResource::handler_POST_internal(const std::shared_ptr<restbed::Session> session)
|
||||
{
|
||||
const auto request = session->get_request();
|
||||
std::string bodyContent = extractBodyContent(session);
|
||||
|
||||
// Get body params or form params here from the body content string
|
||||
auto pet = extractJsonModelBodyParam<Pet>(bodyContent);
|
||||
|
||||
|
||||
|
||||
|
||||
int status_code = 500;
|
||||
std::shared_ptr<Pet> resultObject = std::make_shared<Pet>();
|
||||
std::string result = "";
|
||||
|
||||
try {
|
||||
std::tie(status_code, resultObject) =
|
||||
handler_POST(pet);
|
||||
}
|
||||
catch(const PetApiException& e) {
|
||||
std::tie(status_code, result) = handlePetApiException(e);
|
||||
}
|
||||
catch(const std::exception& e) {
|
||||
std::tie(status_code, result) = handleStdException(e);
|
||||
}
|
||||
catch(...) {
|
||||
std::tie(status_code, result) = handleUnspecifiedException();
|
||||
}
|
||||
|
||||
if (status_code == 200) {
|
||||
result = resultObject->toJsonString();
|
||||
|
||||
const constexpr auto contentType = "application/json";
|
||||
returnResponse(session, 200, result.empty() ? "successful operation" : result, contentType);
|
||||
return;
|
||||
}
|
||||
if (status_code == 405) {
|
||||
|
||||
const constexpr auto contentType = "text/plain";
|
||||
returnResponse(session, 405, result.empty() ? "Invalid input" : result, contentType);
|
||||
return;
|
||||
}
|
||||
defaultSessionClose(session, status_code, result);
|
||||
}
|
||||
|
||||
// x-extension
|
||||
void PetApiPetResource::handler_PUT_internal(const std::shared_ptr<restbed::Session> session) {
|
||||
|
||||
const auto request = session->get_request();
|
||||
std::string bodyContent = extractBodyContent(session);
|
||||
|
||||
// body params or form params here from the body content string
|
||||
auto pet = extractJsonModelBodyParam<Pet>(bodyContent);
|
||||
|
||||
|
||||
int status_code = 500;
|
||||
std::shared_ptr<Pet> resultObject = std::make_shared<Pet>();
|
||||
std::string result = "";
|
||||
|
||||
try {
|
||||
std::tie(status_code, resultObject) =
|
||||
handler_PUT(pet);
|
||||
}
|
||||
catch(const PetApiException& e) {
|
||||
std::tie(status_code, result) = handlePetApiException(e);
|
||||
}
|
||||
catch(const std::exception& e) {
|
||||
std::tie(status_code, result) = handleStdException(e);
|
||||
}
|
||||
catch(...) {
|
||||
std::tie(status_code, result) = handleUnspecifiedException();
|
||||
}
|
||||
|
||||
if (status_code == 200) {
|
||||
result = resultObject->toJsonString();
|
||||
|
||||
const constexpr auto contentType = "application/json";
|
||||
returnResponse(session, 200, result.empty() ? "successful operation" : result, contentType);
|
||||
return;
|
||||
}
|
||||
if (status_code == 400) {
|
||||
|
||||
const constexpr auto contentType = "text/plain";
|
||||
returnResponse(session, 400, result.empty() ? "Invalid ID supplied" : result, contentType);
|
||||
return;
|
||||
}
|
||||
if (status_code == 404) {
|
||||
|
||||
const constexpr auto contentType = "text/plain";
|
||||
returnResponse(session, 404, result.empty() ? "Pet not found" : result, contentType);
|
||||
return;
|
||||
}
|
||||
if (status_code == 405) {
|
||||
|
||||
const constexpr auto contentType = "text/plain";
|
||||
returnResponse(session, 405, result.empty() ? "Validation exception" : result, contentType);
|
||||
return;
|
||||
}
|
||||
defaultSessionClose(session, status_code, result);
|
||||
}
|
||||
|
||||
std::pair<int, std::shared_ptr<Pet>> PetApiPetResource::handler_POST(
|
||||
std::shared_ptr<Pet> const & pet)
|
||||
{
|
||||
throw PetApiException(501, "Not implemented");
|
||||
}
|
||||
|
||||
std::pair<int, std::shared_ptr<Pet>> PetApiPetResource::handler_PUT(
|
||||
std::shared_ptr<Pet> const & pet)
|
||||
{
|
||||
throw PetApiException(501, "Not implemented");
|
||||
}
|
||||
|
||||
std::string PetApiPetResource::extractBodyContent(const std::shared_ptr<restbed::Session>& session) {
|
||||
const auto request = session->get_request();
|
||||
int content_length = request->get_header("Content-Length", 0);
|
||||
std::string bodyContent;
|
||||
session->fetch(content_length,
|
||||
[&bodyContent](const std::shared_ptr<restbed::Session> session,
|
||||
const restbed::Bytes &body) {
|
||||
bodyContent = restbed::String::format(
|
||||
"%.*s\n", (int)body.size(), body.data());
|
||||
});
|
||||
return bodyContent;
|
||||
}
|
||||
PetApiPetPetIdResource::PetApiPetPetIdResource(const std::string& context /* = "/v2" */)
|
||||
{
|
||||
this->set_path(context + "/pet/{petId: .*}/");
|
||||
this->set_method_handler("DELETE",
|
||||
std::bind(&PetApiPetPetIdResource::handler_DELETE_internal, this,
|
||||
std::placeholders::_1));
|
||||
this->set_method_handler("GET",
|
||||
std::bind(&PetApiPetPetIdResource::handler_GET_internal, this,
|
||||
std::placeholders::_1));
|
||||
this->set_method_handler("POST",
|
||||
std::bind(&PetApiPetPetIdResource::handler_POST_internal, this,
|
||||
std::placeholders::_1));
|
||||
}
|
||||
|
||||
PetApiPetPetIdResource::~PetApiPetPetIdResource()
|
||||
{
|
||||
}
|
||||
|
||||
std::pair<int, std::string> PetApiPetPetIdResource::handlePetApiException(const PetApiException& e)
|
||||
{
|
||||
return std::make_pair<int, std::string>(e.getStatus(), e.what());
|
||||
}
|
||||
|
||||
std::pair<int, std::string> PetApiPetPetIdResource::handleStdException(const std::exception& e)
|
||||
{
|
||||
return std::make_pair<int, std::string>(500, e.what());
|
||||
}
|
||||
|
||||
std::pair<int, std::string> PetApiPetPetIdResource::handleUnspecifiedException()
|
||||
{
|
||||
return std::make_pair<int, std::string>(500, "Unknown exception occurred");
|
||||
}
|
||||
|
||||
void PetApiPetPetIdResource::setResponseHeader(const std::shared_ptr<restbed::Session>& session, const std::string& header)
|
||||
{
|
||||
session->set_header(header, "");
|
||||
}
|
||||
|
||||
void PetApiPetPetIdResource::returnResponse(const std::shared_ptr<restbed::Session>& session, const int status, const std::string& result, const std::string& contentType)
|
||||
{
|
||||
session->close(status, result, { {"Connection", "close"}, {"Content-Type", contentType} });
|
||||
}
|
||||
|
||||
void PetApiPetPetIdResource::defaultSessionClose(const std::shared_ptr<restbed::Session>& session, const int status, const std::string& result)
|
||||
{
|
||||
session->close(status, result, { {"Connection", "close"} });
|
||||
}
|
||||
|
||||
void PetApiPetPetIdResource::handler_DELETE_internal(const std::shared_ptr<restbed::Session> session)
|
||||
{
|
||||
const auto request = session->get_request();
|
||||
|
||||
// Getting the path params
|
||||
const int64_t petId = getPathParam_petId(request);
|
||||
|
||||
|
||||
// Getting the headers
|
||||
const std::string apiKey = getHeader_api_key(request);
|
||||
|
||||
int status_code = 500;
|
||||
std::string result = "";
|
||||
|
||||
try {
|
||||
status_code =
|
||||
handler_DELETE(petId, apiKey);
|
||||
}
|
||||
catch(const PetApiException& e) {
|
||||
std::tie(status_code, result) = handlePetApiException(e);
|
||||
}
|
||||
catch(const std::exception& e) {
|
||||
std::tie(status_code, result) = handleStdException(e);
|
||||
}
|
||||
catch(...) {
|
||||
std::tie(status_code, result) = handleUnspecifiedException();
|
||||
}
|
||||
|
||||
if (status_code == 400) {
|
||||
|
||||
const constexpr auto contentType = "text/plain";
|
||||
returnResponse(session, 400, result.empty() ? "Invalid pet value" : result, contentType);
|
||||
return;
|
||||
}
|
||||
defaultSessionClose(session, status_code, result);
|
||||
}
|
||||
|
||||
// x-extension
|
||||
void PetApiPetPetIdResource::handler_GET_internal(const std::shared_ptr<restbed::Session> session) {
|
||||
|
||||
const auto request = session->get_request();
|
||||
|
||||
// Getting the path params
|
||||
const int64_t petId = getPathParam_petId_x_extension(request);
|
||||
|
||||
|
||||
int status_code = 500;
|
||||
std::shared_ptr<Pet> resultObject = std::make_shared<Pet>();
|
||||
std::string result = "";
|
||||
|
||||
try {
|
||||
std::tie(status_code, resultObject) =
|
||||
handler_GET(petId);
|
||||
}
|
||||
catch(const PetApiException& e) {
|
||||
std::tie(status_code, result) = handlePetApiException(e);
|
||||
}
|
||||
catch(const std::exception& e) {
|
||||
std::tie(status_code, result) = handleStdException(e);
|
||||
}
|
||||
catch(...) {
|
||||
std::tie(status_code, result) = handleUnspecifiedException();
|
||||
}
|
||||
|
||||
if (status_code == 200) {
|
||||
result = resultObject->toJsonString();
|
||||
|
||||
const constexpr auto contentType = "application/json";
|
||||
returnResponse(session, 200, result.empty() ? "successful operation" : result, contentType);
|
||||
return;
|
||||
}
|
||||
if (status_code == 400) {
|
||||
|
||||
const constexpr auto contentType = "text/plain";
|
||||
returnResponse(session, 400, result.empty() ? "Invalid ID supplied" : result, contentType);
|
||||
return;
|
||||
}
|
||||
if (status_code == 404) {
|
||||
|
||||
const constexpr auto contentType = "text/plain";
|
||||
returnResponse(session, 404, result.empty() ? "Pet not found" : result, contentType);
|
||||
return;
|
||||
}
|
||||
defaultSessionClose(session, status_code, result);
|
||||
}
|
||||
// x-extension
|
||||
void PetApiPetPetIdResource::handler_POST_internal(const std::shared_ptr<restbed::Session> session) {
|
||||
|
||||
const auto request = session->get_request();
|
||||
|
||||
// Getting the path params
|
||||
const int64_t petId = getPathParam_petId_x_extension(request);
|
||||
|
||||
|
||||
int status_code = 500;
|
||||
std::string result = "";
|
||||
|
||||
try {
|
||||
status_code =
|
||||
handler_POST(petId, name, status);
|
||||
}
|
||||
catch(const PetApiException& e) {
|
||||
std::tie(status_code, result) = handlePetApiException(e);
|
||||
}
|
||||
catch(const std::exception& e) {
|
||||
std::tie(status_code, result) = handleStdException(e);
|
||||
}
|
||||
catch(...) {
|
||||
std::tie(status_code, result) = handleUnspecifiedException();
|
||||
}
|
||||
|
||||
if (status_code == 405) {
|
||||
|
||||
const constexpr auto contentType = "text/plain";
|
||||
returnResponse(session, 405, result.empty() ? "Invalid input" : result, contentType);
|
||||
return;
|
||||
}
|
||||
defaultSessionClose(session, status_code, result);
|
||||
}
|
||||
|
||||
int PetApiPetPetIdResource::handler_DELETE(
|
||||
int64_t const & petId, std::string const & apiKey)
|
||||
{
|
||||
throw PetApiException(501, "Not implemented");
|
||||
}
|
||||
|
||||
std::pair<int, std::shared_ptr<Pet>> PetApiPetPetIdResource::handler_GET(
|
||||
int64_t const & petId)
|
||||
{
|
||||
throw PetApiException(501, "Not implemented");
|
||||
}
|
||||
int PetApiPetPetIdResource::handler_POST(
|
||||
int64_t const & petId, std::string const & name, std::string const & status)
|
||||
{
|
||||
throw PetApiException(501, "Not implemented");
|
||||
}
|
||||
|
||||
std::string PetApiPetPetIdResource::extractBodyContent(const std::shared_ptr<restbed::Session>& session) {
|
||||
const auto request = session->get_request();
|
||||
int content_length = request->get_header("Content-Length", 0);
|
||||
std::string bodyContent;
|
||||
session->fetch(content_length,
|
||||
[&bodyContent](const std::shared_ptr<restbed::Session> session,
|
||||
const restbed::Bytes &body) {
|
||||
bodyContent = restbed::String::format(
|
||||
"%.*s\n", (int)body.size(), body.data());
|
||||
});
|
||||
return bodyContent;
|
||||
}
|
||||
PetApiPetFindByStatusResource::PetApiPetFindByStatusResource(const std::string& context /* = "/v2" */)
|
||||
{
|
||||
this->set_path(context + "/pet/findByStatus/");
|
||||
this->set_method_handler("GET",
|
||||
std::bind(&PetApiPetFindByStatusResource::handler_GET_internal, this,
|
||||
std::placeholders::_1));
|
||||
}
|
||||
|
||||
PetApiPetFindByStatusResource::~PetApiPetFindByStatusResource()
|
||||
{
|
||||
}
|
||||
|
||||
std::pair<int, std::string> PetApiPetFindByStatusResource::handlePetApiException(const PetApiException& e)
|
||||
{
|
||||
return std::make_pair<int, std::string>(e.getStatus(), e.what());
|
||||
}
|
||||
|
||||
std::pair<int, std::string> PetApiPetFindByStatusResource::handleStdException(const std::exception& e)
|
||||
{
|
||||
return std::make_pair<int, std::string>(500, e.what());
|
||||
}
|
||||
|
||||
std::pair<int, std::string> PetApiPetFindByStatusResource::handleUnspecifiedException()
|
||||
{
|
||||
return std::make_pair<int, std::string>(500, "Unknown exception occurred");
|
||||
}
|
||||
|
||||
void PetApiPetFindByStatusResource::setResponseHeader(const std::shared_ptr<restbed::Session>& session, const std::string& header)
|
||||
{
|
||||
session->set_header(header, "");
|
||||
}
|
||||
|
||||
void PetApiPetFindByStatusResource::returnResponse(const std::shared_ptr<restbed::Session>& session, const int status, const std::string& result, const std::string& contentType)
|
||||
{
|
||||
session->close(status, result, { {"Connection", "close"}, {"Content-Type", contentType} });
|
||||
}
|
||||
|
||||
void PetApiPetFindByStatusResource::defaultSessionClose(const std::shared_ptr<restbed::Session>& session, const int status, const std::string& result)
|
||||
{
|
||||
session->close(status, result, { {"Connection", "close"} });
|
||||
}
|
||||
|
||||
void PetApiPetFindByStatusResource::handler_GET_internal(const std::shared_ptr<restbed::Session> session)
|
||||
{
|
||||
const auto request = session->get_request();
|
||||
|
||||
|
||||
// Getting the query params
|
||||
|
||||
|
||||
int status_code = 500;
|
||||
std::vector<std::shared_ptr<Pet>> resultObject = std::vector<std::shared_ptr<Pet>>();
|
||||
std::string result = "";
|
||||
|
||||
try {
|
||||
std::tie(status_code, resultObject) =
|
||||
handler_GET(status);
|
||||
}
|
||||
catch(const PetApiException& e) {
|
||||
std::tie(status_code, result) = handlePetApiException(e);
|
||||
}
|
||||
catch(const std::exception& e) {
|
||||
std::tie(status_code, result) = handleStdException(e);
|
||||
}
|
||||
catch(...) {
|
||||
std::tie(status_code, result) = handleUnspecifiedException();
|
||||
}
|
||||
|
||||
if (status_code == 200) {
|
||||
|
||||
const constexpr auto contentType = "application/json";
|
||||
returnResponse(session, 200, result.empty() ? "successful operation" : result, contentType);
|
||||
return;
|
||||
}
|
||||
if (status_code == 400) {
|
||||
|
||||
const constexpr auto contentType = "text/plain";
|
||||
returnResponse(session, 400, result.empty() ? "Invalid status value" : result, contentType);
|
||||
return;
|
||||
}
|
||||
defaultSessionClose(session, status_code, result);
|
||||
}
|
||||
|
||||
|
||||
std::pair<int, std::vector<std::shared_ptr<Pet>>> PetApiPetFindByStatusResource::handler_GET(
|
||||
std::vector<std::string> const & status)
|
||||
{
|
||||
throw PetApiException(501, "Not implemented");
|
||||
}
|
||||
|
||||
|
||||
std::string PetApiPetFindByStatusResource::extractBodyContent(const std::shared_ptr<restbed::Session>& session) {
|
||||
const auto request = session->get_request();
|
||||
int content_length = request->get_header("Content-Length", 0);
|
||||
std::string bodyContent;
|
||||
session->fetch(content_length,
|
||||
[&bodyContent](const std::shared_ptr<restbed::Session> session,
|
||||
const restbed::Bytes &body) {
|
||||
bodyContent = restbed::String::format(
|
||||
"%.*s\n", (int)body.size(), body.data());
|
||||
});
|
||||
return bodyContent;
|
||||
}
|
||||
PetApiPetFindByTagsResource::PetApiPetFindByTagsResource(const std::string& context /* = "/v2" */)
|
||||
{
|
||||
this->set_path(context + "/pet/findByTags/");
|
||||
this->set_method_handler("GET",
|
||||
std::bind(&PetApiPetFindByTagsResource::handler_GET_internal, this,
|
||||
std::placeholders::_1));
|
||||
}
|
||||
|
||||
PetApiPetFindByTagsResource::~PetApiPetFindByTagsResource()
|
||||
{
|
||||
}
|
||||
|
||||
std::pair<int, std::string> PetApiPetFindByTagsResource::handlePetApiException(const PetApiException& e)
|
||||
{
|
||||
return std::make_pair<int, std::string>(e.getStatus(), e.what());
|
||||
}
|
||||
|
||||
std::pair<int, std::string> PetApiPetFindByTagsResource::handleStdException(const std::exception& e)
|
||||
{
|
||||
return std::make_pair<int, std::string>(500, e.what());
|
||||
}
|
||||
|
||||
std::pair<int, std::string> PetApiPetFindByTagsResource::handleUnspecifiedException()
|
||||
{
|
||||
return std::make_pair<int, std::string>(500, "Unknown exception occurred");
|
||||
}
|
||||
|
||||
void PetApiPetFindByTagsResource::setResponseHeader(const std::shared_ptr<restbed::Session>& session, const std::string& header)
|
||||
{
|
||||
session->set_header(header, "");
|
||||
}
|
||||
|
||||
void PetApiPetFindByTagsResource::returnResponse(const std::shared_ptr<restbed::Session>& session, const int status, const std::string& result, const std::string& contentType)
|
||||
{
|
||||
session->close(status, result, { {"Connection", "close"}, {"Content-Type", contentType} });
|
||||
}
|
||||
|
||||
void PetApiPetFindByTagsResource::defaultSessionClose(const std::shared_ptr<restbed::Session>& session, const int status, const std::string& result)
|
||||
{
|
||||
session->close(status, result, { {"Connection", "close"} });
|
||||
}
|
||||
|
||||
void PetApiPetFindByTagsResource::handler_GET_internal(const std::shared_ptr<restbed::Session> session)
|
||||
{
|
||||
const auto request = session->get_request();
|
||||
|
||||
|
||||
// Getting the query params
|
||||
|
||||
|
||||
int status_code = 500;
|
||||
std::vector<std::shared_ptr<Pet>> resultObject = std::vector<std::shared_ptr<Pet>>();
|
||||
std::string result = "";
|
||||
|
||||
try {
|
||||
std::tie(status_code, resultObject) =
|
||||
handler_GET(tags);
|
||||
}
|
||||
catch(const PetApiException& e) {
|
||||
std::tie(status_code, result) = handlePetApiException(e);
|
||||
}
|
||||
catch(const std::exception& e) {
|
||||
std::tie(status_code, result) = handleStdException(e);
|
||||
}
|
||||
catch(...) {
|
||||
std::tie(status_code, result) = handleUnspecifiedException();
|
||||
}
|
||||
|
||||
if (status_code == 200) {
|
||||
|
||||
const constexpr auto contentType = "application/json";
|
||||
returnResponse(session, 200, result.empty() ? "successful operation" : result, contentType);
|
||||
return;
|
||||
}
|
||||
if (status_code == 400) {
|
||||
|
||||
const constexpr auto contentType = "text/plain";
|
||||
returnResponse(session, 400, result.empty() ? "Invalid tag value" : result, contentType);
|
||||
return;
|
||||
}
|
||||
defaultSessionClose(session, status_code, result);
|
||||
}
|
||||
|
||||
|
||||
std::pair<int, std::vector<std::shared_ptr<Pet>>> PetApiPetFindByTagsResource::handler_GET(
|
||||
std::vector<std::string> const & tags)
|
||||
{
|
||||
throw PetApiException(501, "Not implemented");
|
||||
}
|
||||
|
||||
|
||||
std::string PetApiPetFindByTagsResource::extractBodyContent(const std::shared_ptr<restbed::Session>& session) {
|
||||
const auto request = session->get_request();
|
||||
int content_length = request->get_header("Content-Length", 0);
|
||||
std::string bodyContent;
|
||||
session->fetch(content_length,
|
||||
[&bodyContent](const std::shared_ptr<restbed::Session> session,
|
||||
const restbed::Bytes &body) {
|
||||
bodyContent = restbed::String::format(
|
||||
"%.*s\n", (int)body.size(), body.data());
|
||||
});
|
||||
return bodyContent;
|
||||
}
|
||||
PetApiPetPetIdUploadImageResource::PetApiPetPetIdUploadImageResource(const std::string& context /* = "/v2" */)
|
||||
{
|
||||
this->set_path(context + "/pet/{petId: .*}/uploadImage/");
|
||||
this->set_method_handler("POST",
|
||||
std::bind(&PetApiPetPetIdUploadImageResource::handler_POST_internal, this,
|
||||
std::placeholders::_1));
|
||||
}
|
||||
|
||||
PetApiPetPetIdUploadImageResource::~PetApiPetPetIdUploadImageResource()
|
||||
{
|
||||
}
|
||||
|
||||
std::pair<int, std::string> PetApiPetPetIdUploadImageResource::handlePetApiException(const PetApiException& e)
|
||||
{
|
||||
return std::make_pair<int, std::string>(e.getStatus(), e.what());
|
||||
}
|
||||
|
||||
std::pair<int, std::string> PetApiPetPetIdUploadImageResource::handleStdException(const std::exception& e)
|
||||
{
|
||||
return std::make_pair<int, std::string>(500, e.what());
|
||||
}
|
||||
|
||||
std::pair<int, std::string> PetApiPetPetIdUploadImageResource::handleUnspecifiedException()
|
||||
{
|
||||
return std::make_pair<int, std::string>(500, "Unknown exception occurred");
|
||||
}
|
||||
|
||||
void PetApiPetPetIdUploadImageResource::setResponseHeader(const std::shared_ptr<restbed::Session>& session, const std::string& header)
|
||||
{
|
||||
session->set_header(header, "");
|
||||
}
|
||||
|
||||
void PetApiPetPetIdUploadImageResource::returnResponse(const std::shared_ptr<restbed::Session>& session, const int status, const std::string& result, const std::string& contentType)
|
||||
{
|
||||
session->close(status, result, { {"Connection", "close"}, {"Content-Type", contentType} });
|
||||
}
|
||||
|
||||
void PetApiPetPetIdUploadImageResource::defaultSessionClose(const std::shared_ptr<restbed::Session>& session, const int status, const std::string& result)
|
||||
{
|
||||
session->close(status, result, { {"Connection", "close"} });
|
||||
}
|
||||
|
||||
void PetApiPetPetIdUploadImageResource::handler_POST_internal(const std::shared_ptr<restbed::Session> session)
|
||||
{
|
||||
const auto request = session->get_request();
|
||||
|
||||
// Getting the path params
|
||||
const int64_t petId = getPathParam_petId(request);
|
||||
|
||||
|
||||
|
||||
int status_code = 500;
|
||||
std::shared_ptr<ApiResponse> resultObject = std::make_shared<ApiResponse>();
|
||||
std::string result = "";
|
||||
|
||||
try {
|
||||
std::tie(status_code, resultObject) =
|
||||
handler_POST(petId, additionalMetadata, file);
|
||||
}
|
||||
catch(const PetApiException& e) {
|
||||
std::tie(status_code, result) = handlePetApiException(e);
|
||||
}
|
||||
catch(const std::exception& e) {
|
||||
std::tie(status_code, result) = handleStdException(e);
|
||||
}
|
||||
catch(...) {
|
||||
std::tie(status_code, result) = handleUnspecifiedException();
|
||||
}
|
||||
|
||||
if (status_code == 200) {
|
||||
result = resultObject->toJsonString();
|
||||
|
||||
const constexpr auto contentType = "application/json";
|
||||
returnResponse(session, 200, result.empty() ? "successful operation" : result, contentType);
|
||||
return;
|
||||
}
|
||||
defaultSessionClose(session, status_code, result);
|
||||
}
|
||||
|
||||
|
||||
std::pair<int, std::shared_ptr<ApiResponse>> PetApiPetPetIdUploadImageResource::handler_POST(
|
||||
int64_t const & petId, std::string const & additionalMetadata, std::string const & file)
|
||||
{
|
||||
throw PetApiException(501, "Not implemented");
|
||||
}
|
||||
|
||||
|
||||
std::string PetApiPetPetIdUploadImageResource::extractBodyContent(const std::shared_ptr<restbed::Session>& session) {
|
||||
const auto request = session->get_request();
|
||||
int content_length = request->get_header("Content-Length", 0);
|
||||
std::string bodyContent;
|
||||
session->fetch(content_length,
|
||||
[&bodyContent](const std::shared_ptr<restbed::Session> session,
|
||||
const restbed::Bytes &body) {
|
||||
bodyContent = restbed::String::format(
|
||||
"%.*s\n", (int)body.size(), body.data());
|
||||
});
|
||||
return bodyContent;
|
||||
}
|
||||
|
||||
PetApi::PetApi(std::shared_ptr<restbed::Service> const& restbedService)
|
||||
: m_service(restbedService)
|
||||
{
|
||||
}
|
||||
|
||||
PetApi::~PetApi() {}
|
||||
|
||||
void PetApi::setPetApiPetResource(std::shared_ptr<PetApiPetResource> spPetApiPetResource) {
|
||||
m_spPetApiPetResource = spPetApiPetResource;
|
||||
m_service->publish(m_spPetApiPetResource);
|
||||
}
|
||||
void PetApi::setPetApiPetPetIdResource(std::shared_ptr<PetApiPetPetIdResource> spPetApiPetPetIdResource) {
|
||||
m_spPetApiPetPetIdResource = spPetApiPetPetIdResource;
|
||||
m_service->publish(m_spPetApiPetPetIdResource);
|
||||
}
|
||||
void PetApi::setPetApiPetFindByStatusResource(std::shared_ptr<PetApiPetFindByStatusResource> spPetApiPetFindByStatusResource) {
|
||||
m_spPetApiPetFindByStatusResource = spPetApiPetFindByStatusResource;
|
||||
m_service->publish(m_spPetApiPetFindByStatusResource);
|
||||
}
|
||||
void PetApi::setPetApiPetFindByTagsResource(std::shared_ptr<PetApiPetFindByTagsResource> spPetApiPetFindByTagsResource) {
|
||||
m_spPetApiPetFindByTagsResource = spPetApiPetFindByTagsResource;
|
||||
m_service->publish(m_spPetApiPetFindByTagsResource);
|
||||
}
|
||||
void PetApi::setPetApiPetPetIdUploadImageResource(std::shared_ptr<PetApiPetPetIdUploadImageResource> spPetApiPetPetIdUploadImageResource) {
|
||||
m_spPetApiPetPetIdUploadImageResource = spPetApiPetPetIdUploadImageResource;
|
||||
m_service->publish(m_spPetApiPetPetIdUploadImageResource);
|
||||
}
|
||||
|
||||
|
||||
void PetApi::publishDefaultResources() {
|
||||
if (!m_spPetApiPetResource) {
|
||||
setPetApiPetResource(std::make_shared<PetApiPetResource>());
|
||||
}
|
||||
if (!m_spPetApiPetPetIdResource) {
|
||||
setPetApiPetPetIdResource(std::make_shared<PetApiPetPetIdResource>());
|
||||
}
|
||||
if (!m_spPetApiPetFindByStatusResource) {
|
||||
setPetApiPetFindByStatusResource(std::make_shared<PetApiPetFindByStatusResource>());
|
||||
}
|
||||
if (!m_spPetApiPetFindByTagsResource) {
|
||||
setPetApiPetFindByTagsResource(std::make_shared<PetApiPetFindByTagsResource>());
|
||||
}
|
||||
if (!m_spPetApiPetPetIdUploadImageResource) {
|
||||
setPetApiPetPetIdUploadImageResource(std::make_shared<PetApiPetPetIdUploadImageResource>());
|
||||
}
|
||||
}
|
||||
|
||||
std::shared_ptr<restbed::Service> PetApi::service() {
|
||||
return m_service;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
370
samples/server/petstore/cpp-restbed-deprecated/api/PetApi.h
Normal file
370
samples/server/petstore/cpp-restbed-deprecated/api/PetApi.h
Normal file
@@ -0,0 +1,370 @@
|
||||
/**
|
||||
* OpenAPI Petstore
|
||||
* This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
|
||||
*
|
||||
* The version of the OpenAPI document: 1.0.0
|
||||
*
|
||||
*
|
||||
* NOTE: This class is auto generated by OpenAPI-Generator unset.
|
||||
* https://openapi-generator.tech
|
||||
* Do not edit the class manually.
|
||||
*/
|
||||
|
||||
/*
|
||||
* PetApi.h
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef PetApi_H_
|
||||
#define PetApi_H_
|
||||
|
||||
|
||||
#include <memory>
|
||||
#include <utility>
|
||||
#include <exception>
|
||||
|
||||
#include <corvusoft/restbed/session.hpp>
|
||||
#include <corvusoft/restbed/resource.hpp>
|
||||
#include <corvusoft/restbed/request.hpp>
|
||||
#include <corvusoft/restbed/service.hpp>
|
||||
#include <corvusoft/restbed/settings.hpp>
|
||||
|
||||
#include "ApiResponse.h"
|
||||
#include "Pet.h"
|
||||
#include <string>
|
||||
|
||||
namespace org {
|
||||
namespace openapitools {
|
||||
namespace server {
|
||||
namespace api {
|
||||
|
||||
using namespace org::openapitools::server::model;
|
||||
|
||||
///
|
||||
/// Exception to flag problems in the handlers
|
||||
///
|
||||
class PetApiException: public std::exception
|
||||
{
|
||||
public:
|
||||
PetApiException(int status_code, std::string what);
|
||||
|
||||
int getStatus() const;
|
||||
const char* what() const noexcept override;
|
||||
|
||||
private:
|
||||
int m_status;
|
||||
std::string m_what;
|
||||
};
|
||||
|
||||
/// <summary>
|
||||
/// Add a new pet to the store
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
///
|
||||
/// </remarks>
|
||||
class PetApiPetResource: public restbed::Resource
|
||||
{
|
||||
public:
|
||||
PetApiPetResource(const std::string& context = "/v2");
|
||||
virtual ~PetApiPetResource();
|
||||
|
||||
protected:
|
||||
//////////////////////////////////////////////////////////
|
||||
// Override these to implement the server functionality //
|
||||
//////////////////////////////////////////////////////////
|
||||
|
||||
virtual std::pair<int, std::shared_ptr<Pet>> handler_POST(
|
||||
std::shared_ptr<Pet> const & pet);
|
||||
|
||||
virtual std::pair<int, std::shared_ptr<Pet>> handler_PUT(
|
||||
std::shared_ptr<Pet> const & pet);
|
||||
|
||||
protected:
|
||||
//////////////////////////////////////
|
||||
// Override these for customization //
|
||||
//////////////////////////////////////
|
||||
|
||||
virtual std::string extractBodyContent(const std::shared_ptr<restbed::Session>& session);
|
||||
|
||||
|
||||
|
||||
virtual std::pair<int, std::string> handlePetApiException(const PetApiException& e);
|
||||
virtual std::pair<int, std::string> handleStdException(const std::exception& e);
|
||||
virtual std::pair<int, std::string> handleUnspecifiedException();
|
||||
|
||||
virtual void setResponseHeader(const std::shared_ptr<restbed::Session>& session,
|
||||
const std::string& header);
|
||||
|
||||
|
||||
virtual void returnResponse(const std::shared_ptr<restbed::Session>& session,
|
||||
const int status, const std::string& result, const std::string& contentType);
|
||||
virtual void defaultSessionClose(const std::shared_ptr<restbed::Session>& session,
|
||||
const int status, const std::string& result);
|
||||
|
||||
private:
|
||||
void handler_POST_internal(const std::shared_ptr<restbed::Session> session);
|
||||
void handler_PUT_internal(const std::shared_ptr<restbed::Session> session);
|
||||
};
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Deletes a pet
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
///
|
||||
/// </remarks>
|
||||
class PetApiPetPetIdResource: public restbed::Resource
|
||||
{
|
||||
public:
|
||||
PetApiPetPetIdResource(const std::string& context = "/v2");
|
||||
virtual ~PetApiPetPetIdResource();
|
||||
|
||||
protected:
|
||||
//////////////////////////////////////////////////////////
|
||||
// Override these to implement the server functionality //
|
||||
//////////////////////////////////////////////////////////
|
||||
|
||||
virtual int handler_DELETE(
|
||||
int64_t const & petId, std::string const & apiKey);
|
||||
|
||||
virtual std::pair<int, std::shared_ptr<Pet>> handler_GET(
|
||||
int64_t const & petId);
|
||||
virtual int handler_POST(
|
||||
int64_t const & petId, std::string const & name, std::string const & status);
|
||||
|
||||
protected:
|
||||
//////////////////////////////////////
|
||||
// Override these for customization //
|
||||
//////////////////////////////////////
|
||||
|
||||
virtual std::string extractBodyContent(const std::shared_ptr<restbed::Session>& session);
|
||||
|
||||
virtual int64_t getPathParam_petId(const std::shared_ptr<const restbed::Request>& request)
|
||||
{
|
||||
return request->get_path_parameter("petId", 0L);
|
||||
}
|
||||
|
||||
virtual std::string getHeader_api_key(const std::shared_ptr<const restbed::Request>& request)
|
||||
{
|
||||
return request->get_header("api_key", "");
|
||||
}
|
||||
|
||||
|
||||
virtual int64_t getPathParam_petId_x_extension(const std::shared_ptr<const restbed::Request>& request)
|
||||
{
|
||||
return request->get_path_parameter("petId", 0L);
|
||||
}
|
||||
virtual int64_t getPathParam_petId_x_extension(const std::shared_ptr<const restbed::Request>& request)
|
||||
{
|
||||
return request->get_path_parameter("petId", 0L);
|
||||
}
|
||||
|
||||
virtual std::pair<int, std::string> handlePetApiException(const PetApiException& e);
|
||||
virtual std::pair<int, std::string> handleStdException(const std::exception& e);
|
||||
virtual std::pair<int, std::string> handleUnspecifiedException();
|
||||
|
||||
virtual void setResponseHeader(const std::shared_ptr<restbed::Session>& session,
|
||||
const std::string& header);
|
||||
|
||||
|
||||
virtual void returnResponse(const std::shared_ptr<restbed::Session>& session,
|
||||
const int status, const std::string& result, const std::string& contentType);
|
||||
virtual void defaultSessionClose(const std::shared_ptr<restbed::Session>& session,
|
||||
const int status, const std::string& result);
|
||||
|
||||
private:
|
||||
void handler_DELETE_internal(const std::shared_ptr<restbed::Session> session);
|
||||
void handler_GET_internal(const std::shared_ptr<restbed::Session> session);
|
||||
void handler_POST_internal(const std::shared_ptr<restbed::Session> session);
|
||||
};
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Finds Pets by status
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Multiple status values can be provided with comma separated strings
|
||||
/// </remarks>
|
||||
class PetApiPetFindByStatusResource: public restbed::Resource
|
||||
{
|
||||
public:
|
||||
PetApiPetFindByStatusResource(const std::string& context = "/v2");
|
||||
virtual ~PetApiPetFindByStatusResource();
|
||||
|
||||
protected:
|
||||
//////////////////////////////////////////////////////////
|
||||
// Override these to implement the server functionality //
|
||||
//////////////////////////////////////////////////////////
|
||||
|
||||
virtual std::pair<int, std::vector<std::shared_ptr<Pet>>> handler_GET(
|
||||
std::vector<std::string> const & status);
|
||||
|
||||
|
||||
protected:
|
||||
//////////////////////////////////////
|
||||
// Override these for customization //
|
||||
//////////////////////////////////////
|
||||
|
||||
virtual std::string extractBodyContent(const std::shared_ptr<restbed::Session>& session);
|
||||
|
||||
|
||||
|
||||
virtual std::pair<int, std::string> handlePetApiException(const PetApiException& e);
|
||||
virtual std::pair<int, std::string> handleStdException(const std::exception& e);
|
||||
virtual std::pair<int, std::string> handleUnspecifiedException();
|
||||
|
||||
virtual void setResponseHeader(const std::shared_ptr<restbed::Session>& session,
|
||||
const std::string& header);
|
||||
|
||||
|
||||
virtual void returnResponse(const std::shared_ptr<restbed::Session>& session,
|
||||
const int status, const std::string& result, const std::string& contentType);
|
||||
virtual void defaultSessionClose(const std::shared_ptr<restbed::Session>& session,
|
||||
const int status, const std::string& result);
|
||||
|
||||
private:
|
||||
void handler_GET_internal(const std::shared_ptr<restbed::Session> session);
|
||||
};
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Finds Pets by tags
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.
|
||||
/// </remarks>
|
||||
class PetApiPetFindByTagsResource: public restbed::Resource
|
||||
{
|
||||
public:
|
||||
PetApiPetFindByTagsResource(const std::string& context = "/v2");
|
||||
virtual ~PetApiPetFindByTagsResource();
|
||||
|
||||
protected:
|
||||
//////////////////////////////////////////////////////////
|
||||
// Override these to implement the server functionality //
|
||||
//////////////////////////////////////////////////////////
|
||||
|
||||
virtual std::pair<int, std::vector<std::shared_ptr<Pet>>> handler_GET(
|
||||
std::vector<std::string> const & tags);
|
||||
|
||||
|
||||
protected:
|
||||
//////////////////////////////////////
|
||||
// Override these for customization //
|
||||
//////////////////////////////////////
|
||||
|
||||
virtual std::string extractBodyContent(const std::shared_ptr<restbed::Session>& session);
|
||||
|
||||
|
||||
|
||||
virtual std::pair<int, std::string> handlePetApiException(const PetApiException& e);
|
||||
virtual std::pair<int, std::string> handleStdException(const std::exception& e);
|
||||
virtual std::pair<int, std::string> handleUnspecifiedException();
|
||||
|
||||
virtual void setResponseHeader(const std::shared_ptr<restbed::Session>& session,
|
||||
const std::string& header);
|
||||
|
||||
|
||||
virtual void returnResponse(const std::shared_ptr<restbed::Session>& session,
|
||||
const int status, const std::string& result, const std::string& contentType);
|
||||
virtual void defaultSessionClose(const std::shared_ptr<restbed::Session>& session,
|
||||
const int status, const std::string& result);
|
||||
|
||||
private:
|
||||
void handler_GET_internal(const std::shared_ptr<restbed::Session> session);
|
||||
};
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// uploads an image
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
///
|
||||
/// </remarks>
|
||||
class PetApiPetPetIdUploadImageResource: public restbed::Resource
|
||||
{
|
||||
public:
|
||||
PetApiPetPetIdUploadImageResource(const std::string& context = "/v2");
|
||||
virtual ~PetApiPetPetIdUploadImageResource();
|
||||
|
||||
protected:
|
||||
//////////////////////////////////////////////////////////
|
||||
// Override these to implement the server functionality //
|
||||
//////////////////////////////////////////////////////////
|
||||
|
||||
virtual std::pair<int, std::shared_ptr<ApiResponse>> handler_POST(
|
||||
int64_t const & petId, std::string const & additionalMetadata, std::string const & file);
|
||||
|
||||
|
||||
protected:
|
||||
//////////////////////////////////////
|
||||
// Override these for customization //
|
||||
//////////////////////////////////////
|
||||
|
||||
virtual std::string extractBodyContent(const std::shared_ptr<restbed::Session>& session);
|
||||
|
||||
virtual int64_t getPathParam_petId(const std::shared_ptr<const restbed::Request>& request)
|
||||
{
|
||||
return request->get_path_parameter("petId", 0L);
|
||||
}
|
||||
|
||||
|
||||
|
||||
virtual std::pair<int, std::string> handlePetApiException(const PetApiException& e);
|
||||
virtual std::pair<int, std::string> handleStdException(const std::exception& e);
|
||||
virtual std::pair<int, std::string> handleUnspecifiedException();
|
||||
|
||||
virtual void setResponseHeader(const std::shared_ptr<restbed::Session>& session,
|
||||
const std::string& header);
|
||||
|
||||
|
||||
virtual void returnResponse(const std::shared_ptr<restbed::Session>& session,
|
||||
const int status, const std::string& result, const std::string& contentType);
|
||||
virtual void defaultSessionClose(const std::shared_ptr<restbed::Session>& session,
|
||||
const int status, const std::string& result);
|
||||
|
||||
private:
|
||||
void handler_POST_internal(const std::shared_ptr<restbed::Session> session);
|
||||
};
|
||||
|
||||
|
||||
|
||||
//
|
||||
// The restbed service to actually implement the REST server
|
||||
//
|
||||
class PetApi
|
||||
{
|
||||
public:
|
||||
explicit PetApi(std::shared_ptr<restbed::Service> const& restbedService);
|
||||
virtual ~PetApi();
|
||||
|
||||
virtual void setPetApiPetResource(std::shared_ptr<PetApiPetResource> spPetApiPetResource);
|
||||
virtual void setPetApiPetPetIdResource(std::shared_ptr<PetApiPetPetIdResource> spPetApiPetPetIdResource);
|
||||
virtual void setPetApiPetFindByStatusResource(std::shared_ptr<PetApiPetFindByStatusResource> spPetApiPetFindByStatusResource);
|
||||
virtual void setPetApiPetFindByTagsResource(std::shared_ptr<PetApiPetFindByTagsResource> spPetApiPetFindByTagsResource);
|
||||
virtual void setPetApiPetPetIdUploadImageResource(std::shared_ptr<PetApiPetPetIdUploadImageResource> spPetApiPetPetIdUploadImageResource);
|
||||
|
||||
virtual void publishDefaultResources();
|
||||
|
||||
virtual std::shared_ptr<restbed::Service> service();
|
||||
|
||||
protected:
|
||||
std::shared_ptr<PetApiPetResource> m_spPetApiPetResource;
|
||||
std::shared_ptr<PetApiPetPetIdResource> m_spPetApiPetPetIdResource;
|
||||
std::shared_ptr<PetApiPetFindByStatusResource> m_spPetApiPetFindByStatusResource;
|
||||
std::shared_ptr<PetApiPetFindByTagsResource> m_spPetApiPetFindByTagsResource;
|
||||
std::shared_ptr<PetApiPetPetIdUploadImageResource> m_spPetApiPetPetIdUploadImageResource;
|
||||
|
||||
private:
|
||||
std::shared_ptr<restbed::Service> m_service;
|
||||
};
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif /* PetApi_H_ */
|
||||
|
||||
497
samples/server/petstore/cpp-restbed-deprecated/api/StoreApi.cpp
Normal file
497
samples/server/petstore/cpp-restbed-deprecated/api/StoreApi.cpp
Normal file
@@ -0,0 +1,497 @@
|
||||
/**
|
||||
* OpenAPI Petstore
|
||||
* This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
|
||||
*
|
||||
* The version of the OpenAPI document: 1.0.0
|
||||
*
|
||||
*
|
||||
* NOTE: This class is auto generated by OpenAPI-Generator unset.
|
||||
* https://openapi-generator.tech
|
||||
* Do not edit the class manually.
|
||||
*/
|
||||
|
||||
|
||||
#include <corvusoft/restbed/byte.hpp>
|
||||
#include <corvusoft/restbed/string.hpp>
|
||||
#include <corvusoft/restbed/settings.hpp>
|
||||
#include <corvusoft/restbed/request.hpp>
|
||||
#include <corvusoft/restbed/uri.hpp>
|
||||
#include <boost/property_tree/ptree.hpp>
|
||||
#include <boost/property_tree/json_parser.hpp>
|
||||
#include <boost/lexical_cast.hpp>
|
||||
#include <boost/algorithm/string.hpp>
|
||||
|
||||
#include "StoreApi.h"
|
||||
|
||||
namespace org {
|
||||
namespace openapitools {
|
||||
namespace server {
|
||||
namespace api {
|
||||
|
||||
using namespace org::openapitools::server::model;
|
||||
|
||||
StoreApiException::StoreApiException(int status_code, std::string what)
|
||||
: m_status(status_code),
|
||||
m_what(what)
|
||||
{
|
||||
|
||||
}
|
||||
int StoreApiException::getStatus() const
|
||||
{
|
||||
return m_status;
|
||||
}
|
||||
const char* StoreApiException::what() const noexcept
|
||||
{
|
||||
return m_what.c_str();
|
||||
}
|
||||
|
||||
|
||||
template<class MODEL_T>
|
||||
std::shared_ptr<MODEL_T> extractJsonModelBodyParam(const std::string& bodyContent)
|
||||
{
|
||||
std::stringstream sstream(bodyContent);
|
||||
boost::property_tree::ptree pt;
|
||||
boost::property_tree::json_parser::read_json(sstream, pt);
|
||||
|
||||
auto model = std::make_shared<MODEL_T>(pt);
|
||||
return model;
|
||||
}
|
||||
|
||||
template<class MODEL_T>
|
||||
std::vector<std::shared_ptr<MODEL_T>> extractJsonArrayBodyParam(const std::string& bodyContent)
|
||||
{
|
||||
std::stringstream sstream(bodyContent);
|
||||
boost::property_tree::ptree pt;
|
||||
boost::property_tree::json_parser::read_json(sstream, pt);
|
||||
|
||||
auto arrayRet = std::vector<std::shared_ptr<MODEL_T>>();
|
||||
for (const auto& child: pt) {
|
||||
arrayRet.emplace_back(std::make_shared<MODEL_T>(child.second));
|
||||
}
|
||||
return arrayRet;
|
||||
}
|
||||
|
||||
template <class KEY_T, class VAL_T>
|
||||
std::string convertMapResponse(const std::map<KEY_T, VAL_T>& map)
|
||||
{
|
||||
boost::property_tree::ptree pt;
|
||||
for(const auto &kv: map) {
|
||||
pt.push_back(boost::property_tree::ptree::value_type(
|
||||
boost::lexical_cast<std::string>(kv.first),
|
||||
boost::property_tree::ptree(
|
||||
boost::lexical_cast<std::string>(kv.second))));
|
||||
}
|
||||
std::stringstream sstream;
|
||||
write_json(sstream, pt);
|
||||
std::string result = sstream.str();
|
||||
return result;
|
||||
}
|
||||
|
||||
StoreApiStoreOrderOrderIdResource::StoreApiStoreOrderOrderIdResource(const std::string& context /* = "/v2" */)
|
||||
{
|
||||
this->set_path(context + "/store/order/{orderId: .*}/");
|
||||
this->set_method_handler("DELETE",
|
||||
std::bind(&StoreApiStoreOrderOrderIdResource::handler_DELETE_internal, this,
|
||||
std::placeholders::_1));
|
||||
this->set_method_handler("GET",
|
||||
std::bind(&StoreApiStoreOrderOrderIdResource::handler_GET_internal, this,
|
||||
std::placeholders::_1));
|
||||
}
|
||||
|
||||
StoreApiStoreOrderOrderIdResource::~StoreApiStoreOrderOrderIdResource()
|
||||
{
|
||||
}
|
||||
|
||||
std::pair<int, std::string> StoreApiStoreOrderOrderIdResource::handleStoreApiException(const StoreApiException& e)
|
||||
{
|
||||
return std::make_pair<int, std::string>(e.getStatus(), e.what());
|
||||
}
|
||||
|
||||
std::pair<int, std::string> StoreApiStoreOrderOrderIdResource::handleStdException(const std::exception& e)
|
||||
{
|
||||
return std::make_pair<int, std::string>(500, e.what());
|
||||
}
|
||||
|
||||
std::pair<int, std::string> StoreApiStoreOrderOrderIdResource::handleUnspecifiedException()
|
||||
{
|
||||
return std::make_pair<int, std::string>(500, "Unknown exception occurred");
|
||||
}
|
||||
|
||||
void StoreApiStoreOrderOrderIdResource::setResponseHeader(const std::shared_ptr<restbed::Session>& session, const std::string& header)
|
||||
{
|
||||
session->set_header(header, "");
|
||||
}
|
||||
|
||||
void StoreApiStoreOrderOrderIdResource::returnResponse(const std::shared_ptr<restbed::Session>& session, const int status, const std::string& result, const std::string& contentType)
|
||||
{
|
||||
session->close(status, result, { {"Connection", "close"}, {"Content-Type", contentType} });
|
||||
}
|
||||
|
||||
void StoreApiStoreOrderOrderIdResource::defaultSessionClose(const std::shared_ptr<restbed::Session>& session, const int status, const std::string& result)
|
||||
{
|
||||
session->close(status, result, { {"Connection", "close"} });
|
||||
}
|
||||
|
||||
void StoreApiStoreOrderOrderIdResource::handler_DELETE_internal(const std::shared_ptr<restbed::Session> session)
|
||||
{
|
||||
const auto request = session->get_request();
|
||||
|
||||
// Getting the path params
|
||||
const std::string orderId = getPathParam_orderId(request);
|
||||
|
||||
|
||||
|
||||
int status_code = 500;
|
||||
std::string result = "";
|
||||
|
||||
try {
|
||||
status_code =
|
||||
handler_DELETE(orderId);
|
||||
}
|
||||
catch(const StoreApiException& e) {
|
||||
std::tie(status_code, result) = handleStoreApiException(e);
|
||||
}
|
||||
catch(const std::exception& e) {
|
||||
std::tie(status_code, result) = handleStdException(e);
|
||||
}
|
||||
catch(...) {
|
||||
std::tie(status_code, result) = handleUnspecifiedException();
|
||||
}
|
||||
|
||||
if (status_code == 400) {
|
||||
|
||||
const constexpr auto contentType = "text/plain";
|
||||
returnResponse(session, 400, result.empty() ? "Invalid ID supplied" : result, contentType);
|
||||
return;
|
||||
}
|
||||
if (status_code == 404) {
|
||||
|
||||
const constexpr auto contentType = "text/plain";
|
||||
returnResponse(session, 404, result.empty() ? "Order not found" : result, contentType);
|
||||
return;
|
||||
}
|
||||
defaultSessionClose(session, status_code, result);
|
||||
}
|
||||
|
||||
// x-extension
|
||||
void StoreApiStoreOrderOrderIdResource::handler_GET_internal(const std::shared_ptr<restbed::Session> session) {
|
||||
|
||||
const auto request = session->get_request();
|
||||
|
||||
// Getting the path params
|
||||
const int64_t orderId = getPathParam_orderId_x_extension(request);
|
||||
|
||||
|
||||
int status_code = 500;
|
||||
std::shared_ptr<Order> resultObject = std::make_shared<Order>();
|
||||
std::string result = "";
|
||||
|
||||
try {
|
||||
std::tie(status_code, resultObject) =
|
||||
handler_GET(orderId);
|
||||
}
|
||||
catch(const StoreApiException& e) {
|
||||
std::tie(status_code, result) = handleStoreApiException(e);
|
||||
}
|
||||
catch(const std::exception& e) {
|
||||
std::tie(status_code, result) = handleStdException(e);
|
||||
}
|
||||
catch(...) {
|
||||
std::tie(status_code, result) = handleUnspecifiedException();
|
||||
}
|
||||
|
||||
if (status_code == 200) {
|
||||
result = resultObject->toJsonString();
|
||||
|
||||
const constexpr auto contentType = "application/json";
|
||||
returnResponse(session, 200, result.empty() ? "successful operation" : result, contentType);
|
||||
return;
|
||||
}
|
||||
if (status_code == 400) {
|
||||
|
||||
const constexpr auto contentType = "text/plain";
|
||||
returnResponse(session, 400, result.empty() ? "Invalid ID supplied" : result, contentType);
|
||||
return;
|
||||
}
|
||||
if (status_code == 404) {
|
||||
|
||||
const constexpr auto contentType = "text/plain";
|
||||
returnResponse(session, 404, result.empty() ? "Order not found" : result, contentType);
|
||||
return;
|
||||
}
|
||||
defaultSessionClose(session, status_code, result);
|
||||
}
|
||||
|
||||
int StoreApiStoreOrderOrderIdResource::handler_DELETE(
|
||||
std::string const & orderId)
|
||||
{
|
||||
throw StoreApiException(501, "Not implemented");
|
||||
}
|
||||
|
||||
std::pair<int, std::shared_ptr<Order>> StoreApiStoreOrderOrderIdResource::handler_GET(
|
||||
int64_t const & orderId)
|
||||
{
|
||||
throw StoreApiException(501, "Not implemented");
|
||||
}
|
||||
|
||||
std::string StoreApiStoreOrderOrderIdResource::extractBodyContent(const std::shared_ptr<restbed::Session>& session) {
|
||||
const auto request = session->get_request();
|
||||
int content_length = request->get_header("Content-Length", 0);
|
||||
std::string bodyContent;
|
||||
session->fetch(content_length,
|
||||
[&bodyContent](const std::shared_ptr<restbed::Session> session,
|
||||
const restbed::Bytes &body) {
|
||||
bodyContent = restbed::String::format(
|
||||
"%.*s\n", (int)body.size(), body.data());
|
||||
});
|
||||
return bodyContent;
|
||||
}
|
||||
StoreApiStoreInventoryResource::StoreApiStoreInventoryResource(const std::string& context /* = "/v2" */)
|
||||
{
|
||||
this->set_path(context + "/store/inventory/");
|
||||
this->set_method_handler("GET",
|
||||
std::bind(&StoreApiStoreInventoryResource::handler_GET_internal, this,
|
||||
std::placeholders::_1));
|
||||
}
|
||||
|
||||
StoreApiStoreInventoryResource::~StoreApiStoreInventoryResource()
|
||||
{
|
||||
}
|
||||
|
||||
std::pair<int, std::string> StoreApiStoreInventoryResource::handleStoreApiException(const StoreApiException& e)
|
||||
{
|
||||
return std::make_pair<int, std::string>(e.getStatus(), e.what());
|
||||
}
|
||||
|
||||
std::pair<int, std::string> StoreApiStoreInventoryResource::handleStdException(const std::exception& e)
|
||||
{
|
||||
return std::make_pair<int, std::string>(500, e.what());
|
||||
}
|
||||
|
||||
std::pair<int, std::string> StoreApiStoreInventoryResource::handleUnspecifiedException()
|
||||
{
|
||||
return std::make_pair<int, std::string>(500, "Unknown exception occurred");
|
||||
}
|
||||
|
||||
void StoreApiStoreInventoryResource::setResponseHeader(const std::shared_ptr<restbed::Session>& session, const std::string& header)
|
||||
{
|
||||
session->set_header(header, "");
|
||||
}
|
||||
|
||||
void StoreApiStoreInventoryResource::returnResponse(const std::shared_ptr<restbed::Session>& session, const int status, const std::string& result, const std::string& contentType)
|
||||
{
|
||||
session->close(status, result, { {"Connection", "close"}, {"Content-Type", contentType} });
|
||||
}
|
||||
|
||||
void StoreApiStoreInventoryResource::defaultSessionClose(const std::shared_ptr<restbed::Session>& session, const int status, const std::string& result)
|
||||
{
|
||||
session->close(status, result, { {"Connection", "close"} });
|
||||
}
|
||||
|
||||
void StoreApiStoreInventoryResource::handler_GET_internal(const std::shared_ptr<restbed::Session> session)
|
||||
{
|
||||
const auto request = session->get_request();
|
||||
|
||||
|
||||
|
||||
|
||||
int status_code = 500;
|
||||
std::map<std::string, int32_t> resultObject = std::map<std::string, int32_t>();
|
||||
std::string result = "";
|
||||
|
||||
try {
|
||||
std::tie(status_code, resultObject) =
|
||||
handler_GET();
|
||||
}
|
||||
catch(const StoreApiException& e) {
|
||||
std::tie(status_code, result) = handleStoreApiException(e);
|
||||
}
|
||||
catch(const std::exception& e) {
|
||||
std::tie(status_code, result) = handleStdException(e);
|
||||
}
|
||||
catch(...) {
|
||||
std::tie(status_code, result) = handleUnspecifiedException();
|
||||
}
|
||||
|
||||
if (status_code == 200) {
|
||||
result = resultObject->toJsonString();
|
||||
result = convertMapResponse(resultObject);
|
||||
|
||||
const constexpr auto contentType = "application/json";
|
||||
returnResponse(session, 200, result.empty() ? "successful operation" : result, contentType);
|
||||
return;
|
||||
}
|
||||
defaultSessionClose(session, status_code, result);
|
||||
}
|
||||
|
||||
|
||||
std::pair<int, std::map<std::string, int32_t>> StoreApiStoreInventoryResource::handler_GET(
|
||||
)
|
||||
{
|
||||
throw StoreApiException(501, "Not implemented");
|
||||
}
|
||||
|
||||
|
||||
std::string StoreApiStoreInventoryResource::extractBodyContent(const std::shared_ptr<restbed::Session>& session) {
|
||||
const auto request = session->get_request();
|
||||
int content_length = request->get_header("Content-Length", 0);
|
||||
std::string bodyContent;
|
||||
session->fetch(content_length,
|
||||
[&bodyContent](const std::shared_ptr<restbed::Session> session,
|
||||
const restbed::Bytes &body) {
|
||||
bodyContent = restbed::String::format(
|
||||
"%.*s\n", (int)body.size(), body.data());
|
||||
});
|
||||
return bodyContent;
|
||||
}
|
||||
StoreApiStoreOrderResource::StoreApiStoreOrderResource(const std::string& context /* = "/v2" */)
|
||||
{
|
||||
this->set_path(context + "/store/order/");
|
||||
this->set_method_handler("POST",
|
||||
std::bind(&StoreApiStoreOrderResource::handler_POST_internal, this,
|
||||
std::placeholders::_1));
|
||||
}
|
||||
|
||||
StoreApiStoreOrderResource::~StoreApiStoreOrderResource()
|
||||
{
|
||||
}
|
||||
|
||||
std::pair<int, std::string> StoreApiStoreOrderResource::handleStoreApiException(const StoreApiException& e)
|
||||
{
|
||||
return std::make_pair<int, std::string>(e.getStatus(), e.what());
|
||||
}
|
||||
|
||||
std::pair<int, std::string> StoreApiStoreOrderResource::handleStdException(const std::exception& e)
|
||||
{
|
||||
return std::make_pair<int, std::string>(500, e.what());
|
||||
}
|
||||
|
||||
std::pair<int, std::string> StoreApiStoreOrderResource::handleUnspecifiedException()
|
||||
{
|
||||
return std::make_pair<int, std::string>(500, "Unknown exception occurred");
|
||||
}
|
||||
|
||||
void StoreApiStoreOrderResource::setResponseHeader(const std::shared_ptr<restbed::Session>& session, const std::string& header)
|
||||
{
|
||||
session->set_header(header, "");
|
||||
}
|
||||
|
||||
void StoreApiStoreOrderResource::returnResponse(const std::shared_ptr<restbed::Session>& session, const int status, const std::string& result, const std::string& contentType)
|
||||
{
|
||||
session->close(status, result, { {"Connection", "close"}, {"Content-Type", contentType} });
|
||||
}
|
||||
|
||||
void StoreApiStoreOrderResource::defaultSessionClose(const std::shared_ptr<restbed::Session>& session, const int status, const std::string& result)
|
||||
{
|
||||
session->close(status, result, { {"Connection", "close"} });
|
||||
}
|
||||
|
||||
void StoreApiStoreOrderResource::handler_POST_internal(const std::shared_ptr<restbed::Session> session)
|
||||
{
|
||||
const auto request = session->get_request();
|
||||
std::string bodyContent = extractBodyContent(session);
|
||||
|
||||
// Get body params or form params here from the body content string
|
||||
auto order = extractJsonModelBodyParam<Order>(bodyContent);
|
||||
|
||||
|
||||
|
||||
|
||||
int status_code = 500;
|
||||
std::shared_ptr<Order> resultObject = std::make_shared<Order>();
|
||||
std::string result = "";
|
||||
|
||||
try {
|
||||
std::tie(status_code, resultObject) =
|
||||
handler_POST(order);
|
||||
}
|
||||
catch(const StoreApiException& e) {
|
||||
std::tie(status_code, result) = handleStoreApiException(e);
|
||||
}
|
||||
catch(const std::exception& e) {
|
||||
std::tie(status_code, result) = handleStdException(e);
|
||||
}
|
||||
catch(...) {
|
||||
std::tie(status_code, result) = handleUnspecifiedException();
|
||||
}
|
||||
|
||||
if (status_code == 200) {
|
||||
result = resultObject->toJsonString();
|
||||
|
||||
const constexpr auto contentType = "application/json";
|
||||
returnResponse(session, 200, result.empty() ? "successful operation" : result, contentType);
|
||||
return;
|
||||
}
|
||||
if (status_code == 400) {
|
||||
|
||||
const constexpr auto contentType = "text/plain";
|
||||
returnResponse(session, 400, result.empty() ? "Invalid Order" : result, contentType);
|
||||
return;
|
||||
}
|
||||
defaultSessionClose(session, status_code, result);
|
||||
}
|
||||
|
||||
|
||||
std::pair<int, std::shared_ptr<Order>> StoreApiStoreOrderResource::handler_POST(
|
||||
std::shared_ptr<Order> const & order)
|
||||
{
|
||||
throw StoreApiException(501, "Not implemented");
|
||||
}
|
||||
|
||||
|
||||
std::string StoreApiStoreOrderResource::extractBodyContent(const std::shared_ptr<restbed::Session>& session) {
|
||||
const auto request = session->get_request();
|
||||
int content_length = request->get_header("Content-Length", 0);
|
||||
std::string bodyContent;
|
||||
session->fetch(content_length,
|
||||
[&bodyContent](const std::shared_ptr<restbed::Session> session,
|
||||
const restbed::Bytes &body) {
|
||||
bodyContent = restbed::String::format(
|
||||
"%.*s\n", (int)body.size(), body.data());
|
||||
});
|
||||
return bodyContent;
|
||||
}
|
||||
|
||||
StoreApi::StoreApi(std::shared_ptr<restbed::Service> const& restbedService)
|
||||
: m_service(restbedService)
|
||||
{
|
||||
}
|
||||
|
||||
StoreApi::~StoreApi() {}
|
||||
|
||||
void StoreApi::setStoreApiStoreOrderOrderIdResource(std::shared_ptr<StoreApiStoreOrderOrderIdResource> spStoreApiStoreOrderOrderIdResource) {
|
||||
m_spStoreApiStoreOrderOrderIdResource = spStoreApiStoreOrderOrderIdResource;
|
||||
m_service->publish(m_spStoreApiStoreOrderOrderIdResource);
|
||||
}
|
||||
void StoreApi::setStoreApiStoreInventoryResource(std::shared_ptr<StoreApiStoreInventoryResource> spStoreApiStoreInventoryResource) {
|
||||
m_spStoreApiStoreInventoryResource = spStoreApiStoreInventoryResource;
|
||||
m_service->publish(m_spStoreApiStoreInventoryResource);
|
||||
}
|
||||
void StoreApi::setStoreApiStoreOrderResource(std::shared_ptr<StoreApiStoreOrderResource> spStoreApiStoreOrderResource) {
|
||||
m_spStoreApiStoreOrderResource = spStoreApiStoreOrderResource;
|
||||
m_service->publish(m_spStoreApiStoreOrderResource);
|
||||
}
|
||||
|
||||
|
||||
void StoreApi::publishDefaultResources() {
|
||||
if (!m_spStoreApiStoreOrderOrderIdResource) {
|
||||
setStoreApiStoreOrderOrderIdResource(std::make_shared<StoreApiStoreOrderOrderIdResource>());
|
||||
}
|
||||
if (!m_spStoreApiStoreInventoryResource) {
|
||||
setStoreApiStoreInventoryResource(std::make_shared<StoreApiStoreInventoryResource>());
|
||||
}
|
||||
if (!m_spStoreApiStoreOrderResource) {
|
||||
setStoreApiStoreOrderResource(std::make_shared<StoreApiStoreOrderResource>());
|
||||
}
|
||||
}
|
||||
|
||||
std::shared_ptr<restbed::Service> StoreApi::service() {
|
||||
return m_service;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
250
samples/server/petstore/cpp-restbed-deprecated/api/StoreApi.h
Normal file
250
samples/server/petstore/cpp-restbed-deprecated/api/StoreApi.h
Normal file
@@ -0,0 +1,250 @@
|
||||
/**
|
||||
* OpenAPI Petstore
|
||||
* This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
|
||||
*
|
||||
* The version of the OpenAPI document: 1.0.0
|
||||
*
|
||||
*
|
||||
* NOTE: This class is auto generated by OpenAPI-Generator unset.
|
||||
* https://openapi-generator.tech
|
||||
* Do not edit the class manually.
|
||||
*/
|
||||
|
||||
/*
|
||||
* StoreApi.h
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef StoreApi_H_
|
||||
#define StoreApi_H_
|
||||
|
||||
|
||||
#include <memory>
|
||||
#include <utility>
|
||||
#include <exception>
|
||||
|
||||
#include <corvusoft/restbed/session.hpp>
|
||||
#include <corvusoft/restbed/resource.hpp>
|
||||
#include <corvusoft/restbed/request.hpp>
|
||||
#include <corvusoft/restbed/service.hpp>
|
||||
#include <corvusoft/restbed/settings.hpp>
|
||||
|
||||
#include "Order.h"
|
||||
#include <map>
|
||||
#include <string>
|
||||
|
||||
namespace org {
|
||||
namespace openapitools {
|
||||
namespace server {
|
||||
namespace api {
|
||||
|
||||
using namespace org::openapitools::server::model;
|
||||
|
||||
///
|
||||
/// Exception to flag problems in the handlers
|
||||
///
|
||||
class StoreApiException: public std::exception
|
||||
{
|
||||
public:
|
||||
StoreApiException(int status_code, std::string what);
|
||||
|
||||
int getStatus() const;
|
||||
const char* what() const noexcept override;
|
||||
|
||||
private:
|
||||
int m_status;
|
||||
std::string m_what;
|
||||
};
|
||||
|
||||
/// <summary>
|
||||
/// Delete purchase order by ID
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors
|
||||
/// </remarks>
|
||||
class StoreApiStoreOrderOrderIdResource: public restbed::Resource
|
||||
{
|
||||
public:
|
||||
StoreApiStoreOrderOrderIdResource(const std::string& context = "/v2");
|
||||
virtual ~StoreApiStoreOrderOrderIdResource();
|
||||
|
||||
protected:
|
||||
//////////////////////////////////////////////////////////
|
||||
// Override these to implement the server functionality //
|
||||
//////////////////////////////////////////////////////////
|
||||
|
||||
virtual int handler_DELETE(
|
||||
std::string const & orderId);
|
||||
|
||||
virtual std::pair<int, std::shared_ptr<Order>> handler_GET(
|
||||
int64_t const & orderId);
|
||||
|
||||
protected:
|
||||
//////////////////////////////////////
|
||||
// Override these for customization //
|
||||
//////////////////////////////////////
|
||||
|
||||
virtual std::string extractBodyContent(const std::shared_ptr<restbed::Session>& session);
|
||||
|
||||
virtual std::string getPathParam_orderId(const std::shared_ptr<const restbed::Request>& request)
|
||||
{
|
||||
return request->get_path_parameter("orderId", "");
|
||||
}
|
||||
|
||||
|
||||
virtual int64_t getPathParam_orderId_x_extension(const std::shared_ptr<const restbed::Request>& request)
|
||||
{
|
||||
return request->get_path_parameter("orderId", 0L);
|
||||
}
|
||||
|
||||
virtual std::pair<int, std::string> handleStoreApiException(const StoreApiException& e);
|
||||
virtual std::pair<int, std::string> handleStdException(const std::exception& e);
|
||||
virtual std::pair<int, std::string> handleUnspecifiedException();
|
||||
|
||||
virtual void setResponseHeader(const std::shared_ptr<restbed::Session>& session,
|
||||
const std::string& header);
|
||||
|
||||
|
||||
virtual void returnResponse(const std::shared_ptr<restbed::Session>& session,
|
||||
const int status, const std::string& result, const std::string& contentType);
|
||||
virtual void defaultSessionClose(const std::shared_ptr<restbed::Session>& session,
|
||||
const int status, const std::string& result);
|
||||
|
||||
private:
|
||||
void handler_DELETE_internal(const std::shared_ptr<restbed::Session> session);
|
||||
void handler_GET_internal(const std::shared_ptr<restbed::Session> session);
|
||||
};
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Returns pet inventories by status
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Returns a map of status codes to quantities
|
||||
/// </remarks>
|
||||
class StoreApiStoreInventoryResource: public restbed::Resource
|
||||
{
|
||||
public:
|
||||
StoreApiStoreInventoryResource(const std::string& context = "/v2");
|
||||
virtual ~StoreApiStoreInventoryResource();
|
||||
|
||||
protected:
|
||||
//////////////////////////////////////////////////////////
|
||||
// Override these to implement the server functionality //
|
||||
//////////////////////////////////////////////////////////
|
||||
|
||||
virtual std::pair<int, std::map<std::string, int32_t>> handler_GET(
|
||||
);
|
||||
|
||||
|
||||
protected:
|
||||
//////////////////////////////////////
|
||||
// Override these for customization //
|
||||
//////////////////////////////////////
|
||||
|
||||
virtual std::string extractBodyContent(const std::shared_ptr<restbed::Session>& session);
|
||||
|
||||
|
||||
|
||||
virtual std::pair<int, std::string> handleStoreApiException(const StoreApiException& e);
|
||||
virtual std::pair<int, std::string> handleStdException(const std::exception& e);
|
||||
virtual std::pair<int, std::string> handleUnspecifiedException();
|
||||
|
||||
virtual void setResponseHeader(const std::shared_ptr<restbed::Session>& session,
|
||||
const std::string& header);
|
||||
|
||||
|
||||
virtual void returnResponse(const std::shared_ptr<restbed::Session>& session,
|
||||
const int status, const std::string& result, const std::string& contentType);
|
||||
virtual void defaultSessionClose(const std::shared_ptr<restbed::Session>& session,
|
||||
const int status, const std::string& result);
|
||||
|
||||
private:
|
||||
void handler_GET_internal(const std::shared_ptr<restbed::Session> session);
|
||||
};
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Place an order for a pet
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
///
|
||||
/// </remarks>
|
||||
class StoreApiStoreOrderResource: public restbed::Resource
|
||||
{
|
||||
public:
|
||||
StoreApiStoreOrderResource(const std::string& context = "/v2");
|
||||
virtual ~StoreApiStoreOrderResource();
|
||||
|
||||
protected:
|
||||
//////////////////////////////////////////////////////////
|
||||
// Override these to implement the server functionality //
|
||||
//////////////////////////////////////////////////////////
|
||||
|
||||
virtual std::pair<int, std::shared_ptr<Order>> handler_POST(
|
||||
std::shared_ptr<Order> const & order);
|
||||
|
||||
|
||||
protected:
|
||||
//////////////////////////////////////
|
||||
// Override these for customization //
|
||||
//////////////////////////////////////
|
||||
|
||||
virtual std::string extractBodyContent(const std::shared_ptr<restbed::Session>& session);
|
||||
|
||||
|
||||
|
||||
virtual std::pair<int, std::string> handleStoreApiException(const StoreApiException& e);
|
||||
virtual std::pair<int, std::string> handleStdException(const std::exception& e);
|
||||
virtual std::pair<int, std::string> handleUnspecifiedException();
|
||||
|
||||
virtual void setResponseHeader(const std::shared_ptr<restbed::Session>& session,
|
||||
const std::string& header);
|
||||
|
||||
|
||||
virtual void returnResponse(const std::shared_ptr<restbed::Session>& session,
|
||||
const int status, const std::string& result, const std::string& contentType);
|
||||
virtual void defaultSessionClose(const std::shared_ptr<restbed::Session>& session,
|
||||
const int status, const std::string& result);
|
||||
|
||||
private:
|
||||
void handler_POST_internal(const std::shared_ptr<restbed::Session> session);
|
||||
};
|
||||
|
||||
|
||||
|
||||
//
|
||||
// The restbed service to actually implement the REST server
|
||||
//
|
||||
class StoreApi
|
||||
{
|
||||
public:
|
||||
explicit StoreApi(std::shared_ptr<restbed::Service> const& restbedService);
|
||||
virtual ~StoreApi();
|
||||
|
||||
virtual void setStoreApiStoreOrderOrderIdResource(std::shared_ptr<StoreApiStoreOrderOrderIdResource> spStoreApiStoreOrderOrderIdResource);
|
||||
virtual void setStoreApiStoreInventoryResource(std::shared_ptr<StoreApiStoreInventoryResource> spStoreApiStoreInventoryResource);
|
||||
virtual void setStoreApiStoreOrderResource(std::shared_ptr<StoreApiStoreOrderResource> spStoreApiStoreOrderResource);
|
||||
|
||||
virtual void publishDefaultResources();
|
||||
|
||||
virtual std::shared_ptr<restbed::Service> service();
|
||||
|
||||
protected:
|
||||
std::shared_ptr<StoreApiStoreOrderOrderIdResource> m_spStoreApiStoreOrderOrderIdResource;
|
||||
std::shared_ptr<StoreApiStoreInventoryResource> m_spStoreApiStoreInventoryResource;
|
||||
std::shared_ptr<StoreApiStoreOrderResource> m_spStoreApiStoreOrderResource;
|
||||
|
||||
private:
|
||||
std::shared_ptr<restbed::Service> m_service;
|
||||
};
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif /* StoreApi_H_ */
|
||||
|
||||
870
samples/server/petstore/cpp-restbed-deprecated/api/UserApi.cpp
Normal file
870
samples/server/petstore/cpp-restbed-deprecated/api/UserApi.cpp
Normal file
@@ -0,0 +1,870 @@
|
||||
/**
|
||||
* OpenAPI Petstore
|
||||
* This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
|
||||
*
|
||||
* The version of the OpenAPI document: 1.0.0
|
||||
*
|
||||
*
|
||||
* NOTE: This class is auto generated by OpenAPI-Generator unset.
|
||||
* https://openapi-generator.tech
|
||||
* Do not edit the class manually.
|
||||
*/
|
||||
|
||||
|
||||
#include <corvusoft/restbed/byte.hpp>
|
||||
#include <corvusoft/restbed/string.hpp>
|
||||
#include <corvusoft/restbed/settings.hpp>
|
||||
#include <corvusoft/restbed/request.hpp>
|
||||
#include <corvusoft/restbed/uri.hpp>
|
||||
#include <boost/property_tree/ptree.hpp>
|
||||
#include <boost/property_tree/json_parser.hpp>
|
||||
#include <boost/lexical_cast.hpp>
|
||||
#include <boost/algorithm/string.hpp>
|
||||
|
||||
#include "UserApi.h"
|
||||
|
||||
namespace org {
|
||||
namespace openapitools {
|
||||
namespace server {
|
||||
namespace api {
|
||||
|
||||
using namespace org::openapitools::server::model;
|
||||
|
||||
UserApiException::UserApiException(int status_code, std::string what)
|
||||
: m_status(status_code),
|
||||
m_what(what)
|
||||
{
|
||||
|
||||
}
|
||||
int UserApiException::getStatus() const
|
||||
{
|
||||
return m_status;
|
||||
}
|
||||
const char* UserApiException::what() const noexcept
|
||||
{
|
||||
return m_what.c_str();
|
||||
}
|
||||
|
||||
|
||||
template<class MODEL_T>
|
||||
std::shared_ptr<MODEL_T> extractJsonModelBodyParam(const std::string& bodyContent)
|
||||
{
|
||||
std::stringstream sstream(bodyContent);
|
||||
boost::property_tree::ptree pt;
|
||||
boost::property_tree::json_parser::read_json(sstream, pt);
|
||||
|
||||
auto model = std::make_shared<MODEL_T>(pt);
|
||||
return model;
|
||||
}
|
||||
|
||||
template<class MODEL_T>
|
||||
std::vector<std::shared_ptr<MODEL_T>> extractJsonArrayBodyParam(const std::string& bodyContent)
|
||||
{
|
||||
std::stringstream sstream(bodyContent);
|
||||
boost::property_tree::ptree pt;
|
||||
boost::property_tree::json_parser::read_json(sstream, pt);
|
||||
|
||||
auto arrayRet = std::vector<std::shared_ptr<MODEL_T>>();
|
||||
for (const auto& child: pt) {
|
||||
arrayRet.emplace_back(std::make_shared<MODEL_T>(child.second));
|
||||
}
|
||||
return arrayRet;
|
||||
}
|
||||
|
||||
template <class KEY_T, class VAL_T>
|
||||
std::string convertMapResponse(const std::map<KEY_T, VAL_T>& map)
|
||||
{
|
||||
boost::property_tree::ptree pt;
|
||||
for(const auto &kv: map) {
|
||||
pt.push_back(boost::property_tree::ptree::value_type(
|
||||
boost::lexical_cast<std::string>(kv.first),
|
||||
boost::property_tree::ptree(
|
||||
boost::lexical_cast<std::string>(kv.second))));
|
||||
}
|
||||
std::stringstream sstream;
|
||||
write_json(sstream, pt);
|
||||
std::string result = sstream.str();
|
||||
return result;
|
||||
}
|
||||
|
||||
UserApiUserResource::UserApiUserResource(const std::string& context /* = "/v2" */)
|
||||
{
|
||||
this->set_path(context + "/user/");
|
||||
this->set_method_handler("POST",
|
||||
std::bind(&UserApiUserResource::handler_POST_internal, this,
|
||||
std::placeholders::_1));
|
||||
}
|
||||
|
||||
UserApiUserResource::~UserApiUserResource()
|
||||
{
|
||||
}
|
||||
|
||||
std::pair<int, std::string> UserApiUserResource::handleUserApiException(const UserApiException& e)
|
||||
{
|
||||
return std::make_pair<int, std::string>(e.getStatus(), e.what());
|
||||
}
|
||||
|
||||
std::pair<int, std::string> UserApiUserResource::handleStdException(const std::exception& e)
|
||||
{
|
||||
return std::make_pair<int, std::string>(500, e.what());
|
||||
}
|
||||
|
||||
std::pair<int, std::string> UserApiUserResource::handleUnspecifiedException()
|
||||
{
|
||||
return std::make_pair<int, std::string>(500, "Unknown exception occurred");
|
||||
}
|
||||
|
||||
void UserApiUserResource::setResponseHeader(const std::shared_ptr<restbed::Session>& session, const std::string& header)
|
||||
{
|
||||
session->set_header(header, "");
|
||||
}
|
||||
|
||||
void UserApiUserResource::returnResponse(const std::shared_ptr<restbed::Session>& session, const int status, const std::string& result, const std::string& contentType)
|
||||
{
|
||||
session->close(status, result, { {"Connection", "close"}, {"Content-Type", contentType} });
|
||||
}
|
||||
|
||||
void UserApiUserResource::defaultSessionClose(const std::shared_ptr<restbed::Session>& session, const int status, const std::string& result)
|
||||
{
|
||||
session->close(status, result, { {"Connection", "close"} });
|
||||
}
|
||||
|
||||
void UserApiUserResource::handler_POST_internal(const std::shared_ptr<restbed::Session> session)
|
||||
{
|
||||
const auto request = session->get_request();
|
||||
std::string bodyContent = extractBodyContent(session);
|
||||
|
||||
// Get body params or form params here from the body content string
|
||||
auto user = extractJsonModelBodyParam<User>(bodyContent);
|
||||
|
||||
|
||||
|
||||
|
||||
int status_code = 500;
|
||||
std::string result = "";
|
||||
|
||||
try {
|
||||
status_code =
|
||||
handler_POST(user);
|
||||
}
|
||||
catch(const UserApiException& e) {
|
||||
std::tie(status_code, result) = handleUserApiException(e);
|
||||
}
|
||||
catch(const std::exception& e) {
|
||||
std::tie(status_code, result) = handleStdException(e);
|
||||
}
|
||||
catch(...) {
|
||||
std::tie(status_code, result) = handleUnspecifiedException();
|
||||
}
|
||||
|
||||
if (status_code == 0) {
|
||||
|
||||
const constexpr auto contentType = "text/plain";
|
||||
returnResponse(session, 0, result.empty() ? "successful operation" : result, contentType);
|
||||
return;
|
||||
}
|
||||
defaultSessionClose(session, status_code, result);
|
||||
}
|
||||
|
||||
|
||||
int UserApiUserResource::handler_POST(
|
||||
std::shared_ptr<User> const & user)
|
||||
{
|
||||
throw UserApiException(501, "Not implemented");
|
||||
}
|
||||
|
||||
|
||||
std::string UserApiUserResource::extractBodyContent(const std::shared_ptr<restbed::Session>& session) {
|
||||
const auto request = session->get_request();
|
||||
int content_length = request->get_header("Content-Length", 0);
|
||||
std::string bodyContent;
|
||||
session->fetch(content_length,
|
||||
[&bodyContent](const std::shared_ptr<restbed::Session> session,
|
||||
const restbed::Bytes &body) {
|
||||
bodyContent = restbed::String::format(
|
||||
"%.*s\n", (int)body.size(), body.data());
|
||||
});
|
||||
return bodyContent;
|
||||
}
|
||||
UserApiUserCreateWithArrayResource::UserApiUserCreateWithArrayResource(const std::string& context /* = "/v2" */)
|
||||
{
|
||||
this->set_path(context + "/user/createWithArray/");
|
||||
this->set_method_handler("POST",
|
||||
std::bind(&UserApiUserCreateWithArrayResource::handler_POST_internal, this,
|
||||
std::placeholders::_1));
|
||||
}
|
||||
|
||||
UserApiUserCreateWithArrayResource::~UserApiUserCreateWithArrayResource()
|
||||
{
|
||||
}
|
||||
|
||||
std::pair<int, std::string> UserApiUserCreateWithArrayResource::handleUserApiException(const UserApiException& e)
|
||||
{
|
||||
return std::make_pair<int, std::string>(e.getStatus(), e.what());
|
||||
}
|
||||
|
||||
std::pair<int, std::string> UserApiUserCreateWithArrayResource::handleStdException(const std::exception& e)
|
||||
{
|
||||
return std::make_pair<int, std::string>(500, e.what());
|
||||
}
|
||||
|
||||
std::pair<int, std::string> UserApiUserCreateWithArrayResource::handleUnspecifiedException()
|
||||
{
|
||||
return std::make_pair<int, std::string>(500, "Unknown exception occurred");
|
||||
}
|
||||
|
||||
void UserApiUserCreateWithArrayResource::setResponseHeader(const std::shared_ptr<restbed::Session>& session, const std::string& header)
|
||||
{
|
||||
session->set_header(header, "");
|
||||
}
|
||||
|
||||
void UserApiUserCreateWithArrayResource::returnResponse(const std::shared_ptr<restbed::Session>& session, const int status, const std::string& result, const std::string& contentType)
|
||||
{
|
||||
session->close(status, result, { {"Connection", "close"}, {"Content-Type", contentType} });
|
||||
}
|
||||
|
||||
void UserApiUserCreateWithArrayResource::defaultSessionClose(const std::shared_ptr<restbed::Session>& session, const int status, const std::string& result)
|
||||
{
|
||||
session->close(status, result, { {"Connection", "close"} });
|
||||
}
|
||||
|
||||
void UserApiUserCreateWithArrayResource::handler_POST_internal(const std::shared_ptr<restbed::Session> session)
|
||||
{
|
||||
const auto request = session->get_request();
|
||||
std::string bodyContent = extractBodyContent(session);
|
||||
|
||||
// Get body params or form params here from the body content string
|
||||
auto user = extractJsonArrayBodyParam<User>(bodyContent);
|
||||
|
||||
|
||||
|
||||
|
||||
int status_code = 500;
|
||||
std::string result = "";
|
||||
|
||||
try {
|
||||
status_code =
|
||||
handler_POST(user);
|
||||
}
|
||||
catch(const UserApiException& e) {
|
||||
std::tie(status_code, result) = handleUserApiException(e);
|
||||
}
|
||||
catch(const std::exception& e) {
|
||||
std::tie(status_code, result) = handleStdException(e);
|
||||
}
|
||||
catch(...) {
|
||||
std::tie(status_code, result) = handleUnspecifiedException();
|
||||
}
|
||||
|
||||
if (status_code == 0) {
|
||||
|
||||
const constexpr auto contentType = "text/plain";
|
||||
returnResponse(session, 0, result.empty() ? "successful operation" : result, contentType);
|
||||
return;
|
||||
}
|
||||
defaultSessionClose(session, status_code, result);
|
||||
}
|
||||
|
||||
|
||||
int UserApiUserCreateWithArrayResource::handler_POST(
|
||||
std::vector<std::shared_ptr<User>> const & user)
|
||||
{
|
||||
throw UserApiException(501, "Not implemented");
|
||||
}
|
||||
|
||||
|
||||
std::string UserApiUserCreateWithArrayResource::extractBodyContent(const std::shared_ptr<restbed::Session>& session) {
|
||||
const auto request = session->get_request();
|
||||
int content_length = request->get_header("Content-Length", 0);
|
||||
std::string bodyContent;
|
||||
session->fetch(content_length,
|
||||
[&bodyContent](const std::shared_ptr<restbed::Session> session,
|
||||
const restbed::Bytes &body) {
|
||||
bodyContent = restbed::String::format(
|
||||
"%.*s\n", (int)body.size(), body.data());
|
||||
});
|
||||
return bodyContent;
|
||||
}
|
||||
UserApiUserCreateWithListResource::UserApiUserCreateWithListResource(const std::string& context /* = "/v2" */)
|
||||
{
|
||||
this->set_path(context + "/user/createWithList/");
|
||||
this->set_method_handler("POST",
|
||||
std::bind(&UserApiUserCreateWithListResource::handler_POST_internal, this,
|
||||
std::placeholders::_1));
|
||||
}
|
||||
|
||||
UserApiUserCreateWithListResource::~UserApiUserCreateWithListResource()
|
||||
{
|
||||
}
|
||||
|
||||
std::pair<int, std::string> UserApiUserCreateWithListResource::handleUserApiException(const UserApiException& e)
|
||||
{
|
||||
return std::make_pair<int, std::string>(e.getStatus(), e.what());
|
||||
}
|
||||
|
||||
std::pair<int, std::string> UserApiUserCreateWithListResource::handleStdException(const std::exception& e)
|
||||
{
|
||||
return std::make_pair<int, std::string>(500, e.what());
|
||||
}
|
||||
|
||||
std::pair<int, std::string> UserApiUserCreateWithListResource::handleUnspecifiedException()
|
||||
{
|
||||
return std::make_pair<int, std::string>(500, "Unknown exception occurred");
|
||||
}
|
||||
|
||||
void UserApiUserCreateWithListResource::setResponseHeader(const std::shared_ptr<restbed::Session>& session, const std::string& header)
|
||||
{
|
||||
session->set_header(header, "");
|
||||
}
|
||||
|
||||
void UserApiUserCreateWithListResource::returnResponse(const std::shared_ptr<restbed::Session>& session, const int status, const std::string& result, const std::string& contentType)
|
||||
{
|
||||
session->close(status, result, { {"Connection", "close"}, {"Content-Type", contentType} });
|
||||
}
|
||||
|
||||
void UserApiUserCreateWithListResource::defaultSessionClose(const std::shared_ptr<restbed::Session>& session, const int status, const std::string& result)
|
||||
{
|
||||
session->close(status, result, { {"Connection", "close"} });
|
||||
}
|
||||
|
||||
void UserApiUserCreateWithListResource::handler_POST_internal(const std::shared_ptr<restbed::Session> session)
|
||||
{
|
||||
const auto request = session->get_request();
|
||||
std::string bodyContent = extractBodyContent(session);
|
||||
|
||||
// Get body params or form params here from the body content string
|
||||
auto user = extractJsonArrayBodyParam<User>(bodyContent);
|
||||
|
||||
|
||||
|
||||
|
||||
int status_code = 500;
|
||||
std::string result = "";
|
||||
|
||||
try {
|
||||
status_code =
|
||||
handler_POST(user);
|
||||
}
|
||||
catch(const UserApiException& e) {
|
||||
std::tie(status_code, result) = handleUserApiException(e);
|
||||
}
|
||||
catch(const std::exception& e) {
|
||||
std::tie(status_code, result) = handleStdException(e);
|
||||
}
|
||||
catch(...) {
|
||||
std::tie(status_code, result) = handleUnspecifiedException();
|
||||
}
|
||||
|
||||
if (status_code == 0) {
|
||||
|
||||
const constexpr auto contentType = "text/plain";
|
||||
returnResponse(session, 0, result.empty() ? "successful operation" : result, contentType);
|
||||
return;
|
||||
}
|
||||
defaultSessionClose(session, status_code, result);
|
||||
}
|
||||
|
||||
|
||||
int UserApiUserCreateWithListResource::handler_POST(
|
||||
std::vector<std::shared_ptr<User>> const & user)
|
||||
{
|
||||
throw UserApiException(501, "Not implemented");
|
||||
}
|
||||
|
||||
|
||||
std::string UserApiUserCreateWithListResource::extractBodyContent(const std::shared_ptr<restbed::Session>& session) {
|
||||
const auto request = session->get_request();
|
||||
int content_length = request->get_header("Content-Length", 0);
|
||||
std::string bodyContent;
|
||||
session->fetch(content_length,
|
||||
[&bodyContent](const std::shared_ptr<restbed::Session> session,
|
||||
const restbed::Bytes &body) {
|
||||
bodyContent = restbed::String::format(
|
||||
"%.*s\n", (int)body.size(), body.data());
|
||||
});
|
||||
return bodyContent;
|
||||
}
|
||||
UserApiUserUsernameResource::UserApiUserUsernameResource(const std::string& context /* = "/v2" */)
|
||||
{
|
||||
this->set_path(context + "/user/{username: .*}/");
|
||||
this->set_method_handler("DELETE",
|
||||
std::bind(&UserApiUserUsernameResource::handler_DELETE_internal, this,
|
||||
std::placeholders::_1));
|
||||
this->set_method_handler("GET",
|
||||
std::bind(&UserApiUserUsernameResource::handler_GET_internal, this,
|
||||
std::placeholders::_1));
|
||||
this->set_method_handler("PUT",
|
||||
std::bind(&UserApiUserUsernameResource::handler_PUT_internal, this,
|
||||
std::placeholders::_1));
|
||||
}
|
||||
|
||||
UserApiUserUsernameResource::~UserApiUserUsernameResource()
|
||||
{
|
||||
}
|
||||
|
||||
std::pair<int, std::string> UserApiUserUsernameResource::handleUserApiException(const UserApiException& e)
|
||||
{
|
||||
return std::make_pair<int, std::string>(e.getStatus(), e.what());
|
||||
}
|
||||
|
||||
std::pair<int, std::string> UserApiUserUsernameResource::handleStdException(const std::exception& e)
|
||||
{
|
||||
return std::make_pair<int, std::string>(500, e.what());
|
||||
}
|
||||
|
||||
std::pair<int, std::string> UserApiUserUsernameResource::handleUnspecifiedException()
|
||||
{
|
||||
return std::make_pair<int, std::string>(500, "Unknown exception occurred");
|
||||
}
|
||||
|
||||
void UserApiUserUsernameResource::setResponseHeader(const std::shared_ptr<restbed::Session>& session, const std::string& header)
|
||||
{
|
||||
session->set_header(header, "");
|
||||
}
|
||||
|
||||
void UserApiUserUsernameResource::returnResponse(const std::shared_ptr<restbed::Session>& session, const int status, const std::string& result, const std::string& contentType)
|
||||
{
|
||||
session->close(status, result, { {"Connection", "close"}, {"Content-Type", contentType} });
|
||||
}
|
||||
|
||||
void UserApiUserUsernameResource::defaultSessionClose(const std::shared_ptr<restbed::Session>& session, const int status, const std::string& result)
|
||||
{
|
||||
session->close(status, result, { {"Connection", "close"} });
|
||||
}
|
||||
|
||||
void UserApiUserUsernameResource::handler_DELETE_internal(const std::shared_ptr<restbed::Session> session)
|
||||
{
|
||||
const auto request = session->get_request();
|
||||
|
||||
// Getting the path params
|
||||
const std::string username = getPathParam_username(request);
|
||||
|
||||
|
||||
|
||||
int status_code = 500;
|
||||
std::string result = "";
|
||||
|
||||
try {
|
||||
status_code =
|
||||
handler_DELETE(username);
|
||||
}
|
||||
catch(const UserApiException& e) {
|
||||
std::tie(status_code, result) = handleUserApiException(e);
|
||||
}
|
||||
catch(const std::exception& e) {
|
||||
std::tie(status_code, result) = handleStdException(e);
|
||||
}
|
||||
catch(...) {
|
||||
std::tie(status_code, result) = handleUnspecifiedException();
|
||||
}
|
||||
|
||||
if (status_code == 400) {
|
||||
|
||||
const constexpr auto contentType = "text/plain";
|
||||
returnResponse(session, 400, result.empty() ? "Invalid username supplied" : result, contentType);
|
||||
return;
|
||||
}
|
||||
if (status_code == 404) {
|
||||
|
||||
const constexpr auto contentType = "text/plain";
|
||||
returnResponse(session, 404, result.empty() ? "User not found" : result, contentType);
|
||||
return;
|
||||
}
|
||||
defaultSessionClose(session, status_code, result);
|
||||
}
|
||||
|
||||
// x-extension
|
||||
void UserApiUserUsernameResource::handler_GET_internal(const std::shared_ptr<restbed::Session> session) {
|
||||
|
||||
const auto request = session->get_request();
|
||||
|
||||
// Getting the path params
|
||||
const std::string username = getPathParam_username_x_extension(request);
|
||||
|
||||
|
||||
int status_code = 500;
|
||||
std::shared_ptr<User> resultObject = std::make_shared<User>();
|
||||
std::string result = "";
|
||||
|
||||
try {
|
||||
std::tie(status_code, resultObject) =
|
||||
handler_GET(username);
|
||||
}
|
||||
catch(const UserApiException& e) {
|
||||
std::tie(status_code, result) = handleUserApiException(e);
|
||||
}
|
||||
catch(const std::exception& e) {
|
||||
std::tie(status_code, result) = handleStdException(e);
|
||||
}
|
||||
catch(...) {
|
||||
std::tie(status_code, result) = handleUnspecifiedException();
|
||||
}
|
||||
|
||||
if (status_code == 200) {
|
||||
result = resultObject->toJsonString();
|
||||
|
||||
const constexpr auto contentType = "application/json";
|
||||
returnResponse(session, 200, result.empty() ? "successful operation" : result, contentType);
|
||||
return;
|
||||
}
|
||||
if (status_code == 400) {
|
||||
|
||||
const constexpr auto contentType = "text/plain";
|
||||
returnResponse(session, 400, result.empty() ? "Invalid username supplied" : result, contentType);
|
||||
return;
|
||||
}
|
||||
if (status_code == 404) {
|
||||
|
||||
const constexpr auto contentType = "text/plain";
|
||||
returnResponse(session, 404, result.empty() ? "User not found" : result, contentType);
|
||||
return;
|
||||
}
|
||||
defaultSessionClose(session, status_code, result);
|
||||
}
|
||||
// x-extension
|
||||
void UserApiUserUsernameResource::handler_PUT_internal(const std::shared_ptr<restbed::Session> session) {
|
||||
|
||||
const auto request = session->get_request();
|
||||
std::string bodyContent = extractBodyContent(session);
|
||||
|
||||
// body params or form params here from the body content string
|
||||
auto username = std::make_shared<>(bodyContent);
|
||||
auto user = extractJsonModelBodyParam<User>(bodyContent);
|
||||
|
||||
// Getting the path params
|
||||
const std::string username = getPathParam_username_x_extension(request);
|
||||
|
||||
|
||||
int status_code = 500;
|
||||
std::string result = "";
|
||||
|
||||
try {
|
||||
status_code =
|
||||
handler_PUT(username, user);
|
||||
}
|
||||
catch(const UserApiException& e) {
|
||||
std::tie(status_code, result) = handleUserApiException(e);
|
||||
}
|
||||
catch(const std::exception& e) {
|
||||
std::tie(status_code, result) = handleStdException(e);
|
||||
}
|
||||
catch(...) {
|
||||
std::tie(status_code, result) = handleUnspecifiedException();
|
||||
}
|
||||
|
||||
if (status_code == 400) {
|
||||
|
||||
const constexpr auto contentType = "text/plain";
|
||||
returnResponse(session, 400, result.empty() ? "Invalid user supplied" : result, contentType);
|
||||
return;
|
||||
}
|
||||
if (status_code == 404) {
|
||||
|
||||
const constexpr auto contentType = "text/plain";
|
||||
returnResponse(session, 404, result.empty() ? "User not found" : result, contentType);
|
||||
return;
|
||||
}
|
||||
defaultSessionClose(session, status_code, result);
|
||||
}
|
||||
|
||||
int UserApiUserUsernameResource::handler_DELETE(
|
||||
std::string const & username)
|
||||
{
|
||||
throw UserApiException(501, "Not implemented");
|
||||
}
|
||||
|
||||
std::pair<int, std::shared_ptr<User>> UserApiUserUsernameResource::handler_GET(
|
||||
std::string const & username)
|
||||
{
|
||||
throw UserApiException(501, "Not implemented");
|
||||
}
|
||||
int UserApiUserUsernameResource::handler_PUT(
|
||||
std::string const & username, std::shared_ptr<User> const & user)
|
||||
{
|
||||
throw UserApiException(501, "Not implemented");
|
||||
}
|
||||
|
||||
std::string UserApiUserUsernameResource::extractBodyContent(const std::shared_ptr<restbed::Session>& session) {
|
||||
const auto request = session->get_request();
|
||||
int content_length = request->get_header("Content-Length", 0);
|
||||
std::string bodyContent;
|
||||
session->fetch(content_length,
|
||||
[&bodyContent](const std::shared_ptr<restbed::Session> session,
|
||||
const restbed::Bytes &body) {
|
||||
bodyContent = restbed::String::format(
|
||||
"%.*s\n", (int)body.size(), body.data());
|
||||
});
|
||||
return bodyContent;
|
||||
}
|
||||
UserApiUserLoginResource::UserApiUserLoginResource(const std::string& context /* = "/v2" */)
|
||||
{
|
||||
this->set_path(context + "/user/login/");
|
||||
this->set_method_handler("GET",
|
||||
std::bind(&UserApiUserLoginResource::handler_GET_internal, this,
|
||||
std::placeholders::_1));
|
||||
}
|
||||
|
||||
UserApiUserLoginResource::~UserApiUserLoginResource()
|
||||
{
|
||||
}
|
||||
|
||||
std::pair<int, std::string> UserApiUserLoginResource::handleUserApiException(const UserApiException& e)
|
||||
{
|
||||
return std::make_pair<int, std::string>(e.getStatus(), e.what());
|
||||
}
|
||||
|
||||
std::pair<int, std::string> UserApiUserLoginResource::handleStdException(const std::exception& e)
|
||||
{
|
||||
return std::make_pair<int, std::string>(500, e.what());
|
||||
}
|
||||
|
||||
std::pair<int, std::string> UserApiUserLoginResource::handleUnspecifiedException()
|
||||
{
|
||||
return std::make_pair<int, std::string>(500, "Unknown exception occurred");
|
||||
}
|
||||
|
||||
void UserApiUserLoginResource::setResponseHeader(const std::shared_ptr<restbed::Session>& session, const std::string& header)
|
||||
{
|
||||
session->set_header(header, "");
|
||||
}
|
||||
|
||||
void UserApiUserLoginResource::returnResponse(const std::shared_ptr<restbed::Session>& session, const int status, const std::string& result, const std::string& contentType)
|
||||
{
|
||||
session->close(status, result, { {"Connection", "close"}, {"Content-Type", contentType} });
|
||||
}
|
||||
|
||||
void UserApiUserLoginResource::defaultSessionClose(const std::shared_ptr<restbed::Session>& session, const int status, const std::string& result)
|
||||
{
|
||||
session->close(status, result, { {"Connection", "close"} });
|
||||
}
|
||||
|
||||
void UserApiUserLoginResource::handler_GET_internal(const std::shared_ptr<restbed::Session> session)
|
||||
{
|
||||
const auto request = session->get_request();
|
||||
|
||||
|
||||
// Getting the query params
|
||||
const std::string username = getQueryParam_username(request);
|
||||
const std::string password = getQueryParam_password(request);
|
||||
|
||||
|
||||
int status_code = 500;
|
||||
std::string resultObject = "";
|
||||
std::string result = "";
|
||||
|
||||
try {
|
||||
std::tie(status_code, resultObject) =
|
||||
handler_GET(username, password);
|
||||
}
|
||||
catch(const UserApiException& e) {
|
||||
std::tie(status_code, result) = handleUserApiException(e);
|
||||
}
|
||||
catch(const std::exception& e) {
|
||||
std::tie(status_code, result) = handleStdException(e);
|
||||
}
|
||||
catch(...) {
|
||||
std::tie(status_code, result) = handleUnspecifiedException();
|
||||
}
|
||||
|
||||
if (status_code == 200) {
|
||||
result = resultObject;
|
||||
// Description: Cookie authentication key for use with the `api_key` apiKey authentication.
|
||||
setResponseHeader(session, "Set-Cookie");
|
||||
// Description: calls per hour allowed by the user
|
||||
setResponseHeader(session, "X-Rate-Limit");
|
||||
// Description: date in UTC when token expires
|
||||
setResponseHeader(session, "X-Expires-After");
|
||||
|
||||
const constexpr auto contentType = "application/json";
|
||||
returnResponse(session, 200, result.empty() ? "successful operation" : result, contentType);
|
||||
return;
|
||||
}
|
||||
if (status_code == 400) {
|
||||
|
||||
const constexpr auto contentType = "text/plain";
|
||||
returnResponse(session, 400, result.empty() ? "Invalid username/password supplied" : result, contentType);
|
||||
return;
|
||||
}
|
||||
defaultSessionClose(session, status_code, result);
|
||||
}
|
||||
|
||||
|
||||
std::pair<int, std::string> UserApiUserLoginResource::handler_GET(
|
||||
std::string const & username, std::string const & password)
|
||||
{
|
||||
throw UserApiException(501, "Not implemented");
|
||||
}
|
||||
|
||||
|
||||
std::string UserApiUserLoginResource::extractBodyContent(const std::shared_ptr<restbed::Session>& session) {
|
||||
const auto request = session->get_request();
|
||||
int content_length = request->get_header("Content-Length", 0);
|
||||
std::string bodyContent;
|
||||
session->fetch(content_length,
|
||||
[&bodyContent](const std::shared_ptr<restbed::Session> session,
|
||||
const restbed::Bytes &body) {
|
||||
bodyContent = restbed::String::format(
|
||||
"%.*s\n", (int)body.size(), body.data());
|
||||
});
|
||||
return bodyContent;
|
||||
}
|
||||
UserApiUserLogoutResource::UserApiUserLogoutResource(const std::string& context /* = "/v2" */)
|
||||
{
|
||||
this->set_path(context + "/user/logout/");
|
||||
this->set_method_handler("GET",
|
||||
std::bind(&UserApiUserLogoutResource::handler_GET_internal, this,
|
||||
std::placeholders::_1));
|
||||
}
|
||||
|
||||
UserApiUserLogoutResource::~UserApiUserLogoutResource()
|
||||
{
|
||||
}
|
||||
|
||||
std::pair<int, std::string> UserApiUserLogoutResource::handleUserApiException(const UserApiException& e)
|
||||
{
|
||||
return std::make_pair<int, std::string>(e.getStatus(), e.what());
|
||||
}
|
||||
|
||||
std::pair<int, std::string> UserApiUserLogoutResource::handleStdException(const std::exception& e)
|
||||
{
|
||||
return std::make_pair<int, std::string>(500, e.what());
|
||||
}
|
||||
|
||||
std::pair<int, std::string> UserApiUserLogoutResource::handleUnspecifiedException()
|
||||
{
|
||||
return std::make_pair<int, std::string>(500, "Unknown exception occurred");
|
||||
}
|
||||
|
||||
void UserApiUserLogoutResource::setResponseHeader(const std::shared_ptr<restbed::Session>& session, const std::string& header)
|
||||
{
|
||||
session->set_header(header, "");
|
||||
}
|
||||
|
||||
void UserApiUserLogoutResource::returnResponse(const std::shared_ptr<restbed::Session>& session, const int status, const std::string& result, const std::string& contentType)
|
||||
{
|
||||
session->close(status, result, { {"Connection", "close"}, {"Content-Type", contentType} });
|
||||
}
|
||||
|
||||
void UserApiUserLogoutResource::defaultSessionClose(const std::shared_ptr<restbed::Session>& session, const int status, const std::string& result)
|
||||
{
|
||||
session->close(status, result, { {"Connection", "close"} });
|
||||
}
|
||||
|
||||
void UserApiUserLogoutResource::handler_GET_internal(const std::shared_ptr<restbed::Session> session)
|
||||
{
|
||||
const auto request = session->get_request();
|
||||
|
||||
|
||||
|
||||
|
||||
int status_code = 500;
|
||||
std::string result = "";
|
||||
|
||||
try {
|
||||
status_code =
|
||||
handler_GET();
|
||||
}
|
||||
catch(const UserApiException& e) {
|
||||
std::tie(status_code, result) = handleUserApiException(e);
|
||||
}
|
||||
catch(const std::exception& e) {
|
||||
std::tie(status_code, result) = handleStdException(e);
|
||||
}
|
||||
catch(...) {
|
||||
std::tie(status_code, result) = handleUnspecifiedException();
|
||||
}
|
||||
|
||||
if (status_code == 0) {
|
||||
|
||||
const constexpr auto contentType = "text/plain";
|
||||
returnResponse(session, 0, result.empty() ? "successful operation" : result, contentType);
|
||||
return;
|
||||
}
|
||||
defaultSessionClose(session, status_code, result);
|
||||
}
|
||||
|
||||
|
||||
int UserApiUserLogoutResource::handler_GET(
|
||||
)
|
||||
{
|
||||
throw UserApiException(501, "Not implemented");
|
||||
}
|
||||
|
||||
|
||||
std::string UserApiUserLogoutResource::extractBodyContent(const std::shared_ptr<restbed::Session>& session) {
|
||||
const auto request = session->get_request();
|
||||
int content_length = request->get_header("Content-Length", 0);
|
||||
std::string bodyContent;
|
||||
session->fetch(content_length,
|
||||
[&bodyContent](const std::shared_ptr<restbed::Session> session,
|
||||
const restbed::Bytes &body) {
|
||||
bodyContent = restbed::String::format(
|
||||
"%.*s\n", (int)body.size(), body.data());
|
||||
});
|
||||
return bodyContent;
|
||||
}
|
||||
|
||||
UserApi::UserApi(std::shared_ptr<restbed::Service> const& restbedService)
|
||||
: m_service(restbedService)
|
||||
{
|
||||
}
|
||||
|
||||
UserApi::~UserApi() {}
|
||||
|
||||
void UserApi::setUserApiUserResource(std::shared_ptr<UserApiUserResource> spUserApiUserResource) {
|
||||
m_spUserApiUserResource = spUserApiUserResource;
|
||||
m_service->publish(m_spUserApiUserResource);
|
||||
}
|
||||
void UserApi::setUserApiUserCreateWithArrayResource(std::shared_ptr<UserApiUserCreateWithArrayResource> spUserApiUserCreateWithArrayResource) {
|
||||
m_spUserApiUserCreateWithArrayResource = spUserApiUserCreateWithArrayResource;
|
||||
m_service->publish(m_spUserApiUserCreateWithArrayResource);
|
||||
}
|
||||
void UserApi::setUserApiUserCreateWithListResource(std::shared_ptr<UserApiUserCreateWithListResource> spUserApiUserCreateWithListResource) {
|
||||
m_spUserApiUserCreateWithListResource = spUserApiUserCreateWithListResource;
|
||||
m_service->publish(m_spUserApiUserCreateWithListResource);
|
||||
}
|
||||
void UserApi::setUserApiUserUsernameResource(std::shared_ptr<UserApiUserUsernameResource> spUserApiUserUsernameResource) {
|
||||
m_spUserApiUserUsernameResource = spUserApiUserUsernameResource;
|
||||
m_service->publish(m_spUserApiUserUsernameResource);
|
||||
}
|
||||
void UserApi::setUserApiUserLoginResource(std::shared_ptr<UserApiUserLoginResource> spUserApiUserLoginResource) {
|
||||
m_spUserApiUserLoginResource = spUserApiUserLoginResource;
|
||||
m_service->publish(m_spUserApiUserLoginResource);
|
||||
}
|
||||
void UserApi::setUserApiUserLogoutResource(std::shared_ptr<UserApiUserLogoutResource> spUserApiUserLogoutResource) {
|
||||
m_spUserApiUserLogoutResource = spUserApiUserLogoutResource;
|
||||
m_service->publish(m_spUserApiUserLogoutResource);
|
||||
}
|
||||
|
||||
|
||||
void UserApi::publishDefaultResources() {
|
||||
if (!m_spUserApiUserResource) {
|
||||
setUserApiUserResource(std::make_shared<UserApiUserResource>());
|
||||
}
|
||||
if (!m_spUserApiUserCreateWithArrayResource) {
|
||||
setUserApiUserCreateWithArrayResource(std::make_shared<UserApiUserCreateWithArrayResource>());
|
||||
}
|
||||
if (!m_spUserApiUserCreateWithListResource) {
|
||||
setUserApiUserCreateWithListResource(std::make_shared<UserApiUserCreateWithListResource>());
|
||||
}
|
||||
if (!m_spUserApiUserUsernameResource) {
|
||||
setUserApiUserUsernameResource(std::make_shared<UserApiUserUsernameResource>());
|
||||
}
|
||||
if (!m_spUserApiUserLoginResource) {
|
||||
setUserApiUserLoginResource(std::make_shared<UserApiUserLoginResource>());
|
||||
}
|
||||
if (!m_spUserApiUserLogoutResource) {
|
||||
setUserApiUserLogoutResource(std::make_shared<UserApiUserLogoutResource>());
|
||||
}
|
||||
}
|
||||
|
||||
std::shared_ptr<restbed::Service> UserApi::service() {
|
||||
return m_service;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
417
samples/server/petstore/cpp-restbed-deprecated/api/UserApi.h
Normal file
417
samples/server/petstore/cpp-restbed-deprecated/api/UserApi.h
Normal file
@@ -0,0 +1,417 @@
|
||||
/**
|
||||
* OpenAPI Petstore
|
||||
* This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
|
||||
*
|
||||
* The version of the OpenAPI document: 1.0.0
|
||||
*
|
||||
*
|
||||
* NOTE: This class is auto generated by OpenAPI-Generator unset.
|
||||
* https://openapi-generator.tech
|
||||
* Do not edit the class manually.
|
||||
*/
|
||||
|
||||
/*
|
||||
* UserApi.h
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef UserApi_H_
|
||||
#define UserApi_H_
|
||||
|
||||
|
||||
#include <memory>
|
||||
#include <utility>
|
||||
#include <exception>
|
||||
|
||||
#include <corvusoft/restbed/session.hpp>
|
||||
#include <corvusoft/restbed/resource.hpp>
|
||||
#include <corvusoft/restbed/request.hpp>
|
||||
#include <corvusoft/restbed/service.hpp>
|
||||
#include <corvusoft/restbed/settings.hpp>
|
||||
|
||||
#include "User.h"
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
namespace org {
|
||||
namespace openapitools {
|
||||
namespace server {
|
||||
namespace api {
|
||||
|
||||
using namespace org::openapitools::server::model;
|
||||
|
||||
///
|
||||
/// Exception to flag problems in the handlers
|
||||
///
|
||||
class UserApiException: public std::exception
|
||||
{
|
||||
public:
|
||||
UserApiException(int status_code, std::string what);
|
||||
|
||||
int getStatus() const;
|
||||
const char* what() const noexcept override;
|
||||
|
||||
private:
|
||||
int m_status;
|
||||
std::string m_what;
|
||||
};
|
||||
|
||||
/// <summary>
|
||||
/// Create user
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// This can only be done by the logged in user.
|
||||
/// </remarks>
|
||||
class UserApiUserResource: public restbed::Resource
|
||||
{
|
||||
public:
|
||||
UserApiUserResource(const std::string& context = "/v2");
|
||||
virtual ~UserApiUserResource();
|
||||
|
||||
protected:
|
||||
//////////////////////////////////////////////////////////
|
||||
// Override these to implement the server functionality //
|
||||
//////////////////////////////////////////////////////////
|
||||
|
||||
virtual int handler_POST(
|
||||
std::shared_ptr<User> const & user);
|
||||
|
||||
|
||||
protected:
|
||||
//////////////////////////////////////
|
||||
// Override these for customization //
|
||||
//////////////////////////////////////
|
||||
|
||||
virtual std::string extractBodyContent(const std::shared_ptr<restbed::Session>& session);
|
||||
|
||||
|
||||
|
||||
virtual std::pair<int, std::string> handleUserApiException(const UserApiException& e);
|
||||
virtual std::pair<int, std::string> handleStdException(const std::exception& e);
|
||||
virtual std::pair<int, std::string> handleUnspecifiedException();
|
||||
|
||||
virtual void setResponseHeader(const std::shared_ptr<restbed::Session>& session,
|
||||
const std::string& header);
|
||||
|
||||
|
||||
virtual void returnResponse(const std::shared_ptr<restbed::Session>& session,
|
||||
const int status, const std::string& result, const std::string& contentType);
|
||||
virtual void defaultSessionClose(const std::shared_ptr<restbed::Session>& session,
|
||||
const int status, const std::string& result);
|
||||
|
||||
private:
|
||||
void handler_POST_internal(const std::shared_ptr<restbed::Session> session);
|
||||
};
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Creates list of users with given input array
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
///
|
||||
/// </remarks>
|
||||
class UserApiUserCreateWithArrayResource: public restbed::Resource
|
||||
{
|
||||
public:
|
||||
UserApiUserCreateWithArrayResource(const std::string& context = "/v2");
|
||||
virtual ~UserApiUserCreateWithArrayResource();
|
||||
|
||||
protected:
|
||||
//////////////////////////////////////////////////////////
|
||||
// Override these to implement the server functionality //
|
||||
//////////////////////////////////////////////////////////
|
||||
|
||||
virtual int handler_POST(
|
||||
std::vector<std::shared_ptr<User>> const & user);
|
||||
|
||||
|
||||
protected:
|
||||
//////////////////////////////////////
|
||||
// Override these for customization //
|
||||
//////////////////////////////////////
|
||||
|
||||
virtual std::string extractBodyContent(const std::shared_ptr<restbed::Session>& session);
|
||||
|
||||
|
||||
|
||||
virtual std::pair<int, std::string> handleUserApiException(const UserApiException& e);
|
||||
virtual std::pair<int, std::string> handleStdException(const std::exception& e);
|
||||
virtual std::pair<int, std::string> handleUnspecifiedException();
|
||||
|
||||
virtual void setResponseHeader(const std::shared_ptr<restbed::Session>& session,
|
||||
const std::string& header);
|
||||
|
||||
|
||||
virtual void returnResponse(const std::shared_ptr<restbed::Session>& session,
|
||||
const int status, const std::string& result, const std::string& contentType);
|
||||
virtual void defaultSessionClose(const std::shared_ptr<restbed::Session>& session,
|
||||
const int status, const std::string& result);
|
||||
|
||||
private:
|
||||
void handler_POST_internal(const std::shared_ptr<restbed::Session> session);
|
||||
};
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Creates list of users with given input array
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
///
|
||||
/// </remarks>
|
||||
class UserApiUserCreateWithListResource: public restbed::Resource
|
||||
{
|
||||
public:
|
||||
UserApiUserCreateWithListResource(const std::string& context = "/v2");
|
||||
virtual ~UserApiUserCreateWithListResource();
|
||||
|
||||
protected:
|
||||
//////////////////////////////////////////////////////////
|
||||
// Override these to implement the server functionality //
|
||||
//////////////////////////////////////////////////////////
|
||||
|
||||
virtual int handler_POST(
|
||||
std::vector<std::shared_ptr<User>> const & user);
|
||||
|
||||
|
||||
protected:
|
||||
//////////////////////////////////////
|
||||
// Override these for customization //
|
||||
//////////////////////////////////////
|
||||
|
||||
virtual std::string extractBodyContent(const std::shared_ptr<restbed::Session>& session);
|
||||
|
||||
|
||||
|
||||
virtual std::pair<int, std::string> handleUserApiException(const UserApiException& e);
|
||||
virtual std::pair<int, std::string> handleStdException(const std::exception& e);
|
||||
virtual std::pair<int, std::string> handleUnspecifiedException();
|
||||
|
||||
virtual void setResponseHeader(const std::shared_ptr<restbed::Session>& session,
|
||||
const std::string& header);
|
||||
|
||||
|
||||
virtual void returnResponse(const std::shared_ptr<restbed::Session>& session,
|
||||
const int status, const std::string& result, const std::string& contentType);
|
||||
virtual void defaultSessionClose(const std::shared_ptr<restbed::Session>& session,
|
||||
const int status, const std::string& result);
|
||||
|
||||
private:
|
||||
void handler_POST_internal(const std::shared_ptr<restbed::Session> session);
|
||||
};
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Delete user
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// This can only be done by the logged in user.
|
||||
/// </remarks>
|
||||
class UserApiUserUsernameResource: public restbed::Resource
|
||||
{
|
||||
public:
|
||||
UserApiUserUsernameResource(const std::string& context = "/v2");
|
||||
virtual ~UserApiUserUsernameResource();
|
||||
|
||||
protected:
|
||||
//////////////////////////////////////////////////////////
|
||||
// Override these to implement the server functionality //
|
||||
//////////////////////////////////////////////////////////
|
||||
|
||||
virtual int handler_DELETE(
|
||||
std::string const & username);
|
||||
|
||||
virtual std::pair<int, std::shared_ptr<User>> handler_GET(
|
||||
std::string const & username);
|
||||
virtual int handler_PUT(
|
||||
std::string const & username, std::shared_ptr<User> const & user);
|
||||
|
||||
protected:
|
||||
//////////////////////////////////////
|
||||
// Override these for customization //
|
||||
//////////////////////////////////////
|
||||
|
||||
virtual std::string extractBodyContent(const std::shared_ptr<restbed::Session>& session);
|
||||
|
||||
virtual std::string getPathParam_username(const std::shared_ptr<const restbed::Request>& request)
|
||||
{
|
||||
return request->get_path_parameter("username", "");
|
||||
}
|
||||
|
||||
|
||||
virtual std::string getPathParam_username_x_extension(const std::shared_ptr<const restbed::Request>& request)
|
||||
{
|
||||
return request->get_path_parameter("username", "");
|
||||
}
|
||||
virtual std::string getPathParam_username_x_extension(const std::shared_ptr<const restbed::Request>& request)
|
||||
{
|
||||
return request->get_path_parameter("username", "");
|
||||
}
|
||||
|
||||
virtual std::pair<int, std::string> handleUserApiException(const UserApiException& e);
|
||||
virtual std::pair<int, std::string> handleStdException(const std::exception& e);
|
||||
virtual std::pair<int, std::string> handleUnspecifiedException();
|
||||
|
||||
virtual void setResponseHeader(const std::shared_ptr<restbed::Session>& session,
|
||||
const std::string& header);
|
||||
|
||||
|
||||
virtual void returnResponse(const std::shared_ptr<restbed::Session>& session,
|
||||
const int status, const std::string& result, const std::string& contentType);
|
||||
virtual void defaultSessionClose(const std::shared_ptr<restbed::Session>& session,
|
||||
const int status, const std::string& result);
|
||||
|
||||
private:
|
||||
void handler_DELETE_internal(const std::shared_ptr<restbed::Session> session);
|
||||
void handler_GET_internal(const std::shared_ptr<restbed::Session> session);
|
||||
void handler_PUT_internal(const std::shared_ptr<restbed::Session> session);
|
||||
};
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Logs user into the system
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
///
|
||||
/// </remarks>
|
||||
class UserApiUserLoginResource: public restbed::Resource
|
||||
{
|
||||
public:
|
||||
UserApiUserLoginResource(const std::string& context = "/v2");
|
||||
virtual ~UserApiUserLoginResource();
|
||||
|
||||
protected:
|
||||
//////////////////////////////////////////////////////////
|
||||
// Override these to implement the server functionality //
|
||||
//////////////////////////////////////////////////////////
|
||||
|
||||
virtual std::pair<int, std::string> handler_GET(
|
||||
std::string const & username, std::string const & password);
|
||||
|
||||
|
||||
protected:
|
||||
//////////////////////////////////////
|
||||
// Override these for customization //
|
||||
//////////////////////////////////////
|
||||
|
||||
virtual std::string extractBodyContent(const std::shared_ptr<restbed::Session>& session);
|
||||
|
||||
virtual std::string getQueryParam_username(const std::shared_ptr<const restbed::Request>& request)
|
||||
{
|
||||
return request->get_query_parameter("username", "");
|
||||
}
|
||||
|
||||
virtual std::string getQueryParam_password(const std::shared_ptr<const restbed::Request>& request)
|
||||
{
|
||||
return request->get_query_parameter("password", "");
|
||||
}
|
||||
|
||||
|
||||
|
||||
virtual std::pair<int, std::string> handleUserApiException(const UserApiException& e);
|
||||
virtual std::pair<int, std::string> handleStdException(const std::exception& e);
|
||||
virtual std::pair<int, std::string> handleUnspecifiedException();
|
||||
|
||||
virtual void setResponseHeader(const std::shared_ptr<restbed::Session>& session,
|
||||
const std::string& header);
|
||||
|
||||
|
||||
virtual void returnResponse(const std::shared_ptr<restbed::Session>& session,
|
||||
const int status, const std::string& result, const std::string& contentType);
|
||||
virtual void defaultSessionClose(const std::shared_ptr<restbed::Session>& session,
|
||||
const int status, const std::string& result);
|
||||
|
||||
private:
|
||||
void handler_GET_internal(const std::shared_ptr<restbed::Session> session);
|
||||
};
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Logs out current logged in user session
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
///
|
||||
/// </remarks>
|
||||
class UserApiUserLogoutResource: public restbed::Resource
|
||||
{
|
||||
public:
|
||||
UserApiUserLogoutResource(const std::string& context = "/v2");
|
||||
virtual ~UserApiUserLogoutResource();
|
||||
|
||||
protected:
|
||||
//////////////////////////////////////////////////////////
|
||||
// Override these to implement the server functionality //
|
||||
//////////////////////////////////////////////////////////
|
||||
|
||||
virtual int handler_GET(
|
||||
);
|
||||
|
||||
|
||||
protected:
|
||||
//////////////////////////////////////
|
||||
// Override these for customization //
|
||||
//////////////////////////////////////
|
||||
|
||||
virtual std::string extractBodyContent(const std::shared_ptr<restbed::Session>& session);
|
||||
|
||||
|
||||
|
||||
virtual std::pair<int, std::string> handleUserApiException(const UserApiException& e);
|
||||
virtual std::pair<int, std::string> handleStdException(const std::exception& e);
|
||||
virtual std::pair<int, std::string> handleUnspecifiedException();
|
||||
|
||||
virtual void setResponseHeader(const std::shared_ptr<restbed::Session>& session,
|
||||
const std::string& header);
|
||||
|
||||
|
||||
virtual void returnResponse(const std::shared_ptr<restbed::Session>& session,
|
||||
const int status, const std::string& result, const std::string& contentType);
|
||||
virtual void defaultSessionClose(const std::shared_ptr<restbed::Session>& session,
|
||||
const int status, const std::string& result);
|
||||
|
||||
private:
|
||||
void handler_GET_internal(const std::shared_ptr<restbed::Session> session);
|
||||
};
|
||||
|
||||
|
||||
|
||||
//
|
||||
// The restbed service to actually implement the REST server
|
||||
//
|
||||
class UserApi
|
||||
{
|
||||
public:
|
||||
explicit UserApi(std::shared_ptr<restbed::Service> const& restbedService);
|
||||
virtual ~UserApi();
|
||||
|
||||
virtual void setUserApiUserResource(std::shared_ptr<UserApiUserResource> spUserApiUserResource);
|
||||
virtual void setUserApiUserCreateWithArrayResource(std::shared_ptr<UserApiUserCreateWithArrayResource> spUserApiUserCreateWithArrayResource);
|
||||
virtual void setUserApiUserCreateWithListResource(std::shared_ptr<UserApiUserCreateWithListResource> spUserApiUserCreateWithListResource);
|
||||
virtual void setUserApiUserUsernameResource(std::shared_ptr<UserApiUserUsernameResource> spUserApiUserUsernameResource);
|
||||
virtual void setUserApiUserLoginResource(std::shared_ptr<UserApiUserLoginResource> spUserApiUserLoginResource);
|
||||
virtual void setUserApiUserLogoutResource(std::shared_ptr<UserApiUserLogoutResource> spUserApiUserLogoutResource);
|
||||
|
||||
virtual void publishDefaultResources();
|
||||
|
||||
virtual std::shared_ptr<restbed::Service> service();
|
||||
|
||||
protected:
|
||||
std::shared_ptr<UserApiUserResource> m_spUserApiUserResource;
|
||||
std::shared_ptr<UserApiUserCreateWithArrayResource> m_spUserApiUserCreateWithArrayResource;
|
||||
std::shared_ptr<UserApiUserCreateWithListResource> m_spUserApiUserCreateWithListResource;
|
||||
std::shared_ptr<UserApiUserUsernameResource> m_spUserApiUserUsernameResource;
|
||||
std::shared_ptr<UserApiUserLoginResource> m_spUserApiUserLoginResource;
|
||||
std::shared_ptr<UserApiUserLogoutResource> m_spUserApiUserLogoutResource;
|
||||
|
||||
private:
|
||||
std::shared_ptr<restbed::Service> m_service;
|
||||
};
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif /* UserApi_H_ */
|
||||
|
||||
57
samples/server/petstore/cpp-restbed-deprecated/git_push.sh
Normal file
57
samples/server/petstore/cpp-restbed-deprecated/git_push.sh
Normal file
@@ -0,0 +1,57 @@
|
||||
#!/bin/sh
|
||||
# ref: https://help.github.com/articles/adding-an-existing-project-to-github-using-the-command-line/
|
||||
#
|
||||
# Usage example: /bin/sh ./git_push.sh wing328 openapi-petstore-perl "minor update" "gitlab.com"
|
||||
|
||||
git_user_id=$1
|
||||
git_repo_id=$2
|
||||
release_note=$3
|
||||
git_host=$4
|
||||
|
||||
if [ "$git_host" = "" ]; then
|
||||
git_host="github.com"
|
||||
echo "[INFO] No command line input provided. Set \$git_host to $git_host"
|
||||
fi
|
||||
|
||||
if [ "$git_user_id" = "" ]; then
|
||||
git_user_id="GIT_USER_ID"
|
||||
echo "[INFO] No command line input provided. Set \$git_user_id to $git_user_id"
|
||||
fi
|
||||
|
||||
if [ "$git_repo_id" = "" ]; then
|
||||
git_repo_id="GIT_REPO_ID"
|
||||
echo "[INFO] No command line input provided. Set \$git_repo_id to $git_repo_id"
|
||||
fi
|
||||
|
||||
if [ "$release_note" = "" ]; then
|
||||
release_note="Minor update"
|
||||
echo "[INFO] No command line input provided. Set \$release_note to $release_note"
|
||||
fi
|
||||
|
||||
# Initialize the local directory as a Git repository
|
||||
git init
|
||||
|
||||
# Adds the files in the local repository and stages them for commit.
|
||||
git add .
|
||||
|
||||
# Commits the tracked changes and prepares them to be pushed to a remote repository.
|
||||
git commit -m "$release_note"
|
||||
|
||||
# Sets the new remote
|
||||
git_remote=$(git remote)
|
||||
if [ "$git_remote" = "" ]; then # git remote not defined
|
||||
|
||||
if [ "$GIT_TOKEN" = "" ]; then
|
||||
echo "[INFO] \$GIT_TOKEN (environment variable) is not set. Using the git credential in your environment."
|
||||
git remote add origin https://${git_host}/${git_user_id}/${git_repo_id}.git
|
||||
else
|
||||
git remote add origin https://${git_user_id}:"${GIT_TOKEN}"@${git_host}/${git_user_id}/${git_repo_id}.git
|
||||
fi
|
||||
|
||||
fi
|
||||
|
||||
git pull origin master
|
||||
|
||||
# Pushes (Forces) the changes in the local repository up to the remote repository
|
||||
echo "Git pushing to https://${git_host}/${git_user_id}/${git_repo_id}.git"
|
||||
git push origin master 2>&1 | grep -v 'To https'
|
||||
@@ -0,0 +1,137 @@
|
||||
/**
|
||||
* OpenAPI Petstore
|
||||
* This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
|
||||
*
|
||||
* The version of the OpenAPI document: 1.0.0
|
||||
*
|
||||
*
|
||||
* NOTE: This class is auto generated by OpenAPI-Generator unset.
|
||||
* https://openapi-generator.tech
|
||||
* Do not edit the class manually.
|
||||
*/
|
||||
|
||||
|
||||
|
||||
#include "ApiResponse.h"
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <sstream>
|
||||
#include <stdexcept>
|
||||
#include <boost/property_tree/ptree.hpp>
|
||||
#include <boost/property_tree/json_parser.hpp>
|
||||
|
||||
using boost::property_tree::ptree;
|
||||
using boost::property_tree::read_json;
|
||||
using boost::property_tree::write_json;
|
||||
|
||||
namespace org {
|
||||
namespace openapitools {
|
||||
namespace server {
|
||||
namespace model {
|
||||
|
||||
ApiResponse::ApiResponse(boost::property_tree::ptree const& pt)
|
||||
{
|
||||
fromPropertyTree(pt);
|
||||
}
|
||||
|
||||
std::string ApiResponse::toJsonString(bool prettyJson /* = false */)
|
||||
{
|
||||
return toJsonString_internal(prettyJson);
|
||||
}
|
||||
|
||||
void ApiResponse::fromJsonString(std::string const& jsonString)
|
||||
{
|
||||
fromJsonString_internal(jsonString);
|
||||
}
|
||||
|
||||
boost::property_tree::ptree ApiResponse::toPropertyTree()
|
||||
{
|
||||
return toPropertyTree_internal();
|
||||
}
|
||||
|
||||
void ApiResponse::fromPropertyTree(boost::property_tree::ptree const& pt)
|
||||
{
|
||||
fromPropertyTree_internal(pt);
|
||||
}
|
||||
|
||||
std::string ApiResponse::toJsonString_internal(bool prettyJson)
|
||||
{
|
||||
std::stringstream ss;
|
||||
write_json(ss, this->toPropertyTree(), prettyJson);
|
||||
return ss.str();
|
||||
}
|
||||
|
||||
void ApiResponse::fromJsonString_internal(std::string const& jsonString)
|
||||
{
|
||||
std::stringstream ss(jsonString);
|
||||
ptree pt;
|
||||
read_json(ss,pt);
|
||||
this->fromPropertyTree(pt);
|
||||
}
|
||||
|
||||
ptree ApiResponse::toPropertyTree_internal()
|
||||
{
|
||||
ptree pt;
|
||||
ptree tmp_node;
|
||||
pt.put("code", m_Code);
|
||||
pt.put("type", m_Type);
|
||||
pt.put("message", m_Message);
|
||||
return pt;
|
||||
}
|
||||
|
||||
void ApiResponse::fromPropertyTree_internal(ptree const &pt)
|
||||
{
|
||||
ptree tmp_node;
|
||||
m_Code = pt.get("code", 0);
|
||||
m_Type = pt.get("type", "");
|
||||
m_Message = pt.get("message", "");
|
||||
}
|
||||
|
||||
int32_t ApiResponse::getCode() const
|
||||
{
|
||||
return m_Code;
|
||||
}
|
||||
|
||||
void ApiResponse::setCode(int32_t value)
|
||||
{
|
||||
m_Code = value;
|
||||
}
|
||||
std::string ApiResponse::getType() const
|
||||
{
|
||||
return m_Type;
|
||||
}
|
||||
|
||||
void ApiResponse::setType(std::string value)
|
||||
{
|
||||
m_Type = value;
|
||||
}
|
||||
std::string ApiResponse::getMessage() const
|
||||
{
|
||||
return m_Message;
|
||||
}
|
||||
|
||||
void ApiResponse::setMessage(std::string value)
|
||||
{
|
||||
m_Message = value;
|
||||
}
|
||||
|
||||
std::vector<ApiResponse> createApiResponseVectorFromJsonString(const std::string& json)
|
||||
{
|
||||
std::stringstream sstream(json);
|
||||
boost::property_tree::ptree pt;
|
||||
boost::property_tree::json_parser::read_json(sstream,pt);
|
||||
|
||||
auto vec = std::vector<ApiResponse>();
|
||||
for (const auto& child: pt) {
|
||||
vec.emplace_back(ApiResponse(child.second));
|
||||
}
|
||||
|
||||
return vec;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,94 @@
|
||||
/**
|
||||
* OpenAPI Petstore
|
||||
* This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
|
||||
*
|
||||
* The version of the OpenAPI document: 1.0.0
|
||||
*
|
||||
*
|
||||
* NOTE: This class is auto generated by OpenAPI-Generator unset.
|
||||
* https://openapi-generator.tech
|
||||
* Do not edit the class manually.
|
||||
*/
|
||||
|
||||
/*
|
||||
* ApiResponse.h
|
||||
*
|
||||
* Describes the result of uploading an image resource
|
||||
*/
|
||||
|
||||
#ifndef ApiResponse_H_
|
||||
#define ApiResponse_H_
|
||||
|
||||
|
||||
|
||||
#include <string>
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
#include <boost/property_tree/ptree.hpp>
|
||||
|
||||
namespace org {
|
||||
namespace openapitools {
|
||||
namespace server {
|
||||
namespace model {
|
||||
|
||||
/// <summary>
|
||||
/// Describes the result of uploading an image resource
|
||||
/// </summary>
|
||||
class ApiResponse
|
||||
{
|
||||
public:
|
||||
ApiResponse() = default;
|
||||
explicit ApiResponse(boost::property_tree::ptree const& pt);
|
||||
virtual ~ApiResponse() = default;
|
||||
|
||||
std::string toJsonString(bool prettyJson = false);
|
||||
void fromJsonString(std::string const& jsonString);
|
||||
boost::property_tree::ptree toPropertyTree();
|
||||
void fromPropertyTree(boost::property_tree::ptree const& pt);
|
||||
|
||||
/////////////////////////////////////////////
|
||||
/// ApiResponse members
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
int32_t getCode() const;
|
||||
void setCode(int32_t value);
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
std::string getType() const;
|
||||
void setType(std::string value);
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
std::string getMessage() const;
|
||||
void setMessage(std::string value);
|
||||
|
||||
protected:
|
||||
//////////////////////////////////////
|
||||
// Override these for customization //
|
||||
//////////////////////////////////////
|
||||
|
||||
virtual std::string toJsonString_internal(bool prettyJson = false);
|
||||
virtual void fromJsonString_internal(std::string const& jsonString);
|
||||
virtual boost::property_tree::ptree toPropertyTree_internal();
|
||||
virtual void fromPropertyTree_internal(boost::property_tree::ptree const& pt);
|
||||
|
||||
|
||||
protected:
|
||||
int32_t m_Code = 0;
|
||||
std::string m_Type = "";
|
||||
std::string m_Message = "";
|
||||
};
|
||||
|
||||
std::vector<ApiResponse> createApiResponseVectorFromJsonString(const std::string& json);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif /* ApiResponse_H_ */
|
||||
@@ -0,0 +1,126 @@
|
||||
/**
|
||||
* OpenAPI Petstore
|
||||
* This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
|
||||
*
|
||||
* The version of the OpenAPI document: 1.0.0
|
||||
*
|
||||
*
|
||||
* NOTE: This class is auto generated by OpenAPI-Generator unset.
|
||||
* https://openapi-generator.tech
|
||||
* Do not edit the class manually.
|
||||
*/
|
||||
|
||||
|
||||
|
||||
#include "Category.h"
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <sstream>
|
||||
#include <stdexcept>
|
||||
#include <boost/property_tree/ptree.hpp>
|
||||
#include <boost/property_tree/json_parser.hpp>
|
||||
|
||||
using boost::property_tree::ptree;
|
||||
using boost::property_tree::read_json;
|
||||
using boost::property_tree::write_json;
|
||||
|
||||
namespace org {
|
||||
namespace openapitools {
|
||||
namespace server {
|
||||
namespace model {
|
||||
|
||||
Category::Category(boost::property_tree::ptree const& pt)
|
||||
{
|
||||
fromPropertyTree(pt);
|
||||
}
|
||||
|
||||
std::string Category::toJsonString(bool prettyJson /* = false */)
|
||||
{
|
||||
return toJsonString_internal(prettyJson);
|
||||
}
|
||||
|
||||
void Category::fromJsonString(std::string const& jsonString)
|
||||
{
|
||||
fromJsonString_internal(jsonString);
|
||||
}
|
||||
|
||||
boost::property_tree::ptree Category::toPropertyTree()
|
||||
{
|
||||
return toPropertyTree_internal();
|
||||
}
|
||||
|
||||
void Category::fromPropertyTree(boost::property_tree::ptree const& pt)
|
||||
{
|
||||
fromPropertyTree_internal(pt);
|
||||
}
|
||||
|
||||
std::string Category::toJsonString_internal(bool prettyJson)
|
||||
{
|
||||
std::stringstream ss;
|
||||
write_json(ss, this->toPropertyTree(), prettyJson);
|
||||
return ss.str();
|
||||
}
|
||||
|
||||
void Category::fromJsonString_internal(std::string const& jsonString)
|
||||
{
|
||||
std::stringstream ss(jsonString);
|
||||
ptree pt;
|
||||
read_json(ss,pt);
|
||||
this->fromPropertyTree(pt);
|
||||
}
|
||||
|
||||
ptree Category::toPropertyTree_internal()
|
||||
{
|
||||
ptree pt;
|
||||
ptree tmp_node;
|
||||
pt.put("id", m_Id);
|
||||
pt.put("name", m_Name);
|
||||
return pt;
|
||||
}
|
||||
|
||||
void Category::fromPropertyTree_internal(ptree const &pt)
|
||||
{
|
||||
ptree tmp_node;
|
||||
m_Id = pt.get("id", 0L);
|
||||
m_Name = pt.get("name", "");
|
||||
}
|
||||
|
||||
int64_t Category::getId() const
|
||||
{
|
||||
return m_Id;
|
||||
}
|
||||
|
||||
void Category::setId(int64_t value)
|
||||
{
|
||||
m_Id = value;
|
||||
}
|
||||
std::string Category::getName() const
|
||||
{
|
||||
return m_Name;
|
||||
}
|
||||
|
||||
void Category::setName(std::string value)
|
||||
{
|
||||
m_Name = value;
|
||||
}
|
||||
|
||||
std::vector<Category> createCategoryVectorFromJsonString(const std::string& json)
|
||||
{
|
||||
std::stringstream sstream(json);
|
||||
boost::property_tree::ptree pt;
|
||||
boost::property_tree::json_parser::read_json(sstream,pt);
|
||||
|
||||
auto vec = std::vector<Category>();
|
||||
for (const auto& child: pt) {
|
||||
vec.emplace_back(Category(child.second));
|
||||
}
|
||||
|
||||
return vec;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,87 @@
|
||||
/**
|
||||
* OpenAPI Petstore
|
||||
* This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
|
||||
*
|
||||
* The version of the OpenAPI document: 1.0.0
|
||||
*
|
||||
*
|
||||
* NOTE: This class is auto generated by OpenAPI-Generator unset.
|
||||
* https://openapi-generator.tech
|
||||
* Do not edit the class manually.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Category.h
|
||||
*
|
||||
* A category for a pet
|
||||
*/
|
||||
|
||||
#ifndef Category_H_
|
||||
#define Category_H_
|
||||
|
||||
|
||||
|
||||
#include <string>
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
#include <boost/property_tree/ptree.hpp>
|
||||
|
||||
namespace org {
|
||||
namespace openapitools {
|
||||
namespace server {
|
||||
namespace model {
|
||||
|
||||
/// <summary>
|
||||
/// A category for a pet
|
||||
/// </summary>
|
||||
class Category
|
||||
{
|
||||
public:
|
||||
Category() = default;
|
||||
explicit Category(boost::property_tree::ptree const& pt);
|
||||
virtual ~Category() = default;
|
||||
|
||||
std::string toJsonString(bool prettyJson = false);
|
||||
void fromJsonString(std::string const& jsonString);
|
||||
boost::property_tree::ptree toPropertyTree();
|
||||
void fromPropertyTree(boost::property_tree::ptree const& pt);
|
||||
|
||||
/////////////////////////////////////////////
|
||||
/// Category members
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
int64_t getId() const;
|
||||
void setId(int64_t value);
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
std::string getName() const;
|
||||
void setName(std::string value);
|
||||
|
||||
protected:
|
||||
//////////////////////////////////////
|
||||
// Override these for customization //
|
||||
//////////////////////////////////////
|
||||
|
||||
virtual std::string toJsonString_internal(bool prettyJson = false);
|
||||
virtual void fromJsonString_internal(std::string const& jsonString);
|
||||
virtual boost::property_tree::ptree toPropertyTree_internal();
|
||||
virtual void fromPropertyTree_internal(boost::property_tree::ptree const& pt);
|
||||
|
||||
|
||||
protected:
|
||||
int64_t m_Id = 0L;
|
||||
std::string m_Name = "";
|
||||
};
|
||||
|
||||
std::vector<Category> createCategoryVectorFromJsonString(const std::string& json);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif /* Category_H_ */
|
||||
175
samples/server/petstore/cpp-restbed-deprecated/model/Order.cpp
Normal file
175
samples/server/petstore/cpp-restbed-deprecated/model/Order.cpp
Normal file
@@ -0,0 +1,175 @@
|
||||
/**
|
||||
* OpenAPI Petstore
|
||||
* This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
|
||||
*
|
||||
* The version of the OpenAPI document: 1.0.0
|
||||
*
|
||||
*
|
||||
* NOTE: This class is auto generated by OpenAPI-Generator unset.
|
||||
* https://openapi-generator.tech
|
||||
* Do not edit the class manually.
|
||||
*/
|
||||
|
||||
|
||||
|
||||
#include "Order.h"
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <sstream>
|
||||
#include <stdexcept>
|
||||
#include <algorithm>
|
||||
#include <boost/property_tree/ptree.hpp>
|
||||
#include <boost/property_tree/json_parser.hpp>
|
||||
|
||||
using boost::property_tree::ptree;
|
||||
using boost::property_tree::read_json;
|
||||
using boost::property_tree::write_json;
|
||||
|
||||
namespace org {
|
||||
namespace openapitools {
|
||||
namespace server {
|
||||
namespace model {
|
||||
|
||||
Order::Order(boost::property_tree::ptree const& pt)
|
||||
{
|
||||
fromPropertyTree(pt);
|
||||
}
|
||||
|
||||
std::string Order::toJsonString(bool prettyJson /* = false */)
|
||||
{
|
||||
return toJsonString_internal(prettyJson);
|
||||
}
|
||||
|
||||
void Order::fromJsonString(std::string const& jsonString)
|
||||
{
|
||||
fromJsonString_internal(jsonString);
|
||||
}
|
||||
|
||||
boost::property_tree::ptree Order::toPropertyTree()
|
||||
{
|
||||
return toPropertyTree_internal();
|
||||
}
|
||||
|
||||
void Order::fromPropertyTree(boost::property_tree::ptree const& pt)
|
||||
{
|
||||
fromPropertyTree_internal(pt);
|
||||
}
|
||||
|
||||
std::string Order::toJsonString_internal(bool prettyJson)
|
||||
{
|
||||
std::stringstream ss;
|
||||
write_json(ss, this->toPropertyTree(), prettyJson);
|
||||
return ss.str();
|
||||
}
|
||||
|
||||
void Order::fromJsonString_internal(std::string const& jsonString)
|
||||
{
|
||||
std::stringstream ss(jsonString);
|
||||
ptree pt;
|
||||
read_json(ss,pt);
|
||||
this->fromPropertyTree(pt);
|
||||
}
|
||||
|
||||
ptree Order::toPropertyTree_internal()
|
||||
{
|
||||
ptree pt;
|
||||
ptree tmp_node;
|
||||
pt.put("id", m_Id);
|
||||
pt.put("petId", m_PetId);
|
||||
pt.put("quantity", m_Quantity);
|
||||
pt.put("shipDate", m_ShipDate);
|
||||
pt.put("status", m_Status);
|
||||
pt.put("complete", m_Complete);
|
||||
return pt;
|
||||
}
|
||||
|
||||
void Order::fromPropertyTree_internal(ptree const &pt)
|
||||
{
|
||||
ptree tmp_node;
|
||||
m_Id = pt.get("id", 0L);
|
||||
m_PetId = pt.get("petId", 0L);
|
||||
m_Quantity = pt.get("quantity", 0);
|
||||
m_ShipDate = pt.get("shipDate", "");
|
||||
setStatus(pt.get("status", ""));
|
||||
m_Complete = pt.get("complete", false);
|
||||
}
|
||||
|
||||
int64_t Order::getId() const
|
||||
{
|
||||
return m_Id;
|
||||
}
|
||||
|
||||
void Order::setId(int64_t value)
|
||||
{
|
||||
m_Id = value;
|
||||
}
|
||||
int64_t Order::getPetId() const
|
||||
{
|
||||
return m_PetId;
|
||||
}
|
||||
|
||||
void Order::setPetId(int64_t value)
|
||||
{
|
||||
m_PetId = value;
|
||||
}
|
||||
int32_t Order::getQuantity() const
|
||||
{
|
||||
return m_Quantity;
|
||||
}
|
||||
|
||||
void Order::setQuantity(int32_t value)
|
||||
{
|
||||
m_Quantity = value;
|
||||
}
|
||||
std::string Order::getShipDate() const
|
||||
{
|
||||
return m_ShipDate;
|
||||
}
|
||||
|
||||
void Order::setShipDate(std::string value)
|
||||
{
|
||||
m_ShipDate = value;
|
||||
}
|
||||
std::string Order::getStatus() const
|
||||
{
|
||||
return m_Status;
|
||||
}
|
||||
|
||||
void Order::setStatus(std::string value)
|
||||
{
|
||||
if (std::find(m_StatusEnum.begin(), m_StatusEnum.end(), value) != m_StatusEnum.end()) {
|
||||
m_Status = value;
|
||||
} else {
|
||||
throw std::runtime_error("Value " + value + " not allowed");
|
||||
}
|
||||
}
|
||||
bool Order::isComplete() const
|
||||
{
|
||||
return m_Complete;
|
||||
}
|
||||
|
||||
void Order::setComplete(bool value)
|
||||
{
|
||||
m_Complete = value;
|
||||
}
|
||||
|
||||
std::vector<Order> createOrderVectorFromJsonString(const std::string& json)
|
||||
{
|
||||
std::stringstream sstream(json);
|
||||
boost::property_tree::ptree pt;
|
||||
boost::property_tree::json_parser::read_json(sstream,pt);
|
||||
|
||||
auto vec = std::vector<Order>();
|
||||
for (const auto& child: pt) {
|
||||
vec.emplace_back(Order(child.second));
|
||||
}
|
||||
|
||||
return vec;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
121
samples/server/petstore/cpp-restbed-deprecated/model/Order.h
Normal file
121
samples/server/petstore/cpp-restbed-deprecated/model/Order.h
Normal file
@@ -0,0 +1,121 @@
|
||||
/**
|
||||
* OpenAPI Petstore
|
||||
* This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
|
||||
*
|
||||
* The version of the OpenAPI document: 1.0.0
|
||||
*
|
||||
*
|
||||
* NOTE: This class is auto generated by OpenAPI-Generator unset.
|
||||
* https://openapi-generator.tech
|
||||
* Do not edit the class manually.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Order.h
|
||||
*
|
||||
* An order for a pets from the pet store
|
||||
*/
|
||||
|
||||
#ifndef Order_H_
|
||||
#define Order_H_
|
||||
|
||||
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
#include <array>
|
||||
#include <boost/property_tree/ptree.hpp>
|
||||
|
||||
namespace org {
|
||||
namespace openapitools {
|
||||
namespace server {
|
||||
namespace model {
|
||||
|
||||
/// <summary>
|
||||
/// An order for a pets from the pet store
|
||||
/// </summary>
|
||||
class Order
|
||||
{
|
||||
public:
|
||||
Order() = default;
|
||||
explicit Order(boost::property_tree::ptree const& pt);
|
||||
virtual ~Order() = default;
|
||||
|
||||
std::string toJsonString(bool prettyJson = false);
|
||||
void fromJsonString(std::string const& jsonString);
|
||||
boost::property_tree::ptree toPropertyTree();
|
||||
void fromPropertyTree(boost::property_tree::ptree const& pt);
|
||||
|
||||
/////////////////////////////////////////////
|
||||
/// Order members
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
int64_t getId() const;
|
||||
void setId(int64_t value);
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
int64_t getPetId() const;
|
||||
void setPetId(int64_t value);
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
int32_t getQuantity() const;
|
||||
void setQuantity(int32_t value);
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
std::string getShipDate() const;
|
||||
void setShipDate(std::string value);
|
||||
|
||||
/// <summary>
|
||||
/// Order Status
|
||||
/// </summary>
|
||||
std::string getStatus() const;
|
||||
void setStatus(std::string value);
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
bool isComplete() const;
|
||||
void setComplete(bool value);
|
||||
|
||||
protected:
|
||||
//////////////////////////////////////
|
||||
// Override these for customization //
|
||||
//////////////////////////////////////
|
||||
|
||||
virtual std::string toJsonString_internal(bool prettyJson = false);
|
||||
virtual void fromJsonString_internal(std::string const& jsonString);
|
||||
virtual boost::property_tree::ptree toPropertyTree_internal();
|
||||
virtual void fromPropertyTree_internal(boost::property_tree::ptree const& pt);
|
||||
|
||||
|
||||
protected:
|
||||
int64_t m_Id = 0L;
|
||||
int64_t m_PetId = 0L;
|
||||
int32_t m_Quantity = 0;
|
||||
std::string m_ShipDate = "";
|
||||
std::string m_Status = "";
|
||||
bool m_Complete = false;
|
||||
const std::array<std::string, 3> m_StatusEnum = {
|
||||
"placed","approved","delivered"
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
std::vector<Order> createOrderVectorFromJsonString(const std::string& json);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif /* Order_H_ */
|
||||
210
samples/server/petstore/cpp-restbed-deprecated/model/Pet.cpp
Normal file
210
samples/server/petstore/cpp-restbed-deprecated/model/Pet.cpp
Normal file
@@ -0,0 +1,210 @@
|
||||
/**
|
||||
* OpenAPI Petstore
|
||||
* This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
|
||||
*
|
||||
* The version of the OpenAPI document: 1.0.0
|
||||
*
|
||||
*
|
||||
* NOTE: This class is auto generated by OpenAPI-Generator unset.
|
||||
* https://openapi-generator.tech
|
||||
* Do not edit the class manually.
|
||||
*/
|
||||
|
||||
|
||||
|
||||
#include "Pet.h"
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <sstream>
|
||||
#include <stdexcept>
|
||||
#include <algorithm>
|
||||
#include <boost/property_tree/ptree.hpp>
|
||||
#include <boost/property_tree/json_parser.hpp>
|
||||
|
||||
using boost::property_tree::ptree;
|
||||
using boost::property_tree::read_json;
|
||||
using boost::property_tree::write_json;
|
||||
|
||||
namespace org {
|
||||
namespace openapitools {
|
||||
namespace server {
|
||||
namespace model {
|
||||
|
||||
Pet::Pet(boost::property_tree::ptree const& pt)
|
||||
{
|
||||
fromPropertyTree(pt);
|
||||
}
|
||||
|
||||
std::string Pet::toJsonString(bool prettyJson /* = false */)
|
||||
{
|
||||
return toJsonString_internal(prettyJson);
|
||||
}
|
||||
|
||||
void Pet::fromJsonString(std::string const& jsonString)
|
||||
{
|
||||
fromJsonString_internal(jsonString);
|
||||
}
|
||||
|
||||
boost::property_tree::ptree Pet::toPropertyTree()
|
||||
{
|
||||
return toPropertyTree_internal();
|
||||
}
|
||||
|
||||
void Pet::fromPropertyTree(boost::property_tree::ptree const& pt)
|
||||
{
|
||||
fromPropertyTree_internal(pt);
|
||||
}
|
||||
|
||||
std::string Pet::toJsonString_internal(bool prettyJson)
|
||||
{
|
||||
std::stringstream ss;
|
||||
write_json(ss, this->toPropertyTree(), prettyJson);
|
||||
return ss.str();
|
||||
}
|
||||
|
||||
void Pet::fromJsonString_internal(std::string const& jsonString)
|
||||
{
|
||||
std::stringstream ss(jsonString);
|
||||
ptree pt;
|
||||
read_json(ss,pt);
|
||||
this->fromPropertyTree(pt);
|
||||
}
|
||||
|
||||
ptree Pet::toPropertyTree_internal()
|
||||
{
|
||||
ptree pt;
|
||||
ptree tmp_node;
|
||||
pt.put("id", m_Id);
|
||||
if (m_Category != nullptr) {
|
||||
pt.add_child("category", m_Category->toPropertyTree());
|
||||
}
|
||||
pt.put("name", m_Name);
|
||||
// generate tree for PhotoUrls
|
||||
if (!m_PhotoUrls.empty()) {
|
||||
for (const auto &childEntry : m_PhotoUrls) {
|
||||
ptree PhotoUrls_node;
|
||||
PhotoUrls_node.put("", childEntry);
|
||||
tmp_node.push_back(std::make_pair("", PhotoUrls_node));
|
||||
}
|
||||
pt.add_child("photoUrls", tmp_node);
|
||||
tmp_node.clear();
|
||||
}
|
||||
// generate tree for Tags
|
||||
if (!m_Tags.empty()) {
|
||||
for (const auto &childEntry : m_Tags) {
|
||||
tmp_node.push_back(std::make_pair("", childEntry->toPropertyTree()));
|
||||
}
|
||||
pt.add_child("tags", tmp_node);
|
||||
tmp_node.clear();
|
||||
}
|
||||
pt.put("status", m_Status);
|
||||
return pt;
|
||||
}
|
||||
|
||||
void Pet::fromPropertyTree_internal(ptree const &pt)
|
||||
{
|
||||
ptree tmp_node;
|
||||
m_Id = pt.get("id", 0L);
|
||||
if (pt.get_child_optional("category")) {
|
||||
m_Category = std::make_shared<Category>();
|
||||
m_Category->fromPropertyTree(pt.get_child("category"));
|
||||
}
|
||||
m_Name = pt.get("name", "");
|
||||
// push all items of PhotoUrls into member vector
|
||||
if (pt.get_child_optional("photoUrls")) {
|
||||
for (const auto &childTree : pt.get_child("photoUrls")) {
|
||||
std::string val =
|
||||
childTree.second.data();
|
||||
m_PhotoUrls.emplace_back(std::move(val));
|
||||
}
|
||||
}
|
||||
// push all items of Tags into member vector
|
||||
if (pt.get_child_optional("tags")) {
|
||||
for (const auto &childTree : pt.get_child("tags")) {
|
||||
std::shared_ptr<Tag> val =
|
||||
std::make_shared<Tag>(childTree.second);
|
||||
m_Tags.emplace_back(std::move(val));
|
||||
}
|
||||
}
|
||||
setStatus(pt.get("status", ""));
|
||||
}
|
||||
|
||||
int64_t Pet::getId() const
|
||||
{
|
||||
return m_Id;
|
||||
}
|
||||
|
||||
void Pet::setId(int64_t value)
|
||||
{
|
||||
m_Id = value;
|
||||
}
|
||||
std::shared_ptr<Category> Pet::getCategory() const
|
||||
{
|
||||
return m_Category;
|
||||
}
|
||||
|
||||
void Pet::setCategory(std::shared_ptr<Category> value)
|
||||
{
|
||||
m_Category = value;
|
||||
}
|
||||
std::string Pet::getName() const
|
||||
{
|
||||
return m_Name;
|
||||
}
|
||||
|
||||
void Pet::setName(std::string value)
|
||||
{
|
||||
m_Name = value;
|
||||
}
|
||||
std::vector<std::string> Pet::getPhotoUrls() const
|
||||
{
|
||||
return m_PhotoUrls;
|
||||
}
|
||||
|
||||
void Pet::setPhotoUrls(std::vector<std::string> value)
|
||||
{
|
||||
m_PhotoUrls = value;
|
||||
}
|
||||
std::vector<std::shared_ptr<Tag>> Pet::getTags() const
|
||||
{
|
||||
return m_Tags;
|
||||
}
|
||||
|
||||
void Pet::setTags(std::vector<std::shared_ptr<Tag>> value)
|
||||
{
|
||||
m_Tags = value;
|
||||
}
|
||||
std::string Pet::getStatus() const
|
||||
{
|
||||
return m_Status;
|
||||
}
|
||||
|
||||
void Pet::setStatus(std::string value)
|
||||
{
|
||||
if (std::find(m_StatusEnum.begin(), m_StatusEnum.end(), value) != m_StatusEnum.end()) {
|
||||
m_Status = value;
|
||||
} else {
|
||||
throw std::runtime_error("Value " + value + " not allowed");
|
||||
}
|
||||
}
|
||||
|
||||
std::vector<Pet> createPetVectorFromJsonString(const std::string& json)
|
||||
{
|
||||
std::stringstream sstream(json);
|
||||
boost::property_tree::ptree pt;
|
||||
boost::property_tree::json_parser::read_json(sstream,pt);
|
||||
|
||||
auto vec = std::vector<Pet>();
|
||||
for (const auto& child: pt) {
|
||||
vec.emplace_back(Pet(child.second));
|
||||
}
|
||||
|
||||
return vec;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
123
samples/server/petstore/cpp-restbed-deprecated/model/Pet.h
Normal file
123
samples/server/petstore/cpp-restbed-deprecated/model/Pet.h
Normal file
@@ -0,0 +1,123 @@
|
||||
/**
|
||||
* OpenAPI Petstore
|
||||
* This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
|
||||
*
|
||||
* The version of the OpenAPI document: 1.0.0
|
||||
*
|
||||
*
|
||||
* NOTE: This class is auto generated by OpenAPI-Generator unset.
|
||||
* https://openapi-generator.tech
|
||||
* Do not edit the class manually.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Pet.h
|
||||
*
|
||||
* A pet for sale in the pet store
|
||||
*/
|
||||
|
||||
#ifndef Pet_H_
|
||||
#define Pet_H_
|
||||
|
||||
|
||||
|
||||
#include "Tag.h"
|
||||
#include <string>
|
||||
#include "Category.h"
|
||||
#include <vector>
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
#include <array>
|
||||
#include <boost/property_tree/ptree.hpp>
|
||||
|
||||
namespace org {
|
||||
namespace openapitools {
|
||||
namespace server {
|
||||
namespace model {
|
||||
|
||||
/// <summary>
|
||||
/// A pet for sale in the pet store
|
||||
/// </summary>
|
||||
class Pet
|
||||
{
|
||||
public:
|
||||
Pet() = default;
|
||||
explicit Pet(boost::property_tree::ptree const& pt);
|
||||
virtual ~Pet() = default;
|
||||
|
||||
std::string toJsonString(bool prettyJson = false);
|
||||
void fromJsonString(std::string const& jsonString);
|
||||
boost::property_tree::ptree toPropertyTree();
|
||||
void fromPropertyTree(boost::property_tree::ptree const& pt);
|
||||
|
||||
/////////////////////////////////////////////
|
||||
/// Pet members
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
int64_t getId() const;
|
||||
void setId(int64_t value);
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
std::shared_ptr<Category> getCategory() const;
|
||||
void setCategory(std::shared_ptr<Category> value);
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
std::string getName() const;
|
||||
void setName(std::string value);
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
std::vector<std::string> getPhotoUrls() const;
|
||||
void setPhotoUrls(std::vector<std::string> value);
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
std::vector<std::shared_ptr<Tag>> getTags() const;
|
||||
void setTags(std::vector<std::shared_ptr<Tag>> value);
|
||||
|
||||
/// <summary>
|
||||
/// pet status in the store
|
||||
/// </summary>
|
||||
std::string getStatus() const;
|
||||
void setStatus(std::string value);
|
||||
|
||||
protected:
|
||||
//////////////////////////////////////
|
||||
// Override these for customization //
|
||||
//////////////////////////////////////
|
||||
|
||||
virtual std::string toJsonString_internal(bool prettyJson = false);
|
||||
virtual void fromJsonString_internal(std::string const& jsonString);
|
||||
virtual boost::property_tree::ptree toPropertyTree_internal();
|
||||
virtual void fromPropertyTree_internal(boost::property_tree::ptree const& pt);
|
||||
|
||||
|
||||
protected:
|
||||
int64_t m_Id = 0L;
|
||||
std::shared_ptr<Category> m_Category;
|
||||
std::string m_Name = "";
|
||||
std::vector<std::string> m_PhotoUrls;
|
||||
std::vector<std::shared_ptr<Tag>> m_Tags;
|
||||
std::string m_Status = "";
|
||||
const std::array<std::string, 3> m_StatusEnum = {
|
||||
"available","pending","sold"
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
std::vector<Pet> createPetVectorFromJsonString(const std::string& json);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif /* Pet_H_ */
|
||||
126
samples/server/petstore/cpp-restbed-deprecated/model/Tag.cpp
Normal file
126
samples/server/petstore/cpp-restbed-deprecated/model/Tag.cpp
Normal file
@@ -0,0 +1,126 @@
|
||||
/**
|
||||
* OpenAPI Petstore
|
||||
* This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
|
||||
*
|
||||
* The version of the OpenAPI document: 1.0.0
|
||||
*
|
||||
*
|
||||
* NOTE: This class is auto generated by OpenAPI-Generator unset.
|
||||
* https://openapi-generator.tech
|
||||
* Do not edit the class manually.
|
||||
*/
|
||||
|
||||
|
||||
|
||||
#include "Tag.h"
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <sstream>
|
||||
#include <stdexcept>
|
||||
#include <boost/property_tree/ptree.hpp>
|
||||
#include <boost/property_tree/json_parser.hpp>
|
||||
|
||||
using boost::property_tree::ptree;
|
||||
using boost::property_tree::read_json;
|
||||
using boost::property_tree::write_json;
|
||||
|
||||
namespace org {
|
||||
namespace openapitools {
|
||||
namespace server {
|
||||
namespace model {
|
||||
|
||||
Tag::Tag(boost::property_tree::ptree const& pt)
|
||||
{
|
||||
fromPropertyTree(pt);
|
||||
}
|
||||
|
||||
std::string Tag::toJsonString(bool prettyJson /* = false */)
|
||||
{
|
||||
return toJsonString_internal(prettyJson);
|
||||
}
|
||||
|
||||
void Tag::fromJsonString(std::string const& jsonString)
|
||||
{
|
||||
fromJsonString_internal(jsonString);
|
||||
}
|
||||
|
||||
boost::property_tree::ptree Tag::toPropertyTree()
|
||||
{
|
||||
return toPropertyTree_internal();
|
||||
}
|
||||
|
||||
void Tag::fromPropertyTree(boost::property_tree::ptree const& pt)
|
||||
{
|
||||
fromPropertyTree_internal(pt);
|
||||
}
|
||||
|
||||
std::string Tag::toJsonString_internal(bool prettyJson)
|
||||
{
|
||||
std::stringstream ss;
|
||||
write_json(ss, this->toPropertyTree(), prettyJson);
|
||||
return ss.str();
|
||||
}
|
||||
|
||||
void Tag::fromJsonString_internal(std::string const& jsonString)
|
||||
{
|
||||
std::stringstream ss(jsonString);
|
||||
ptree pt;
|
||||
read_json(ss,pt);
|
||||
this->fromPropertyTree(pt);
|
||||
}
|
||||
|
||||
ptree Tag::toPropertyTree_internal()
|
||||
{
|
||||
ptree pt;
|
||||
ptree tmp_node;
|
||||
pt.put("id", m_Id);
|
||||
pt.put("name", m_Name);
|
||||
return pt;
|
||||
}
|
||||
|
||||
void Tag::fromPropertyTree_internal(ptree const &pt)
|
||||
{
|
||||
ptree tmp_node;
|
||||
m_Id = pt.get("id", 0L);
|
||||
m_Name = pt.get("name", "");
|
||||
}
|
||||
|
||||
int64_t Tag::getId() const
|
||||
{
|
||||
return m_Id;
|
||||
}
|
||||
|
||||
void Tag::setId(int64_t value)
|
||||
{
|
||||
m_Id = value;
|
||||
}
|
||||
std::string Tag::getName() const
|
||||
{
|
||||
return m_Name;
|
||||
}
|
||||
|
||||
void Tag::setName(std::string value)
|
||||
{
|
||||
m_Name = value;
|
||||
}
|
||||
|
||||
std::vector<Tag> createTagVectorFromJsonString(const std::string& json)
|
||||
{
|
||||
std::stringstream sstream(json);
|
||||
boost::property_tree::ptree pt;
|
||||
boost::property_tree::json_parser::read_json(sstream,pt);
|
||||
|
||||
auto vec = std::vector<Tag>();
|
||||
for (const auto& child: pt) {
|
||||
vec.emplace_back(Tag(child.second));
|
||||
}
|
||||
|
||||
return vec;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
87
samples/server/petstore/cpp-restbed-deprecated/model/Tag.h
Normal file
87
samples/server/petstore/cpp-restbed-deprecated/model/Tag.h
Normal file
@@ -0,0 +1,87 @@
|
||||
/**
|
||||
* OpenAPI Petstore
|
||||
* This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
|
||||
*
|
||||
* The version of the OpenAPI document: 1.0.0
|
||||
*
|
||||
*
|
||||
* NOTE: This class is auto generated by OpenAPI-Generator unset.
|
||||
* https://openapi-generator.tech
|
||||
* Do not edit the class manually.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Tag.h
|
||||
*
|
||||
* A tag for a pet
|
||||
*/
|
||||
|
||||
#ifndef Tag_H_
|
||||
#define Tag_H_
|
||||
|
||||
|
||||
|
||||
#include <string>
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
#include <boost/property_tree/ptree.hpp>
|
||||
|
||||
namespace org {
|
||||
namespace openapitools {
|
||||
namespace server {
|
||||
namespace model {
|
||||
|
||||
/// <summary>
|
||||
/// A tag for a pet
|
||||
/// </summary>
|
||||
class Tag
|
||||
{
|
||||
public:
|
||||
Tag() = default;
|
||||
explicit Tag(boost::property_tree::ptree const& pt);
|
||||
virtual ~Tag() = default;
|
||||
|
||||
std::string toJsonString(bool prettyJson = false);
|
||||
void fromJsonString(std::string const& jsonString);
|
||||
boost::property_tree::ptree toPropertyTree();
|
||||
void fromPropertyTree(boost::property_tree::ptree const& pt);
|
||||
|
||||
/////////////////////////////////////////////
|
||||
/// Tag members
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
int64_t getId() const;
|
||||
void setId(int64_t value);
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
std::string getName() const;
|
||||
void setName(std::string value);
|
||||
|
||||
protected:
|
||||
//////////////////////////////////////
|
||||
// Override these for customization //
|
||||
//////////////////////////////////////
|
||||
|
||||
virtual std::string toJsonString_internal(bool prettyJson = false);
|
||||
virtual void fromJsonString_internal(std::string const& jsonString);
|
||||
virtual boost::property_tree::ptree toPropertyTree_internal();
|
||||
virtual void fromPropertyTree_internal(boost::property_tree::ptree const& pt);
|
||||
|
||||
|
||||
protected:
|
||||
int64_t m_Id = 0L;
|
||||
std::string m_Name = "";
|
||||
};
|
||||
|
||||
std::vector<Tag> createTagVectorFromJsonString(const std::string& json);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif /* Tag_H_ */
|
||||
192
samples/server/petstore/cpp-restbed-deprecated/model/User.cpp
Normal file
192
samples/server/petstore/cpp-restbed-deprecated/model/User.cpp
Normal file
@@ -0,0 +1,192 @@
|
||||
/**
|
||||
* OpenAPI Petstore
|
||||
* This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
|
||||
*
|
||||
* The version of the OpenAPI document: 1.0.0
|
||||
*
|
||||
*
|
||||
* NOTE: This class is auto generated by OpenAPI-Generator unset.
|
||||
* https://openapi-generator.tech
|
||||
* Do not edit the class manually.
|
||||
*/
|
||||
|
||||
|
||||
|
||||
#include "User.h"
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <sstream>
|
||||
#include <stdexcept>
|
||||
#include <boost/property_tree/ptree.hpp>
|
||||
#include <boost/property_tree/json_parser.hpp>
|
||||
|
||||
using boost::property_tree::ptree;
|
||||
using boost::property_tree::read_json;
|
||||
using boost::property_tree::write_json;
|
||||
|
||||
namespace org {
|
||||
namespace openapitools {
|
||||
namespace server {
|
||||
namespace model {
|
||||
|
||||
User::User(boost::property_tree::ptree const& pt)
|
||||
{
|
||||
fromPropertyTree(pt);
|
||||
}
|
||||
|
||||
std::string User::toJsonString(bool prettyJson /* = false */)
|
||||
{
|
||||
return toJsonString_internal(prettyJson);
|
||||
}
|
||||
|
||||
void User::fromJsonString(std::string const& jsonString)
|
||||
{
|
||||
fromJsonString_internal(jsonString);
|
||||
}
|
||||
|
||||
boost::property_tree::ptree User::toPropertyTree()
|
||||
{
|
||||
return toPropertyTree_internal();
|
||||
}
|
||||
|
||||
void User::fromPropertyTree(boost::property_tree::ptree const& pt)
|
||||
{
|
||||
fromPropertyTree_internal(pt);
|
||||
}
|
||||
|
||||
std::string User::toJsonString_internal(bool prettyJson)
|
||||
{
|
||||
std::stringstream ss;
|
||||
write_json(ss, this->toPropertyTree(), prettyJson);
|
||||
return ss.str();
|
||||
}
|
||||
|
||||
void User::fromJsonString_internal(std::string const& jsonString)
|
||||
{
|
||||
std::stringstream ss(jsonString);
|
||||
ptree pt;
|
||||
read_json(ss,pt);
|
||||
this->fromPropertyTree(pt);
|
||||
}
|
||||
|
||||
ptree User::toPropertyTree_internal()
|
||||
{
|
||||
ptree pt;
|
||||
ptree tmp_node;
|
||||
pt.put("id", m_Id);
|
||||
pt.put("username", m_Username);
|
||||
pt.put("firstName", m_FirstName);
|
||||
pt.put("lastName", m_LastName);
|
||||
pt.put("email", m_Email);
|
||||
pt.put("password", m_Password);
|
||||
pt.put("phone", m_Phone);
|
||||
pt.put("userStatus", m_UserStatus);
|
||||
return pt;
|
||||
}
|
||||
|
||||
void User::fromPropertyTree_internal(ptree const &pt)
|
||||
{
|
||||
ptree tmp_node;
|
||||
m_Id = pt.get("id", 0L);
|
||||
m_Username = pt.get("username", "");
|
||||
m_FirstName = pt.get("firstName", "");
|
||||
m_LastName = pt.get("lastName", "");
|
||||
m_Email = pt.get("email", "");
|
||||
m_Password = pt.get("password", "");
|
||||
m_Phone = pt.get("phone", "");
|
||||
m_UserStatus = pt.get("userStatus", 0);
|
||||
}
|
||||
|
||||
int64_t User::getId() const
|
||||
{
|
||||
return m_Id;
|
||||
}
|
||||
|
||||
void User::setId(int64_t value)
|
||||
{
|
||||
m_Id = value;
|
||||
}
|
||||
std::string User::getUsername() const
|
||||
{
|
||||
return m_Username;
|
||||
}
|
||||
|
||||
void User::setUsername(std::string value)
|
||||
{
|
||||
m_Username = value;
|
||||
}
|
||||
std::string User::getFirstName() const
|
||||
{
|
||||
return m_FirstName;
|
||||
}
|
||||
|
||||
void User::setFirstName(std::string value)
|
||||
{
|
||||
m_FirstName = value;
|
||||
}
|
||||
std::string User::getLastName() const
|
||||
{
|
||||
return m_LastName;
|
||||
}
|
||||
|
||||
void User::setLastName(std::string value)
|
||||
{
|
||||
m_LastName = value;
|
||||
}
|
||||
std::string User::getEmail() const
|
||||
{
|
||||
return m_Email;
|
||||
}
|
||||
|
||||
void User::setEmail(std::string value)
|
||||
{
|
||||
m_Email = value;
|
||||
}
|
||||
std::string User::getPassword() const
|
||||
{
|
||||
return m_Password;
|
||||
}
|
||||
|
||||
void User::setPassword(std::string value)
|
||||
{
|
||||
m_Password = value;
|
||||
}
|
||||
std::string User::getPhone() const
|
||||
{
|
||||
return m_Phone;
|
||||
}
|
||||
|
||||
void User::setPhone(std::string value)
|
||||
{
|
||||
m_Phone = value;
|
||||
}
|
||||
int32_t User::getUserStatus() const
|
||||
{
|
||||
return m_UserStatus;
|
||||
}
|
||||
|
||||
void User::setUserStatus(int32_t value)
|
||||
{
|
||||
m_UserStatus = value;
|
||||
}
|
||||
|
||||
std::vector<User> createUserVectorFromJsonString(const std::string& json)
|
||||
{
|
||||
std::stringstream sstream(json);
|
||||
boost::property_tree::ptree pt;
|
||||
boost::property_tree::json_parser::read_json(sstream,pt);
|
||||
|
||||
auto vec = std::vector<User>();
|
||||
for (const auto& child: pt) {
|
||||
vec.emplace_back(User(child.second));
|
||||
}
|
||||
|
||||
return vec;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
129
samples/server/petstore/cpp-restbed-deprecated/model/User.h
Normal file
129
samples/server/petstore/cpp-restbed-deprecated/model/User.h
Normal file
@@ -0,0 +1,129 @@
|
||||
/**
|
||||
* OpenAPI Petstore
|
||||
* This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
|
||||
*
|
||||
* The version of the OpenAPI document: 1.0.0
|
||||
*
|
||||
*
|
||||
* NOTE: This class is auto generated by OpenAPI-Generator unset.
|
||||
* https://openapi-generator.tech
|
||||
* Do not edit the class manually.
|
||||
*/
|
||||
|
||||
/*
|
||||
* User.h
|
||||
*
|
||||
* A User who is purchasing from the pet store
|
||||
*/
|
||||
|
||||
#ifndef User_H_
|
||||
#define User_H_
|
||||
|
||||
|
||||
|
||||
#include <string>
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
#include <boost/property_tree/ptree.hpp>
|
||||
|
||||
namespace org {
|
||||
namespace openapitools {
|
||||
namespace server {
|
||||
namespace model {
|
||||
|
||||
/// <summary>
|
||||
/// A User who is purchasing from the pet store
|
||||
/// </summary>
|
||||
class User
|
||||
{
|
||||
public:
|
||||
User() = default;
|
||||
explicit User(boost::property_tree::ptree const& pt);
|
||||
virtual ~User() = default;
|
||||
|
||||
std::string toJsonString(bool prettyJson = false);
|
||||
void fromJsonString(std::string const& jsonString);
|
||||
boost::property_tree::ptree toPropertyTree();
|
||||
void fromPropertyTree(boost::property_tree::ptree const& pt);
|
||||
|
||||
/////////////////////////////////////////////
|
||||
/// User members
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
int64_t getId() const;
|
||||
void setId(int64_t value);
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
std::string getUsername() const;
|
||||
void setUsername(std::string value);
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
std::string getFirstName() const;
|
||||
void setFirstName(std::string value);
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
std::string getLastName() const;
|
||||
void setLastName(std::string value);
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
std::string getEmail() const;
|
||||
void setEmail(std::string value);
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
std::string getPassword() const;
|
||||
void setPassword(std::string value);
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
std::string getPhone() const;
|
||||
void setPhone(std::string value);
|
||||
|
||||
/// <summary>
|
||||
/// User Status
|
||||
/// </summary>
|
||||
int32_t getUserStatus() const;
|
||||
void setUserStatus(int32_t value);
|
||||
|
||||
protected:
|
||||
//////////////////////////////////////
|
||||
// Override these for customization //
|
||||
//////////////////////////////////////
|
||||
|
||||
virtual std::string toJsonString_internal(bool prettyJson = false);
|
||||
virtual void fromJsonString_internal(std::string const& jsonString);
|
||||
virtual boost::property_tree::ptree toPropertyTree_internal();
|
||||
virtual void fromPropertyTree_internal(boost::property_tree::ptree const& pt);
|
||||
|
||||
|
||||
protected:
|
||||
int64_t m_Id = 0L;
|
||||
std::string m_Username = "";
|
||||
std::string m_FirstName = "";
|
||||
std::string m_LastName = "";
|
||||
std::string m_Email = "";
|
||||
std::string m_Password = "";
|
||||
std::string m_Phone = "";
|
||||
int32_t m_UserStatus = 0;
|
||||
};
|
||||
|
||||
std::vector<User> createUserVectorFromJsonString(const std::string& json);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif /* User_H_ */
|
||||
Reference in New Issue
Block a user