mirror of
https://github.com/OpenAPITools/openapi-generator.git
synced 2025-12-18 23:57:06 +00:00
Merge remote-tracking branch 'origin/6.3.x' into 7.0.x
This commit is contained in:
33
samples/server/petstore/cpp-restbed/.gitignore
vendored
33
samples/server/petstore/cpp-restbed/.gitignore
vendored
@@ -1,29 +1,4 @@
|
||||
# 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
|
||||
build/
|
||||
.idea/
|
||||
cmake-build-*/
|
||||
*.received.txt
|
||||
|
||||
@@ -1,21 +0,0 @@
|
||||
.gitignore
|
||||
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
|
||||
@@ -1 +0,0 @@
|
||||
unset
|
||||
33
samples/server/petstore/cpp-restbed/CMakeLists.txt
Normal file
33
samples/server/petstore/cpp-restbed/CMakeLists.txt
Normal file
@@ -0,0 +1,33 @@
|
||||
cmake_policy(SET CMP0048 NEW)
|
||||
|
||||
project(cpp-restped-server-open-api VERSION 1)
|
||||
cmake_minimum_required(VERSION 3.16)
|
||||
|
||||
set(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake ${CMAKE_MODULE_PATH})
|
||||
message(${CMAKE_MODULE_PATH})
|
||||
|
||||
include(dependencies)
|
||||
include(JavaClientTests)
|
||||
|
||||
|
||||
set(CMAKE_CXX_STANDARD 14)
|
||||
|
||||
# Coverage
|
||||
if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fprofile-instr-generate -fcoverage-mapping")
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fprofile-instr-generate -fcoverage-mapping")
|
||||
message("Using clang coverage")
|
||||
elseif (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} --coverage")
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} --coverage")
|
||||
endif()
|
||||
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall")
|
||||
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pthread")
|
||||
set(CMAKE_EXE_LINKER_FLAGS ${CMAKE_EXE_LINKER_FLAGS} -lpthread)
|
||||
|
||||
enable_testing()
|
||||
|
||||
add_subdirectory(generated/3_0)
|
||||
add_subdirectory(test)
|
||||
@@ -1,23 +0,0 @@
|
||||
# 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
|
||||
@@ -1,803 +0,0 @@
|
||||
/**
|
||||
* 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 body = extractJsonModelBodyParam<Pet>(bodyContent);
|
||||
|
||||
|
||||
|
||||
|
||||
int status_code = 500;
|
||||
std::string result = "";
|
||||
|
||||
try {
|
||||
status_code =
|
||||
handler_POST(body);
|
||||
}
|
||||
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);
|
||||
}
|
||||
|
||||
// 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 body = extractJsonModelBodyParam<Pet>(bodyContent);
|
||||
|
||||
|
||||
int status_code = 500;
|
||||
std::string result = "";
|
||||
|
||||
try {
|
||||
status_code =
|
||||
handler_PUT(body);
|
||||
}
|
||||
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 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);
|
||||
}
|
||||
|
||||
int PetApiPetResource::handler_POST(
|
||||
std::shared_ptr<Pet> const & body)
|
||||
{
|
||||
throw PetApiException(501, "Not implemented");
|
||||
}
|
||||
|
||||
int PetApiPetResource::handler_PUT(
|
||||
std::shared_ptr<Pet> const & body)
|
||||
{
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,370 +0,0 @@
|
||||
/**
|
||||
* 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 int handler_POST(
|
||||
std::shared_ptr<Pet> const & body);
|
||||
|
||||
virtual int handler_PUT(
|
||||
std::shared_ptr<Pet> const & body);
|
||||
|
||||
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_ */
|
||||
|
||||
@@ -1,496 +0,0 @@
|
||||
/**
|
||||
* 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 = 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 body = 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(body);
|
||||
}
|
||||
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 & body)
|
||||
{
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,250 +0,0 @@
|
||||
/**
|
||||
* 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 & body);
|
||||
|
||||
|
||||
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_ */
|
||||
|
||||
@@ -1,868 +0,0 @@
|
||||
/**
|
||||
* 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 body = extractJsonModelBodyParam<User>(bodyContent);
|
||||
|
||||
|
||||
|
||||
|
||||
int status_code = 500;
|
||||
std::string result = "";
|
||||
|
||||
try {
|
||||
status_code =
|
||||
handler_POST(body);
|
||||
}
|
||||
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 & body)
|
||||
{
|
||||
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 body = extractJsonArrayBodyParam<User>(bodyContent);
|
||||
|
||||
|
||||
|
||||
|
||||
int status_code = 500;
|
||||
std::string result = "";
|
||||
|
||||
try {
|
||||
status_code =
|
||||
handler_POST(body);
|
||||
}
|
||||
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 & body)
|
||||
{
|
||||
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 body = extractJsonArrayBodyParam<User>(bodyContent);
|
||||
|
||||
|
||||
|
||||
|
||||
int status_code = 500;
|
||||
std::string result = "";
|
||||
|
||||
try {
|
||||
status_code =
|
||||
handler_POST(body);
|
||||
}
|
||||
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 & body)
|
||||
{
|
||||
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 body = 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, body);
|
||||
}
|
||||
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 & body)
|
||||
{
|
||||
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: calls per hour allowed by the user
|
||||
setResponseHeader(session, "X-Rate-Limit");
|
||||
// Description: date in UTC when toekn 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;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,417 +0,0 @@
|
||||
/**
|
||||
* 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 & body);
|
||||
|
||||
|
||||
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 & body);
|
||||
|
||||
|
||||
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 & body);
|
||||
|
||||
|
||||
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 & body);
|
||||
|
||||
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_ */
|
||||
|
||||
21
samples/server/petstore/cpp-restbed/build_and_test.sh
Executable file
21
samples/server/petstore/cpp-restbed/build_and_test.sh
Executable file
@@ -0,0 +1,21 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
set -u
|
||||
set -e
|
||||
|
||||
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
|
||||
|
||||
cd ${SCRIPT_DIR}
|
||||
|
||||
rm -rf build
|
||||
|
||||
cmake -S . -B build
|
||||
cd build
|
||||
make
|
||||
|
||||
# pure C++ tests
|
||||
make test -j4
|
||||
|
||||
# tests with Java client
|
||||
# run them during development
|
||||
#make run_all_java_client_test_for_cpp_server
|
||||
@@ -0,0 +1,35 @@
|
||||
|
||||
add_custom_target(run_all_java_client_test_for_cpp_server)
|
||||
|
||||
define_property(GLOBAL
|
||||
PROPERTY LAST_JAVA_CLIENT_TEST
|
||||
BRIEF_DOCS Used to order the tests to run after each other
|
||||
FULL_DOCS The tests are ordered by defining a dependency chain)
|
||||
set_property(GLOBAL
|
||||
PROPERTY LAST_JAVA_CLIENT_TEST run_all_java_client_test_for_cpp_server)
|
||||
|
||||
set(RUN_CLIENT_TESTS_SHELL_TEMPLATE "run_java_client_tests_template.txt")
|
||||
|
||||
function(run_java_client_test_for_cpp_server TARGET_NAME)
|
||||
set(TEST_SERVER_EXECUTABLE "${CMAKE_CURRENT_BINARY_DIR}/${TARGET_NAME}")
|
||||
|
||||
set(RUN_TESTS_TARGET run_${TARGET_NAME}_test)
|
||||
configure_file(${CMAKE_SOURCE_DIR}/cmake/${RUN_CLIENT_TESTS_SHELL_TEMPLATE}
|
||||
${CMAKE_CURRENT_BINARY_DIR}/${RUN_TESTS_TARGET}.sh
|
||||
@ONLY)
|
||||
|
||||
add_custom_target(${RUN_TESTS_TARGET}
|
||||
COMMAND ${CMAKE_CURRENT_BINARY_DIR}/${RUN_TESTS_TARGET}.sh
|
||||
DEPENDS ${TARGET_NAME}
|
||||
USES_TERMINAL
|
||||
COMMENT "Running tests: ${TARGET_NAME}")
|
||||
|
||||
get_property(LAST_TEST
|
||||
GLOBAL
|
||||
PROPERTY LAST_JAVA_CLIENT_TEST)
|
||||
add_dependencies(run_all_java_client_test_for_cpp_server ${RUN_TESTS_TARGET})
|
||||
add_dependencies(${LAST_TEST} ${RUN_TESTS_TARGET})
|
||||
set_property(GLOBAL
|
||||
PROPERTY LAST_JAVA_CLIENT_TEST ${RUN_TESTS_TARGET})
|
||||
|
||||
endfunction()
|
||||
25
samples/server/petstore/cpp-restbed/cmake/dependencies.cmake
Normal file
25
samples/server/petstore/cpp-restbed/cmake/dependencies.cmake
Normal file
@@ -0,0 +1,25 @@
|
||||
|
||||
|
||||
include(FetchContent)
|
||||
|
||||
## Restbed
|
||||
FetchContent_Declare(
|
||||
restbed
|
||||
GIT_REPOSITORY https://github.com/Corvusoft/restbed
|
||||
GIT_TAG 4.7
|
||||
)
|
||||
|
||||
set(BUILD_TESTS OFF CACHE BOOL "Disable internal restbed tests")
|
||||
set(BUILD_SSL OFF CACHE BOOL "Disable SSL")
|
||||
FetchContent_MakeAvailable(restbed)
|
||||
|
||||
FetchContent_GetProperties(restbed)
|
||||
if(NOT restbed_POPULATED)
|
||||
|
||||
FetchContent_Populate(restbed)
|
||||
add_subdirectory(${restbed_SOURCE_DIR} ${restbed_BINARY_DIR})
|
||||
endif()
|
||||
|
||||
|
||||
## Boost
|
||||
find_package(Boost 1.7.0 COMPONENTS system unit_test_framework REQUIRED)
|
||||
28
samples/server/petstore/cpp-restbed/cmake/run_java_client_tests_template.txt
Executable file
28
samples/server/petstore/cpp-restbed/cmake/run_java_client_tests_template.txt
Executable file
@@ -0,0 +1,28 @@
|
||||
#!/bin/bash
|
||||
set -u
|
||||
set -e
|
||||
#set -x
|
||||
|
||||
SCRIPTPATH="$( cd -- "$(dirname "$0")" >/dev/null 2>&1 ; pwd -P )"
|
||||
echo "Running ${SCRIPTPATH}"
|
||||
|
||||
echo Running @TEST_SERVER_EXECUTABLE@
|
||||
@TEST_SERVER_EXECUTABLE@ &
|
||||
pid=$!
|
||||
|
||||
|
||||
function kill_test_server()
|
||||
{
|
||||
kill -9 $pid
|
||||
}
|
||||
|
||||
trap kill_test_server EXIT
|
||||
|
||||
echo Running Java client tests
|
||||
cd "@CMAKE_CURRENT_LIST_DIR@/../../java_client"
|
||||
./gradlew --no-daemon clean test --tests "test_@TARGET_NAME@.*" -i
|
||||
|
||||
set +e
|
||||
kill $pid
|
||||
|
||||
echo Done running @TEST_SERVER_EXECUTABLE@
|
||||
29
samples/server/petstore/cpp-restbed/generated/3_0/.gitignore
vendored
Normal file
29
samples/server/petstore/cpp-restbed/generated/3_0/.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,116 @@
|
||||
.gitignore
|
||||
CMakeLists.txt
|
||||
FindRestbedAndBoost.cmake
|
||||
README.md
|
||||
api/AnotherFakeApi.cpp
|
||||
api/AnotherFakeApi.h
|
||||
api/DefaultApi.cpp
|
||||
api/DefaultApi.h
|
||||
api/FakeApi.cpp
|
||||
api/FakeApi.h
|
||||
api/FakeClassnameTags123Api.cpp
|
||||
api/FakeClassnameTags123Api.h
|
||||
api/PetApi.cpp
|
||||
api/PetApi.h
|
||||
api/StoreApi.cpp
|
||||
api/StoreApi.h
|
||||
api/UserApi.cpp
|
||||
api/UserApi.h
|
||||
git_push.sh
|
||||
model/AdditionalPropertiesClass.cpp
|
||||
model/AdditionalPropertiesClass.h
|
||||
model/AllOfWithSingleRef.cpp
|
||||
model/AllOfWithSingleRef.h
|
||||
model/Animal.cpp
|
||||
model/Animal.h
|
||||
model/ApiResponse.cpp
|
||||
model/ApiResponse.h
|
||||
model/ArrayOfArrayOfNumberOnly.cpp
|
||||
model/ArrayOfArrayOfNumberOnly.h
|
||||
model/ArrayOfNumberOnly.cpp
|
||||
model/ArrayOfNumberOnly.h
|
||||
model/ArrayTest.cpp
|
||||
model/ArrayTest.h
|
||||
model/Capitalization.cpp
|
||||
model/Capitalization.h
|
||||
model/Cat.cpp
|
||||
model/Cat.h
|
||||
model/Cat_allOf.cpp
|
||||
model/Cat_allOf.h
|
||||
model/Category.cpp
|
||||
model/Category.h
|
||||
model/ClassModel.cpp
|
||||
model/ClassModel.h
|
||||
model/Client.cpp
|
||||
model/Client.h
|
||||
model/DeprecatedObject.cpp
|
||||
model/DeprecatedObject.h
|
||||
model/Dog.cpp
|
||||
model/Dog.h
|
||||
model/Dog_allOf.cpp
|
||||
model/Dog_allOf.h
|
||||
model/EnumArrays.cpp
|
||||
model/EnumArrays.h
|
||||
model/EnumClass.cpp
|
||||
model/EnumClass.h
|
||||
model/Enum_Test.cpp
|
||||
model/Enum_Test.h
|
||||
model/File.cpp
|
||||
model/File.h
|
||||
model/FileSchemaTestClass.cpp
|
||||
model/FileSchemaTestClass.h
|
||||
model/Foo.cpp
|
||||
model/Foo.h
|
||||
model/Format_test.cpp
|
||||
model/Format_test.h
|
||||
model/HasOnlyReadOnly.cpp
|
||||
model/HasOnlyReadOnly.h
|
||||
model/HealthCheckResult.cpp
|
||||
model/HealthCheckResult.h
|
||||
model/List.cpp
|
||||
model/List.h
|
||||
model/MapTest.cpp
|
||||
model/MapTest.h
|
||||
model/MixedPropertiesAndAdditionalPropertiesClass.cpp
|
||||
model/MixedPropertiesAndAdditionalPropertiesClass.h
|
||||
model/Name.cpp
|
||||
model/Name.h
|
||||
model/NullableClass.cpp
|
||||
model/NullableClass.h
|
||||
model/NumberOnly.cpp
|
||||
model/NumberOnly.h
|
||||
model/ObjectWithDeprecatedFields.cpp
|
||||
model/ObjectWithDeprecatedFields.h
|
||||
model/Order.cpp
|
||||
model/Order.h
|
||||
model/OuterComposite.cpp
|
||||
model/OuterComposite.h
|
||||
model/OuterEnum.cpp
|
||||
model/OuterEnum.h
|
||||
model/OuterEnumDefaultValue.cpp
|
||||
model/OuterEnumDefaultValue.h
|
||||
model/OuterEnumInteger.cpp
|
||||
model/OuterEnumInteger.h
|
||||
model/OuterEnumIntegerDefaultValue.cpp
|
||||
model/OuterEnumIntegerDefaultValue.h
|
||||
model/OuterObjectWithEnumProperty.cpp
|
||||
model/OuterObjectWithEnumProperty.h
|
||||
model/Pet.cpp
|
||||
model/Pet.h
|
||||
model/ReadOnlyFirst.cpp
|
||||
model/ReadOnlyFirst.h
|
||||
model/Return.cpp
|
||||
model/Return.h
|
||||
model/SingleRefType.cpp
|
||||
model/SingleRefType.h
|
||||
model/Tag.cpp
|
||||
model/Tag.h
|
||||
model/User.cpp
|
||||
model/User.h
|
||||
model/_foo_get_default_response.cpp
|
||||
model/_foo_get_default_response.h
|
||||
model/_special_model_name_.cpp
|
||||
model/_special_model_name_.h
|
||||
model/helpers.h
|
||||
model/r_200_response.cpp
|
||||
model/r_200_response.h
|
||||
@@ -0,0 +1 @@
|
||||
7.0.0-SNAPSHOT
|
||||
@@ -0,0 +1,34 @@
|
||||
set(TARGET_NAME org.openapitools.server.apiStubs)
|
||||
|
||||
# Get generated filenames
|
||||
file(STRINGS "${CMAKE_CURRENT_LIST_DIR}/.openapi-generator/FILES" GENERATED_SOURCES)
|
||||
list(FILTER GENERATED_SOURCES INCLUDE REGEX ".*cpp$")
|
||||
|
||||
set(GENERATED_SOURCES_INCLUDE_DIRS
|
||||
${CMAKE_CURRENT_LIST_DIR}/model
|
||||
${CMAKE_CURRENT_LIST_DIR}/api
|
||||
${CMAKE_CURRENT_LIST_DIR}
|
||||
)
|
||||
|
||||
|
||||
add_library(${TARGET_NAME} SHARED)
|
||||
|
||||
target_sources(${TARGET_NAME}
|
||||
PRIVATE
|
||||
${GENERATED_SOURCES})
|
||||
|
||||
target_include_directories(${TARGET_NAME}
|
||||
PUBLIC
|
||||
${GENERATED_SOURCES_INCLUDE_DIRS}
|
||||
)
|
||||
|
||||
|
||||
target_include_directories(${TARGET_NAME}
|
||||
SYSTEM PUBLIC
|
||||
${restbed_SOURCE_DIR}/source)
|
||||
|
||||
target_link_libraries(${TARGET_NAME}
|
||||
PUBLIC
|
||||
Boost::system
|
||||
restbed-shared
|
||||
-lpthread)
|
||||
@@ -0,0 +1,22 @@
|
||||
|
||||
include(FetchContent)
|
||||
|
||||
## Restbed
|
||||
FetchContent_Declare(
|
||||
restbed
|
||||
GIT_REPOSITORY https://github.com/Corvusoft/restbed
|
||||
GIT_TAG 4.7
|
||||
)
|
||||
|
||||
FetchContent_MakeAvailable(restbed)
|
||||
|
||||
FetchContent_GetProperties(restbed)
|
||||
if(NOT restbed_POPULATED)
|
||||
|
||||
FetchContent_Populate(restbed)
|
||||
add_subdirectory(${restbed_SOURCE_DIR} ${restbed_BINARY_DIR})
|
||||
endif()
|
||||
|
||||
|
||||
## Boost
|
||||
find_package(Boost 1.7.0 COMPONENTS system REQUIRED)
|
||||
70
samples/server/petstore/cpp-restbed/generated/3_0/README.md
Normal file
70
samples/server/petstore/cpp-restbed/generated/3_0/README.md
Normal file
@@ -0,0 +1,70 @@
|
||||
# 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
|
||||
|
||||
|
||||
## Example
|
||||
|
||||
The handler functionality can be implemented in two different ways.
|
||||
Either inherit the given resource and override the handler methods.
|
||||
Or set a handler lambda to a resource.
|
||||
|
||||
This example shows how this can be done with the pet store API.
|
||||
|
||||
```
|
||||
#include "api/StoreApi.h"
|
||||
#include "api/UserApi.h"
|
||||
|
||||
using namespace org::openapitools::server::api;
|
||||
using namespace org::openapitools::server::api::StoreApiResources;
|
||||
using namespace org::openapitools::server::api::UserApiResources;
|
||||
|
||||
/* 1. variant: inherit from the resource and override handler method */
|
||||
class MyStoreApiStoreOrderResource : public StoreOrderResource {
|
||||
public:
|
||||
std::pair<int, Order>
|
||||
handler_POST(Order &order) override {
|
||||
auto ret = Order();
|
||||
/* ... add your implementation here .... */
|
||||
return std::make_pair(200, ret);
|
||||
}
|
||||
};
|
||||
|
||||
int main() {
|
||||
const auto service = std::make_shared<restbed::Service>();
|
||||
|
||||
auto storeApi = StoreApi(service);
|
||||
storeApi.setResource(std::make_shared<MyStoreApiStoreOrderResource>());
|
||||
|
||||
auto userApi = UserApi(service);
|
||||
/* 2. variant: implement handler as lambda */
|
||||
userApi.getUserResource()->handler_POST_func = [](auto& user) {
|
||||
/* ... add your implementation here .... */
|
||||
return 200;};
|
||||
|
||||
const auto settings = std::make_shared<restbed::Settings>();
|
||||
settings->set_port(1236);
|
||||
|
||||
service->start(settings);
|
||||
}
|
||||
```
|
||||
@@ -0,0 +1,273 @@
|
||||
/**
|
||||
* OpenAPI Petstore
|
||||
* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
|
||||
*
|
||||
* The version of the OpenAPI document: 1.0.0
|
||||
*
|
||||
*
|
||||
* NOTE: This class is auto generated by OpenAPI-Generator 7.0.0-SNAPSHOT.
|
||||
* 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 "AnotherFakeApi.h"
|
||||
|
||||
namespace org {
|
||||
namespace openapitools {
|
||||
namespace server {
|
||||
namespace api {
|
||||
|
||||
using namespace org::openapitools::server::model;
|
||||
|
||||
namespace {
|
||||
[[maybe_unused]]
|
||||
std::string selectPreferredContentType(const std::vector<std::string>& contentTypes) {
|
||||
if (contentTypes.size() == 0) {
|
||||
return "application/json";
|
||||
}
|
||||
|
||||
if (contentTypes.size() == 1) {
|
||||
return contentTypes.at(0);
|
||||
}
|
||||
|
||||
static const std::array<std::string, 2> preferredTypes = {"json", "xml"};
|
||||
for (const auto& preferredType: preferredTypes) {
|
||||
const auto ret = std::find_if(contentTypes.cbegin(),
|
||||
contentTypes.cend(),
|
||||
[preferredType](const std::string& str) {
|
||||
return str.find(preferredType) != std::string::npos;});
|
||||
if (ret != contentTypes.cend()) {
|
||||
return *ret;
|
||||
}
|
||||
}
|
||||
|
||||
return contentTypes.at(0);
|
||||
}
|
||||
}
|
||||
|
||||
AnotherFakeApiException::AnotherFakeApiException(int status_code, std::string what)
|
||||
: m_status(status_code),
|
||||
m_what(what)
|
||||
{
|
||||
|
||||
}
|
||||
int AnotherFakeApiException::getStatus() const
|
||||
{
|
||||
return m_status;
|
||||
}
|
||||
const char* AnotherFakeApiException::what() const noexcept
|
||||
{
|
||||
return m_what.c_str();
|
||||
}
|
||||
|
||||
|
||||
template<class MODEL_T>
|
||||
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 = MODEL_T(pt);
|
||||
return model;
|
||||
}
|
||||
|
||||
template<class MODEL_T>
|
||||
std::vector<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<MODEL_T>();
|
||||
for (const auto& child: pt) {
|
||||
arrayRet.emplace_back(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;
|
||||
}
|
||||
|
||||
namespace AnotherFakeApiResources {
|
||||
Another_fakeDummyResource::Another_fakeDummyResource(const std::string& context /* = "/v2" */)
|
||||
{
|
||||
this->set_path(context + "/another-fake/dummy");
|
||||
this->set_method_handler("PATCH",
|
||||
std::bind(&Another_fakeDummyResource::handler_PATCH_internal, this,
|
||||
std::placeholders::_1));
|
||||
}
|
||||
|
||||
std::pair<int, std::string> Another_fakeDummyResource::handleAnotherFakeApiException(const AnotherFakeApiException& e)
|
||||
{
|
||||
return std::make_pair<int, std::string>(e.getStatus(), e.what());
|
||||
}
|
||||
|
||||
std::pair<int, std::string> Another_fakeDummyResource::handleStdException(const std::exception& e)
|
||||
{
|
||||
return std::make_pair<int, std::string>(500, e.what());
|
||||
}
|
||||
|
||||
std::pair<int, std::string> Another_fakeDummyResource::handleUnspecifiedException()
|
||||
{
|
||||
return std::make_pair<int, std::string>(500, "Unknown exception occurred");
|
||||
}
|
||||
|
||||
void Another_fakeDummyResource::setResponseHeader(const std::shared_ptr<restbed::Session>& session, const std::string& header)
|
||||
{
|
||||
session->set_header(header, "");
|
||||
}
|
||||
|
||||
void Another_fakeDummyResource::returnResponse(const std::shared_ptr<restbed::Session>& session, const int status, const std::string& result, std::multimap<std::string, std::string>& responseHeaders)
|
||||
{
|
||||
responseHeaders.insert(std::make_pair("Connection", "close"));
|
||||
session->close(status, result, responseHeaders);
|
||||
}
|
||||
|
||||
void Another_fakeDummyResource::defaultSessionClose(const std::shared_ptr<restbed::Session>& session, const int status, const std::string& result)
|
||||
{
|
||||
session->close(status, result, { {"Connection", "close"} });
|
||||
}
|
||||
|
||||
void Another_fakeDummyResource::handler_PATCH_internal(const std::shared_ptr<restbed::Session> session)
|
||||
{
|
||||
const auto request = session->get_request();
|
||||
// body params or form params here from the body content string
|
||||
std::string bodyContent = extractBodyContent(session);
|
||||
auto client = extractJsonModelBodyParam<Client>(bodyContent);
|
||||
|
||||
int status_code = 500;
|
||||
Client resultObject = Client{};
|
||||
std::string result = "";
|
||||
|
||||
try {
|
||||
std::tie(status_code, resultObject) =
|
||||
handler_PATCH(client);
|
||||
}
|
||||
catch(const AnotherFakeApiException& e) {
|
||||
std::tie(status_code, result) = handleAnotherFakeApiException(e);
|
||||
}
|
||||
catch(const std::exception& e) {
|
||||
std::tie(status_code, result) = handleStdException(e);
|
||||
}
|
||||
catch(...) {
|
||||
std::tie(status_code, result) = handleUnspecifiedException();
|
||||
}
|
||||
|
||||
std::multimap< std::string, std::string > responseHeaders {};
|
||||
static const std::vector<std::string> contentTypes{
|
||||
"application/json",
|
||||
};
|
||||
static const std::string acceptTypes{
|
||||
"application/json, "
|
||||
};
|
||||
|
||||
if (status_code == 200) {
|
||||
responseHeaders.insert(std::make_pair("Content-Type", selectPreferredContentType(contentTypes)));
|
||||
if (!acceptTypes.empty()) {
|
||||
responseHeaders.insert(std::make_pair("Accept", acceptTypes));
|
||||
}
|
||||
|
||||
result = resultObject.toJsonString();
|
||||
returnResponse(session, 200, result.empty() ? "{}" : result, responseHeaders);
|
||||
return;
|
||||
}
|
||||
defaultSessionClose(session, status_code, result);
|
||||
}
|
||||
|
||||
|
||||
std::pair<int, Client> Another_fakeDummyResource::handler_PATCH(
|
||||
Client & client)
|
||||
{
|
||||
return handler_PATCH_func(client);
|
||||
}
|
||||
|
||||
|
||||
std::string Another_fakeDummyResource::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;
|
||||
}
|
||||
|
||||
std::string Another_fakeDummyResource::extractFormParamsFromBody(const std::string& paramName, const std::string& body) {
|
||||
const auto uri = restbed::Uri("urlencoded?" + body, true);
|
||||
const auto params = uri.get_query_parameters();
|
||||
const auto result = params.find(paramName);
|
||||
if (result != params.cend()) {
|
||||
return result->second;
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
} /* namespace AnotherFakeApiResources */
|
||||
|
||||
AnotherFakeApi::AnotherFakeApi(std::shared_ptr<restbed::Service> const& restbedService)
|
||||
: m_service(restbedService)
|
||||
{
|
||||
}
|
||||
|
||||
AnotherFakeApi::~AnotherFakeApi() {}
|
||||
|
||||
std::shared_ptr<AnotherFakeApiResources::Another_fakeDummyResource> AnotherFakeApi::getAnother_fakeDummyResource() {
|
||||
if (!m_spAnother_fakeDummyResource) {
|
||||
setResource(std::make_shared<AnotherFakeApiResources::Another_fakeDummyResource>());
|
||||
}
|
||||
return m_spAnother_fakeDummyResource;
|
||||
}
|
||||
void AnotherFakeApi::setResource(std::shared_ptr<AnotherFakeApiResources::Another_fakeDummyResource> resource) {
|
||||
m_spAnother_fakeDummyResource = resource;
|
||||
m_service->publish(m_spAnother_fakeDummyResource);
|
||||
}
|
||||
void AnotherFakeApi::setAnotherFakeApiAnother_fakeDummyResource(std::shared_ptr<AnotherFakeApiResources::Another_fakeDummyResource> spAnother_fakeDummyResource) {
|
||||
m_spAnother_fakeDummyResource = spAnother_fakeDummyResource;
|
||||
m_service->publish(m_spAnother_fakeDummyResource);
|
||||
}
|
||||
|
||||
|
||||
void AnotherFakeApi::publishDefaultResources() {
|
||||
if (!m_spAnother_fakeDummyResource) {
|
||||
setResource(std::make_shared<AnotherFakeApiResources::Another_fakeDummyResource>());
|
||||
}
|
||||
}
|
||||
|
||||
std::shared_ptr<restbed::Service> AnotherFakeApi::service() {
|
||||
return m_service;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,159 @@
|
||||
/**
|
||||
* OpenAPI Petstore
|
||||
* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
|
||||
*
|
||||
* The version of the OpenAPI document: 1.0.0
|
||||
*
|
||||
*
|
||||
* NOTE: This class is auto generated by OpenAPI-Generator 7.0.0-SNAPSHOT.
|
||||
* https://openapi-generator.tech
|
||||
* Do not edit the class manually.
|
||||
*/
|
||||
|
||||
/*
|
||||
* AnotherFakeApi.h
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef AnotherFakeApi_H_
|
||||
#define AnotherFakeApi_H_
|
||||
|
||||
|
||||
#include <memory>
|
||||
#include <utility>
|
||||
#include <exception>
|
||||
#include <functional>
|
||||
|
||||
#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 "Client.h"
|
||||
|
||||
namespace org {
|
||||
namespace openapitools {
|
||||
namespace server {
|
||||
namespace api {
|
||||
|
||||
using namespace org::openapitools::server::model;
|
||||
|
||||
///
|
||||
/// Exception to flag problems in the handlers
|
||||
///
|
||||
class AnotherFakeApiException: public std::exception
|
||||
{
|
||||
public:
|
||||
AnotherFakeApiException(int status_code, std::string what);
|
||||
|
||||
int getStatus() const;
|
||||
const char* what() const noexcept override;
|
||||
|
||||
private:
|
||||
int m_status;
|
||||
std::string m_what;
|
||||
};
|
||||
|
||||
namespace AnotherFakeApiResources {
|
||||
/// <summary>
|
||||
/// To test special tags
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// To test special tags and operation ID starting with number
|
||||
/// </remarks>
|
||||
class Another_fakeDummyResource: public restbed::Resource
|
||||
{
|
||||
public:
|
||||
Another_fakeDummyResource(const std::string& context = "/v2");
|
||||
virtual ~Another_fakeDummyResource() = default;
|
||||
|
||||
Another_fakeDummyResource(
|
||||
const Another_fakeDummyResource& other) = default; // copy constructor
|
||||
Another_fakeDummyResource(Another_fakeDummyResource&& other) noexcept = default; // move constructor
|
||||
|
||||
Another_fakeDummyResource& operator=(const Another_fakeDummyResource& other) = default; // copy assignment
|
||||
Another_fakeDummyResource& operator=(Another_fakeDummyResource&& other) noexcept = default; // move assignment
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
// Set these to implement the server functionality //
|
||||
/////////////////////////////////////////////////////
|
||||
std::function<std::pair<int, Client>(
|
||||
Client & client)> handler_PATCH_func =
|
||||
[](Client &) -> std::pair<int, Client>
|
||||
{ throw AnotherFakeApiException(501, "Not implemented"); };
|
||||
|
||||
|
||||
protected:
|
||||
//////////////////////////////////////////////////////////
|
||||
// As an alternative to setting the `std::function`s //
|
||||
// override these to implement the server functionality //
|
||||
//////////////////////////////////////////////////////////
|
||||
|
||||
virtual std::pair<int, Client> handler_PATCH(
|
||||
Client & client);
|
||||
|
||||
|
||||
protected:
|
||||
//////////////////////////////////////
|
||||
// Override these for customization //
|
||||
//////////////////////////////////////
|
||||
|
||||
virtual std::string extractBodyContent(const std::shared_ptr<restbed::Session>& session);
|
||||
virtual std::string extractFormParamsFromBody(const std::string& paramName, const std::string& body);
|
||||
|
||||
virtual std::pair<int, std::string> handleAnotherFakeApiException(const AnotherFakeApiException& 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, std::multimap<std::string, std::string>& contentType);
|
||||
virtual void defaultSessionClose(const std::shared_ptr<restbed::Session>& session,
|
||||
const int status, const std::string& result);
|
||||
|
||||
private:
|
||||
void handler_PATCH_internal(const std::shared_ptr<restbed::Session> session);
|
||||
};
|
||||
|
||||
} /* namespace AnotherFakeApiResources */
|
||||
|
||||
using AnotherFakeApiAnother_fakeDummyResource [[deprecated]] = AnotherFakeApiResources::Another_fakeDummyResource;
|
||||
|
||||
//
|
||||
// The restbed service to actually implement the REST server
|
||||
//
|
||||
class AnotherFakeApi
|
||||
{
|
||||
public:
|
||||
explicit AnotherFakeApi(std::shared_ptr<restbed::Service> const& restbedService);
|
||||
virtual ~AnotherFakeApi();
|
||||
|
||||
std::shared_ptr<AnotherFakeApiResources::Another_fakeDummyResource> getAnother_fakeDummyResource();
|
||||
|
||||
void setResource(std::shared_ptr<AnotherFakeApiResources::Another_fakeDummyResource> resource);
|
||||
[[deprecated("use setResource()")]]
|
||||
virtual void setAnotherFakeApiAnother_fakeDummyResource(std::shared_ptr<AnotherFakeApiResources::Another_fakeDummyResource> spAnotherFakeApiAnother_fakeDummyResource);
|
||||
|
||||
virtual void publishDefaultResources();
|
||||
|
||||
virtual std::shared_ptr<restbed::Service> service();
|
||||
|
||||
protected:
|
||||
std::shared_ptr<AnotherFakeApiResources::Another_fakeDummyResource> m_spAnother_fakeDummyResource;
|
||||
|
||||
private:
|
||||
std::shared_ptr<restbed::Service> m_service;
|
||||
};
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif /* AnotherFakeApi_H_ */
|
||||
|
||||
@@ -0,0 +1,267 @@
|
||||
/**
|
||||
* OpenAPI Petstore
|
||||
* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
|
||||
*
|
||||
* The version of the OpenAPI document: 1.0.0
|
||||
*
|
||||
*
|
||||
* NOTE: This class is auto generated by OpenAPI-Generator 7.0.0-SNAPSHOT.
|
||||
* 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 "DefaultApi.h"
|
||||
|
||||
namespace org {
|
||||
namespace openapitools {
|
||||
namespace server {
|
||||
namespace api {
|
||||
|
||||
using namespace org::openapitools::server::model;
|
||||
|
||||
namespace {
|
||||
[[maybe_unused]]
|
||||
std::string selectPreferredContentType(const std::vector<std::string>& contentTypes) {
|
||||
if (contentTypes.size() == 0) {
|
||||
return "application/json";
|
||||
}
|
||||
|
||||
if (contentTypes.size() == 1) {
|
||||
return contentTypes.at(0);
|
||||
}
|
||||
|
||||
static const std::array<std::string, 2> preferredTypes = {"json", "xml"};
|
||||
for (const auto& preferredType: preferredTypes) {
|
||||
const auto ret = std::find_if(contentTypes.cbegin(),
|
||||
contentTypes.cend(),
|
||||
[preferredType](const std::string& str) {
|
||||
return str.find(preferredType) != std::string::npos;});
|
||||
if (ret != contentTypes.cend()) {
|
||||
return *ret;
|
||||
}
|
||||
}
|
||||
|
||||
return contentTypes.at(0);
|
||||
}
|
||||
}
|
||||
|
||||
DefaultApiException::DefaultApiException(int status_code, std::string what)
|
||||
: m_status(status_code),
|
||||
m_what(what)
|
||||
{
|
||||
|
||||
}
|
||||
int DefaultApiException::getStatus() const
|
||||
{
|
||||
return m_status;
|
||||
}
|
||||
const char* DefaultApiException::what() const noexcept
|
||||
{
|
||||
return m_what.c_str();
|
||||
}
|
||||
|
||||
|
||||
template<class MODEL_T>
|
||||
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 = MODEL_T(pt);
|
||||
return model;
|
||||
}
|
||||
|
||||
template<class MODEL_T>
|
||||
std::vector<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<MODEL_T>();
|
||||
for (const auto& child: pt) {
|
||||
arrayRet.emplace_back(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;
|
||||
}
|
||||
|
||||
namespace DefaultApiResources {
|
||||
FooResource::FooResource(const std::string& context /* = "/v2" */)
|
||||
{
|
||||
this->set_path(context + "/foo");
|
||||
this->set_method_handler("GET",
|
||||
std::bind(&FooResource::handler_GET_internal, this,
|
||||
std::placeholders::_1));
|
||||
}
|
||||
|
||||
std::pair<int, std::string> FooResource::handleDefaultApiException(const DefaultApiException& e)
|
||||
{
|
||||
return std::make_pair<int, std::string>(e.getStatus(), e.what());
|
||||
}
|
||||
|
||||
std::pair<int, std::string> FooResource::handleStdException(const std::exception& e)
|
||||
{
|
||||
return std::make_pair<int, std::string>(500, e.what());
|
||||
}
|
||||
|
||||
std::pair<int, std::string> FooResource::handleUnspecifiedException()
|
||||
{
|
||||
return std::make_pair<int, std::string>(500, "Unknown exception occurred");
|
||||
}
|
||||
|
||||
void FooResource::setResponseHeader(const std::shared_ptr<restbed::Session>& session, const std::string& header)
|
||||
{
|
||||
session->set_header(header, "");
|
||||
}
|
||||
|
||||
void FooResource::returnResponse(const std::shared_ptr<restbed::Session>& session, const int status, const std::string& result, std::multimap<std::string, std::string>& responseHeaders)
|
||||
{
|
||||
responseHeaders.insert(std::make_pair("Connection", "close"));
|
||||
session->close(status, result, responseHeaders);
|
||||
}
|
||||
|
||||
void FooResource::defaultSessionClose(const std::shared_ptr<restbed::Session>& session, const int status, const std::string& result)
|
||||
{
|
||||
session->close(status, result, { {"Connection", "close"} });
|
||||
}
|
||||
|
||||
void FooResource::handler_GET_internal(const std::shared_ptr<restbed::Session> session)
|
||||
{
|
||||
const auto request = session->get_request();
|
||||
|
||||
int status_code = 500;
|
||||
_foo_get_default_response resultObject = _foo_get_default_response{};
|
||||
std::string result = "";
|
||||
|
||||
try {
|
||||
std::tie(status_code, resultObject) =
|
||||
handler_GET();
|
||||
}
|
||||
catch(const DefaultApiException& e) {
|
||||
std::tie(status_code, result) = handleDefaultApiException(e);
|
||||
}
|
||||
catch(const std::exception& e) {
|
||||
std::tie(status_code, result) = handleStdException(e);
|
||||
}
|
||||
catch(...) {
|
||||
std::tie(status_code, result) = handleUnspecifiedException();
|
||||
}
|
||||
|
||||
std::multimap< std::string, std::string > responseHeaders {};
|
||||
static const std::vector<std::string> contentTypes{
|
||||
"application/json",
|
||||
};
|
||||
static const std::string acceptTypes{
|
||||
};
|
||||
|
||||
if (status_code == 0) {
|
||||
responseHeaders.insert(std::make_pair("Content-Type", "text/plain"));
|
||||
result = "response";
|
||||
|
||||
result = resultObject.toJsonString();
|
||||
returnResponse(session, 0, result.empty() ? "{}" : result, responseHeaders);
|
||||
return;
|
||||
}
|
||||
defaultSessionClose(session, status_code, result);
|
||||
}
|
||||
|
||||
|
||||
std::pair<int, _foo_get_default_response> FooResource::handler_GET(
|
||||
)
|
||||
{
|
||||
return handler_GET_func();
|
||||
}
|
||||
|
||||
|
||||
std::string FooResource::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;
|
||||
}
|
||||
|
||||
std::string FooResource::extractFormParamsFromBody(const std::string& paramName, const std::string& body) {
|
||||
const auto uri = restbed::Uri("urlencoded?" + body, true);
|
||||
const auto params = uri.get_query_parameters();
|
||||
const auto result = params.find(paramName);
|
||||
if (result != params.cend()) {
|
||||
return result->second;
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
} /* namespace DefaultApiResources */
|
||||
|
||||
DefaultApi::DefaultApi(std::shared_ptr<restbed::Service> const& restbedService)
|
||||
: m_service(restbedService)
|
||||
{
|
||||
}
|
||||
|
||||
DefaultApi::~DefaultApi() {}
|
||||
|
||||
std::shared_ptr<DefaultApiResources::FooResource> DefaultApi::getFooResource() {
|
||||
if (!m_spFooResource) {
|
||||
setResource(std::make_shared<DefaultApiResources::FooResource>());
|
||||
}
|
||||
return m_spFooResource;
|
||||
}
|
||||
void DefaultApi::setResource(std::shared_ptr<DefaultApiResources::FooResource> resource) {
|
||||
m_spFooResource = resource;
|
||||
m_service->publish(m_spFooResource);
|
||||
}
|
||||
void DefaultApi::setDefaultApiFooResource(std::shared_ptr<DefaultApiResources::FooResource> spFooResource) {
|
||||
m_spFooResource = spFooResource;
|
||||
m_service->publish(m_spFooResource);
|
||||
}
|
||||
|
||||
|
||||
void DefaultApi::publishDefaultResources() {
|
||||
if (!m_spFooResource) {
|
||||
setResource(std::make_shared<DefaultApiResources::FooResource>());
|
||||
}
|
||||
}
|
||||
|
||||
std::shared_ptr<restbed::Service> DefaultApi::service() {
|
||||
return m_service;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,159 @@
|
||||
/**
|
||||
* OpenAPI Petstore
|
||||
* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
|
||||
*
|
||||
* The version of the OpenAPI document: 1.0.0
|
||||
*
|
||||
*
|
||||
* NOTE: This class is auto generated by OpenAPI-Generator 7.0.0-SNAPSHOT.
|
||||
* https://openapi-generator.tech
|
||||
* Do not edit the class manually.
|
||||
*/
|
||||
|
||||
/*
|
||||
* DefaultApi.h
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef DefaultApi_H_
|
||||
#define DefaultApi_H_
|
||||
|
||||
|
||||
#include <memory>
|
||||
#include <utility>
|
||||
#include <exception>
|
||||
#include <functional>
|
||||
|
||||
#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 "_foo_get_default_response.h"
|
||||
|
||||
namespace org {
|
||||
namespace openapitools {
|
||||
namespace server {
|
||||
namespace api {
|
||||
|
||||
using namespace org::openapitools::server::model;
|
||||
|
||||
///
|
||||
/// Exception to flag problems in the handlers
|
||||
///
|
||||
class DefaultApiException: public std::exception
|
||||
{
|
||||
public:
|
||||
DefaultApiException(int status_code, std::string what);
|
||||
|
||||
int getStatus() const;
|
||||
const char* what() const noexcept override;
|
||||
|
||||
private:
|
||||
int m_status;
|
||||
std::string m_what;
|
||||
};
|
||||
|
||||
namespace DefaultApiResources {
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
///
|
||||
/// </remarks>
|
||||
class FooResource: public restbed::Resource
|
||||
{
|
||||
public:
|
||||
FooResource(const std::string& context = "/v2");
|
||||
virtual ~FooResource() = default;
|
||||
|
||||
FooResource(
|
||||
const FooResource& other) = default; // copy constructor
|
||||
FooResource(FooResource&& other) noexcept = default; // move constructor
|
||||
|
||||
FooResource& operator=(const FooResource& other) = default; // copy assignment
|
||||
FooResource& operator=(FooResource&& other) noexcept = default; // move assignment
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
// Set these to implement the server functionality //
|
||||
/////////////////////////////////////////////////////
|
||||
std::function<std::pair<int, _foo_get_default_response>(
|
||||
)> handler_GET_func =
|
||||
[]() -> std::pair<int, _foo_get_default_response>
|
||||
{ throw DefaultApiException(501, "Not implemented"); };
|
||||
|
||||
|
||||
protected:
|
||||
//////////////////////////////////////////////////////////
|
||||
// As an alternative to setting the `std::function`s //
|
||||
// override these to implement the server functionality //
|
||||
//////////////////////////////////////////////////////////
|
||||
|
||||
virtual std::pair<int, _foo_get_default_response> handler_GET(
|
||||
);
|
||||
|
||||
|
||||
protected:
|
||||
//////////////////////////////////////
|
||||
// Override these for customization //
|
||||
//////////////////////////////////////
|
||||
|
||||
virtual std::string extractBodyContent(const std::shared_ptr<restbed::Session>& session);
|
||||
virtual std::string extractFormParamsFromBody(const std::string& paramName, const std::string& body);
|
||||
|
||||
virtual std::pair<int, std::string> handleDefaultApiException(const DefaultApiException& 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, std::multimap<std::string, 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);
|
||||
};
|
||||
|
||||
} /* namespace DefaultApiResources */
|
||||
|
||||
using DefaultApiFooResource [[deprecated]] = DefaultApiResources::FooResource;
|
||||
|
||||
//
|
||||
// The restbed service to actually implement the REST server
|
||||
//
|
||||
class DefaultApi
|
||||
{
|
||||
public:
|
||||
explicit DefaultApi(std::shared_ptr<restbed::Service> const& restbedService);
|
||||
virtual ~DefaultApi();
|
||||
|
||||
std::shared_ptr<DefaultApiResources::FooResource> getFooResource();
|
||||
|
||||
void setResource(std::shared_ptr<DefaultApiResources::FooResource> resource);
|
||||
[[deprecated("use setResource()")]]
|
||||
virtual void setDefaultApiFooResource(std::shared_ptr<DefaultApiResources::FooResource> spDefaultApiFooResource);
|
||||
|
||||
virtual void publishDefaultResources();
|
||||
|
||||
virtual std::shared_ptr<restbed::Service> service();
|
||||
|
||||
protected:
|
||||
std::shared_ptr<DefaultApiResources::FooResource> m_spFooResource;
|
||||
|
||||
private:
|
||||
std::shared_ptr<restbed::Service> m_service;
|
||||
};
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif /* DefaultApi_H_ */
|
||||
|
||||
2200
samples/server/petstore/cpp-restbed/generated/3_0/api/FakeApi.cpp
Normal file
2200
samples/server/petstore/cpp-restbed/generated/3_0/api/FakeApi.cpp
Normal file
File diff suppressed because it is too large
Load Diff
1076
samples/server/petstore/cpp-restbed/generated/3_0/api/FakeApi.h
Normal file
1076
samples/server/petstore/cpp-restbed/generated/3_0/api/FakeApi.h
Normal file
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,273 @@
|
||||
/**
|
||||
* OpenAPI Petstore
|
||||
* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
|
||||
*
|
||||
* The version of the OpenAPI document: 1.0.0
|
||||
*
|
||||
*
|
||||
* NOTE: This class is auto generated by OpenAPI-Generator 7.0.0-SNAPSHOT.
|
||||
* 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 "FakeClassnameTags123Api.h"
|
||||
|
||||
namespace org {
|
||||
namespace openapitools {
|
||||
namespace server {
|
||||
namespace api {
|
||||
|
||||
using namespace org::openapitools::server::model;
|
||||
|
||||
namespace {
|
||||
[[maybe_unused]]
|
||||
std::string selectPreferredContentType(const std::vector<std::string>& contentTypes) {
|
||||
if (contentTypes.size() == 0) {
|
||||
return "application/json";
|
||||
}
|
||||
|
||||
if (contentTypes.size() == 1) {
|
||||
return contentTypes.at(0);
|
||||
}
|
||||
|
||||
static const std::array<std::string, 2> preferredTypes = {"json", "xml"};
|
||||
for (const auto& preferredType: preferredTypes) {
|
||||
const auto ret = std::find_if(contentTypes.cbegin(),
|
||||
contentTypes.cend(),
|
||||
[preferredType](const std::string& str) {
|
||||
return str.find(preferredType) != std::string::npos;});
|
||||
if (ret != contentTypes.cend()) {
|
||||
return *ret;
|
||||
}
|
||||
}
|
||||
|
||||
return contentTypes.at(0);
|
||||
}
|
||||
}
|
||||
|
||||
FakeClassnameTags123ApiException::FakeClassnameTags123ApiException(int status_code, std::string what)
|
||||
: m_status(status_code),
|
||||
m_what(what)
|
||||
{
|
||||
|
||||
}
|
||||
int FakeClassnameTags123ApiException::getStatus() const
|
||||
{
|
||||
return m_status;
|
||||
}
|
||||
const char* FakeClassnameTags123ApiException::what() const noexcept
|
||||
{
|
||||
return m_what.c_str();
|
||||
}
|
||||
|
||||
|
||||
template<class MODEL_T>
|
||||
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 = MODEL_T(pt);
|
||||
return model;
|
||||
}
|
||||
|
||||
template<class MODEL_T>
|
||||
std::vector<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<MODEL_T>();
|
||||
for (const auto& child: pt) {
|
||||
arrayRet.emplace_back(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;
|
||||
}
|
||||
|
||||
namespace FakeClassnameTags123ApiResources {
|
||||
Fake_classname_testResource::Fake_classname_testResource(const std::string& context /* = "/v2" */)
|
||||
{
|
||||
this->set_path(context + "/fake_classname_test");
|
||||
this->set_method_handler("PATCH",
|
||||
std::bind(&Fake_classname_testResource::handler_PATCH_internal, this,
|
||||
std::placeholders::_1));
|
||||
}
|
||||
|
||||
std::pair<int, std::string> Fake_classname_testResource::handleFakeClassnameTags123ApiException(const FakeClassnameTags123ApiException& e)
|
||||
{
|
||||
return std::make_pair<int, std::string>(e.getStatus(), e.what());
|
||||
}
|
||||
|
||||
std::pair<int, std::string> Fake_classname_testResource::handleStdException(const std::exception& e)
|
||||
{
|
||||
return std::make_pair<int, std::string>(500, e.what());
|
||||
}
|
||||
|
||||
std::pair<int, std::string> Fake_classname_testResource::handleUnspecifiedException()
|
||||
{
|
||||
return std::make_pair<int, std::string>(500, "Unknown exception occurred");
|
||||
}
|
||||
|
||||
void Fake_classname_testResource::setResponseHeader(const std::shared_ptr<restbed::Session>& session, const std::string& header)
|
||||
{
|
||||
session->set_header(header, "");
|
||||
}
|
||||
|
||||
void Fake_classname_testResource::returnResponse(const std::shared_ptr<restbed::Session>& session, const int status, const std::string& result, std::multimap<std::string, std::string>& responseHeaders)
|
||||
{
|
||||
responseHeaders.insert(std::make_pair("Connection", "close"));
|
||||
session->close(status, result, responseHeaders);
|
||||
}
|
||||
|
||||
void Fake_classname_testResource::defaultSessionClose(const std::shared_ptr<restbed::Session>& session, const int status, const std::string& result)
|
||||
{
|
||||
session->close(status, result, { {"Connection", "close"} });
|
||||
}
|
||||
|
||||
void Fake_classname_testResource::handler_PATCH_internal(const std::shared_ptr<restbed::Session> session)
|
||||
{
|
||||
const auto request = session->get_request();
|
||||
// body params or form params here from the body content string
|
||||
std::string bodyContent = extractBodyContent(session);
|
||||
auto client = extractJsonModelBodyParam<Client>(bodyContent);
|
||||
|
||||
int status_code = 500;
|
||||
Client resultObject = Client{};
|
||||
std::string result = "";
|
||||
|
||||
try {
|
||||
std::tie(status_code, resultObject) =
|
||||
handler_PATCH(client);
|
||||
}
|
||||
catch(const FakeClassnameTags123ApiException& e) {
|
||||
std::tie(status_code, result) = handleFakeClassnameTags123ApiException(e);
|
||||
}
|
||||
catch(const std::exception& e) {
|
||||
std::tie(status_code, result) = handleStdException(e);
|
||||
}
|
||||
catch(...) {
|
||||
std::tie(status_code, result) = handleUnspecifiedException();
|
||||
}
|
||||
|
||||
std::multimap< std::string, std::string > responseHeaders {};
|
||||
static const std::vector<std::string> contentTypes{
|
||||
"application/json",
|
||||
};
|
||||
static const std::string acceptTypes{
|
||||
"application/json, "
|
||||
};
|
||||
|
||||
if (status_code == 200) {
|
||||
responseHeaders.insert(std::make_pair("Content-Type", selectPreferredContentType(contentTypes)));
|
||||
if (!acceptTypes.empty()) {
|
||||
responseHeaders.insert(std::make_pair("Accept", acceptTypes));
|
||||
}
|
||||
|
||||
result = resultObject.toJsonString();
|
||||
returnResponse(session, 200, result.empty() ? "{}" : result, responseHeaders);
|
||||
return;
|
||||
}
|
||||
defaultSessionClose(session, status_code, result);
|
||||
}
|
||||
|
||||
|
||||
std::pair<int, Client> Fake_classname_testResource::handler_PATCH(
|
||||
Client & client)
|
||||
{
|
||||
return handler_PATCH_func(client);
|
||||
}
|
||||
|
||||
|
||||
std::string Fake_classname_testResource::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;
|
||||
}
|
||||
|
||||
std::string Fake_classname_testResource::extractFormParamsFromBody(const std::string& paramName, const std::string& body) {
|
||||
const auto uri = restbed::Uri("urlencoded?" + body, true);
|
||||
const auto params = uri.get_query_parameters();
|
||||
const auto result = params.find(paramName);
|
||||
if (result != params.cend()) {
|
||||
return result->second;
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
} /* namespace FakeClassnameTags123ApiResources */
|
||||
|
||||
FakeClassnameTags123Api::FakeClassnameTags123Api(std::shared_ptr<restbed::Service> const& restbedService)
|
||||
: m_service(restbedService)
|
||||
{
|
||||
}
|
||||
|
||||
FakeClassnameTags123Api::~FakeClassnameTags123Api() {}
|
||||
|
||||
std::shared_ptr<FakeClassnameTags123ApiResources::Fake_classname_testResource> FakeClassnameTags123Api::getFake_classname_testResource() {
|
||||
if (!m_spFake_classname_testResource) {
|
||||
setResource(std::make_shared<FakeClassnameTags123ApiResources::Fake_classname_testResource>());
|
||||
}
|
||||
return m_spFake_classname_testResource;
|
||||
}
|
||||
void FakeClassnameTags123Api::setResource(std::shared_ptr<FakeClassnameTags123ApiResources::Fake_classname_testResource> resource) {
|
||||
m_spFake_classname_testResource = resource;
|
||||
m_service->publish(m_spFake_classname_testResource);
|
||||
}
|
||||
void FakeClassnameTags123Api::setFakeClassnameTags123ApiFake_classname_testResource(std::shared_ptr<FakeClassnameTags123ApiResources::Fake_classname_testResource> spFake_classname_testResource) {
|
||||
m_spFake_classname_testResource = spFake_classname_testResource;
|
||||
m_service->publish(m_spFake_classname_testResource);
|
||||
}
|
||||
|
||||
|
||||
void FakeClassnameTags123Api::publishDefaultResources() {
|
||||
if (!m_spFake_classname_testResource) {
|
||||
setResource(std::make_shared<FakeClassnameTags123ApiResources::Fake_classname_testResource>());
|
||||
}
|
||||
}
|
||||
|
||||
std::shared_ptr<restbed::Service> FakeClassnameTags123Api::service() {
|
||||
return m_service;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,159 @@
|
||||
/**
|
||||
* OpenAPI Petstore
|
||||
* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
|
||||
*
|
||||
* The version of the OpenAPI document: 1.0.0
|
||||
*
|
||||
*
|
||||
* NOTE: This class is auto generated by OpenAPI-Generator 7.0.0-SNAPSHOT.
|
||||
* https://openapi-generator.tech
|
||||
* Do not edit the class manually.
|
||||
*/
|
||||
|
||||
/*
|
||||
* FakeClassnameTags123Api.h
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef FakeClassnameTags123Api_H_
|
||||
#define FakeClassnameTags123Api_H_
|
||||
|
||||
|
||||
#include <memory>
|
||||
#include <utility>
|
||||
#include <exception>
|
||||
#include <functional>
|
||||
|
||||
#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 "Client.h"
|
||||
|
||||
namespace org {
|
||||
namespace openapitools {
|
||||
namespace server {
|
||||
namespace api {
|
||||
|
||||
using namespace org::openapitools::server::model;
|
||||
|
||||
///
|
||||
/// Exception to flag problems in the handlers
|
||||
///
|
||||
class FakeClassnameTags123ApiException: public std::exception
|
||||
{
|
||||
public:
|
||||
FakeClassnameTags123ApiException(int status_code, std::string what);
|
||||
|
||||
int getStatus() const;
|
||||
const char* what() const noexcept override;
|
||||
|
||||
private:
|
||||
int m_status;
|
||||
std::string m_what;
|
||||
};
|
||||
|
||||
namespace FakeClassnameTags123ApiResources {
|
||||
/// <summary>
|
||||
/// To test class name in snake case
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// To test class name in snake case
|
||||
/// </remarks>
|
||||
class Fake_classname_testResource: public restbed::Resource
|
||||
{
|
||||
public:
|
||||
Fake_classname_testResource(const std::string& context = "/v2");
|
||||
virtual ~Fake_classname_testResource() = default;
|
||||
|
||||
Fake_classname_testResource(
|
||||
const Fake_classname_testResource& other) = default; // copy constructor
|
||||
Fake_classname_testResource(Fake_classname_testResource&& other) noexcept = default; // move constructor
|
||||
|
||||
Fake_classname_testResource& operator=(const Fake_classname_testResource& other) = default; // copy assignment
|
||||
Fake_classname_testResource& operator=(Fake_classname_testResource&& other) noexcept = default; // move assignment
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
// Set these to implement the server functionality //
|
||||
/////////////////////////////////////////////////////
|
||||
std::function<std::pair<int, Client>(
|
||||
Client & client)> handler_PATCH_func =
|
||||
[](Client &) -> std::pair<int, Client>
|
||||
{ throw FakeClassnameTags123ApiException(501, "Not implemented"); };
|
||||
|
||||
|
||||
protected:
|
||||
//////////////////////////////////////////////////////////
|
||||
// As an alternative to setting the `std::function`s //
|
||||
// override these to implement the server functionality //
|
||||
//////////////////////////////////////////////////////////
|
||||
|
||||
virtual std::pair<int, Client> handler_PATCH(
|
||||
Client & client);
|
||||
|
||||
|
||||
protected:
|
||||
//////////////////////////////////////
|
||||
// Override these for customization //
|
||||
//////////////////////////////////////
|
||||
|
||||
virtual std::string extractBodyContent(const std::shared_ptr<restbed::Session>& session);
|
||||
virtual std::string extractFormParamsFromBody(const std::string& paramName, const std::string& body);
|
||||
|
||||
virtual std::pair<int, std::string> handleFakeClassnameTags123ApiException(const FakeClassnameTags123ApiException& 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, std::multimap<std::string, std::string>& contentType);
|
||||
virtual void defaultSessionClose(const std::shared_ptr<restbed::Session>& session,
|
||||
const int status, const std::string& result);
|
||||
|
||||
private:
|
||||
void handler_PATCH_internal(const std::shared_ptr<restbed::Session> session);
|
||||
};
|
||||
|
||||
} /* namespace FakeClassnameTags123ApiResources */
|
||||
|
||||
using FakeClassnameTags123ApiFake_classname_testResource [[deprecated]] = FakeClassnameTags123ApiResources::Fake_classname_testResource;
|
||||
|
||||
//
|
||||
// The restbed service to actually implement the REST server
|
||||
//
|
||||
class FakeClassnameTags123Api
|
||||
{
|
||||
public:
|
||||
explicit FakeClassnameTags123Api(std::shared_ptr<restbed::Service> const& restbedService);
|
||||
virtual ~FakeClassnameTags123Api();
|
||||
|
||||
std::shared_ptr<FakeClassnameTags123ApiResources::Fake_classname_testResource> getFake_classname_testResource();
|
||||
|
||||
void setResource(std::shared_ptr<FakeClassnameTags123ApiResources::Fake_classname_testResource> resource);
|
||||
[[deprecated("use setResource()")]]
|
||||
virtual void setFakeClassnameTags123ApiFake_classname_testResource(std::shared_ptr<FakeClassnameTags123ApiResources::Fake_classname_testResource> spFakeClassnameTags123ApiFake_classname_testResource);
|
||||
|
||||
virtual void publishDefaultResources();
|
||||
|
||||
virtual std::shared_ptr<restbed::Service> service();
|
||||
|
||||
protected:
|
||||
std::shared_ptr<FakeClassnameTags123ApiResources::Fake_classname_testResource> m_spFake_classname_testResource;
|
||||
|
||||
private:
|
||||
std::shared_ptr<restbed::Service> m_service;
|
||||
};
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif /* FakeClassnameTags123Api_H_ */
|
||||
|
||||
1157
samples/server/petstore/cpp-restbed/generated/3_0/api/PetApi.cpp
Normal file
1157
samples/server/petstore/cpp-restbed/generated/3_0/api/PetApi.cpp
Normal file
File diff suppressed because it is too large
Load Diff
526
samples/server/petstore/cpp-restbed/generated/3_0/api/PetApi.h
Normal file
526
samples/server/petstore/cpp-restbed/generated/3_0/api/PetApi.h
Normal file
@@ -0,0 +1,526 @@
|
||||
/**
|
||||
* OpenAPI Petstore
|
||||
* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
|
||||
*
|
||||
* The version of the OpenAPI document: 1.0.0
|
||||
*
|
||||
*
|
||||
* NOTE: This class is auto generated by OpenAPI-Generator 7.0.0-SNAPSHOT.
|
||||
* 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 <functional>
|
||||
|
||||
#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 <set>
|
||||
#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;
|
||||
};
|
||||
|
||||
namespace PetApiResources {
|
||||
/// <summary>
|
||||
/// Add a new pet to the store
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
///
|
||||
/// </remarks>
|
||||
class PetResource: public restbed::Resource
|
||||
{
|
||||
public:
|
||||
PetResource(const std::string& context = "/v2");
|
||||
virtual ~PetResource() = default;
|
||||
|
||||
PetResource(
|
||||
const PetResource& other) = default; // copy constructor
|
||||
PetResource(PetResource&& other) noexcept = default; // move constructor
|
||||
|
||||
PetResource& operator=(const PetResource& other) = default; // copy assignment
|
||||
PetResource& operator=(PetResource&& other) noexcept = default; // move assignment
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
// Set these to implement the server functionality //
|
||||
/////////////////////////////////////////////////////
|
||||
std::function<int(
|
||||
Pet & pet)> handler_POST_func =
|
||||
[](Pet &) -> int
|
||||
{ throw PetApiException(501, "Not implemented"); };
|
||||
|
||||
std::function<int(
|
||||
Pet & pet)> handler_PUT_func =
|
||||
[](Pet &) -> int
|
||||
{ throw PetApiException(501, "Not implemented"); };
|
||||
|
||||
|
||||
protected:
|
||||
//////////////////////////////////////////////////////////
|
||||
// As an alternative to setting the `std::function`s //
|
||||
// override these to implement the server functionality //
|
||||
//////////////////////////////////////////////////////////
|
||||
|
||||
virtual int handler_POST(
|
||||
Pet & pet);
|
||||
|
||||
virtual int handler_PUT(
|
||||
Pet & pet);
|
||||
|
||||
protected:
|
||||
//////////////////////////////////////
|
||||
// Override these for customization //
|
||||
//////////////////////////////////////
|
||||
|
||||
virtual std::string extractBodyContent(const std::shared_ptr<restbed::Session>& session);
|
||||
virtual std::string extractFormParamsFromBody(const std::string& paramName, const std::string& body);
|
||||
|
||||
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, std::multimap<std::string, 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 PetPetIdResource: public restbed::Resource
|
||||
{
|
||||
public:
|
||||
PetPetIdResource(const std::string& context = "/v2");
|
||||
virtual ~PetPetIdResource() = default;
|
||||
|
||||
PetPetIdResource(
|
||||
const PetPetIdResource& other) = default; // copy constructor
|
||||
PetPetIdResource(PetPetIdResource&& other) noexcept = default; // move constructor
|
||||
|
||||
PetPetIdResource& operator=(const PetPetIdResource& other) = default; // copy assignment
|
||||
PetPetIdResource& operator=(PetPetIdResource&& other) noexcept = default; // move assignment
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
// Set these to implement the server functionality //
|
||||
/////////////////////////////////////////////////////
|
||||
std::function<int(
|
||||
int64_t & petId, std::string & apiKey)> handler_DELETE_func =
|
||||
[](int64_t &, std::string &) -> int
|
||||
{ throw PetApiException(501, "Not implemented"); };
|
||||
|
||||
std::function<std::pair<int, Pet>(
|
||||
int64_t & petId)> handler_GET_func =
|
||||
[](int64_t &) -> std::pair<int, Pet>
|
||||
{ throw PetApiException(501, "Not implemented"); };
|
||||
|
||||
std::function<int(
|
||||
int64_t & petId, std::string & name, std::string & status)> handler_POST_func =
|
||||
[](int64_t &, std::string &, std::string &) -> int
|
||||
{ throw PetApiException(501, "Not implemented"); };
|
||||
|
||||
|
||||
protected:
|
||||
//////////////////////////////////////////////////////////
|
||||
// As an alternative to setting the `std::function`s //
|
||||
// override these to implement the server functionality //
|
||||
//////////////////////////////////////////////////////////
|
||||
|
||||
virtual int handler_DELETE(
|
||||
int64_t & petId, std::string & apiKey);
|
||||
|
||||
virtual std::pair<int, Pet> handler_GET(
|
||||
int64_t & petId);
|
||||
virtual int handler_POST(
|
||||
int64_t & petId, std::string & name, std::string & status);
|
||||
|
||||
protected:
|
||||
//////////////////////////////////////
|
||||
// Override these for customization //
|
||||
//////////////////////////////////////
|
||||
|
||||
virtual std::string extractBodyContent(const std::shared_ptr<restbed::Session>& session);
|
||||
virtual std::string extractFormParamsFromBody(const std::string& paramName, const std::string& body);
|
||||
|
||||
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, std::multimap<std::string, 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 PetFindByStatusResource: public restbed::Resource
|
||||
{
|
||||
public:
|
||||
PetFindByStatusResource(const std::string& context = "/v2");
|
||||
virtual ~PetFindByStatusResource() = default;
|
||||
|
||||
PetFindByStatusResource(
|
||||
const PetFindByStatusResource& other) = default; // copy constructor
|
||||
PetFindByStatusResource(PetFindByStatusResource&& other) noexcept = default; // move constructor
|
||||
|
||||
PetFindByStatusResource& operator=(const PetFindByStatusResource& other) = default; // copy assignment
|
||||
PetFindByStatusResource& operator=(PetFindByStatusResource&& other) noexcept = default; // move assignment
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
// Set these to implement the server functionality //
|
||||
/////////////////////////////////////////////////////
|
||||
std::function<std::pair<int, std::vector<Pet>>(
|
||||
std::vector<std::string> & status)> handler_GET_func =
|
||||
[](std::vector<std::string> &) -> std::pair<int, std::vector<Pet>>
|
||||
{ throw PetApiException(501, "Not implemented"); };
|
||||
|
||||
|
||||
protected:
|
||||
//////////////////////////////////////////////////////////
|
||||
// As an alternative to setting the `std::function`s //
|
||||
// override these to implement the server functionality //
|
||||
//////////////////////////////////////////////////////////
|
||||
|
||||
virtual std::pair<int, std::vector<Pet>> handler_GET(
|
||||
std::vector<std::string> & status);
|
||||
|
||||
|
||||
protected:
|
||||
//////////////////////////////////////
|
||||
// Override these for customization //
|
||||
//////////////////////////////////////
|
||||
|
||||
virtual std::string extractBodyContent(const std::shared_ptr<restbed::Session>& session);
|
||||
virtual std::string extractFormParamsFromBody(const std::string& paramName, const std::string& body);
|
||||
|
||||
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, std::multimap<std::string, 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 PetFindByTagsResource: public restbed::Resource
|
||||
{
|
||||
public:
|
||||
PetFindByTagsResource(const std::string& context = "/v2");
|
||||
virtual ~PetFindByTagsResource() = default;
|
||||
|
||||
PetFindByTagsResource(
|
||||
const PetFindByTagsResource& other) = default; // copy constructor
|
||||
PetFindByTagsResource(PetFindByTagsResource&& other) noexcept = default; // move constructor
|
||||
|
||||
PetFindByTagsResource& operator=(const PetFindByTagsResource& other) = default; // copy assignment
|
||||
PetFindByTagsResource& operator=(PetFindByTagsResource&& other) noexcept = default; // move assignment
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
// Set these to implement the server functionality //
|
||||
/////////////////////////////////////////////////////
|
||||
std::function<std::pair<int, std::set<Pet>>(
|
||||
std::set<std::string> & tags)> handler_GET_func =
|
||||
[](std::set<std::string> &) -> std::pair<int, std::set<Pet>>
|
||||
{ throw PetApiException(501, "Not implemented"); };
|
||||
|
||||
|
||||
protected:
|
||||
//////////////////////////////////////////////////////////
|
||||
// As an alternative to setting the `std::function`s //
|
||||
// override these to implement the server functionality //
|
||||
//////////////////////////////////////////////////////////
|
||||
|
||||
virtual std::pair<int, std::set<Pet>> handler_GET(
|
||||
std::set<std::string> & tags);
|
||||
|
||||
|
||||
protected:
|
||||
//////////////////////////////////////
|
||||
// Override these for customization //
|
||||
//////////////////////////////////////
|
||||
|
||||
virtual std::string extractBodyContent(const std::shared_ptr<restbed::Session>& session);
|
||||
virtual std::string extractFormParamsFromBody(const std::string& paramName, const std::string& body);
|
||||
|
||||
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, std::multimap<std::string, 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 PetPetIdUploadImageResource: public restbed::Resource
|
||||
{
|
||||
public:
|
||||
PetPetIdUploadImageResource(const std::string& context = "/v2");
|
||||
virtual ~PetPetIdUploadImageResource() = default;
|
||||
|
||||
PetPetIdUploadImageResource(
|
||||
const PetPetIdUploadImageResource& other) = default; // copy constructor
|
||||
PetPetIdUploadImageResource(PetPetIdUploadImageResource&& other) noexcept = default; // move constructor
|
||||
|
||||
PetPetIdUploadImageResource& operator=(const PetPetIdUploadImageResource& other) = default; // copy assignment
|
||||
PetPetIdUploadImageResource& operator=(PetPetIdUploadImageResource&& other) noexcept = default; // move assignment
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
// Set these to implement the server functionality //
|
||||
/////////////////////////////////////////////////////
|
||||
std::function<std::pair<int, ApiResponse>(
|
||||
int64_t & petId, std::string & additionalMetadata, std::string & file)> handler_POST_func =
|
||||
[](int64_t &, std::string &, std::string &) -> std::pair<int, ApiResponse>
|
||||
{ throw PetApiException(501, "Not implemented"); };
|
||||
|
||||
|
||||
protected:
|
||||
//////////////////////////////////////////////////////////
|
||||
// As an alternative to setting the `std::function`s //
|
||||
// override these to implement the server functionality //
|
||||
//////////////////////////////////////////////////////////
|
||||
|
||||
virtual std::pair<int, ApiResponse> handler_POST(
|
||||
int64_t & petId, std::string & additionalMetadata, std::string & file);
|
||||
|
||||
|
||||
protected:
|
||||
//////////////////////////////////////
|
||||
// Override these for customization //
|
||||
//////////////////////////////////////
|
||||
|
||||
virtual std::string extractBodyContent(const std::shared_ptr<restbed::Session>& session);
|
||||
virtual std::string extractFormParamsFromBody(const std::string& paramName, const std::string& body);
|
||||
|
||||
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, std::multimap<std::string, 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>
|
||||
/// uploads an image (required)
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
///
|
||||
/// </remarks>
|
||||
class FakePetIdUploadImageWithRequiredFileResource: public restbed::Resource
|
||||
{
|
||||
public:
|
||||
FakePetIdUploadImageWithRequiredFileResource(const std::string& context = "/v2");
|
||||
virtual ~FakePetIdUploadImageWithRequiredFileResource() = default;
|
||||
|
||||
FakePetIdUploadImageWithRequiredFileResource(
|
||||
const FakePetIdUploadImageWithRequiredFileResource& other) = default; // copy constructor
|
||||
FakePetIdUploadImageWithRequiredFileResource(FakePetIdUploadImageWithRequiredFileResource&& other) noexcept = default; // move constructor
|
||||
|
||||
FakePetIdUploadImageWithRequiredFileResource& operator=(const FakePetIdUploadImageWithRequiredFileResource& other) = default; // copy assignment
|
||||
FakePetIdUploadImageWithRequiredFileResource& operator=(FakePetIdUploadImageWithRequiredFileResource&& other) noexcept = default; // move assignment
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
// Set these to implement the server functionality //
|
||||
/////////////////////////////////////////////////////
|
||||
std::function<std::pair<int, ApiResponse>(
|
||||
int64_t & petId, std::string & requiredFile, std::string & additionalMetadata)> handler_POST_func =
|
||||
[](int64_t &, std::string &, std::string &) -> std::pair<int, ApiResponse>
|
||||
{ throw PetApiException(501, "Not implemented"); };
|
||||
|
||||
|
||||
protected:
|
||||
//////////////////////////////////////////////////////////
|
||||
// As an alternative to setting the `std::function`s //
|
||||
// override these to implement the server functionality //
|
||||
//////////////////////////////////////////////////////////
|
||||
|
||||
virtual std::pair<int, ApiResponse> handler_POST(
|
||||
int64_t & petId, std::string & requiredFile, std::string & additionalMetadata);
|
||||
|
||||
|
||||
protected:
|
||||
//////////////////////////////////////
|
||||
// Override these for customization //
|
||||
//////////////////////////////////////
|
||||
|
||||
virtual std::string extractBodyContent(const std::shared_ptr<restbed::Session>& session);
|
||||
virtual std::string extractFormParamsFromBody(const std::string& paramName, const std::string& body);
|
||||
|
||||
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, std::multimap<std::string, 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);
|
||||
};
|
||||
|
||||
} /* namespace PetApiResources */
|
||||
|
||||
using PetApiPetResource [[deprecated]] = PetApiResources::PetResource;
|
||||
using PetApiPetPetIdResource [[deprecated]] = PetApiResources::PetPetIdResource;
|
||||
using PetApiPetFindByStatusResource [[deprecated]] = PetApiResources::PetFindByStatusResource;
|
||||
using PetApiPetFindByTagsResource [[deprecated]] = PetApiResources::PetFindByTagsResource;
|
||||
using PetApiPetPetIdUploadImageResource [[deprecated]] = PetApiResources::PetPetIdUploadImageResource;
|
||||
using PetApiFakePetIdUploadImageWithRequiredFileResource [[deprecated]] = PetApiResources::FakePetIdUploadImageWithRequiredFileResource;
|
||||
|
||||
//
|
||||
// The restbed service to actually implement the REST server
|
||||
//
|
||||
class PetApi
|
||||
{
|
||||
public:
|
||||
explicit PetApi(std::shared_ptr<restbed::Service> const& restbedService);
|
||||
virtual ~PetApi();
|
||||
|
||||
std::shared_ptr<PetApiResources::PetResource> getPetResource();
|
||||
std::shared_ptr<PetApiResources::PetPetIdResource> getPetPetIdResource();
|
||||
std::shared_ptr<PetApiResources::PetFindByStatusResource> getPetFindByStatusResource();
|
||||
std::shared_ptr<PetApiResources::PetFindByTagsResource> getPetFindByTagsResource();
|
||||
std::shared_ptr<PetApiResources::PetPetIdUploadImageResource> getPetPetIdUploadImageResource();
|
||||
std::shared_ptr<PetApiResources::FakePetIdUploadImageWithRequiredFileResource> getFakePetIdUploadImageWithRequiredFileResource();
|
||||
|
||||
void setResource(std::shared_ptr<PetApiResources::PetResource> resource);
|
||||
void setResource(std::shared_ptr<PetApiResources::PetPetIdResource> resource);
|
||||
void setResource(std::shared_ptr<PetApiResources::PetFindByStatusResource> resource);
|
||||
void setResource(std::shared_ptr<PetApiResources::PetFindByTagsResource> resource);
|
||||
void setResource(std::shared_ptr<PetApiResources::PetPetIdUploadImageResource> resource);
|
||||
void setResource(std::shared_ptr<PetApiResources::FakePetIdUploadImageWithRequiredFileResource> resource);
|
||||
[[deprecated("use setResource()")]]
|
||||
virtual void setPetApiPetResource(std::shared_ptr<PetApiResources::PetResource> spPetApiPetResource);
|
||||
[[deprecated("use setResource()")]]
|
||||
virtual void setPetApiPetPetIdResource(std::shared_ptr<PetApiResources::PetPetIdResource> spPetApiPetPetIdResource);
|
||||
[[deprecated("use setResource()")]]
|
||||
virtual void setPetApiPetFindByStatusResource(std::shared_ptr<PetApiResources::PetFindByStatusResource> spPetApiPetFindByStatusResource);
|
||||
[[deprecated("use setResource()")]]
|
||||
virtual void setPetApiPetFindByTagsResource(std::shared_ptr<PetApiResources::PetFindByTagsResource> spPetApiPetFindByTagsResource);
|
||||
[[deprecated("use setResource()")]]
|
||||
virtual void setPetApiPetPetIdUploadImageResource(std::shared_ptr<PetApiResources::PetPetIdUploadImageResource> spPetApiPetPetIdUploadImageResource);
|
||||
[[deprecated("use setResource()")]]
|
||||
virtual void setPetApiFakePetIdUploadImageWithRequiredFileResource(std::shared_ptr<PetApiResources::FakePetIdUploadImageWithRequiredFileResource> spPetApiFakePetIdUploadImageWithRequiredFileResource);
|
||||
|
||||
virtual void publishDefaultResources();
|
||||
|
||||
virtual std::shared_ptr<restbed::Service> service();
|
||||
|
||||
protected:
|
||||
std::shared_ptr<PetApiResources::PetResource> m_spPetResource;
|
||||
std::shared_ptr<PetApiResources::PetPetIdResource> m_spPetPetIdResource;
|
||||
std::shared_ptr<PetApiResources::PetFindByStatusResource> m_spPetFindByStatusResource;
|
||||
std::shared_ptr<PetApiResources::PetFindByTagsResource> m_spPetFindByTagsResource;
|
||||
std::shared_ptr<PetApiResources::PetPetIdUploadImageResource> m_spPetPetIdUploadImageResource;
|
||||
std::shared_ptr<PetApiResources::FakePetIdUploadImageWithRequiredFileResource> m_spFakePetIdUploadImageWithRequiredFileResource;
|
||||
|
||||
private:
|
||||
std::shared_ptr<restbed::Service> m_service;
|
||||
};
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif /* PetApi_H_ */
|
||||
|
||||
@@ -0,0 +1,606 @@
|
||||
/**
|
||||
* OpenAPI Petstore
|
||||
* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
|
||||
*
|
||||
* The version of the OpenAPI document: 1.0.0
|
||||
*
|
||||
*
|
||||
* NOTE: This class is auto generated by OpenAPI-Generator 7.0.0-SNAPSHOT.
|
||||
* 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;
|
||||
|
||||
namespace {
|
||||
[[maybe_unused]]
|
||||
std::string selectPreferredContentType(const std::vector<std::string>& contentTypes) {
|
||||
if (contentTypes.size() == 0) {
|
||||
return "application/json";
|
||||
}
|
||||
|
||||
if (contentTypes.size() == 1) {
|
||||
return contentTypes.at(0);
|
||||
}
|
||||
|
||||
static const std::array<std::string, 2> preferredTypes = {"json", "xml"};
|
||||
for (const auto& preferredType: preferredTypes) {
|
||||
const auto ret = std::find_if(contentTypes.cbegin(),
|
||||
contentTypes.cend(),
|
||||
[preferredType](const std::string& str) {
|
||||
return str.find(preferredType) != std::string::npos;});
|
||||
if (ret != contentTypes.cend()) {
|
||||
return *ret;
|
||||
}
|
||||
}
|
||||
|
||||
return contentTypes.at(0);
|
||||
}
|
||||
}
|
||||
|
||||
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>
|
||||
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 = MODEL_T(pt);
|
||||
return model;
|
||||
}
|
||||
|
||||
template<class MODEL_T>
|
||||
std::vector<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<MODEL_T>();
|
||||
for (const auto& child: pt) {
|
||||
arrayRet.emplace_back(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;
|
||||
}
|
||||
|
||||
namespace StoreApiResources {
|
||||
StoreOrderOrder_idResource::StoreOrderOrder_idResource(const std::string& context /* = "/v2" */)
|
||||
{
|
||||
this->set_path(context + "/store/order/{order_id: .*}");
|
||||
this->set_method_handler("DELETE",
|
||||
std::bind(&StoreOrderOrder_idResource::handler_DELETE_internal, this,
|
||||
std::placeholders::_1));
|
||||
this->set_method_handler("GET",
|
||||
std::bind(&StoreOrderOrder_idResource::handler_GET_internal, this,
|
||||
std::placeholders::_1));
|
||||
}
|
||||
|
||||
std::pair<int, std::string> StoreOrderOrder_idResource::handleStoreApiException(const StoreApiException& e)
|
||||
{
|
||||
return std::make_pair<int, std::string>(e.getStatus(), e.what());
|
||||
}
|
||||
|
||||
std::pair<int, std::string> StoreOrderOrder_idResource::handleStdException(const std::exception& e)
|
||||
{
|
||||
return std::make_pair<int, std::string>(500, e.what());
|
||||
}
|
||||
|
||||
std::pair<int, std::string> StoreOrderOrder_idResource::handleUnspecifiedException()
|
||||
{
|
||||
return std::make_pair<int, std::string>(500, "Unknown exception occurred");
|
||||
}
|
||||
|
||||
void StoreOrderOrder_idResource::setResponseHeader(const std::shared_ptr<restbed::Session>& session, const std::string& header)
|
||||
{
|
||||
session->set_header(header, "");
|
||||
}
|
||||
|
||||
void StoreOrderOrder_idResource::returnResponse(const std::shared_ptr<restbed::Session>& session, const int status, const std::string& result, std::multimap<std::string, std::string>& responseHeaders)
|
||||
{
|
||||
responseHeaders.insert(std::make_pair("Connection", "close"));
|
||||
session->close(status, result, responseHeaders);
|
||||
}
|
||||
|
||||
void StoreOrderOrder_idResource::defaultSessionClose(const std::shared_ptr<restbed::Session>& session, const int status, const std::string& result)
|
||||
{
|
||||
session->close(status, result, { {"Connection", "close"} });
|
||||
}
|
||||
|
||||
void StoreOrderOrder_idResource::handler_DELETE_internal(const std::shared_ptr<restbed::Session> session)
|
||||
{
|
||||
const auto request = session->get_request();
|
||||
// Getting the path params
|
||||
std::string orderId = request->get_path_parameter("order_id", "");
|
||||
|
||||
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();
|
||||
}
|
||||
|
||||
std::multimap< std::string, std::string > responseHeaders {};
|
||||
static const std::vector<std::string> contentTypes{
|
||||
"application/json"
|
||||
};
|
||||
static const std::string acceptTypes{
|
||||
};
|
||||
|
||||
if (status_code == 400) {
|
||||
responseHeaders.insert(std::make_pair("Content-Type", "text/plain"));
|
||||
result = "Invalid ID supplied";
|
||||
|
||||
returnResponse(session, 400, result.empty() ? "{}" : result, responseHeaders);
|
||||
return;
|
||||
}
|
||||
if (status_code == 404) {
|
||||
responseHeaders.insert(std::make_pair("Content-Type", "text/plain"));
|
||||
result = "Order not found";
|
||||
|
||||
returnResponse(session, 404, result.empty() ? "{}" : result, responseHeaders);
|
||||
return;
|
||||
}
|
||||
defaultSessionClose(session, status_code, result);
|
||||
}
|
||||
|
||||
// x-extension
|
||||
void StoreOrderOrder_idResource::handler_GET_internal(const std::shared_ptr<restbed::Session> session) {
|
||||
const auto request = session->get_request();
|
||||
// Getting the path params
|
||||
int64_t orderId = request->get_path_parameter("order_id", 0L);
|
||||
|
||||
int status_code = 500;
|
||||
Order resultObject = 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();
|
||||
}
|
||||
|
||||
std::multimap< std::string, std::string > responseHeaders {};
|
||||
static const std::vector<std::string> contentTypes{
|
||||
"application/xml","application/json",
|
||||
};
|
||||
static const std::string acceptTypes{
|
||||
};
|
||||
|
||||
if (status_code == 200) {
|
||||
responseHeaders.insert(std::make_pair("Content-Type", selectPreferredContentType(contentTypes)));
|
||||
if (!acceptTypes.empty()) {
|
||||
responseHeaders.insert(std::make_pair("Accept", acceptTypes));
|
||||
}
|
||||
|
||||
result = resultObject.toJsonString();
|
||||
returnResponse(session, 200, result.empty() ? "{}" : result, responseHeaders);
|
||||
return;
|
||||
}
|
||||
if (status_code == 400) {
|
||||
responseHeaders.insert(std::make_pair("Content-Type", "text/plain"));
|
||||
result = "Invalid ID supplied";
|
||||
|
||||
returnResponse(session, 400, result.empty() ? "{}" : result, responseHeaders);
|
||||
return;
|
||||
}
|
||||
if (status_code == 404) {
|
||||
responseHeaders.insert(std::make_pair("Content-Type", "text/plain"));
|
||||
result = "Order not found";
|
||||
|
||||
returnResponse(session, 404, result.empty() ? "{}" : result, responseHeaders);
|
||||
return;
|
||||
}
|
||||
defaultSessionClose(session, status_code, result);
|
||||
}
|
||||
|
||||
int StoreOrderOrder_idResource::handler_DELETE(
|
||||
std::string & orderId)
|
||||
{
|
||||
return handler_DELETE_func(orderId);
|
||||
}
|
||||
|
||||
std::pair<int, Order> StoreOrderOrder_idResource::handler_GET(
|
||||
int64_t & orderId)
|
||||
{
|
||||
return handler_GET_func(orderId);
|
||||
}
|
||||
|
||||
std::string StoreOrderOrder_idResource::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;
|
||||
}
|
||||
|
||||
std::string StoreOrderOrder_idResource::extractFormParamsFromBody(const std::string& paramName, const std::string& body) {
|
||||
const auto uri = restbed::Uri("urlencoded?" + body, true);
|
||||
const auto params = uri.get_query_parameters();
|
||||
const auto result = params.find(paramName);
|
||||
if (result != params.cend()) {
|
||||
return result->second;
|
||||
}
|
||||
return "";
|
||||
}
|
||||
StoreInventoryResource::StoreInventoryResource(const std::string& context /* = "/v2" */)
|
||||
{
|
||||
this->set_path(context + "/store/inventory");
|
||||
this->set_method_handler("GET",
|
||||
std::bind(&StoreInventoryResource::handler_GET_internal, this,
|
||||
std::placeholders::_1));
|
||||
}
|
||||
|
||||
std::pair<int, std::string> StoreInventoryResource::handleStoreApiException(const StoreApiException& e)
|
||||
{
|
||||
return std::make_pair<int, std::string>(e.getStatus(), e.what());
|
||||
}
|
||||
|
||||
std::pair<int, std::string> StoreInventoryResource::handleStdException(const std::exception& e)
|
||||
{
|
||||
return std::make_pair<int, std::string>(500, e.what());
|
||||
}
|
||||
|
||||
std::pair<int, std::string> StoreInventoryResource::handleUnspecifiedException()
|
||||
{
|
||||
return std::make_pair<int, std::string>(500, "Unknown exception occurred");
|
||||
}
|
||||
|
||||
void StoreInventoryResource::setResponseHeader(const std::shared_ptr<restbed::Session>& session, const std::string& header)
|
||||
{
|
||||
session->set_header(header, "");
|
||||
}
|
||||
|
||||
void StoreInventoryResource::returnResponse(const std::shared_ptr<restbed::Session>& session, const int status, const std::string& result, std::multimap<std::string, std::string>& responseHeaders)
|
||||
{
|
||||
responseHeaders.insert(std::make_pair("Connection", "close"));
|
||||
session->close(status, result, responseHeaders);
|
||||
}
|
||||
|
||||
void StoreInventoryResource::defaultSessionClose(const std::shared_ptr<restbed::Session>& session, const int status, const std::string& result)
|
||||
{
|
||||
session->close(status, result, { {"Connection", "close"} });
|
||||
}
|
||||
|
||||
void StoreInventoryResource::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();
|
||||
}
|
||||
|
||||
std::multimap< std::string, std::string > responseHeaders {};
|
||||
static const std::vector<std::string> contentTypes{
|
||||
"application/json",
|
||||
};
|
||||
static const std::string acceptTypes{
|
||||
};
|
||||
|
||||
if (status_code == 200) {
|
||||
responseHeaders.insert(std::make_pair("Content-Type", selectPreferredContentType(contentTypes)));
|
||||
if (!acceptTypes.empty()) {
|
||||
responseHeaders.insert(std::make_pair("Accept", acceptTypes));
|
||||
}
|
||||
|
||||
result = convertMapResponse(resultObject);
|
||||
returnResponse(session, 200, result.empty() ? "{}" : result, responseHeaders);
|
||||
return;
|
||||
}
|
||||
defaultSessionClose(session, status_code, result);
|
||||
}
|
||||
|
||||
|
||||
std::pair<int, std::map<std::string, int32_t>> StoreInventoryResource::handler_GET(
|
||||
)
|
||||
{
|
||||
return handler_GET_func();
|
||||
}
|
||||
|
||||
|
||||
std::string StoreInventoryResource::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;
|
||||
}
|
||||
|
||||
std::string StoreInventoryResource::extractFormParamsFromBody(const std::string& paramName, const std::string& body) {
|
||||
const auto uri = restbed::Uri("urlencoded?" + body, true);
|
||||
const auto params = uri.get_query_parameters();
|
||||
const auto result = params.find(paramName);
|
||||
if (result != params.cend()) {
|
||||
return result->second;
|
||||
}
|
||||
return "";
|
||||
}
|
||||
StoreOrderResource::StoreOrderResource(const std::string& context /* = "/v2" */)
|
||||
{
|
||||
this->set_path(context + "/store/order");
|
||||
this->set_method_handler("POST",
|
||||
std::bind(&StoreOrderResource::handler_POST_internal, this,
|
||||
std::placeholders::_1));
|
||||
}
|
||||
|
||||
std::pair<int, std::string> StoreOrderResource::handleStoreApiException(const StoreApiException& e)
|
||||
{
|
||||
return std::make_pair<int, std::string>(e.getStatus(), e.what());
|
||||
}
|
||||
|
||||
std::pair<int, std::string> StoreOrderResource::handleStdException(const std::exception& e)
|
||||
{
|
||||
return std::make_pair<int, std::string>(500, e.what());
|
||||
}
|
||||
|
||||
std::pair<int, std::string> StoreOrderResource::handleUnspecifiedException()
|
||||
{
|
||||
return std::make_pair<int, std::string>(500, "Unknown exception occurred");
|
||||
}
|
||||
|
||||
void StoreOrderResource::setResponseHeader(const std::shared_ptr<restbed::Session>& session, const std::string& header)
|
||||
{
|
||||
session->set_header(header, "");
|
||||
}
|
||||
|
||||
void StoreOrderResource::returnResponse(const std::shared_ptr<restbed::Session>& session, const int status, const std::string& result, std::multimap<std::string, std::string>& responseHeaders)
|
||||
{
|
||||
responseHeaders.insert(std::make_pair("Connection", "close"));
|
||||
session->close(status, result, responseHeaders);
|
||||
}
|
||||
|
||||
void StoreOrderResource::defaultSessionClose(const std::shared_ptr<restbed::Session>& session, const int status, const std::string& result)
|
||||
{
|
||||
session->close(status, result, { {"Connection", "close"} });
|
||||
}
|
||||
|
||||
void StoreOrderResource::handler_POST_internal(const std::shared_ptr<restbed::Session> session)
|
||||
{
|
||||
const auto request = session->get_request();
|
||||
// body params or form params here from the body content string
|
||||
std::string bodyContent = extractBodyContent(session);
|
||||
auto order = extractJsonModelBodyParam<Order>(bodyContent);
|
||||
|
||||
int status_code = 500;
|
||||
Order resultObject = 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();
|
||||
}
|
||||
|
||||
std::multimap< std::string, std::string > responseHeaders {};
|
||||
static const std::vector<std::string> contentTypes{
|
||||
"application/xml","application/json",
|
||||
};
|
||||
static const std::string acceptTypes{
|
||||
"application/json, "
|
||||
};
|
||||
|
||||
if (status_code == 200) {
|
||||
responseHeaders.insert(std::make_pair("Content-Type", selectPreferredContentType(contentTypes)));
|
||||
if (!acceptTypes.empty()) {
|
||||
responseHeaders.insert(std::make_pair("Accept", acceptTypes));
|
||||
}
|
||||
|
||||
result = resultObject.toJsonString();
|
||||
returnResponse(session, 200, result.empty() ? "{}" : result, responseHeaders);
|
||||
return;
|
||||
}
|
||||
if (status_code == 400) {
|
||||
responseHeaders.insert(std::make_pair("Content-Type", "text/plain"));
|
||||
result = "Invalid Order";
|
||||
|
||||
returnResponse(session, 400, result.empty() ? "{}" : result, responseHeaders);
|
||||
return;
|
||||
}
|
||||
defaultSessionClose(session, status_code, result);
|
||||
}
|
||||
|
||||
|
||||
std::pair<int, Order> StoreOrderResource::handler_POST(
|
||||
Order & order)
|
||||
{
|
||||
return handler_POST_func(order);
|
||||
}
|
||||
|
||||
|
||||
std::string StoreOrderResource::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;
|
||||
}
|
||||
|
||||
std::string StoreOrderResource::extractFormParamsFromBody(const std::string& paramName, const std::string& body) {
|
||||
const auto uri = restbed::Uri("urlencoded?" + body, true);
|
||||
const auto params = uri.get_query_parameters();
|
||||
const auto result = params.find(paramName);
|
||||
if (result != params.cend()) {
|
||||
return result->second;
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
} /* namespace StoreApiResources */
|
||||
|
||||
StoreApi::StoreApi(std::shared_ptr<restbed::Service> const& restbedService)
|
||||
: m_service(restbedService)
|
||||
{
|
||||
}
|
||||
|
||||
StoreApi::~StoreApi() {}
|
||||
|
||||
std::shared_ptr<StoreApiResources::StoreOrderOrder_idResource> StoreApi::getStoreOrderOrder_idResource() {
|
||||
if (!m_spStoreOrderOrder_idResource) {
|
||||
setResource(std::make_shared<StoreApiResources::StoreOrderOrder_idResource>());
|
||||
}
|
||||
return m_spStoreOrderOrder_idResource;
|
||||
}
|
||||
std::shared_ptr<StoreApiResources::StoreInventoryResource> StoreApi::getStoreInventoryResource() {
|
||||
if (!m_spStoreInventoryResource) {
|
||||
setResource(std::make_shared<StoreApiResources::StoreInventoryResource>());
|
||||
}
|
||||
return m_spStoreInventoryResource;
|
||||
}
|
||||
std::shared_ptr<StoreApiResources::StoreOrderResource> StoreApi::getStoreOrderResource() {
|
||||
if (!m_spStoreOrderResource) {
|
||||
setResource(std::make_shared<StoreApiResources::StoreOrderResource>());
|
||||
}
|
||||
return m_spStoreOrderResource;
|
||||
}
|
||||
void StoreApi::setResource(std::shared_ptr<StoreApiResources::StoreOrderOrder_idResource> resource) {
|
||||
m_spStoreOrderOrder_idResource = resource;
|
||||
m_service->publish(m_spStoreOrderOrder_idResource);
|
||||
}
|
||||
void StoreApi::setResource(std::shared_ptr<StoreApiResources::StoreInventoryResource> resource) {
|
||||
m_spStoreInventoryResource = resource;
|
||||
m_service->publish(m_spStoreInventoryResource);
|
||||
}
|
||||
void StoreApi::setResource(std::shared_ptr<StoreApiResources::StoreOrderResource> resource) {
|
||||
m_spStoreOrderResource = resource;
|
||||
m_service->publish(m_spStoreOrderResource);
|
||||
}
|
||||
void StoreApi::setStoreApiStoreOrderOrder_idResource(std::shared_ptr<StoreApiResources::StoreOrderOrder_idResource> spStoreOrderOrder_idResource) {
|
||||
m_spStoreOrderOrder_idResource = spStoreOrderOrder_idResource;
|
||||
m_service->publish(m_spStoreOrderOrder_idResource);
|
||||
}
|
||||
void StoreApi::setStoreApiStoreInventoryResource(std::shared_ptr<StoreApiResources::StoreInventoryResource> spStoreInventoryResource) {
|
||||
m_spStoreInventoryResource = spStoreInventoryResource;
|
||||
m_service->publish(m_spStoreInventoryResource);
|
||||
}
|
||||
void StoreApi::setStoreApiStoreOrderResource(std::shared_ptr<StoreApiResources::StoreOrderResource> spStoreOrderResource) {
|
||||
m_spStoreOrderResource = spStoreOrderResource;
|
||||
m_service->publish(m_spStoreOrderResource);
|
||||
}
|
||||
|
||||
|
||||
void StoreApi::publishDefaultResources() {
|
||||
if (!m_spStoreOrderOrder_idResource) {
|
||||
setResource(std::make_shared<StoreApiResources::StoreOrderOrder_idResource>());
|
||||
}
|
||||
if (!m_spStoreInventoryResource) {
|
||||
setResource(std::make_shared<StoreApiResources::StoreInventoryResource>());
|
||||
}
|
||||
if (!m_spStoreOrderResource) {
|
||||
setResource(std::make_shared<StoreApiResources::StoreOrderResource>());
|
||||
}
|
||||
}
|
||||
|
||||
std::shared_ptr<restbed::Service> StoreApi::service() {
|
||||
return m_service;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
305
samples/server/petstore/cpp-restbed/generated/3_0/api/StoreApi.h
Normal file
305
samples/server/petstore/cpp-restbed/generated/3_0/api/StoreApi.h
Normal file
@@ -0,0 +1,305 @@
|
||||
/**
|
||||
* OpenAPI Petstore
|
||||
* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
|
||||
*
|
||||
* The version of the OpenAPI document: 1.0.0
|
||||
*
|
||||
*
|
||||
* NOTE: This class is auto generated by OpenAPI-Generator 7.0.0-SNAPSHOT.
|
||||
* 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 <functional>
|
||||
|
||||
#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;
|
||||
};
|
||||
|
||||
namespace StoreApiResources {
|
||||
/// <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 StoreOrderOrder_idResource: public restbed::Resource
|
||||
{
|
||||
public:
|
||||
StoreOrderOrder_idResource(const std::string& context = "/v2");
|
||||
virtual ~StoreOrderOrder_idResource() = default;
|
||||
|
||||
StoreOrderOrder_idResource(
|
||||
const StoreOrderOrder_idResource& other) = default; // copy constructor
|
||||
StoreOrderOrder_idResource(StoreOrderOrder_idResource&& other) noexcept = default; // move constructor
|
||||
|
||||
StoreOrderOrder_idResource& operator=(const StoreOrderOrder_idResource& other) = default; // copy assignment
|
||||
StoreOrderOrder_idResource& operator=(StoreOrderOrder_idResource&& other) noexcept = default; // move assignment
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
// Set these to implement the server functionality //
|
||||
/////////////////////////////////////////////////////
|
||||
std::function<int(
|
||||
std::string & orderId)> handler_DELETE_func =
|
||||
[](std::string &) -> int
|
||||
{ throw StoreApiException(501, "Not implemented"); };
|
||||
|
||||
std::function<std::pair<int, Order>(
|
||||
int64_t & orderId)> handler_GET_func =
|
||||
[](int64_t &) -> std::pair<int, Order>
|
||||
{ throw StoreApiException(501, "Not implemented"); };
|
||||
|
||||
|
||||
protected:
|
||||
//////////////////////////////////////////////////////////
|
||||
// As an alternative to setting the `std::function`s //
|
||||
// override these to implement the server functionality //
|
||||
//////////////////////////////////////////////////////////
|
||||
|
||||
virtual int handler_DELETE(
|
||||
std::string & orderId);
|
||||
|
||||
virtual std::pair<int, Order> handler_GET(
|
||||
int64_t & orderId);
|
||||
|
||||
protected:
|
||||
//////////////////////////////////////
|
||||
// Override these for customization //
|
||||
//////////////////////////////////////
|
||||
|
||||
virtual std::string extractBodyContent(const std::shared_ptr<restbed::Session>& session);
|
||||
virtual std::string extractFormParamsFromBody(const std::string& paramName, const std::string& body);
|
||||
|
||||
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, std::multimap<std::string, 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 StoreInventoryResource: public restbed::Resource
|
||||
{
|
||||
public:
|
||||
StoreInventoryResource(const std::string& context = "/v2");
|
||||
virtual ~StoreInventoryResource() = default;
|
||||
|
||||
StoreInventoryResource(
|
||||
const StoreInventoryResource& other) = default; // copy constructor
|
||||
StoreInventoryResource(StoreInventoryResource&& other) noexcept = default; // move constructor
|
||||
|
||||
StoreInventoryResource& operator=(const StoreInventoryResource& other) = default; // copy assignment
|
||||
StoreInventoryResource& operator=(StoreInventoryResource&& other) noexcept = default; // move assignment
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
// Set these to implement the server functionality //
|
||||
/////////////////////////////////////////////////////
|
||||
std::function<std::pair<int, std::map<std::string, int32_t>>(
|
||||
)> handler_GET_func =
|
||||
[]() -> std::pair<int, std::map<std::string, int32_t>>
|
||||
{ throw StoreApiException(501, "Not implemented"); };
|
||||
|
||||
|
||||
protected:
|
||||
//////////////////////////////////////////////////////////
|
||||
// As an alternative to setting the `std::function`s //
|
||||
// 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::string extractFormParamsFromBody(const std::string& paramName, const std::string& body);
|
||||
|
||||
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, std::multimap<std::string, 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 StoreOrderResource: public restbed::Resource
|
||||
{
|
||||
public:
|
||||
StoreOrderResource(const std::string& context = "/v2");
|
||||
virtual ~StoreOrderResource() = default;
|
||||
|
||||
StoreOrderResource(
|
||||
const StoreOrderResource& other) = default; // copy constructor
|
||||
StoreOrderResource(StoreOrderResource&& other) noexcept = default; // move constructor
|
||||
|
||||
StoreOrderResource& operator=(const StoreOrderResource& other) = default; // copy assignment
|
||||
StoreOrderResource& operator=(StoreOrderResource&& other) noexcept = default; // move assignment
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
// Set these to implement the server functionality //
|
||||
/////////////////////////////////////////////////////
|
||||
std::function<std::pair<int, Order>(
|
||||
Order & order)> handler_POST_func =
|
||||
[](Order &) -> std::pair<int, Order>
|
||||
{ throw StoreApiException(501, "Not implemented"); };
|
||||
|
||||
|
||||
protected:
|
||||
//////////////////////////////////////////////////////////
|
||||
// As an alternative to setting the `std::function`s //
|
||||
// override these to implement the server functionality //
|
||||
//////////////////////////////////////////////////////////
|
||||
|
||||
virtual std::pair<int, Order> handler_POST(
|
||||
Order & order);
|
||||
|
||||
|
||||
protected:
|
||||
//////////////////////////////////////
|
||||
// Override these for customization //
|
||||
//////////////////////////////////////
|
||||
|
||||
virtual std::string extractBodyContent(const std::shared_ptr<restbed::Session>& session);
|
||||
virtual std::string extractFormParamsFromBody(const std::string& paramName, const std::string& body);
|
||||
|
||||
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, std::multimap<std::string, 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);
|
||||
};
|
||||
|
||||
} /* namespace StoreApiResources */
|
||||
|
||||
using StoreApiStoreOrderOrder_idResource [[deprecated]] = StoreApiResources::StoreOrderOrder_idResource;
|
||||
using StoreApiStoreInventoryResource [[deprecated]] = StoreApiResources::StoreInventoryResource;
|
||||
using StoreApiStoreOrderResource [[deprecated]] = StoreApiResources::StoreOrderResource;
|
||||
|
||||
//
|
||||
// The restbed service to actually implement the REST server
|
||||
//
|
||||
class StoreApi
|
||||
{
|
||||
public:
|
||||
explicit StoreApi(std::shared_ptr<restbed::Service> const& restbedService);
|
||||
virtual ~StoreApi();
|
||||
|
||||
std::shared_ptr<StoreApiResources::StoreOrderOrder_idResource> getStoreOrderOrder_idResource();
|
||||
std::shared_ptr<StoreApiResources::StoreInventoryResource> getStoreInventoryResource();
|
||||
std::shared_ptr<StoreApiResources::StoreOrderResource> getStoreOrderResource();
|
||||
|
||||
void setResource(std::shared_ptr<StoreApiResources::StoreOrderOrder_idResource> resource);
|
||||
void setResource(std::shared_ptr<StoreApiResources::StoreInventoryResource> resource);
|
||||
void setResource(std::shared_ptr<StoreApiResources::StoreOrderResource> resource);
|
||||
[[deprecated("use setResource()")]]
|
||||
virtual void setStoreApiStoreOrderOrder_idResource(std::shared_ptr<StoreApiResources::StoreOrderOrder_idResource> spStoreApiStoreOrderOrder_idResource);
|
||||
[[deprecated("use setResource()")]]
|
||||
virtual void setStoreApiStoreInventoryResource(std::shared_ptr<StoreApiResources::StoreInventoryResource> spStoreApiStoreInventoryResource);
|
||||
[[deprecated("use setResource()")]]
|
||||
virtual void setStoreApiStoreOrderResource(std::shared_ptr<StoreApiResources::StoreOrderResource> spStoreApiStoreOrderResource);
|
||||
|
||||
virtual void publishDefaultResources();
|
||||
|
||||
virtual std::shared_ptr<restbed::Service> service();
|
||||
|
||||
protected:
|
||||
std::shared_ptr<StoreApiResources::StoreOrderOrder_idResource> m_spStoreOrderOrder_idResource;
|
||||
std::shared_ptr<StoreApiResources::StoreInventoryResource> m_spStoreInventoryResource;
|
||||
std::shared_ptr<StoreApiResources::StoreOrderResource> m_spStoreOrderResource;
|
||||
|
||||
private:
|
||||
std::shared_ptr<restbed::Service> m_service;
|
||||
};
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif /* StoreApi_H_ */
|
||||
|
||||
1047
samples/server/petstore/cpp-restbed/generated/3_0/api/UserApi.cpp
Normal file
1047
samples/server/petstore/cpp-restbed/generated/3_0/api/UserApi.cpp
Normal file
File diff suppressed because it is too large
Load Diff
517
samples/server/petstore/cpp-restbed/generated/3_0/api/UserApi.h
Normal file
517
samples/server/petstore/cpp-restbed/generated/3_0/api/UserApi.h
Normal file
@@ -0,0 +1,517 @@
|
||||
/**
|
||||
* OpenAPI Petstore
|
||||
* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
|
||||
*
|
||||
* The version of the OpenAPI document: 1.0.0
|
||||
*
|
||||
*
|
||||
* NOTE: This class is auto generated by OpenAPI-Generator 7.0.0-SNAPSHOT.
|
||||
* 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 <functional>
|
||||
|
||||
#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;
|
||||
};
|
||||
|
||||
namespace UserApiResources {
|
||||
/// <summary>
|
||||
/// Create user
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// This can only be done by the logged in user.
|
||||
/// </remarks>
|
||||
class UserResource: public restbed::Resource
|
||||
{
|
||||
public:
|
||||
UserResource(const std::string& context = "/v2");
|
||||
virtual ~UserResource() = default;
|
||||
|
||||
UserResource(
|
||||
const UserResource& other) = default; // copy constructor
|
||||
UserResource(UserResource&& other) noexcept = default; // move constructor
|
||||
|
||||
UserResource& operator=(const UserResource& other) = default; // copy assignment
|
||||
UserResource& operator=(UserResource&& other) noexcept = default; // move assignment
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
// Set these to implement the server functionality //
|
||||
/////////////////////////////////////////////////////
|
||||
std::function<int(
|
||||
User & user)> handler_POST_func =
|
||||
[](User &) -> int
|
||||
{ throw UserApiException(501, "Not implemented"); };
|
||||
|
||||
|
||||
protected:
|
||||
//////////////////////////////////////////////////////////
|
||||
// As an alternative to setting the `std::function`s //
|
||||
// override these to implement the server functionality //
|
||||
//////////////////////////////////////////////////////////
|
||||
|
||||
virtual int handler_POST(
|
||||
User & user);
|
||||
|
||||
|
||||
protected:
|
||||
//////////////////////////////////////
|
||||
// Override these for customization //
|
||||
//////////////////////////////////////
|
||||
|
||||
virtual std::string extractBodyContent(const std::shared_ptr<restbed::Session>& session);
|
||||
virtual std::string extractFormParamsFromBody(const std::string& paramName, const std::string& body);
|
||||
|
||||
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, std::multimap<std::string, 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 UserCreateWithArrayResource: public restbed::Resource
|
||||
{
|
||||
public:
|
||||
UserCreateWithArrayResource(const std::string& context = "/v2");
|
||||
virtual ~UserCreateWithArrayResource() = default;
|
||||
|
||||
UserCreateWithArrayResource(
|
||||
const UserCreateWithArrayResource& other) = default; // copy constructor
|
||||
UserCreateWithArrayResource(UserCreateWithArrayResource&& other) noexcept = default; // move constructor
|
||||
|
||||
UserCreateWithArrayResource& operator=(const UserCreateWithArrayResource& other) = default; // copy assignment
|
||||
UserCreateWithArrayResource& operator=(UserCreateWithArrayResource&& other) noexcept = default; // move assignment
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
// Set these to implement the server functionality //
|
||||
/////////////////////////////////////////////////////
|
||||
std::function<int(
|
||||
std::vector<User> & user)> handler_POST_func =
|
||||
[](std::vector<User> &) -> int
|
||||
{ throw UserApiException(501, "Not implemented"); };
|
||||
|
||||
|
||||
protected:
|
||||
//////////////////////////////////////////////////////////
|
||||
// As an alternative to setting the `std::function`s //
|
||||
// override these to implement the server functionality //
|
||||
//////////////////////////////////////////////////////////
|
||||
|
||||
virtual int handler_POST(
|
||||
std::vector<User> & user);
|
||||
|
||||
|
||||
protected:
|
||||
//////////////////////////////////////
|
||||
// Override these for customization //
|
||||
//////////////////////////////////////
|
||||
|
||||
virtual std::string extractBodyContent(const std::shared_ptr<restbed::Session>& session);
|
||||
virtual std::string extractFormParamsFromBody(const std::string& paramName, const std::string& body);
|
||||
|
||||
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, std::multimap<std::string, 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 UserCreateWithListResource: public restbed::Resource
|
||||
{
|
||||
public:
|
||||
UserCreateWithListResource(const std::string& context = "/v2");
|
||||
virtual ~UserCreateWithListResource() = default;
|
||||
|
||||
UserCreateWithListResource(
|
||||
const UserCreateWithListResource& other) = default; // copy constructor
|
||||
UserCreateWithListResource(UserCreateWithListResource&& other) noexcept = default; // move constructor
|
||||
|
||||
UserCreateWithListResource& operator=(const UserCreateWithListResource& other) = default; // copy assignment
|
||||
UserCreateWithListResource& operator=(UserCreateWithListResource&& other) noexcept = default; // move assignment
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
// Set these to implement the server functionality //
|
||||
/////////////////////////////////////////////////////
|
||||
std::function<int(
|
||||
std::vector<User> & user)> handler_POST_func =
|
||||
[](std::vector<User> &) -> int
|
||||
{ throw UserApiException(501, "Not implemented"); };
|
||||
|
||||
|
||||
protected:
|
||||
//////////////////////////////////////////////////////////
|
||||
// As an alternative to setting the `std::function`s //
|
||||
// override these to implement the server functionality //
|
||||
//////////////////////////////////////////////////////////
|
||||
|
||||
virtual int handler_POST(
|
||||
std::vector<User> & user);
|
||||
|
||||
|
||||
protected:
|
||||
//////////////////////////////////////
|
||||
// Override these for customization //
|
||||
//////////////////////////////////////
|
||||
|
||||
virtual std::string extractBodyContent(const std::shared_ptr<restbed::Session>& session);
|
||||
virtual std::string extractFormParamsFromBody(const std::string& paramName, const std::string& body);
|
||||
|
||||
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, std::multimap<std::string, 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 UserUsernameResource: public restbed::Resource
|
||||
{
|
||||
public:
|
||||
UserUsernameResource(const std::string& context = "/v2");
|
||||
virtual ~UserUsernameResource() = default;
|
||||
|
||||
UserUsernameResource(
|
||||
const UserUsernameResource& other) = default; // copy constructor
|
||||
UserUsernameResource(UserUsernameResource&& other) noexcept = default; // move constructor
|
||||
|
||||
UserUsernameResource& operator=(const UserUsernameResource& other) = default; // copy assignment
|
||||
UserUsernameResource& operator=(UserUsernameResource&& other) noexcept = default; // move assignment
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
// Set these to implement the server functionality //
|
||||
/////////////////////////////////////////////////////
|
||||
std::function<int(
|
||||
std::string & username)> handler_DELETE_func =
|
||||
[](std::string &) -> int
|
||||
{ throw UserApiException(501, "Not implemented"); };
|
||||
|
||||
std::function<std::pair<int, User>(
|
||||
std::string & username)> handler_GET_func =
|
||||
[](std::string &) -> std::pair<int, User>
|
||||
{ throw UserApiException(501, "Not implemented"); };
|
||||
|
||||
std::function<int(
|
||||
std::string & username, User & user)> handler_PUT_func =
|
||||
[](std::string &, User &) -> int
|
||||
{ throw UserApiException(501, "Not implemented"); };
|
||||
|
||||
|
||||
protected:
|
||||
//////////////////////////////////////////////////////////
|
||||
// As an alternative to setting the `std::function`s //
|
||||
// override these to implement the server functionality //
|
||||
//////////////////////////////////////////////////////////
|
||||
|
||||
virtual int handler_DELETE(
|
||||
std::string & username);
|
||||
|
||||
virtual std::pair<int, User> handler_GET(
|
||||
std::string & username);
|
||||
virtual int handler_PUT(
|
||||
std::string & username, User & user);
|
||||
|
||||
protected:
|
||||
//////////////////////////////////////
|
||||
// Override these for customization //
|
||||
//////////////////////////////////////
|
||||
|
||||
virtual std::string extractBodyContent(const std::shared_ptr<restbed::Session>& session);
|
||||
virtual std::string extractFormParamsFromBody(const std::string& paramName, const std::string& body);
|
||||
|
||||
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, std::multimap<std::string, 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 UserLoginResource: public restbed::Resource
|
||||
{
|
||||
public:
|
||||
UserLoginResource(const std::string& context = "/v2");
|
||||
virtual ~UserLoginResource() = default;
|
||||
|
||||
UserLoginResource(
|
||||
const UserLoginResource& other) = default; // copy constructor
|
||||
UserLoginResource(UserLoginResource&& other) noexcept = default; // move constructor
|
||||
|
||||
UserLoginResource& operator=(const UserLoginResource& other) = default; // copy assignment
|
||||
UserLoginResource& operator=(UserLoginResource&& other) noexcept = default; // move assignment
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
// Set these to implement the server functionality //
|
||||
/////////////////////////////////////////////////////
|
||||
std::function<std::pair<int, std::string>(
|
||||
std::string & username, std::string & password)> handler_GET_func =
|
||||
[](std::string &, std::string &) -> std::pair<int, std::string>
|
||||
{ throw UserApiException(501, "Not implemented"); };
|
||||
|
||||
|
||||
protected:
|
||||
//////////////////////////////////////////////////////////
|
||||
// As an alternative to setting the `std::function`s //
|
||||
// override these to implement the server functionality //
|
||||
//////////////////////////////////////////////////////////
|
||||
|
||||
virtual std::pair<int, std::string> handler_GET(
|
||||
std::string & username, std::string & password);
|
||||
|
||||
|
||||
protected:
|
||||
//////////////////////////////////////
|
||||
// Override these for customization //
|
||||
//////////////////////////////////////
|
||||
|
||||
virtual std::string extractBodyContent(const std::shared_ptr<restbed::Session>& session);
|
||||
virtual std::string extractFormParamsFromBody(const std::string& paramName, const std::string& body);
|
||||
|
||||
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, std::multimap<std::string, 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 UserLogoutResource: public restbed::Resource
|
||||
{
|
||||
public:
|
||||
UserLogoutResource(const std::string& context = "/v2");
|
||||
virtual ~UserLogoutResource() = default;
|
||||
|
||||
UserLogoutResource(
|
||||
const UserLogoutResource& other) = default; // copy constructor
|
||||
UserLogoutResource(UserLogoutResource&& other) noexcept = default; // move constructor
|
||||
|
||||
UserLogoutResource& operator=(const UserLogoutResource& other) = default; // copy assignment
|
||||
UserLogoutResource& operator=(UserLogoutResource&& other) noexcept = default; // move assignment
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
// Set these to implement the server functionality //
|
||||
/////////////////////////////////////////////////////
|
||||
std::function<int(
|
||||
)> handler_GET_func =
|
||||
[]() -> int
|
||||
{ throw UserApiException(501, "Not implemented"); };
|
||||
|
||||
|
||||
protected:
|
||||
//////////////////////////////////////////////////////////
|
||||
// As an alternative to setting the `std::function`s //
|
||||
// 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::string extractFormParamsFromBody(const std::string& paramName, const std::string& body);
|
||||
|
||||
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, std::multimap<std::string, 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);
|
||||
};
|
||||
|
||||
} /* namespace UserApiResources */
|
||||
|
||||
using UserApiUserResource [[deprecated]] = UserApiResources::UserResource;
|
||||
using UserApiUserCreateWithArrayResource [[deprecated]] = UserApiResources::UserCreateWithArrayResource;
|
||||
using UserApiUserCreateWithListResource [[deprecated]] = UserApiResources::UserCreateWithListResource;
|
||||
using UserApiUserUsernameResource [[deprecated]] = UserApiResources::UserUsernameResource;
|
||||
using UserApiUserLoginResource [[deprecated]] = UserApiResources::UserLoginResource;
|
||||
using UserApiUserLogoutResource [[deprecated]] = UserApiResources::UserLogoutResource;
|
||||
|
||||
//
|
||||
// The restbed service to actually implement the REST server
|
||||
//
|
||||
class UserApi
|
||||
{
|
||||
public:
|
||||
explicit UserApi(std::shared_ptr<restbed::Service> const& restbedService);
|
||||
virtual ~UserApi();
|
||||
|
||||
std::shared_ptr<UserApiResources::UserResource> getUserResource();
|
||||
std::shared_ptr<UserApiResources::UserCreateWithArrayResource> getUserCreateWithArrayResource();
|
||||
std::shared_ptr<UserApiResources::UserCreateWithListResource> getUserCreateWithListResource();
|
||||
std::shared_ptr<UserApiResources::UserUsernameResource> getUserUsernameResource();
|
||||
std::shared_ptr<UserApiResources::UserLoginResource> getUserLoginResource();
|
||||
std::shared_ptr<UserApiResources::UserLogoutResource> getUserLogoutResource();
|
||||
|
||||
void setResource(std::shared_ptr<UserApiResources::UserResource> resource);
|
||||
void setResource(std::shared_ptr<UserApiResources::UserCreateWithArrayResource> resource);
|
||||
void setResource(std::shared_ptr<UserApiResources::UserCreateWithListResource> resource);
|
||||
void setResource(std::shared_ptr<UserApiResources::UserUsernameResource> resource);
|
||||
void setResource(std::shared_ptr<UserApiResources::UserLoginResource> resource);
|
||||
void setResource(std::shared_ptr<UserApiResources::UserLogoutResource> resource);
|
||||
[[deprecated("use setResource()")]]
|
||||
virtual void setUserApiUserResource(std::shared_ptr<UserApiResources::UserResource> spUserApiUserResource);
|
||||
[[deprecated("use setResource()")]]
|
||||
virtual void setUserApiUserCreateWithArrayResource(std::shared_ptr<UserApiResources::UserCreateWithArrayResource> spUserApiUserCreateWithArrayResource);
|
||||
[[deprecated("use setResource()")]]
|
||||
virtual void setUserApiUserCreateWithListResource(std::shared_ptr<UserApiResources::UserCreateWithListResource> spUserApiUserCreateWithListResource);
|
||||
[[deprecated("use setResource()")]]
|
||||
virtual void setUserApiUserUsernameResource(std::shared_ptr<UserApiResources::UserUsernameResource> spUserApiUserUsernameResource);
|
||||
[[deprecated("use setResource()")]]
|
||||
virtual void setUserApiUserLoginResource(std::shared_ptr<UserApiResources::UserLoginResource> spUserApiUserLoginResource);
|
||||
[[deprecated("use setResource()")]]
|
||||
virtual void setUserApiUserLogoutResource(std::shared_ptr<UserApiResources::UserLogoutResource> spUserApiUserLogoutResource);
|
||||
|
||||
virtual void publishDefaultResources();
|
||||
|
||||
virtual std::shared_ptr<restbed::Service> service();
|
||||
|
||||
protected:
|
||||
std::shared_ptr<UserApiResources::UserResource> m_spUserResource;
|
||||
std::shared_ptr<UserApiResources::UserCreateWithArrayResource> m_spUserCreateWithArrayResource;
|
||||
std::shared_ptr<UserApiResources::UserCreateWithListResource> m_spUserCreateWithListResource;
|
||||
std::shared_ptr<UserApiResources::UserUsernameResource> m_spUserUsernameResource;
|
||||
std::shared_ptr<UserApiResources::UserLoginResource> m_spUserLoginResource;
|
||||
std::shared_ptr<UserApiResources::UserLogoutResource> m_spUserLogoutResource;
|
||||
|
||||
private:
|
||||
std::shared_ptr<restbed::Service> m_service;
|
||||
};
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif /* UserApi_H_ */
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#!/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-pestore-perl "minor update" "gitlab.com"
|
||||
# Usage example: /bin/sh ./git_push.sh wing328 openapi-petstore-perl "minor update" "gitlab.com"
|
||||
|
||||
git_user_id=$1
|
||||
git_repo_id=$2
|
||||
@@ -38,14 +38,14 @@ git add .
|
||||
git commit -m "$release_note"
|
||||
|
||||
# Sets the new remote
|
||||
git_remote=`git 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
|
||||
git remote add origin https://${git_user_id}:"${GIT_TOKEN}"@${git_host}/${git_user_id}/${git_repo_id}.git
|
||||
fi
|
||||
|
||||
fi
|
||||
@@ -55,4 +55,3 @@ 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,118 @@
|
||||
/**
|
||||
* OpenAPI Petstore
|
||||
* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
|
||||
*
|
||||
* The version of the OpenAPI document: 1.0.0
|
||||
*
|
||||
*
|
||||
* NOTE: This class is auto generated by OpenAPI-Generator 6.1.0-SNAPSHOT.
|
||||
* https://openapi-generator.tech
|
||||
* Do not edit the class manually.
|
||||
*/
|
||||
|
||||
|
||||
|
||||
#include "200_response.h"
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <map>
|
||||
#include <sstream>
|
||||
#include <stdexcept>
|
||||
#include <regex>
|
||||
#include <boost/lexical_cast.hpp>
|
||||
#include <boost/property_tree/ptree.hpp>
|
||||
#include <boost/property_tree/json_parser.hpp>
|
||||
#include "helpers.h"
|
||||
|
||||
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 {
|
||||
|
||||
200_response::200_response(boost::property_tree::ptree const& pt)
|
||||
{
|
||||
fromPropertyTree(pt);
|
||||
}
|
||||
|
||||
|
||||
std::string 200_response::toJsonString(bool prettyJson /* = false */) const
|
||||
{
|
||||
std::stringstream ss;
|
||||
write_json(ss, this->toPropertyTree(), prettyJson);
|
||||
// workaround inspired by: https://stackoverflow.com/a/56395440
|
||||
std::regex reg("\\\"([0-9]+\\.{0,1}[0-9]*)\\\"");
|
||||
std::string result = std::regex_replace(ss.str(), reg, "$1");
|
||||
return result;
|
||||
}
|
||||
|
||||
void 200_response::fromJsonString(std::string const& jsonString)
|
||||
{
|
||||
std::stringstream ss(jsonString);
|
||||
ptree pt;
|
||||
read_json(ss,pt);
|
||||
this->fromPropertyTree(pt);
|
||||
}
|
||||
|
||||
ptree 200_response::toPropertyTree() const
|
||||
{
|
||||
ptree pt;
|
||||
ptree tmp_node;
|
||||
pt.put("name", m_Name);
|
||||
pt.put("class", m_r_class);
|
||||
return pt;
|
||||
}
|
||||
|
||||
void 200_response::fromPropertyTree(ptree const &pt)
|
||||
{
|
||||
ptree tmp_node;
|
||||
m_Name = pt.get("name", 0);
|
||||
m_r_class = pt.get("class", "");
|
||||
}
|
||||
|
||||
int32_t 200_response::getName() const
|
||||
{
|
||||
return m_Name;
|
||||
}
|
||||
|
||||
void 200_response::setName(int32_t value)
|
||||
{
|
||||
m_Name = value;
|
||||
}
|
||||
|
||||
|
||||
std::string 200_response::getRClass() const
|
||||
{
|
||||
return m_r_class;
|
||||
}
|
||||
|
||||
void 200_response::setRClass(std::string value)
|
||||
{
|
||||
m_r_class = value;
|
||||
}
|
||||
|
||||
|
||||
|
||||
std::vector<200_response> create200_responseVectorFromJsonString(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<200_response>();
|
||||
for (const auto& child: pt) {
|
||||
vec.emplace_back(200_response(child.second));
|
||||
}
|
||||
|
||||
return vec;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,96 @@
|
||||
/**
|
||||
* OpenAPI Petstore
|
||||
* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
|
||||
*
|
||||
* The version of the OpenAPI document: 1.0.0
|
||||
*
|
||||
*
|
||||
* NOTE: This class is auto generated by OpenAPI-Generator 6.1.0-SNAPSHOT.
|
||||
* https://openapi-generator.tech
|
||||
* Do not edit the class manually.
|
||||
*/
|
||||
|
||||
/*
|
||||
* 200_response.h
|
||||
*
|
||||
* Model for testing model name starting with number
|
||||
*/
|
||||
|
||||
#ifndef 200_response_H_
|
||||
#define 200_response_H_
|
||||
|
||||
|
||||
|
||||
#include <string>
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
#include <boost/property_tree/ptree.hpp>
|
||||
#include "helpers.h"
|
||||
|
||||
namespace org {
|
||||
namespace openapitools {
|
||||
namespace server {
|
||||
namespace model {
|
||||
|
||||
/// <summary>
|
||||
/// Model for testing model name starting with number
|
||||
/// </summary>
|
||||
class 200_response
|
||||
{
|
||||
public:
|
||||
200_response() = default;
|
||||
explicit 200_response(boost::property_tree::ptree const& pt);
|
||||
virtual ~200_response() = default;
|
||||
|
||||
200_response(const 200_response& other) = default; // copy constructor
|
||||
200_response(200_response&& other) noexcept = default; // move constructor
|
||||
|
||||
200_response& operator=(const 200_response& other) = default; // copy assignment
|
||||
200_response& operator=(200_response&& other) noexcept = default; // move assignment
|
||||
|
||||
std::string toJsonString(bool prettyJson = false) const;
|
||||
void fromJsonString(std::string const& jsonString);
|
||||
boost::property_tree::ptree toPropertyTree() const;
|
||||
void fromPropertyTree(boost::property_tree::ptree const& pt);
|
||||
|
||||
|
||||
/////////////////////////////////////////////
|
||||
/// 200_response members
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
int32_t getName() const;
|
||||
void setName(int32_t value);
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
std::string getRClass() const;
|
||||
void setRClass(std::string value);
|
||||
|
||||
protected:
|
||||
int32_t m_Name = 0;
|
||||
std::string m_r_class = "";
|
||||
};
|
||||
|
||||
std::vector<200_response> create200_responseVectorFromJsonString(const std::string& json);
|
||||
|
||||
template<>
|
||||
inline boost::property_tree::ptree toPt<200_response>(const 200_response& val) {
|
||||
return val.toPropertyTree();
|
||||
}
|
||||
|
||||
template<>
|
||||
inline 200_response fromPt<200_response>(const boost::property_tree::ptree& pt) {
|
||||
200_response ret;
|
||||
ret.fromPropertyTree(pt);
|
||||
return ret;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif /* 200_response_H_ */
|
||||
@@ -0,0 +1,132 @@
|
||||
/**
|
||||
* OpenAPI Petstore
|
||||
* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
|
||||
*
|
||||
* The version of the OpenAPI document: 1.0.0
|
||||
*
|
||||
*
|
||||
* NOTE: This class is auto generated by OpenAPI-Generator 7.0.0-SNAPSHOT.
|
||||
* https://openapi-generator.tech
|
||||
* Do not edit the class manually.
|
||||
*/
|
||||
|
||||
|
||||
|
||||
#include "AdditionalPropertiesClass.h"
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <map>
|
||||
#include <sstream>
|
||||
#include <stdexcept>
|
||||
#include <regex>
|
||||
#include <boost/lexical_cast.hpp>
|
||||
#include <boost/property_tree/ptree.hpp>
|
||||
#include <boost/property_tree/json_parser.hpp>
|
||||
#include "helpers.h"
|
||||
|
||||
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 {
|
||||
|
||||
AdditionalPropertiesClass::AdditionalPropertiesClass(boost::property_tree::ptree const& pt)
|
||||
{
|
||||
fromPropertyTree(pt);
|
||||
}
|
||||
|
||||
|
||||
std::string AdditionalPropertiesClass::toJsonString(bool prettyJson /* = false */) const
|
||||
{
|
||||
std::stringstream ss;
|
||||
write_json(ss, this->toPropertyTree(), prettyJson);
|
||||
// workaround inspired by: https://stackoverflow.com/a/56395440
|
||||
std::regex reg("\\\"([0-9]+\\.{0,1}[0-9]*)\\\"");
|
||||
std::string result = std::regex_replace(ss.str(), reg, "$1");
|
||||
return result;
|
||||
}
|
||||
|
||||
void AdditionalPropertiesClass::fromJsonString(std::string const& jsonString)
|
||||
{
|
||||
std::stringstream ss(jsonString);
|
||||
ptree pt;
|
||||
read_json(ss,pt);
|
||||
this->fromPropertyTree(pt);
|
||||
}
|
||||
|
||||
ptree AdditionalPropertiesClass::toPropertyTree() const
|
||||
{
|
||||
ptree pt;
|
||||
ptree tmp_node;
|
||||
// generate tree for Map_property
|
||||
if (!m_Map_property.empty()) {
|
||||
tmp_node = toPt(m_Map_property);
|
||||
pt.add_child("map_property", tmp_node);
|
||||
}
|
||||
tmp_node.clear();
|
||||
// generate tree for Map_of_map_property
|
||||
if (!m_Map_of_map_property.empty()) {
|
||||
tmp_node = toPt(m_Map_of_map_property);
|
||||
pt.add_child("map_of_map_property", tmp_node);
|
||||
}
|
||||
tmp_node.clear();
|
||||
return pt;
|
||||
}
|
||||
|
||||
void AdditionalPropertiesClass::fromPropertyTree(ptree const &pt)
|
||||
{
|
||||
ptree tmp_node;
|
||||
if (pt.get_child_optional("map_property")) {
|
||||
m_Map_property = fromPt<std::map<std::string, std::string>>(pt.get_child("map_property"));
|
||||
}
|
||||
if (pt.get_child_optional("map_of_map_property")) {
|
||||
m_Map_of_map_property = fromPt<std::map<std::string, std::map<std::string, std::string>>>(pt.get_child("map_of_map_property"));
|
||||
}
|
||||
}
|
||||
|
||||
std::map<std::string, std::string> AdditionalPropertiesClass::getMapProperty() const
|
||||
{
|
||||
return m_Map_property;
|
||||
}
|
||||
|
||||
void AdditionalPropertiesClass::setMapProperty(std::map<std::string, std::string> value)
|
||||
{
|
||||
m_Map_property = value;
|
||||
}
|
||||
|
||||
|
||||
std::map<std::string, std::map<std::string, std::string>> AdditionalPropertiesClass::getMapOfMapProperty() const
|
||||
{
|
||||
return m_Map_of_map_property;
|
||||
}
|
||||
|
||||
void AdditionalPropertiesClass::setMapOfMapProperty(std::map<std::string, std::map<std::string, std::string>> value)
|
||||
{
|
||||
m_Map_of_map_property = value;
|
||||
}
|
||||
|
||||
|
||||
|
||||
std::vector<AdditionalPropertiesClass> createAdditionalPropertiesClassVectorFromJsonString(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<AdditionalPropertiesClass>();
|
||||
for (const auto& child: pt) {
|
||||
vec.emplace_back(AdditionalPropertiesClass(child.second));
|
||||
}
|
||||
|
||||
return vec;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,97 @@
|
||||
/**
|
||||
* OpenAPI Petstore
|
||||
* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
|
||||
*
|
||||
* The version of the OpenAPI document: 1.0.0
|
||||
*
|
||||
*
|
||||
* NOTE: This class is auto generated by OpenAPI-Generator 7.0.0-SNAPSHOT.
|
||||
* https://openapi-generator.tech
|
||||
* Do not edit the class manually.
|
||||
*/
|
||||
|
||||
/*
|
||||
* AdditionalPropertiesClass.h
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef AdditionalPropertiesClass_H_
|
||||
#define AdditionalPropertiesClass_H_
|
||||
|
||||
|
||||
|
||||
#include <string>
|
||||
#include <map>
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
#include <boost/property_tree/ptree.hpp>
|
||||
#include "helpers.h"
|
||||
|
||||
namespace org {
|
||||
namespace openapitools {
|
||||
namespace server {
|
||||
namespace model {
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
class AdditionalPropertiesClass
|
||||
{
|
||||
public:
|
||||
AdditionalPropertiesClass() = default;
|
||||
explicit AdditionalPropertiesClass(boost::property_tree::ptree const& pt);
|
||||
virtual ~AdditionalPropertiesClass() = default;
|
||||
|
||||
AdditionalPropertiesClass(const AdditionalPropertiesClass& other) = default; // copy constructor
|
||||
AdditionalPropertiesClass(AdditionalPropertiesClass&& other) noexcept = default; // move constructor
|
||||
|
||||
AdditionalPropertiesClass& operator=(const AdditionalPropertiesClass& other) = default; // copy assignment
|
||||
AdditionalPropertiesClass& operator=(AdditionalPropertiesClass&& other) noexcept = default; // move assignment
|
||||
|
||||
std::string toJsonString(bool prettyJson = false) const;
|
||||
void fromJsonString(std::string const& jsonString);
|
||||
boost::property_tree::ptree toPropertyTree() const;
|
||||
void fromPropertyTree(boost::property_tree::ptree const& pt);
|
||||
|
||||
|
||||
/////////////////////////////////////////////
|
||||
/// AdditionalPropertiesClass members
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
std::map<std::string, std::string> getMapProperty() const;
|
||||
void setMapProperty(std::map<std::string, std::string> value);
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
std::map<std::string, std::map<std::string, std::string>> getMapOfMapProperty() const;
|
||||
void setMapOfMapProperty(std::map<std::string, std::map<std::string, std::string>> value);
|
||||
|
||||
protected:
|
||||
std::map<std::string, std::string> m_Map_property;
|
||||
std::map<std::string, std::map<std::string, std::string>> m_Map_of_map_property;
|
||||
};
|
||||
|
||||
std::vector<AdditionalPropertiesClass> createAdditionalPropertiesClassVectorFromJsonString(const std::string& json);
|
||||
|
||||
template<>
|
||||
inline boost::property_tree::ptree toPt<AdditionalPropertiesClass>(const AdditionalPropertiesClass& val) {
|
||||
return val.toPropertyTree();
|
||||
}
|
||||
|
||||
template<>
|
||||
inline AdditionalPropertiesClass fromPt<AdditionalPropertiesClass>(const boost::property_tree::ptree& pt) {
|
||||
AdditionalPropertiesClass ret;
|
||||
ret.fromPropertyTree(pt);
|
||||
return ret;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif /* AdditionalPropertiesClass_H_ */
|
||||
@@ -0,0 +1,120 @@
|
||||
/**
|
||||
* OpenAPI Petstore
|
||||
* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
|
||||
*
|
||||
* The version of the OpenAPI document: 1.0.0
|
||||
*
|
||||
*
|
||||
* NOTE: This class is auto generated by OpenAPI-Generator 7.0.0-SNAPSHOT.
|
||||
* https://openapi-generator.tech
|
||||
* Do not edit the class manually.
|
||||
*/
|
||||
|
||||
|
||||
|
||||
#include "AllOfWithSingleRef.h"
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <map>
|
||||
#include <sstream>
|
||||
#include <stdexcept>
|
||||
#include <regex>
|
||||
#include <boost/lexical_cast.hpp>
|
||||
#include <boost/property_tree/ptree.hpp>
|
||||
#include <boost/property_tree/json_parser.hpp>
|
||||
#include "helpers.h"
|
||||
|
||||
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 {
|
||||
|
||||
AllOfWithSingleRef::AllOfWithSingleRef(boost::property_tree::ptree const& pt)
|
||||
{
|
||||
fromPropertyTree(pt);
|
||||
}
|
||||
|
||||
|
||||
std::string AllOfWithSingleRef::toJsonString(bool prettyJson /* = false */) const
|
||||
{
|
||||
std::stringstream ss;
|
||||
write_json(ss, this->toPropertyTree(), prettyJson);
|
||||
// workaround inspired by: https://stackoverflow.com/a/56395440
|
||||
std::regex reg("\\\"([0-9]+\\.{0,1}[0-9]*)\\\"");
|
||||
std::string result = std::regex_replace(ss.str(), reg, "$1");
|
||||
return result;
|
||||
}
|
||||
|
||||
void AllOfWithSingleRef::fromJsonString(std::string const& jsonString)
|
||||
{
|
||||
std::stringstream ss(jsonString);
|
||||
ptree pt;
|
||||
read_json(ss,pt);
|
||||
this->fromPropertyTree(pt);
|
||||
}
|
||||
|
||||
ptree AllOfWithSingleRef::toPropertyTree() const
|
||||
{
|
||||
ptree pt;
|
||||
ptree tmp_node;
|
||||
pt.put("username", m_Username);
|
||||
pt.add_child("SingleRefType", m_SingleRefType.toPropertyTree());
|
||||
return pt;
|
||||
}
|
||||
|
||||
void AllOfWithSingleRef::fromPropertyTree(ptree const &pt)
|
||||
{
|
||||
ptree tmp_node;
|
||||
m_Username = pt.get("username", "");
|
||||
if (pt.get_child_optional("SingleRefType")) {
|
||||
m_SingleRefType = fromPt<SingleRefType>(pt.get_child("SingleRefType"));
|
||||
}
|
||||
}
|
||||
|
||||
std::string AllOfWithSingleRef::getUsername() const
|
||||
{
|
||||
return m_Username;
|
||||
}
|
||||
|
||||
void AllOfWithSingleRef::setUsername(std::string value)
|
||||
{
|
||||
m_Username = value;
|
||||
}
|
||||
|
||||
|
||||
SingleRefType AllOfWithSingleRef::getSingleRefType() const
|
||||
{
|
||||
return m_SingleRefType;
|
||||
}
|
||||
|
||||
void AllOfWithSingleRef::setSingleRefType(SingleRefType value)
|
||||
{
|
||||
m_SingleRefType = value;
|
||||
}
|
||||
|
||||
|
||||
|
||||
std::vector<AllOfWithSingleRef> createAllOfWithSingleRefVectorFromJsonString(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<AllOfWithSingleRef>();
|
||||
for (const auto& child: pt) {
|
||||
vec.emplace_back(AllOfWithSingleRef(child.second));
|
||||
}
|
||||
|
||||
return vec;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,97 @@
|
||||
/**
|
||||
* OpenAPI Petstore
|
||||
* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
|
||||
*
|
||||
* The version of the OpenAPI document: 1.0.0
|
||||
*
|
||||
*
|
||||
* NOTE: This class is auto generated by OpenAPI-Generator 7.0.0-SNAPSHOT.
|
||||
* https://openapi-generator.tech
|
||||
* Do not edit the class manually.
|
||||
*/
|
||||
|
||||
/*
|
||||
* AllOfWithSingleRef.h
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef AllOfWithSingleRef_H_
|
||||
#define AllOfWithSingleRef_H_
|
||||
|
||||
|
||||
|
||||
#include <string>
|
||||
#include "SingleRefType.h"
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
#include <boost/property_tree/ptree.hpp>
|
||||
#include "helpers.h"
|
||||
|
||||
namespace org {
|
||||
namespace openapitools {
|
||||
namespace server {
|
||||
namespace model {
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
class AllOfWithSingleRef
|
||||
{
|
||||
public:
|
||||
AllOfWithSingleRef() = default;
|
||||
explicit AllOfWithSingleRef(boost::property_tree::ptree const& pt);
|
||||
virtual ~AllOfWithSingleRef() = default;
|
||||
|
||||
AllOfWithSingleRef(const AllOfWithSingleRef& other) = default; // copy constructor
|
||||
AllOfWithSingleRef(AllOfWithSingleRef&& other) noexcept = default; // move constructor
|
||||
|
||||
AllOfWithSingleRef& operator=(const AllOfWithSingleRef& other) = default; // copy assignment
|
||||
AllOfWithSingleRef& operator=(AllOfWithSingleRef&& other) noexcept = default; // move assignment
|
||||
|
||||
std::string toJsonString(bool prettyJson = false) const;
|
||||
void fromJsonString(std::string const& jsonString);
|
||||
boost::property_tree::ptree toPropertyTree() const;
|
||||
void fromPropertyTree(boost::property_tree::ptree const& pt);
|
||||
|
||||
|
||||
/////////////////////////////////////////////
|
||||
/// AllOfWithSingleRef members
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
std::string getUsername() const;
|
||||
void setUsername(std::string value);
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
SingleRefType getSingleRefType() const;
|
||||
void setSingleRefType(SingleRefType value);
|
||||
|
||||
protected:
|
||||
std::string m_Username = "";
|
||||
SingleRefType m_SingleRefType;
|
||||
};
|
||||
|
||||
std::vector<AllOfWithSingleRef> createAllOfWithSingleRefVectorFromJsonString(const std::string& json);
|
||||
|
||||
template<>
|
||||
inline boost::property_tree::ptree toPt<AllOfWithSingleRef>(const AllOfWithSingleRef& val) {
|
||||
return val.toPropertyTree();
|
||||
}
|
||||
|
||||
template<>
|
||||
inline AllOfWithSingleRef fromPt<AllOfWithSingleRef>(const boost::property_tree::ptree& pt) {
|
||||
AllOfWithSingleRef ret;
|
||||
ret.fromPropertyTree(pt);
|
||||
return ret;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif /* AllOfWithSingleRef_H_ */
|
||||
@@ -0,0 +1,118 @@
|
||||
/**
|
||||
* OpenAPI Petstore
|
||||
* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
|
||||
*
|
||||
* The version of the OpenAPI document: 1.0.0
|
||||
*
|
||||
*
|
||||
* NOTE: This class is auto generated by OpenAPI-Generator 7.0.0-SNAPSHOT.
|
||||
* https://openapi-generator.tech
|
||||
* Do not edit the class manually.
|
||||
*/
|
||||
|
||||
|
||||
|
||||
#include "Animal.h"
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <map>
|
||||
#include <sstream>
|
||||
#include <stdexcept>
|
||||
#include <regex>
|
||||
#include <boost/lexical_cast.hpp>
|
||||
#include <boost/property_tree/ptree.hpp>
|
||||
#include <boost/property_tree/json_parser.hpp>
|
||||
#include "helpers.h"
|
||||
|
||||
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 {
|
||||
|
||||
Animal::Animal(boost::property_tree::ptree const& pt)
|
||||
{
|
||||
fromPropertyTree(pt);
|
||||
}
|
||||
|
||||
|
||||
std::string Animal::toJsonString(bool prettyJson /* = false */) const
|
||||
{
|
||||
std::stringstream ss;
|
||||
write_json(ss, this->toPropertyTree(), prettyJson);
|
||||
// workaround inspired by: https://stackoverflow.com/a/56395440
|
||||
std::regex reg("\\\"([0-9]+\\.{0,1}[0-9]*)\\\"");
|
||||
std::string result = std::regex_replace(ss.str(), reg, "$1");
|
||||
return result;
|
||||
}
|
||||
|
||||
void Animal::fromJsonString(std::string const& jsonString)
|
||||
{
|
||||
std::stringstream ss(jsonString);
|
||||
ptree pt;
|
||||
read_json(ss,pt);
|
||||
this->fromPropertyTree(pt);
|
||||
}
|
||||
|
||||
ptree Animal::toPropertyTree() const
|
||||
{
|
||||
ptree pt;
|
||||
ptree tmp_node;
|
||||
pt.put("className", m_ClassName);
|
||||
pt.put("color", m_Color);
|
||||
return pt;
|
||||
}
|
||||
|
||||
void Animal::fromPropertyTree(ptree const &pt)
|
||||
{
|
||||
ptree tmp_node;
|
||||
m_ClassName = pt.get("className", "");
|
||||
m_Color = pt.get("color", "red");
|
||||
}
|
||||
|
||||
std::string Animal::getClassName() const
|
||||
{
|
||||
return m_ClassName;
|
||||
}
|
||||
|
||||
void Animal::setClassName(std::string value)
|
||||
{
|
||||
m_ClassName = value;
|
||||
}
|
||||
|
||||
|
||||
std::string Animal::getColor() const
|
||||
{
|
||||
return m_Color;
|
||||
}
|
||||
|
||||
void Animal::setColor(std::string value)
|
||||
{
|
||||
m_Color = value;
|
||||
}
|
||||
|
||||
|
||||
|
||||
std::vector<Animal> createAnimalVectorFromJsonString(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<Animal>();
|
||||
for (const auto& child: pt) {
|
||||
vec.emplace_back(Animal(child.second));
|
||||
}
|
||||
|
||||
return vec;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,96 @@
|
||||
/**
|
||||
* OpenAPI Petstore
|
||||
* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
|
||||
*
|
||||
* The version of the OpenAPI document: 1.0.0
|
||||
*
|
||||
*
|
||||
* NOTE: This class is auto generated by OpenAPI-Generator 7.0.0-SNAPSHOT.
|
||||
* https://openapi-generator.tech
|
||||
* Do not edit the class manually.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Animal.h
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef Animal_H_
|
||||
#define Animal_H_
|
||||
|
||||
|
||||
|
||||
#include <string>
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
#include <boost/property_tree/ptree.hpp>
|
||||
#include "helpers.h"
|
||||
|
||||
namespace org {
|
||||
namespace openapitools {
|
||||
namespace server {
|
||||
namespace model {
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
class Animal
|
||||
{
|
||||
public:
|
||||
Animal() = default;
|
||||
explicit Animal(boost::property_tree::ptree const& pt);
|
||||
virtual ~Animal() = default;
|
||||
|
||||
Animal(const Animal& other) = default; // copy constructor
|
||||
Animal(Animal&& other) noexcept = default; // move constructor
|
||||
|
||||
Animal& operator=(const Animal& other) = default; // copy assignment
|
||||
Animal& operator=(Animal&& other) noexcept = default; // move assignment
|
||||
|
||||
std::string toJsonString(bool prettyJson = false) const;
|
||||
void fromJsonString(std::string const& jsonString);
|
||||
boost::property_tree::ptree toPropertyTree() const;
|
||||
void fromPropertyTree(boost::property_tree::ptree const& pt);
|
||||
|
||||
|
||||
/////////////////////////////////////////////
|
||||
/// Animal members
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
std::string getClassName() const;
|
||||
void setClassName(std::string value);
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
std::string getColor() const;
|
||||
void setColor(std::string value);
|
||||
|
||||
protected:
|
||||
std::string m_ClassName = "";
|
||||
std::string m_Color = "red";
|
||||
};
|
||||
|
||||
std::vector<Animal> createAnimalVectorFromJsonString(const std::string& json);
|
||||
|
||||
template<>
|
||||
inline boost::property_tree::ptree toPt<Animal>(const Animal& val) {
|
||||
return val.toPropertyTree();
|
||||
}
|
||||
|
||||
template<>
|
||||
inline Animal fromPt<Animal>(const boost::property_tree::ptree& pt) {
|
||||
Animal ret;
|
||||
ret.fromPropertyTree(pt);
|
||||
return ret;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif /* Animal_H_ */
|
||||
@@ -1,11 +1,11 @@
|
||||
/**
|
||||
* 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.
|
||||
* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
|
||||
*
|
||||
* The version of the OpenAPI document: 1.0.0
|
||||
*
|
||||
*
|
||||
* NOTE: This class is auto generated by OpenAPI-Generator unset.
|
||||
* NOTE: This class is auto generated by OpenAPI-Generator 7.0.0-SNAPSHOT.
|
||||
* https://openapi-generator.tech
|
||||
* Do not edit the class manually.
|
||||
*/
|
||||
@@ -16,10 +16,14 @@
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <map>
|
||||
#include <sstream>
|
||||
#include <stdexcept>
|
||||
#include <regex>
|
||||
#include <boost/lexical_cast.hpp>
|
||||
#include <boost/property_tree/ptree.hpp>
|
||||
#include <boost/property_tree/json_parser.hpp>
|
||||
#include "helpers.h"
|
||||
|
||||
using boost::property_tree::ptree;
|
||||
using boost::property_tree::read_json;
|
||||
@@ -35,34 +39,18 @@ 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::string ApiResponse::toJsonString(bool prettyJson /* = false */) const
|
||||
{
|
||||
std::stringstream ss;
|
||||
write_json(ss, this->toPropertyTree(), prettyJson);
|
||||
return ss.str();
|
||||
// workaround inspired by: https://stackoverflow.com/a/56395440
|
||||
std::regex reg("\\\"([0-9]+\\.{0,1}[0-9]*)\\\"");
|
||||
std::string result = std::regex_replace(ss.str(), reg, "$1");
|
||||
return result;
|
||||
}
|
||||
|
||||
void ApiResponse::fromJsonString_internal(std::string const& jsonString)
|
||||
void ApiResponse::fromJsonString(std::string const& jsonString)
|
||||
{
|
||||
std::stringstream ss(jsonString);
|
||||
ptree pt;
|
||||
@@ -70,7 +58,7 @@ void ApiResponse::fromJsonString_internal(std::string const& jsonString)
|
||||
this->fromPropertyTree(pt);
|
||||
}
|
||||
|
||||
ptree ApiResponse::toPropertyTree_internal()
|
||||
ptree ApiResponse::toPropertyTree() const
|
||||
{
|
||||
ptree pt;
|
||||
ptree tmp_node;
|
||||
@@ -80,7 +68,7 @@ ptree ApiResponse::toPropertyTree_internal()
|
||||
return pt;
|
||||
}
|
||||
|
||||
void ApiResponse::fromPropertyTree_internal(ptree const &pt)
|
||||
void ApiResponse::fromPropertyTree(ptree const &pt)
|
||||
{
|
||||
ptree tmp_node;
|
||||
m_Code = pt.get("code", 0);
|
||||
@@ -95,8 +83,10 @@ int32_t ApiResponse::getCode() const
|
||||
|
||||
void ApiResponse::setCode(int32_t value)
|
||||
{
|
||||
m_Code = value;
|
||||
m_Code = value;
|
||||
}
|
||||
|
||||
|
||||
std::string ApiResponse::getType() const
|
||||
{
|
||||
return m_Type;
|
||||
@@ -104,8 +94,10 @@ std::string ApiResponse::getType() const
|
||||
|
||||
void ApiResponse::setType(std::string value)
|
||||
{
|
||||
m_Type = value;
|
||||
m_Type = value;
|
||||
}
|
||||
|
||||
|
||||
std::string ApiResponse::getMessage() const
|
||||
{
|
||||
return m_Message;
|
||||
@@ -113,9 +105,11 @@ std::string ApiResponse::getMessage() const
|
||||
|
||||
void ApiResponse::setMessage(std::string value)
|
||||
{
|
||||
m_Message = value;
|
||||
m_Message = value;
|
||||
}
|
||||
|
||||
|
||||
|
||||
std::vector<ApiResponse> createApiResponseVectorFromJsonString(const std::string& json)
|
||||
{
|
||||
std::stringstream sstream(json);
|
||||
@@ -1,11 +1,11 @@
|
||||
/**
|
||||
* 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.
|
||||
* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
|
||||
*
|
||||
* The version of the OpenAPI document: 1.0.0
|
||||
*
|
||||
*
|
||||
* NOTE: This class is auto generated by OpenAPI-Generator unset.
|
||||
* NOTE: This class is auto generated by OpenAPI-Generator 7.0.0-SNAPSHOT.
|
||||
* https://openapi-generator.tech
|
||||
* Do not edit the class manually.
|
||||
*/
|
||||
@@ -13,7 +13,7 @@
|
||||
/*
|
||||
* ApiResponse.h
|
||||
*
|
||||
* Describes the result of uploading an image resource
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef ApiResponse_H_
|
||||
@@ -25,6 +25,7 @@
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
#include <boost/property_tree/ptree.hpp>
|
||||
#include "helpers.h"
|
||||
|
||||
namespace org {
|
||||
namespace openapitools {
|
||||
@@ -32,7 +33,7 @@ namespace server {
|
||||
namespace model {
|
||||
|
||||
/// <summary>
|
||||
/// Describes the result of uploading an image resource
|
||||
///
|
||||
/// </summary>
|
||||
class ApiResponse
|
||||
{
|
||||
@@ -40,12 +41,19 @@ public:
|
||||
ApiResponse() = default;
|
||||
explicit ApiResponse(boost::property_tree::ptree const& pt);
|
||||
virtual ~ApiResponse() = default;
|
||||
|
||||
std::string toJsonString(bool prettyJson = false);
|
||||
|
||||
ApiResponse(const ApiResponse& other) = default; // copy constructor
|
||||
ApiResponse(ApiResponse&& other) noexcept = default; // move constructor
|
||||
|
||||
ApiResponse& operator=(const ApiResponse& other) = default; // copy assignment
|
||||
ApiResponse& operator=(ApiResponse&& other) noexcept = default; // move assignment
|
||||
|
||||
std::string toJsonString(bool prettyJson = false) const;
|
||||
void fromJsonString(std::string const& jsonString);
|
||||
boost::property_tree::ptree toPropertyTree();
|
||||
boost::property_tree::ptree toPropertyTree() const;
|
||||
void fromPropertyTree(boost::property_tree::ptree const& pt);
|
||||
|
||||
|
||||
/////////////////////////////////////////////
|
||||
/// ApiResponse members
|
||||
|
||||
@@ -67,17 +75,6 @@ public:
|
||||
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 = "";
|
||||
@@ -86,6 +83,18 @@ protected:
|
||||
|
||||
std::vector<ApiResponse> createApiResponseVectorFromJsonString(const std::string& json);
|
||||
|
||||
template<>
|
||||
inline boost::property_tree::ptree toPt<ApiResponse>(const ApiResponse& val) {
|
||||
return val.toPropertyTree();
|
||||
}
|
||||
|
||||
template<>
|
||||
inline ApiResponse fromPt<ApiResponse>(const boost::property_tree::ptree& pt) {
|
||||
ApiResponse ret;
|
||||
ret.fromPropertyTree(pt);
|
||||
return ret;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,114 @@
|
||||
/**
|
||||
* OpenAPI Petstore
|
||||
* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
|
||||
*
|
||||
* The version of the OpenAPI document: 1.0.0
|
||||
*
|
||||
*
|
||||
* NOTE: This class is auto generated by OpenAPI-Generator 7.0.0-SNAPSHOT.
|
||||
* https://openapi-generator.tech
|
||||
* Do not edit the class manually.
|
||||
*/
|
||||
|
||||
|
||||
|
||||
#include "ArrayOfArrayOfNumberOnly.h"
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <map>
|
||||
#include <sstream>
|
||||
#include <stdexcept>
|
||||
#include <regex>
|
||||
#include <boost/lexical_cast.hpp>
|
||||
#include <boost/property_tree/ptree.hpp>
|
||||
#include <boost/property_tree/json_parser.hpp>
|
||||
#include "helpers.h"
|
||||
|
||||
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 {
|
||||
|
||||
ArrayOfArrayOfNumberOnly::ArrayOfArrayOfNumberOnly(boost::property_tree::ptree const& pt)
|
||||
{
|
||||
fromPropertyTree(pt);
|
||||
}
|
||||
|
||||
|
||||
std::string ArrayOfArrayOfNumberOnly::toJsonString(bool prettyJson /* = false */) const
|
||||
{
|
||||
std::stringstream ss;
|
||||
write_json(ss, this->toPropertyTree(), prettyJson);
|
||||
// workaround inspired by: https://stackoverflow.com/a/56395440
|
||||
std::regex reg("\\\"([0-9]+\\.{0,1}[0-9]*)\\\"");
|
||||
std::string result = std::regex_replace(ss.str(), reg, "$1");
|
||||
return result;
|
||||
}
|
||||
|
||||
void ArrayOfArrayOfNumberOnly::fromJsonString(std::string const& jsonString)
|
||||
{
|
||||
std::stringstream ss(jsonString);
|
||||
ptree pt;
|
||||
read_json(ss,pt);
|
||||
this->fromPropertyTree(pt);
|
||||
}
|
||||
|
||||
ptree ArrayOfArrayOfNumberOnly::toPropertyTree() const
|
||||
{
|
||||
ptree pt;
|
||||
ptree tmp_node;
|
||||
// generate tree for ArrayArrayNumber
|
||||
tmp_node.clear();
|
||||
if (!m_ArrayArrayNumber.empty()) {
|
||||
tmp_node = toPt(m_ArrayArrayNumber);
|
||||
pt.add_child("ArrayArrayNumber", tmp_node);
|
||||
tmp_node.clear();
|
||||
}
|
||||
return pt;
|
||||
}
|
||||
|
||||
void ArrayOfArrayOfNumberOnly::fromPropertyTree(ptree const &pt)
|
||||
{
|
||||
ptree tmp_node;
|
||||
// push all items of ArrayArrayNumber into member
|
||||
if (pt.get_child_optional("ArrayArrayNumber")) {
|
||||
m_ArrayArrayNumber = fromPt<std::vector<std::vector<double>>>(pt.get_child("ArrayArrayNumber"));
|
||||
}
|
||||
}
|
||||
|
||||
std::vector<std::vector<double>> ArrayOfArrayOfNumberOnly::getArrayArrayNumber() const
|
||||
{
|
||||
return m_ArrayArrayNumber;
|
||||
}
|
||||
|
||||
void ArrayOfArrayOfNumberOnly::setArrayArrayNumber(std::vector<std::vector<double>> value)
|
||||
{
|
||||
m_ArrayArrayNumber = value;
|
||||
}
|
||||
|
||||
|
||||
|
||||
std::vector<ArrayOfArrayOfNumberOnly> createArrayOfArrayOfNumberOnlyVectorFromJsonString(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<ArrayOfArrayOfNumberOnly>();
|
||||
for (const auto& child: pt) {
|
||||
vec.emplace_back(ArrayOfArrayOfNumberOnly(child.second));
|
||||
}
|
||||
|
||||
return vec;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,89 @@
|
||||
/**
|
||||
* OpenAPI Petstore
|
||||
* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
|
||||
*
|
||||
* The version of the OpenAPI document: 1.0.0
|
||||
*
|
||||
*
|
||||
* NOTE: This class is auto generated by OpenAPI-Generator 7.0.0-SNAPSHOT.
|
||||
* https://openapi-generator.tech
|
||||
* Do not edit the class manually.
|
||||
*/
|
||||
|
||||
/*
|
||||
* ArrayOfArrayOfNumberOnly.h
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef ArrayOfArrayOfNumberOnly_H_
|
||||
#define ArrayOfArrayOfNumberOnly_H_
|
||||
|
||||
|
||||
|
||||
#include <vector>
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
#include <boost/property_tree/ptree.hpp>
|
||||
#include "helpers.h"
|
||||
|
||||
namespace org {
|
||||
namespace openapitools {
|
||||
namespace server {
|
||||
namespace model {
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
class ArrayOfArrayOfNumberOnly
|
||||
{
|
||||
public:
|
||||
ArrayOfArrayOfNumberOnly() = default;
|
||||
explicit ArrayOfArrayOfNumberOnly(boost::property_tree::ptree const& pt);
|
||||
virtual ~ArrayOfArrayOfNumberOnly() = default;
|
||||
|
||||
ArrayOfArrayOfNumberOnly(const ArrayOfArrayOfNumberOnly& other) = default; // copy constructor
|
||||
ArrayOfArrayOfNumberOnly(ArrayOfArrayOfNumberOnly&& other) noexcept = default; // move constructor
|
||||
|
||||
ArrayOfArrayOfNumberOnly& operator=(const ArrayOfArrayOfNumberOnly& other) = default; // copy assignment
|
||||
ArrayOfArrayOfNumberOnly& operator=(ArrayOfArrayOfNumberOnly&& other) noexcept = default; // move assignment
|
||||
|
||||
std::string toJsonString(bool prettyJson = false) const;
|
||||
void fromJsonString(std::string const& jsonString);
|
||||
boost::property_tree::ptree toPropertyTree() const;
|
||||
void fromPropertyTree(boost::property_tree::ptree const& pt);
|
||||
|
||||
|
||||
/////////////////////////////////////////////
|
||||
/// ArrayOfArrayOfNumberOnly members
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
std::vector<std::vector<double>> getArrayArrayNumber() const;
|
||||
void setArrayArrayNumber(std::vector<std::vector<double>> value);
|
||||
|
||||
protected:
|
||||
std::vector<std::vector<double>> m_ArrayArrayNumber;
|
||||
};
|
||||
|
||||
std::vector<ArrayOfArrayOfNumberOnly> createArrayOfArrayOfNumberOnlyVectorFromJsonString(const std::string& json);
|
||||
|
||||
template<>
|
||||
inline boost::property_tree::ptree toPt<ArrayOfArrayOfNumberOnly>(const ArrayOfArrayOfNumberOnly& val) {
|
||||
return val.toPropertyTree();
|
||||
}
|
||||
|
||||
template<>
|
||||
inline ArrayOfArrayOfNumberOnly fromPt<ArrayOfArrayOfNumberOnly>(const boost::property_tree::ptree& pt) {
|
||||
ArrayOfArrayOfNumberOnly ret;
|
||||
ret.fromPropertyTree(pt);
|
||||
return ret;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif /* ArrayOfArrayOfNumberOnly_H_ */
|
||||
@@ -0,0 +1,114 @@
|
||||
/**
|
||||
* OpenAPI Petstore
|
||||
* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
|
||||
*
|
||||
* The version of the OpenAPI document: 1.0.0
|
||||
*
|
||||
*
|
||||
* NOTE: This class is auto generated by OpenAPI-Generator 7.0.0-SNAPSHOT.
|
||||
* https://openapi-generator.tech
|
||||
* Do not edit the class manually.
|
||||
*/
|
||||
|
||||
|
||||
|
||||
#include "ArrayOfNumberOnly.h"
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <map>
|
||||
#include <sstream>
|
||||
#include <stdexcept>
|
||||
#include <regex>
|
||||
#include <boost/lexical_cast.hpp>
|
||||
#include <boost/property_tree/ptree.hpp>
|
||||
#include <boost/property_tree/json_parser.hpp>
|
||||
#include "helpers.h"
|
||||
|
||||
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 {
|
||||
|
||||
ArrayOfNumberOnly::ArrayOfNumberOnly(boost::property_tree::ptree const& pt)
|
||||
{
|
||||
fromPropertyTree(pt);
|
||||
}
|
||||
|
||||
|
||||
std::string ArrayOfNumberOnly::toJsonString(bool prettyJson /* = false */) const
|
||||
{
|
||||
std::stringstream ss;
|
||||
write_json(ss, this->toPropertyTree(), prettyJson);
|
||||
// workaround inspired by: https://stackoverflow.com/a/56395440
|
||||
std::regex reg("\\\"([0-9]+\\.{0,1}[0-9]*)\\\"");
|
||||
std::string result = std::regex_replace(ss.str(), reg, "$1");
|
||||
return result;
|
||||
}
|
||||
|
||||
void ArrayOfNumberOnly::fromJsonString(std::string const& jsonString)
|
||||
{
|
||||
std::stringstream ss(jsonString);
|
||||
ptree pt;
|
||||
read_json(ss,pt);
|
||||
this->fromPropertyTree(pt);
|
||||
}
|
||||
|
||||
ptree ArrayOfNumberOnly::toPropertyTree() const
|
||||
{
|
||||
ptree pt;
|
||||
ptree tmp_node;
|
||||
// generate tree for ArrayNumber
|
||||
tmp_node.clear();
|
||||
if (!m_ArrayNumber.empty()) {
|
||||
tmp_node = toPt(m_ArrayNumber);
|
||||
pt.add_child("ArrayNumber", tmp_node);
|
||||
tmp_node.clear();
|
||||
}
|
||||
return pt;
|
||||
}
|
||||
|
||||
void ArrayOfNumberOnly::fromPropertyTree(ptree const &pt)
|
||||
{
|
||||
ptree tmp_node;
|
||||
// push all items of ArrayNumber into member
|
||||
if (pt.get_child_optional("ArrayNumber")) {
|
||||
m_ArrayNumber = fromPt<std::vector<double>>(pt.get_child("ArrayNumber"));
|
||||
}
|
||||
}
|
||||
|
||||
std::vector<double> ArrayOfNumberOnly::getArrayNumber() const
|
||||
{
|
||||
return m_ArrayNumber;
|
||||
}
|
||||
|
||||
void ArrayOfNumberOnly::setArrayNumber(std::vector<double> value)
|
||||
{
|
||||
m_ArrayNumber = value;
|
||||
}
|
||||
|
||||
|
||||
|
||||
std::vector<ArrayOfNumberOnly> createArrayOfNumberOnlyVectorFromJsonString(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<ArrayOfNumberOnly>();
|
||||
for (const auto& child: pt) {
|
||||
vec.emplace_back(ArrayOfNumberOnly(child.second));
|
||||
}
|
||||
|
||||
return vec;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,89 @@
|
||||
/**
|
||||
* OpenAPI Petstore
|
||||
* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
|
||||
*
|
||||
* The version of the OpenAPI document: 1.0.0
|
||||
*
|
||||
*
|
||||
* NOTE: This class is auto generated by OpenAPI-Generator 7.0.0-SNAPSHOT.
|
||||
* https://openapi-generator.tech
|
||||
* Do not edit the class manually.
|
||||
*/
|
||||
|
||||
/*
|
||||
* ArrayOfNumberOnly.h
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef ArrayOfNumberOnly_H_
|
||||
#define ArrayOfNumberOnly_H_
|
||||
|
||||
|
||||
|
||||
#include <vector>
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
#include <boost/property_tree/ptree.hpp>
|
||||
#include "helpers.h"
|
||||
|
||||
namespace org {
|
||||
namespace openapitools {
|
||||
namespace server {
|
||||
namespace model {
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
class ArrayOfNumberOnly
|
||||
{
|
||||
public:
|
||||
ArrayOfNumberOnly() = default;
|
||||
explicit ArrayOfNumberOnly(boost::property_tree::ptree const& pt);
|
||||
virtual ~ArrayOfNumberOnly() = default;
|
||||
|
||||
ArrayOfNumberOnly(const ArrayOfNumberOnly& other) = default; // copy constructor
|
||||
ArrayOfNumberOnly(ArrayOfNumberOnly&& other) noexcept = default; // move constructor
|
||||
|
||||
ArrayOfNumberOnly& operator=(const ArrayOfNumberOnly& other) = default; // copy assignment
|
||||
ArrayOfNumberOnly& operator=(ArrayOfNumberOnly&& other) noexcept = default; // move assignment
|
||||
|
||||
std::string toJsonString(bool prettyJson = false) const;
|
||||
void fromJsonString(std::string const& jsonString);
|
||||
boost::property_tree::ptree toPropertyTree() const;
|
||||
void fromPropertyTree(boost::property_tree::ptree const& pt);
|
||||
|
||||
|
||||
/////////////////////////////////////////////
|
||||
/// ArrayOfNumberOnly members
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
std::vector<double> getArrayNumber() const;
|
||||
void setArrayNumber(std::vector<double> value);
|
||||
|
||||
protected:
|
||||
std::vector<double> m_ArrayNumber;
|
||||
};
|
||||
|
||||
std::vector<ArrayOfNumberOnly> createArrayOfNumberOnlyVectorFromJsonString(const std::string& json);
|
||||
|
||||
template<>
|
||||
inline boost::property_tree::ptree toPt<ArrayOfNumberOnly>(const ArrayOfNumberOnly& val) {
|
||||
return val.toPropertyTree();
|
||||
}
|
||||
|
||||
template<>
|
||||
inline ArrayOfNumberOnly fromPt<ArrayOfNumberOnly>(const boost::property_tree::ptree& pt) {
|
||||
ArrayOfNumberOnly ret;
|
||||
ret.fromPropertyTree(pt);
|
||||
return ret;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif /* ArrayOfNumberOnly_H_ */
|
||||
@@ -0,0 +1,158 @@
|
||||
/**
|
||||
* OpenAPI Petstore
|
||||
* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
|
||||
*
|
||||
* The version of the OpenAPI document: 1.0.0
|
||||
*
|
||||
*
|
||||
* NOTE: This class is auto generated by OpenAPI-Generator 7.0.0-SNAPSHOT.
|
||||
* https://openapi-generator.tech
|
||||
* Do not edit the class manually.
|
||||
*/
|
||||
|
||||
|
||||
|
||||
#include "ArrayTest.h"
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <map>
|
||||
#include <sstream>
|
||||
#include <stdexcept>
|
||||
#include <regex>
|
||||
#include <boost/lexical_cast.hpp>
|
||||
#include <boost/property_tree/ptree.hpp>
|
||||
#include <boost/property_tree/json_parser.hpp>
|
||||
#include "helpers.h"
|
||||
|
||||
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 {
|
||||
|
||||
ArrayTest::ArrayTest(boost::property_tree::ptree const& pt)
|
||||
{
|
||||
fromPropertyTree(pt);
|
||||
}
|
||||
|
||||
|
||||
std::string ArrayTest::toJsonString(bool prettyJson /* = false */) const
|
||||
{
|
||||
std::stringstream ss;
|
||||
write_json(ss, this->toPropertyTree(), prettyJson);
|
||||
// workaround inspired by: https://stackoverflow.com/a/56395440
|
||||
std::regex reg("\\\"([0-9]+\\.{0,1}[0-9]*)\\\"");
|
||||
std::string result = std::regex_replace(ss.str(), reg, "$1");
|
||||
return result;
|
||||
}
|
||||
|
||||
void ArrayTest::fromJsonString(std::string const& jsonString)
|
||||
{
|
||||
std::stringstream ss(jsonString);
|
||||
ptree pt;
|
||||
read_json(ss,pt);
|
||||
this->fromPropertyTree(pt);
|
||||
}
|
||||
|
||||
ptree ArrayTest::toPropertyTree() const
|
||||
{
|
||||
ptree pt;
|
||||
ptree tmp_node;
|
||||
// generate tree for Array_of_string
|
||||
tmp_node.clear();
|
||||
if (!m_Array_of_string.empty()) {
|
||||
tmp_node = toPt(m_Array_of_string);
|
||||
pt.add_child("array_of_string", tmp_node);
|
||||
tmp_node.clear();
|
||||
}
|
||||
// generate tree for Array_array_of_integer
|
||||
tmp_node.clear();
|
||||
if (!m_Array_array_of_integer.empty()) {
|
||||
tmp_node = toPt(m_Array_array_of_integer);
|
||||
pt.add_child("array_array_of_integer", tmp_node);
|
||||
tmp_node.clear();
|
||||
}
|
||||
// generate tree for Array_array_of_model
|
||||
tmp_node.clear();
|
||||
if (!m_Array_array_of_model.empty()) {
|
||||
tmp_node = toPt(m_Array_array_of_model);
|
||||
pt.add_child("array_array_of_model", tmp_node);
|
||||
tmp_node.clear();
|
||||
}
|
||||
return pt;
|
||||
}
|
||||
|
||||
void ArrayTest::fromPropertyTree(ptree const &pt)
|
||||
{
|
||||
ptree tmp_node;
|
||||
// push all items of Array_of_string into member
|
||||
if (pt.get_child_optional("array_of_string")) {
|
||||
m_Array_of_string = fromPt<std::vector<std::string>>(pt.get_child("array_of_string"));
|
||||
}
|
||||
// push all items of Array_array_of_integer into member
|
||||
if (pt.get_child_optional("array_array_of_integer")) {
|
||||
m_Array_array_of_integer = fromPt<std::vector<std::vector<int64_t>>>(pt.get_child("array_array_of_integer"));
|
||||
}
|
||||
// push all items of Array_array_of_model into member
|
||||
if (pt.get_child_optional("array_array_of_model")) {
|
||||
m_Array_array_of_model = fromPt<std::vector<std::vector<ReadOnlyFirst>>>(pt.get_child("array_array_of_model"));
|
||||
}
|
||||
}
|
||||
|
||||
std::vector<std::string> ArrayTest::getArrayOfString() const
|
||||
{
|
||||
return m_Array_of_string;
|
||||
}
|
||||
|
||||
void ArrayTest::setArrayOfString(std::vector<std::string> value)
|
||||
{
|
||||
m_Array_of_string = value;
|
||||
}
|
||||
|
||||
|
||||
std::vector<std::vector<int64_t>> ArrayTest::getArrayArrayOfInteger() const
|
||||
{
|
||||
return m_Array_array_of_integer;
|
||||
}
|
||||
|
||||
void ArrayTest::setArrayArrayOfInteger(std::vector<std::vector<int64_t>> value)
|
||||
{
|
||||
m_Array_array_of_integer = value;
|
||||
}
|
||||
|
||||
|
||||
std::vector<std::vector<ReadOnlyFirst>> ArrayTest::getArrayArrayOfModel() const
|
||||
{
|
||||
return m_Array_array_of_model;
|
||||
}
|
||||
|
||||
void ArrayTest::setArrayArrayOfModel(std::vector<std::vector<ReadOnlyFirst>> value)
|
||||
{
|
||||
m_Array_array_of_model = value;
|
||||
}
|
||||
|
||||
|
||||
|
||||
std::vector<ArrayTest> createArrayTestVectorFromJsonString(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<ArrayTest>();
|
||||
for (const auto& child: pt) {
|
||||
vec.emplace_back(ArrayTest(child.second));
|
||||
}
|
||||
|
||||
return vec;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,105 @@
|
||||
/**
|
||||
* OpenAPI Petstore
|
||||
* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
|
||||
*
|
||||
* The version of the OpenAPI document: 1.0.0
|
||||
*
|
||||
*
|
||||
* NOTE: This class is auto generated by OpenAPI-Generator 7.0.0-SNAPSHOT.
|
||||
* https://openapi-generator.tech
|
||||
* Do not edit the class manually.
|
||||
*/
|
||||
|
||||
/*
|
||||
* ArrayTest.h
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef ArrayTest_H_
|
||||
#define ArrayTest_H_
|
||||
|
||||
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include "ReadOnlyFirst.h"
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
#include <boost/property_tree/ptree.hpp>
|
||||
#include "helpers.h"
|
||||
|
||||
namespace org {
|
||||
namespace openapitools {
|
||||
namespace server {
|
||||
namespace model {
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
class ArrayTest
|
||||
{
|
||||
public:
|
||||
ArrayTest() = default;
|
||||
explicit ArrayTest(boost::property_tree::ptree const& pt);
|
||||
virtual ~ArrayTest() = default;
|
||||
|
||||
ArrayTest(const ArrayTest& other) = default; // copy constructor
|
||||
ArrayTest(ArrayTest&& other) noexcept = default; // move constructor
|
||||
|
||||
ArrayTest& operator=(const ArrayTest& other) = default; // copy assignment
|
||||
ArrayTest& operator=(ArrayTest&& other) noexcept = default; // move assignment
|
||||
|
||||
std::string toJsonString(bool prettyJson = false) const;
|
||||
void fromJsonString(std::string const& jsonString);
|
||||
boost::property_tree::ptree toPropertyTree() const;
|
||||
void fromPropertyTree(boost::property_tree::ptree const& pt);
|
||||
|
||||
|
||||
/////////////////////////////////////////////
|
||||
/// ArrayTest members
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
std::vector<std::string> getArrayOfString() const;
|
||||
void setArrayOfString(std::vector<std::string> value);
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
std::vector<std::vector<int64_t>> getArrayArrayOfInteger() const;
|
||||
void setArrayArrayOfInteger(std::vector<std::vector<int64_t>> value);
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
std::vector<std::vector<ReadOnlyFirst>> getArrayArrayOfModel() const;
|
||||
void setArrayArrayOfModel(std::vector<std::vector<ReadOnlyFirst>> value);
|
||||
|
||||
protected:
|
||||
std::vector<std::string> m_Array_of_string;
|
||||
std::vector<std::vector<int64_t>> m_Array_array_of_integer;
|
||||
std::vector<std::vector<ReadOnlyFirst>> m_Array_array_of_model;
|
||||
};
|
||||
|
||||
std::vector<ArrayTest> createArrayTestVectorFromJsonString(const std::string& json);
|
||||
|
||||
template<>
|
||||
inline boost::property_tree::ptree toPt<ArrayTest>(const ArrayTest& val) {
|
||||
return val.toPropertyTree();
|
||||
}
|
||||
|
||||
template<>
|
||||
inline ArrayTest fromPt<ArrayTest>(const boost::property_tree::ptree& pt) {
|
||||
ArrayTest ret;
|
||||
ret.fromPropertyTree(pt);
|
||||
return ret;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif /* ArrayTest_H_ */
|
||||
@@ -0,0 +1,170 @@
|
||||
/**
|
||||
* OpenAPI Petstore
|
||||
* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
|
||||
*
|
||||
* The version of the OpenAPI document: 1.0.0
|
||||
*
|
||||
*
|
||||
* NOTE: This class is auto generated by OpenAPI-Generator 7.0.0-SNAPSHOT.
|
||||
* https://openapi-generator.tech
|
||||
* Do not edit the class manually.
|
||||
*/
|
||||
|
||||
|
||||
|
||||
#include "Capitalization.h"
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <map>
|
||||
#include <sstream>
|
||||
#include <stdexcept>
|
||||
#include <regex>
|
||||
#include <boost/lexical_cast.hpp>
|
||||
#include <boost/property_tree/ptree.hpp>
|
||||
#include <boost/property_tree/json_parser.hpp>
|
||||
#include "helpers.h"
|
||||
|
||||
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 {
|
||||
|
||||
Capitalization::Capitalization(boost::property_tree::ptree const& pt)
|
||||
{
|
||||
fromPropertyTree(pt);
|
||||
}
|
||||
|
||||
|
||||
std::string Capitalization::toJsonString(bool prettyJson /* = false */) const
|
||||
{
|
||||
std::stringstream ss;
|
||||
write_json(ss, this->toPropertyTree(), prettyJson);
|
||||
// workaround inspired by: https://stackoverflow.com/a/56395440
|
||||
std::regex reg("\\\"([0-9]+\\.{0,1}[0-9]*)\\\"");
|
||||
std::string result = std::regex_replace(ss.str(), reg, "$1");
|
||||
return result;
|
||||
}
|
||||
|
||||
void Capitalization::fromJsonString(std::string const& jsonString)
|
||||
{
|
||||
std::stringstream ss(jsonString);
|
||||
ptree pt;
|
||||
read_json(ss,pt);
|
||||
this->fromPropertyTree(pt);
|
||||
}
|
||||
|
||||
ptree Capitalization::toPropertyTree() const
|
||||
{
|
||||
ptree pt;
|
||||
ptree tmp_node;
|
||||
pt.put("smallCamel", m_SmallCamel);
|
||||
pt.put("CapitalCamel", m_CapitalCamel);
|
||||
pt.put("small_Snake", m_Small_Snake);
|
||||
pt.put("Capital_Snake", m_Capital_Snake);
|
||||
pt.put("SCA_ETH_Flow_Points", m_SCA_ETH_Flow_Points);
|
||||
pt.put("ATT_NAME", m_ATT_NAME);
|
||||
return pt;
|
||||
}
|
||||
|
||||
void Capitalization::fromPropertyTree(ptree const &pt)
|
||||
{
|
||||
ptree tmp_node;
|
||||
m_SmallCamel = pt.get("smallCamel", "");
|
||||
m_CapitalCamel = pt.get("CapitalCamel", "");
|
||||
m_Small_Snake = pt.get("small_Snake", "");
|
||||
m_Capital_Snake = pt.get("Capital_Snake", "");
|
||||
m_SCA_ETH_Flow_Points = pt.get("SCA_ETH_Flow_Points", "");
|
||||
m_ATT_NAME = pt.get("ATT_NAME", "");
|
||||
}
|
||||
|
||||
std::string Capitalization::getSmallCamel() const
|
||||
{
|
||||
return m_SmallCamel;
|
||||
}
|
||||
|
||||
void Capitalization::setSmallCamel(std::string value)
|
||||
{
|
||||
m_SmallCamel = value;
|
||||
}
|
||||
|
||||
|
||||
std::string Capitalization::getCapitalCamel() const
|
||||
{
|
||||
return m_CapitalCamel;
|
||||
}
|
||||
|
||||
void Capitalization::setCapitalCamel(std::string value)
|
||||
{
|
||||
m_CapitalCamel = value;
|
||||
}
|
||||
|
||||
|
||||
std::string Capitalization::getSmallSnake() const
|
||||
{
|
||||
return m_Small_Snake;
|
||||
}
|
||||
|
||||
void Capitalization::setSmallSnake(std::string value)
|
||||
{
|
||||
m_Small_Snake = value;
|
||||
}
|
||||
|
||||
|
||||
std::string Capitalization::getCapitalSnake() const
|
||||
{
|
||||
return m_Capital_Snake;
|
||||
}
|
||||
|
||||
void Capitalization::setCapitalSnake(std::string value)
|
||||
{
|
||||
m_Capital_Snake = value;
|
||||
}
|
||||
|
||||
|
||||
std::string Capitalization::getSCAETHFlowPoints() const
|
||||
{
|
||||
return m_SCA_ETH_Flow_Points;
|
||||
}
|
||||
|
||||
void Capitalization::setSCAETHFlowPoints(std::string value)
|
||||
{
|
||||
m_SCA_ETH_Flow_Points = value;
|
||||
}
|
||||
|
||||
|
||||
std::string Capitalization::getATTNAME() const
|
||||
{
|
||||
return m_ATT_NAME;
|
||||
}
|
||||
|
||||
void Capitalization::setATTNAME(std::string value)
|
||||
{
|
||||
m_ATT_NAME = value;
|
||||
}
|
||||
|
||||
|
||||
|
||||
std::vector<Capitalization> createCapitalizationVectorFromJsonString(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<Capitalization>();
|
||||
for (const auto& child: pt) {
|
||||
vec.emplace_back(Capitalization(child.second));
|
||||
}
|
||||
|
||||
return vec;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,124 @@
|
||||
/**
|
||||
* OpenAPI Petstore
|
||||
* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
|
||||
*
|
||||
* The version of the OpenAPI document: 1.0.0
|
||||
*
|
||||
*
|
||||
* NOTE: This class is auto generated by OpenAPI-Generator 7.0.0-SNAPSHOT.
|
||||
* https://openapi-generator.tech
|
||||
* Do not edit the class manually.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Capitalization.h
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef Capitalization_H_
|
||||
#define Capitalization_H_
|
||||
|
||||
|
||||
|
||||
#include <string>
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
#include <boost/property_tree/ptree.hpp>
|
||||
#include "helpers.h"
|
||||
|
||||
namespace org {
|
||||
namespace openapitools {
|
||||
namespace server {
|
||||
namespace model {
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
class Capitalization
|
||||
{
|
||||
public:
|
||||
Capitalization() = default;
|
||||
explicit Capitalization(boost::property_tree::ptree const& pt);
|
||||
virtual ~Capitalization() = default;
|
||||
|
||||
Capitalization(const Capitalization& other) = default; // copy constructor
|
||||
Capitalization(Capitalization&& other) noexcept = default; // move constructor
|
||||
|
||||
Capitalization& operator=(const Capitalization& other) = default; // copy assignment
|
||||
Capitalization& operator=(Capitalization&& other) noexcept = default; // move assignment
|
||||
|
||||
std::string toJsonString(bool prettyJson = false) const;
|
||||
void fromJsonString(std::string const& jsonString);
|
||||
boost::property_tree::ptree toPropertyTree() const;
|
||||
void fromPropertyTree(boost::property_tree::ptree const& pt);
|
||||
|
||||
|
||||
/////////////////////////////////////////////
|
||||
/// Capitalization members
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
std::string getSmallCamel() const;
|
||||
void setSmallCamel(std::string value);
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
std::string getCapitalCamel() const;
|
||||
void setCapitalCamel(std::string value);
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
std::string getSmallSnake() const;
|
||||
void setSmallSnake(std::string value);
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
std::string getCapitalSnake() const;
|
||||
void setCapitalSnake(std::string value);
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
std::string getSCAETHFlowPoints() const;
|
||||
void setSCAETHFlowPoints(std::string value);
|
||||
|
||||
/// <summary>
|
||||
/// Name of the pet
|
||||
/// </summary>
|
||||
std::string getATTNAME() const;
|
||||
void setATTNAME(std::string value);
|
||||
|
||||
protected:
|
||||
std::string m_SmallCamel = "";
|
||||
std::string m_CapitalCamel = "";
|
||||
std::string m_Small_Snake = "";
|
||||
std::string m_Capital_Snake = "";
|
||||
std::string m_SCA_ETH_Flow_Points = "";
|
||||
std::string m_ATT_NAME = "";
|
||||
};
|
||||
|
||||
std::vector<Capitalization> createCapitalizationVectorFromJsonString(const std::string& json);
|
||||
|
||||
template<>
|
||||
inline boost::property_tree::ptree toPt<Capitalization>(const Capitalization& val) {
|
||||
return val.toPropertyTree();
|
||||
}
|
||||
|
||||
template<>
|
||||
inline Capitalization fromPt<Capitalization>(const boost::property_tree::ptree& pt) {
|
||||
Capitalization ret;
|
||||
ret.fromPropertyTree(pt);
|
||||
return ret;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif /* Capitalization_H_ */
|
||||
131
samples/server/petstore/cpp-restbed/generated/3_0/model/Cat.cpp
Normal file
131
samples/server/petstore/cpp-restbed/generated/3_0/model/Cat.cpp
Normal file
@@ -0,0 +1,131 @@
|
||||
/**
|
||||
* OpenAPI Petstore
|
||||
* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
|
||||
*
|
||||
* The version of the OpenAPI document: 1.0.0
|
||||
*
|
||||
*
|
||||
* NOTE: This class is auto generated by OpenAPI-Generator 7.0.0-SNAPSHOT.
|
||||
* https://openapi-generator.tech
|
||||
* Do not edit the class manually.
|
||||
*/
|
||||
|
||||
|
||||
|
||||
#include "Cat.h"
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <map>
|
||||
#include <sstream>
|
||||
#include <stdexcept>
|
||||
#include <regex>
|
||||
#include <boost/lexical_cast.hpp>
|
||||
#include <boost/property_tree/ptree.hpp>
|
||||
#include <boost/property_tree/json_parser.hpp>
|
||||
#include "helpers.h"
|
||||
|
||||
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 {
|
||||
|
||||
Cat::Cat(boost::property_tree::ptree const& pt)
|
||||
{
|
||||
fromPropertyTree(pt);
|
||||
}
|
||||
|
||||
|
||||
std::string Cat::toJsonString(bool prettyJson /* = false */) const
|
||||
{
|
||||
std::stringstream ss;
|
||||
write_json(ss, this->toPropertyTree(), prettyJson);
|
||||
// workaround inspired by: https://stackoverflow.com/a/56395440
|
||||
std::regex reg("\\\"([0-9]+\\.{0,1}[0-9]*)\\\"");
|
||||
std::string result = std::regex_replace(ss.str(), reg, "$1");
|
||||
return result;
|
||||
}
|
||||
|
||||
void Cat::fromJsonString(std::string const& jsonString)
|
||||
{
|
||||
std::stringstream ss(jsonString);
|
||||
ptree pt;
|
||||
read_json(ss,pt);
|
||||
this->fromPropertyTree(pt);
|
||||
}
|
||||
|
||||
ptree Cat::toPropertyTree() const
|
||||
{
|
||||
ptree pt;
|
||||
ptree tmp_node;
|
||||
pt.put("className", m_ClassName);
|
||||
pt.put("color", m_Color);
|
||||
pt.put("declawed", m_Declawed);
|
||||
return pt;
|
||||
}
|
||||
|
||||
void Cat::fromPropertyTree(ptree const &pt)
|
||||
{
|
||||
ptree tmp_node;
|
||||
m_ClassName = pt.get("className", "");
|
||||
m_Color = pt.get("color", "red");
|
||||
m_Declawed = pt.get("declawed", false);
|
||||
}
|
||||
|
||||
std::string Cat::getClassName() const
|
||||
{
|
||||
return m_ClassName;
|
||||
}
|
||||
|
||||
void Cat::setClassName(std::string value)
|
||||
{
|
||||
m_ClassName = value;
|
||||
}
|
||||
|
||||
|
||||
std::string Cat::getColor() const
|
||||
{
|
||||
return m_Color;
|
||||
}
|
||||
|
||||
void Cat::setColor(std::string value)
|
||||
{
|
||||
m_Color = value;
|
||||
}
|
||||
|
||||
|
||||
bool Cat::isDeclawed() const
|
||||
{
|
||||
return m_Declawed;
|
||||
}
|
||||
|
||||
void Cat::setDeclawed(bool value)
|
||||
{
|
||||
m_Declawed = value;
|
||||
}
|
||||
|
||||
|
||||
|
||||
std::vector<Cat> createCatVectorFromJsonString(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<Cat>();
|
||||
for (const auto& child: pt) {
|
||||
vec.emplace_back(Cat(child.second));
|
||||
}
|
||||
|
||||
return vec;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
106
samples/server/petstore/cpp-restbed/generated/3_0/model/Cat.h
Normal file
106
samples/server/petstore/cpp-restbed/generated/3_0/model/Cat.h
Normal file
@@ -0,0 +1,106 @@
|
||||
/**
|
||||
* OpenAPI Petstore
|
||||
* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
|
||||
*
|
||||
* The version of the OpenAPI document: 1.0.0
|
||||
*
|
||||
*
|
||||
* NOTE: This class is auto generated by OpenAPI-Generator 7.0.0-SNAPSHOT.
|
||||
* https://openapi-generator.tech
|
||||
* Do not edit the class manually.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Cat.h
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef Cat_H_
|
||||
#define Cat_H_
|
||||
|
||||
|
||||
|
||||
#include <string>
|
||||
#include "Animal.h"
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
#include <boost/property_tree/ptree.hpp>
|
||||
#include "Animal.h"
|
||||
#include "Cat_allOf.h"
|
||||
#include "helpers.h"
|
||||
|
||||
namespace org {
|
||||
namespace openapitools {
|
||||
namespace server {
|
||||
namespace model {
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
class Cat : public Animal, public Cat_allOf
|
||||
{
|
||||
public:
|
||||
Cat() = default;
|
||||
explicit Cat(boost::property_tree::ptree const& pt);
|
||||
virtual ~Cat() = default;
|
||||
|
||||
Cat(const Cat& other) = default; // copy constructor
|
||||
Cat(Cat&& other) noexcept = default; // move constructor
|
||||
|
||||
Cat& operator=(const Cat& other) = default; // copy assignment
|
||||
Cat& operator=(Cat&& other) noexcept = default; // move assignment
|
||||
|
||||
std::string toJsonString(bool prettyJson = false) const;
|
||||
void fromJsonString(std::string const& jsonString);
|
||||
boost::property_tree::ptree toPropertyTree() const;
|
||||
void fromPropertyTree(boost::property_tree::ptree const& pt);
|
||||
|
||||
|
||||
/////////////////////////////////////////////
|
||||
/// Cat members
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
std::string getClassName() const;
|
||||
void setClassName(std::string value);
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
std::string getColor() const;
|
||||
void setColor(std::string value);
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
bool isDeclawed() const;
|
||||
void setDeclawed(bool value);
|
||||
|
||||
protected:
|
||||
std::string m_ClassName = "";
|
||||
std::string m_Color = "red";
|
||||
bool m_Declawed = false;
|
||||
};
|
||||
|
||||
std::vector<Cat> createCatVectorFromJsonString(const std::string& json);
|
||||
|
||||
template<>
|
||||
inline boost::property_tree::ptree toPt<Cat>(const Cat& val) {
|
||||
return val.toPropertyTree();
|
||||
}
|
||||
|
||||
template<>
|
||||
inline Cat fromPt<Cat>(const boost::property_tree::ptree& pt) {
|
||||
Cat ret;
|
||||
ret.fromPropertyTree(pt);
|
||||
return ret;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif /* Cat_H_ */
|
||||
@@ -0,0 +1,105 @@
|
||||
/**
|
||||
* OpenAPI Petstore
|
||||
* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
|
||||
*
|
||||
* The version of the OpenAPI document: 1.0.0
|
||||
*
|
||||
*
|
||||
* NOTE: This class is auto generated by OpenAPI-Generator 7.0.0-SNAPSHOT.
|
||||
* https://openapi-generator.tech
|
||||
* Do not edit the class manually.
|
||||
*/
|
||||
|
||||
|
||||
|
||||
#include "Cat_allOf.h"
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <map>
|
||||
#include <sstream>
|
||||
#include <stdexcept>
|
||||
#include <regex>
|
||||
#include <boost/lexical_cast.hpp>
|
||||
#include <boost/property_tree/ptree.hpp>
|
||||
#include <boost/property_tree/json_parser.hpp>
|
||||
#include "helpers.h"
|
||||
|
||||
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 {
|
||||
|
||||
Cat_allOf::Cat_allOf(boost::property_tree::ptree const& pt)
|
||||
{
|
||||
fromPropertyTree(pt);
|
||||
}
|
||||
|
||||
|
||||
std::string Cat_allOf::toJsonString(bool prettyJson /* = false */) const
|
||||
{
|
||||
std::stringstream ss;
|
||||
write_json(ss, this->toPropertyTree(), prettyJson);
|
||||
// workaround inspired by: https://stackoverflow.com/a/56395440
|
||||
std::regex reg("\\\"([0-9]+\\.{0,1}[0-9]*)\\\"");
|
||||
std::string result = std::regex_replace(ss.str(), reg, "$1");
|
||||
return result;
|
||||
}
|
||||
|
||||
void Cat_allOf::fromJsonString(std::string const& jsonString)
|
||||
{
|
||||
std::stringstream ss(jsonString);
|
||||
ptree pt;
|
||||
read_json(ss,pt);
|
||||
this->fromPropertyTree(pt);
|
||||
}
|
||||
|
||||
ptree Cat_allOf::toPropertyTree() const
|
||||
{
|
||||
ptree pt;
|
||||
ptree tmp_node;
|
||||
pt.put("declawed", m_Declawed);
|
||||
return pt;
|
||||
}
|
||||
|
||||
void Cat_allOf::fromPropertyTree(ptree const &pt)
|
||||
{
|
||||
ptree tmp_node;
|
||||
m_Declawed = pt.get("declawed", false);
|
||||
}
|
||||
|
||||
bool Cat_allOf::isDeclawed() const
|
||||
{
|
||||
return m_Declawed;
|
||||
}
|
||||
|
||||
void Cat_allOf::setDeclawed(bool value)
|
||||
{
|
||||
m_Declawed = value;
|
||||
}
|
||||
|
||||
|
||||
|
||||
std::vector<Cat_allOf> createCat_allOfVectorFromJsonString(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<Cat_allOf>();
|
||||
for (const auto& child: pt) {
|
||||
vec.emplace_back(Cat_allOf(child.second));
|
||||
}
|
||||
|
||||
return vec;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,88 @@
|
||||
/**
|
||||
* OpenAPI Petstore
|
||||
* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
|
||||
*
|
||||
* The version of the OpenAPI document: 1.0.0
|
||||
*
|
||||
*
|
||||
* NOTE: This class is auto generated by OpenAPI-Generator 7.0.0-SNAPSHOT.
|
||||
* https://openapi-generator.tech
|
||||
* Do not edit the class manually.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Cat_allOf.h
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef Cat_allOf_H_
|
||||
#define Cat_allOf_H_
|
||||
|
||||
|
||||
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
#include <boost/property_tree/ptree.hpp>
|
||||
#include "helpers.h"
|
||||
|
||||
namespace org {
|
||||
namespace openapitools {
|
||||
namespace server {
|
||||
namespace model {
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
class Cat_allOf
|
||||
{
|
||||
public:
|
||||
Cat_allOf() = default;
|
||||
explicit Cat_allOf(boost::property_tree::ptree const& pt);
|
||||
virtual ~Cat_allOf() = default;
|
||||
|
||||
Cat_allOf(const Cat_allOf& other) = default; // copy constructor
|
||||
Cat_allOf(Cat_allOf&& other) noexcept = default; // move constructor
|
||||
|
||||
Cat_allOf& operator=(const Cat_allOf& other) = default; // copy assignment
|
||||
Cat_allOf& operator=(Cat_allOf&& other) noexcept = default; // move assignment
|
||||
|
||||
std::string toJsonString(bool prettyJson = false) const;
|
||||
void fromJsonString(std::string const& jsonString);
|
||||
boost::property_tree::ptree toPropertyTree() const;
|
||||
void fromPropertyTree(boost::property_tree::ptree const& pt);
|
||||
|
||||
|
||||
/////////////////////////////////////////////
|
||||
/// Cat_allOf members
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
bool isDeclawed() const;
|
||||
void setDeclawed(bool value);
|
||||
|
||||
protected:
|
||||
bool m_Declawed = false;
|
||||
};
|
||||
|
||||
std::vector<Cat_allOf> createCat_allOfVectorFromJsonString(const std::string& json);
|
||||
|
||||
template<>
|
||||
inline boost::property_tree::ptree toPt<Cat_allOf>(const Cat_allOf& val) {
|
||||
return val.toPropertyTree();
|
||||
}
|
||||
|
||||
template<>
|
||||
inline Cat_allOf fromPt<Cat_allOf>(const boost::property_tree::ptree& pt) {
|
||||
Cat_allOf ret;
|
||||
ret.fromPropertyTree(pt);
|
||||
return ret;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif /* Cat_allOf_H_ */
|
||||
@@ -1,11 +1,11 @@
|
||||
/**
|
||||
* 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.
|
||||
* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
|
||||
*
|
||||
* The version of the OpenAPI document: 1.0.0
|
||||
*
|
||||
*
|
||||
* NOTE: This class is auto generated by OpenAPI-Generator unset.
|
||||
* NOTE: This class is auto generated by OpenAPI-Generator 7.0.0-SNAPSHOT.
|
||||
* https://openapi-generator.tech
|
||||
* Do not edit the class manually.
|
||||
*/
|
||||
@@ -16,10 +16,14 @@
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <map>
|
||||
#include <sstream>
|
||||
#include <stdexcept>
|
||||
#include <regex>
|
||||
#include <boost/lexical_cast.hpp>
|
||||
#include <boost/property_tree/ptree.hpp>
|
||||
#include <boost/property_tree/json_parser.hpp>
|
||||
#include "helpers.h"
|
||||
|
||||
using boost::property_tree::ptree;
|
||||
using boost::property_tree::read_json;
|
||||
@@ -35,34 +39,18 @@ 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::string Category::toJsonString(bool prettyJson /* = false */) const
|
||||
{
|
||||
std::stringstream ss;
|
||||
write_json(ss, this->toPropertyTree(), prettyJson);
|
||||
return ss.str();
|
||||
// workaround inspired by: https://stackoverflow.com/a/56395440
|
||||
std::regex reg("\\\"([0-9]+\\.{0,1}[0-9]*)\\\"");
|
||||
std::string result = std::regex_replace(ss.str(), reg, "$1");
|
||||
return result;
|
||||
}
|
||||
|
||||
void Category::fromJsonString_internal(std::string const& jsonString)
|
||||
void Category::fromJsonString(std::string const& jsonString)
|
||||
{
|
||||
std::stringstream ss(jsonString);
|
||||
ptree pt;
|
||||
@@ -70,7 +58,7 @@ void Category::fromJsonString_internal(std::string const& jsonString)
|
||||
this->fromPropertyTree(pt);
|
||||
}
|
||||
|
||||
ptree Category::toPropertyTree_internal()
|
||||
ptree Category::toPropertyTree() const
|
||||
{
|
||||
ptree pt;
|
||||
ptree tmp_node;
|
||||
@@ -79,11 +67,11 @@ ptree Category::toPropertyTree_internal()
|
||||
return pt;
|
||||
}
|
||||
|
||||
void Category::fromPropertyTree_internal(ptree const &pt)
|
||||
void Category::fromPropertyTree(ptree const &pt)
|
||||
{
|
||||
ptree tmp_node;
|
||||
m_Id = pt.get("id", 0L);
|
||||
m_Name = pt.get("name", "");
|
||||
m_Name = pt.get("name", "default-name");
|
||||
}
|
||||
|
||||
int64_t Category::getId() const
|
||||
@@ -93,8 +81,10 @@ int64_t Category::getId() const
|
||||
|
||||
void Category::setId(int64_t value)
|
||||
{
|
||||
m_Id = value;
|
||||
m_Id = value;
|
||||
}
|
||||
|
||||
|
||||
std::string Category::getName() const
|
||||
{
|
||||
return m_Name;
|
||||
@@ -102,9 +92,11 @@ std::string Category::getName() const
|
||||
|
||||
void Category::setName(std::string value)
|
||||
{
|
||||
m_Name = value;
|
||||
m_Name = value;
|
||||
}
|
||||
|
||||
|
||||
|
||||
std::vector<Category> createCategoryVectorFromJsonString(const std::string& json)
|
||||
{
|
||||
std::stringstream sstream(json);
|
||||
@@ -1,11 +1,11 @@
|
||||
/**
|
||||
* 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.
|
||||
* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
|
||||
*
|
||||
* The version of the OpenAPI document: 1.0.0
|
||||
*
|
||||
*
|
||||
* NOTE: This class is auto generated by OpenAPI-Generator unset.
|
||||
* NOTE: This class is auto generated by OpenAPI-Generator 7.0.0-SNAPSHOT.
|
||||
* https://openapi-generator.tech
|
||||
* Do not edit the class manually.
|
||||
*/
|
||||
@@ -13,7 +13,7 @@
|
||||
/*
|
||||
* Category.h
|
||||
*
|
||||
* A category for a pet
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef Category_H_
|
||||
@@ -25,6 +25,7 @@
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
#include <boost/property_tree/ptree.hpp>
|
||||
#include "helpers.h"
|
||||
|
||||
namespace org {
|
||||
namespace openapitools {
|
||||
@@ -32,7 +33,7 @@ namespace server {
|
||||
namespace model {
|
||||
|
||||
/// <summary>
|
||||
/// A category for a pet
|
||||
///
|
||||
/// </summary>
|
||||
class Category
|
||||
{
|
||||
@@ -40,12 +41,19 @@ public:
|
||||
Category() = default;
|
||||
explicit Category(boost::property_tree::ptree const& pt);
|
||||
virtual ~Category() = default;
|
||||
|
||||
std::string toJsonString(bool prettyJson = false);
|
||||
|
||||
Category(const Category& other) = default; // copy constructor
|
||||
Category(Category&& other) noexcept = default; // move constructor
|
||||
|
||||
Category& operator=(const Category& other) = default; // copy assignment
|
||||
Category& operator=(Category&& other) noexcept = default; // move assignment
|
||||
|
||||
std::string toJsonString(bool prettyJson = false) const;
|
||||
void fromJsonString(std::string const& jsonString);
|
||||
boost::property_tree::ptree toPropertyTree();
|
||||
boost::property_tree::ptree toPropertyTree() const;
|
||||
void fromPropertyTree(boost::property_tree::ptree const& pt);
|
||||
|
||||
|
||||
/////////////////////////////////////////////
|
||||
/// Category members
|
||||
|
||||
@@ -61,24 +69,25 @@ public:
|
||||
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::string m_Name = "default-name";
|
||||
};
|
||||
|
||||
std::vector<Category> createCategoryVectorFromJsonString(const std::string& json);
|
||||
|
||||
template<>
|
||||
inline boost::property_tree::ptree toPt<Category>(const Category& val) {
|
||||
return val.toPropertyTree();
|
||||
}
|
||||
|
||||
template<>
|
||||
inline Category fromPt<Category>(const boost::property_tree::ptree& pt) {
|
||||
Category ret;
|
||||
ret.fromPropertyTree(pt);
|
||||
return ret;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,105 @@
|
||||
/**
|
||||
* OpenAPI Petstore
|
||||
* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
|
||||
*
|
||||
* The version of the OpenAPI document: 1.0.0
|
||||
*
|
||||
*
|
||||
* NOTE: This class is auto generated by OpenAPI-Generator 7.0.0-SNAPSHOT.
|
||||
* https://openapi-generator.tech
|
||||
* Do not edit the class manually.
|
||||
*/
|
||||
|
||||
|
||||
|
||||
#include "ClassModel.h"
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <map>
|
||||
#include <sstream>
|
||||
#include <stdexcept>
|
||||
#include <regex>
|
||||
#include <boost/lexical_cast.hpp>
|
||||
#include <boost/property_tree/ptree.hpp>
|
||||
#include <boost/property_tree/json_parser.hpp>
|
||||
#include "helpers.h"
|
||||
|
||||
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 {
|
||||
|
||||
ClassModel::ClassModel(boost::property_tree::ptree const& pt)
|
||||
{
|
||||
fromPropertyTree(pt);
|
||||
}
|
||||
|
||||
|
||||
std::string ClassModel::toJsonString(bool prettyJson /* = false */) const
|
||||
{
|
||||
std::stringstream ss;
|
||||
write_json(ss, this->toPropertyTree(), prettyJson);
|
||||
// workaround inspired by: https://stackoverflow.com/a/56395440
|
||||
std::regex reg("\\\"([0-9]+\\.{0,1}[0-9]*)\\\"");
|
||||
std::string result = std::regex_replace(ss.str(), reg, "$1");
|
||||
return result;
|
||||
}
|
||||
|
||||
void ClassModel::fromJsonString(std::string const& jsonString)
|
||||
{
|
||||
std::stringstream ss(jsonString);
|
||||
ptree pt;
|
||||
read_json(ss,pt);
|
||||
this->fromPropertyTree(pt);
|
||||
}
|
||||
|
||||
ptree ClassModel::toPropertyTree() const
|
||||
{
|
||||
ptree pt;
|
||||
ptree tmp_node;
|
||||
pt.put("_class", m__class);
|
||||
return pt;
|
||||
}
|
||||
|
||||
void ClassModel::fromPropertyTree(ptree const &pt)
|
||||
{
|
||||
ptree tmp_node;
|
||||
m__class = pt.get("_class", "");
|
||||
}
|
||||
|
||||
std::string ClassModel::get_Class() const
|
||||
{
|
||||
return m__class;
|
||||
}
|
||||
|
||||
void ClassModel::set_Class(std::string value)
|
||||
{
|
||||
m__class = value;
|
||||
}
|
||||
|
||||
|
||||
|
||||
std::vector<ClassModel> createClassModelVectorFromJsonString(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<ClassModel>();
|
||||
for (const auto& child: pt) {
|
||||
vec.emplace_back(ClassModel(child.second));
|
||||
}
|
||||
|
||||
return vec;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,89 @@
|
||||
/**
|
||||
* OpenAPI Petstore
|
||||
* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
|
||||
*
|
||||
* The version of the OpenAPI document: 1.0.0
|
||||
*
|
||||
*
|
||||
* NOTE: This class is auto generated by OpenAPI-Generator 7.0.0-SNAPSHOT.
|
||||
* https://openapi-generator.tech
|
||||
* Do not edit the class manually.
|
||||
*/
|
||||
|
||||
/*
|
||||
* ClassModel.h
|
||||
*
|
||||
* Model for testing model with \"_class\" property
|
||||
*/
|
||||
|
||||
#ifndef ClassModel_H_
|
||||
#define ClassModel_H_
|
||||
|
||||
|
||||
|
||||
#include <string>
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
#include <boost/property_tree/ptree.hpp>
|
||||
#include "helpers.h"
|
||||
|
||||
namespace org {
|
||||
namespace openapitools {
|
||||
namespace server {
|
||||
namespace model {
|
||||
|
||||
/// <summary>
|
||||
/// Model for testing model with \"_class\" property
|
||||
/// </summary>
|
||||
class ClassModel
|
||||
{
|
||||
public:
|
||||
ClassModel() = default;
|
||||
explicit ClassModel(boost::property_tree::ptree const& pt);
|
||||
virtual ~ClassModel() = default;
|
||||
|
||||
ClassModel(const ClassModel& other) = default; // copy constructor
|
||||
ClassModel(ClassModel&& other) noexcept = default; // move constructor
|
||||
|
||||
ClassModel& operator=(const ClassModel& other) = default; // copy assignment
|
||||
ClassModel& operator=(ClassModel&& other) noexcept = default; // move assignment
|
||||
|
||||
std::string toJsonString(bool prettyJson = false) const;
|
||||
void fromJsonString(std::string const& jsonString);
|
||||
boost::property_tree::ptree toPropertyTree() const;
|
||||
void fromPropertyTree(boost::property_tree::ptree const& pt);
|
||||
|
||||
|
||||
/////////////////////////////////////////////
|
||||
/// ClassModel members
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
std::string get_Class() const;
|
||||
void set_Class(std::string value);
|
||||
|
||||
protected:
|
||||
std::string m__class = "";
|
||||
};
|
||||
|
||||
std::vector<ClassModel> createClassModelVectorFromJsonString(const std::string& json);
|
||||
|
||||
template<>
|
||||
inline boost::property_tree::ptree toPt<ClassModel>(const ClassModel& val) {
|
||||
return val.toPropertyTree();
|
||||
}
|
||||
|
||||
template<>
|
||||
inline ClassModel fromPt<ClassModel>(const boost::property_tree::ptree& pt) {
|
||||
ClassModel ret;
|
||||
ret.fromPropertyTree(pt);
|
||||
return ret;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif /* ClassModel_H_ */
|
||||
@@ -0,0 +1,105 @@
|
||||
/**
|
||||
* OpenAPI Petstore
|
||||
* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
|
||||
*
|
||||
* The version of the OpenAPI document: 1.0.0
|
||||
*
|
||||
*
|
||||
* NOTE: This class is auto generated by OpenAPI-Generator 7.0.0-SNAPSHOT.
|
||||
* https://openapi-generator.tech
|
||||
* Do not edit the class manually.
|
||||
*/
|
||||
|
||||
|
||||
|
||||
#include "Client.h"
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <map>
|
||||
#include <sstream>
|
||||
#include <stdexcept>
|
||||
#include <regex>
|
||||
#include <boost/lexical_cast.hpp>
|
||||
#include <boost/property_tree/ptree.hpp>
|
||||
#include <boost/property_tree/json_parser.hpp>
|
||||
#include "helpers.h"
|
||||
|
||||
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 {
|
||||
|
||||
Client::Client(boost::property_tree::ptree const& pt)
|
||||
{
|
||||
fromPropertyTree(pt);
|
||||
}
|
||||
|
||||
|
||||
std::string Client::toJsonString(bool prettyJson /* = false */) const
|
||||
{
|
||||
std::stringstream ss;
|
||||
write_json(ss, this->toPropertyTree(), prettyJson);
|
||||
// workaround inspired by: https://stackoverflow.com/a/56395440
|
||||
std::regex reg("\\\"([0-9]+\\.{0,1}[0-9]*)\\\"");
|
||||
std::string result = std::regex_replace(ss.str(), reg, "$1");
|
||||
return result;
|
||||
}
|
||||
|
||||
void Client::fromJsonString(std::string const& jsonString)
|
||||
{
|
||||
std::stringstream ss(jsonString);
|
||||
ptree pt;
|
||||
read_json(ss,pt);
|
||||
this->fromPropertyTree(pt);
|
||||
}
|
||||
|
||||
ptree Client::toPropertyTree() const
|
||||
{
|
||||
ptree pt;
|
||||
ptree tmp_node;
|
||||
pt.put("client", m_Client);
|
||||
return pt;
|
||||
}
|
||||
|
||||
void Client::fromPropertyTree(ptree const &pt)
|
||||
{
|
||||
ptree tmp_node;
|
||||
m_Client = pt.get("client", "");
|
||||
}
|
||||
|
||||
std::string Client::getClient() const
|
||||
{
|
||||
return m_Client;
|
||||
}
|
||||
|
||||
void Client::setClient(std::string value)
|
||||
{
|
||||
m_Client = value;
|
||||
}
|
||||
|
||||
|
||||
|
||||
std::vector<Client> createClientVectorFromJsonString(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<Client>();
|
||||
for (const auto& child: pt) {
|
||||
vec.emplace_back(Client(child.second));
|
||||
}
|
||||
|
||||
return vec;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,89 @@
|
||||
/**
|
||||
* OpenAPI Petstore
|
||||
* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
|
||||
*
|
||||
* The version of the OpenAPI document: 1.0.0
|
||||
*
|
||||
*
|
||||
* NOTE: This class is auto generated by OpenAPI-Generator 7.0.0-SNAPSHOT.
|
||||
* https://openapi-generator.tech
|
||||
* Do not edit the class manually.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Client.h
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef Client_H_
|
||||
#define Client_H_
|
||||
|
||||
|
||||
|
||||
#include <string>
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
#include <boost/property_tree/ptree.hpp>
|
||||
#include "helpers.h"
|
||||
|
||||
namespace org {
|
||||
namespace openapitools {
|
||||
namespace server {
|
||||
namespace model {
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
class Client
|
||||
{
|
||||
public:
|
||||
Client() = default;
|
||||
explicit Client(boost::property_tree::ptree const& pt);
|
||||
virtual ~Client() = default;
|
||||
|
||||
Client(const Client& other) = default; // copy constructor
|
||||
Client(Client&& other) noexcept = default; // move constructor
|
||||
|
||||
Client& operator=(const Client& other) = default; // copy assignment
|
||||
Client& operator=(Client&& other) noexcept = default; // move assignment
|
||||
|
||||
std::string toJsonString(bool prettyJson = false) const;
|
||||
void fromJsonString(std::string const& jsonString);
|
||||
boost::property_tree::ptree toPropertyTree() const;
|
||||
void fromPropertyTree(boost::property_tree::ptree const& pt);
|
||||
|
||||
|
||||
/////////////////////////////////////////////
|
||||
/// Client members
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
std::string getClient() const;
|
||||
void setClient(std::string value);
|
||||
|
||||
protected:
|
||||
std::string m_Client = "";
|
||||
};
|
||||
|
||||
std::vector<Client> createClientVectorFromJsonString(const std::string& json);
|
||||
|
||||
template<>
|
||||
inline boost::property_tree::ptree toPt<Client>(const Client& val) {
|
||||
return val.toPropertyTree();
|
||||
}
|
||||
|
||||
template<>
|
||||
inline Client fromPt<Client>(const boost::property_tree::ptree& pt) {
|
||||
Client ret;
|
||||
ret.fromPropertyTree(pt);
|
||||
return ret;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif /* Client_H_ */
|
||||
@@ -0,0 +1,105 @@
|
||||
/**
|
||||
* OpenAPI Petstore
|
||||
* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
|
||||
*
|
||||
* The version of the OpenAPI document: 1.0.0
|
||||
*
|
||||
*
|
||||
* NOTE: This class is auto generated by OpenAPI-Generator 7.0.0-SNAPSHOT.
|
||||
* https://openapi-generator.tech
|
||||
* Do not edit the class manually.
|
||||
*/
|
||||
|
||||
|
||||
|
||||
#include "DeprecatedObject.h"
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <map>
|
||||
#include <sstream>
|
||||
#include <stdexcept>
|
||||
#include <regex>
|
||||
#include <boost/lexical_cast.hpp>
|
||||
#include <boost/property_tree/ptree.hpp>
|
||||
#include <boost/property_tree/json_parser.hpp>
|
||||
#include "helpers.h"
|
||||
|
||||
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 {
|
||||
|
||||
DeprecatedObject::DeprecatedObject(boost::property_tree::ptree const& pt)
|
||||
{
|
||||
fromPropertyTree(pt);
|
||||
}
|
||||
|
||||
|
||||
std::string DeprecatedObject::toJsonString(bool prettyJson /* = false */) const
|
||||
{
|
||||
std::stringstream ss;
|
||||
write_json(ss, this->toPropertyTree(), prettyJson);
|
||||
// workaround inspired by: https://stackoverflow.com/a/56395440
|
||||
std::regex reg("\\\"([0-9]+\\.{0,1}[0-9]*)\\\"");
|
||||
std::string result = std::regex_replace(ss.str(), reg, "$1");
|
||||
return result;
|
||||
}
|
||||
|
||||
void DeprecatedObject::fromJsonString(std::string const& jsonString)
|
||||
{
|
||||
std::stringstream ss(jsonString);
|
||||
ptree pt;
|
||||
read_json(ss,pt);
|
||||
this->fromPropertyTree(pt);
|
||||
}
|
||||
|
||||
ptree DeprecatedObject::toPropertyTree() const
|
||||
{
|
||||
ptree pt;
|
||||
ptree tmp_node;
|
||||
pt.put("name", m_Name);
|
||||
return pt;
|
||||
}
|
||||
|
||||
void DeprecatedObject::fromPropertyTree(ptree const &pt)
|
||||
{
|
||||
ptree tmp_node;
|
||||
m_Name = pt.get("name", "");
|
||||
}
|
||||
|
||||
std::string DeprecatedObject::getName() const
|
||||
{
|
||||
return m_Name;
|
||||
}
|
||||
|
||||
void DeprecatedObject::setName(std::string value)
|
||||
{
|
||||
m_Name = value;
|
||||
}
|
||||
|
||||
|
||||
|
||||
std::vector<DeprecatedObject> createDeprecatedObjectVectorFromJsonString(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<DeprecatedObject>();
|
||||
for (const auto& child: pt) {
|
||||
vec.emplace_back(DeprecatedObject(child.second));
|
||||
}
|
||||
|
||||
return vec;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,89 @@
|
||||
/**
|
||||
* OpenAPI Petstore
|
||||
* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
|
||||
*
|
||||
* The version of the OpenAPI document: 1.0.0
|
||||
*
|
||||
*
|
||||
* NOTE: This class is auto generated by OpenAPI-Generator 7.0.0-SNAPSHOT.
|
||||
* https://openapi-generator.tech
|
||||
* Do not edit the class manually.
|
||||
*/
|
||||
|
||||
/*
|
||||
* DeprecatedObject.h
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef DeprecatedObject_H_
|
||||
#define DeprecatedObject_H_
|
||||
|
||||
|
||||
|
||||
#include <string>
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
#include <boost/property_tree/ptree.hpp>
|
||||
#include "helpers.h"
|
||||
|
||||
namespace org {
|
||||
namespace openapitools {
|
||||
namespace server {
|
||||
namespace model {
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
class DeprecatedObject
|
||||
{
|
||||
public:
|
||||
DeprecatedObject() = default;
|
||||
explicit DeprecatedObject(boost::property_tree::ptree const& pt);
|
||||
virtual ~DeprecatedObject() = default;
|
||||
|
||||
DeprecatedObject(const DeprecatedObject& other) = default; // copy constructor
|
||||
DeprecatedObject(DeprecatedObject&& other) noexcept = default; // move constructor
|
||||
|
||||
DeprecatedObject& operator=(const DeprecatedObject& other) = default; // copy assignment
|
||||
DeprecatedObject& operator=(DeprecatedObject&& other) noexcept = default; // move assignment
|
||||
|
||||
std::string toJsonString(bool prettyJson = false) const;
|
||||
void fromJsonString(std::string const& jsonString);
|
||||
boost::property_tree::ptree toPropertyTree() const;
|
||||
void fromPropertyTree(boost::property_tree::ptree const& pt);
|
||||
|
||||
|
||||
/////////////////////////////////////////////
|
||||
/// DeprecatedObject members
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
std::string getName() const;
|
||||
void setName(std::string value);
|
||||
|
||||
protected:
|
||||
std::string m_Name = "";
|
||||
};
|
||||
|
||||
std::vector<DeprecatedObject> createDeprecatedObjectVectorFromJsonString(const std::string& json);
|
||||
|
||||
template<>
|
||||
inline boost::property_tree::ptree toPt<DeprecatedObject>(const DeprecatedObject& val) {
|
||||
return val.toPropertyTree();
|
||||
}
|
||||
|
||||
template<>
|
||||
inline DeprecatedObject fromPt<DeprecatedObject>(const boost::property_tree::ptree& pt) {
|
||||
DeprecatedObject ret;
|
||||
ret.fromPropertyTree(pt);
|
||||
return ret;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif /* DeprecatedObject_H_ */
|
||||
131
samples/server/petstore/cpp-restbed/generated/3_0/model/Dog.cpp
Normal file
131
samples/server/petstore/cpp-restbed/generated/3_0/model/Dog.cpp
Normal file
@@ -0,0 +1,131 @@
|
||||
/**
|
||||
* OpenAPI Petstore
|
||||
* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
|
||||
*
|
||||
* The version of the OpenAPI document: 1.0.0
|
||||
*
|
||||
*
|
||||
* NOTE: This class is auto generated by OpenAPI-Generator 7.0.0-SNAPSHOT.
|
||||
* https://openapi-generator.tech
|
||||
* Do not edit the class manually.
|
||||
*/
|
||||
|
||||
|
||||
|
||||
#include "Dog.h"
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <map>
|
||||
#include <sstream>
|
||||
#include <stdexcept>
|
||||
#include <regex>
|
||||
#include <boost/lexical_cast.hpp>
|
||||
#include <boost/property_tree/ptree.hpp>
|
||||
#include <boost/property_tree/json_parser.hpp>
|
||||
#include "helpers.h"
|
||||
|
||||
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 {
|
||||
|
||||
Dog::Dog(boost::property_tree::ptree const& pt)
|
||||
{
|
||||
fromPropertyTree(pt);
|
||||
}
|
||||
|
||||
|
||||
std::string Dog::toJsonString(bool prettyJson /* = false */) const
|
||||
{
|
||||
std::stringstream ss;
|
||||
write_json(ss, this->toPropertyTree(), prettyJson);
|
||||
// workaround inspired by: https://stackoverflow.com/a/56395440
|
||||
std::regex reg("\\\"([0-9]+\\.{0,1}[0-9]*)\\\"");
|
||||
std::string result = std::regex_replace(ss.str(), reg, "$1");
|
||||
return result;
|
||||
}
|
||||
|
||||
void Dog::fromJsonString(std::string const& jsonString)
|
||||
{
|
||||
std::stringstream ss(jsonString);
|
||||
ptree pt;
|
||||
read_json(ss,pt);
|
||||
this->fromPropertyTree(pt);
|
||||
}
|
||||
|
||||
ptree Dog::toPropertyTree() const
|
||||
{
|
||||
ptree pt;
|
||||
ptree tmp_node;
|
||||
pt.put("className", m_ClassName);
|
||||
pt.put("color", m_Color);
|
||||
pt.put("breed", m_Breed);
|
||||
return pt;
|
||||
}
|
||||
|
||||
void Dog::fromPropertyTree(ptree const &pt)
|
||||
{
|
||||
ptree tmp_node;
|
||||
m_ClassName = pt.get("className", "");
|
||||
m_Color = pt.get("color", "red");
|
||||
m_Breed = pt.get("breed", "");
|
||||
}
|
||||
|
||||
std::string Dog::getClassName() const
|
||||
{
|
||||
return m_ClassName;
|
||||
}
|
||||
|
||||
void Dog::setClassName(std::string value)
|
||||
{
|
||||
m_ClassName = value;
|
||||
}
|
||||
|
||||
|
||||
std::string Dog::getColor() const
|
||||
{
|
||||
return m_Color;
|
||||
}
|
||||
|
||||
void Dog::setColor(std::string value)
|
||||
{
|
||||
m_Color = value;
|
||||
}
|
||||
|
||||
|
||||
std::string Dog::getBreed() const
|
||||
{
|
||||
return m_Breed;
|
||||
}
|
||||
|
||||
void Dog::setBreed(std::string value)
|
||||
{
|
||||
m_Breed = value;
|
||||
}
|
||||
|
||||
|
||||
|
||||
std::vector<Dog> createDogVectorFromJsonString(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<Dog>();
|
||||
for (const auto& child: pt) {
|
||||
vec.emplace_back(Dog(child.second));
|
||||
}
|
||||
|
||||
return vec;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
106
samples/server/petstore/cpp-restbed/generated/3_0/model/Dog.h
Normal file
106
samples/server/petstore/cpp-restbed/generated/3_0/model/Dog.h
Normal file
@@ -0,0 +1,106 @@
|
||||
/**
|
||||
* OpenAPI Petstore
|
||||
* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
|
||||
*
|
||||
* The version of the OpenAPI document: 1.0.0
|
||||
*
|
||||
*
|
||||
* NOTE: This class is auto generated by OpenAPI-Generator 7.0.0-SNAPSHOT.
|
||||
* https://openapi-generator.tech
|
||||
* Do not edit the class manually.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Dog.h
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef Dog_H_
|
||||
#define Dog_H_
|
||||
|
||||
|
||||
|
||||
#include <string>
|
||||
#include "Animal.h"
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
#include <boost/property_tree/ptree.hpp>
|
||||
#include "Animal.h"
|
||||
#include "Dog_allOf.h"
|
||||
#include "helpers.h"
|
||||
|
||||
namespace org {
|
||||
namespace openapitools {
|
||||
namespace server {
|
||||
namespace model {
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
class Dog : public Animal, public Dog_allOf
|
||||
{
|
||||
public:
|
||||
Dog() = default;
|
||||
explicit Dog(boost::property_tree::ptree const& pt);
|
||||
virtual ~Dog() = default;
|
||||
|
||||
Dog(const Dog& other) = default; // copy constructor
|
||||
Dog(Dog&& other) noexcept = default; // move constructor
|
||||
|
||||
Dog& operator=(const Dog& other) = default; // copy assignment
|
||||
Dog& operator=(Dog&& other) noexcept = default; // move assignment
|
||||
|
||||
std::string toJsonString(bool prettyJson = false) const;
|
||||
void fromJsonString(std::string const& jsonString);
|
||||
boost::property_tree::ptree toPropertyTree() const;
|
||||
void fromPropertyTree(boost::property_tree::ptree const& pt);
|
||||
|
||||
|
||||
/////////////////////////////////////////////
|
||||
/// Dog members
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
std::string getClassName() const;
|
||||
void setClassName(std::string value);
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
std::string getColor() const;
|
||||
void setColor(std::string value);
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
std::string getBreed() const;
|
||||
void setBreed(std::string value);
|
||||
|
||||
protected:
|
||||
std::string m_ClassName = "";
|
||||
std::string m_Color = "red";
|
||||
std::string m_Breed = "";
|
||||
};
|
||||
|
||||
std::vector<Dog> createDogVectorFromJsonString(const std::string& json);
|
||||
|
||||
template<>
|
||||
inline boost::property_tree::ptree toPt<Dog>(const Dog& val) {
|
||||
return val.toPropertyTree();
|
||||
}
|
||||
|
||||
template<>
|
||||
inline Dog fromPt<Dog>(const boost::property_tree::ptree& pt) {
|
||||
Dog ret;
|
||||
ret.fromPropertyTree(pt);
|
||||
return ret;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif /* Dog_H_ */
|
||||
@@ -0,0 +1,105 @@
|
||||
/**
|
||||
* OpenAPI Petstore
|
||||
* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
|
||||
*
|
||||
* The version of the OpenAPI document: 1.0.0
|
||||
*
|
||||
*
|
||||
* NOTE: This class is auto generated by OpenAPI-Generator 7.0.0-SNAPSHOT.
|
||||
* https://openapi-generator.tech
|
||||
* Do not edit the class manually.
|
||||
*/
|
||||
|
||||
|
||||
|
||||
#include "Dog_allOf.h"
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <map>
|
||||
#include <sstream>
|
||||
#include <stdexcept>
|
||||
#include <regex>
|
||||
#include <boost/lexical_cast.hpp>
|
||||
#include <boost/property_tree/ptree.hpp>
|
||||
#include <boost/property_tree/json_parser.hpp>
|
||||
#include "helpers.h"
|
||||
|
||||
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 {
|
||||
|
||||
Dog_allOf::Dog_allOf(boost::property_tree::ptree const& pt)
|
||||
{
|
||||
fromPropertyTree(pt);
|
||||
}
|
||||
|
||||
|
||||
std::string Dog_allOf::toJsonString(bool prettyJson /* = false */) const
|
||||
{
|
||||
std::stringstream ss;
|
||||
write_json(ss, this->toPropertyTree(), prettyJson);
|
||||
// workaround inspired by: https://stackoverflow.com/a/56395440
|
||||
std::regex reg("\\\"([0-9]+\\.{0,1}[0-9]*)\\\"");
|
||||
std::string result = std::regex_replace(ss.str(), reg, "$1");
|
||||
return result;
|
||||
}
|
||||
|
||||
void Dog_allOf::fromJsonString(std::string const& jsonString)
|
||||
{
|
||||
std::stringstream ss(jsonString);
|
||||
ptree pt;
|
||||
read_json(ss,pt);
|
||||
this->fromPropertyTree(pt);
|
||||
}
|
||||
|
||||
ptree Dog_allOf::toPropertyTree() const
|
||||
{
|
||||
ptree pt;
|
||||
ptree tmp_node;
|
||||
pt.put("breed", m_Breed);
|
||||
return pt;
|
||||
}
|
||||
|
||||
void Dog_allOf::fromPropertyTree(ptree const &pt)
|
||||
{
|
||||
ptree tmp_node;
|
||||
m_Breed = pt.get("breed", "");
|
||||
}
|
||||
|
||||
std::string Dog_allOf::getBreed() const
|
||||
{
|
||||
return m_Breed;
|
||||
}
|
||||
|
||||
void Dog_allOf::setBreed(std::string value)
|
||||
{
|
||||
m_Breed = value;
|
||||
}
|
||||
|
||||
|
||||
|
||||
std::vector<Dog_allOf> createDog_allOfVectorFromJsonString(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<Dog_allOf>();
|
||||
for (const auto& child: pt) {
|
||||
vec.emplace_back(Dog_allOf(child.second));
|
||||
}
|
||||
|
||||
return vec;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,89 @@
|
||||
/**
|
||||
* OpenAPI Petstore
|
||||
* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
|
||||
*
|
||||
* The version of the OpenAPI document: 1.0.0
|
||||
*
|
||||
*
|
||||
* NOTE: This class is auto generated by OpenAPI-Generator 7.0.0-SNAPSHOT.
|
||||
* https://openapi-generator.tech
|
||||
* Do not edit the class manually.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Dog_allOf.h
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef Dog_allOf_H_
|
||||
#define Dog_allOf_H_
|
||||
|
||||
|
||||
|
||||
#include <string>
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
#include <boost/property_tree/ptree.hpp>
|
||||
#include "helpers.h"
|
||||
|
||||
namespace org {
|
||||
namespace openapitools {
|
||||
namespace server {
|
||||
namespace model {
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
class Dog_allOf
|
||||
{
|
||||
public:
|
||||
Dog_allOf() = default;
|
||||
explicit Dog_allOf(boost::property_tree::ptree const& pt);
|
||||
virtual ~Dog_allOf() = default;
|
||||
|
||||
Dog_allOf(const Dog_allOf& other) = default; // copy constructor
|
||||
Dog_allOf(Dog_allOf&& other) noexcept = default; // move constructor
|
||||
|
||||
Dog_allOf& operator=(const Dog_allOf& other) = default; // copy assignment
|
||||
Dog_allOf& operator=(Dog_allOf&& other) noexcept = default; // move assignment
|
||||
|
||||
std::string toJsonString(bool prettyJson = false) const;
|
||||
void fromJsonString(std::string const& jsonString);
|
||||
boost::property_tree::ptree toPropertyTree() const;
|
||||
void fromPropertyTree(boost::property_tree::ptree const& pt);
|
||||
|
||||
|
||||
/////////////////////////////////////////////
|
||||
/// Dog_allOf members
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
std::string getBreed() const;
|
||||
void setBreed(std::string value);
|
||||
|
||||
protected:
|
||||
std::string m_Breed = "";
|
||||
};
|
||||
|
||||
std::vector<Dog_allOf> createDog_allOfVectorFromJsonString(const std::string& json);
|
||||
|
||||
template<>
|
||||
inline boost::property_tree::ptree toPt<Dog_allOf>(const Dog_allOf& val) {
|
||||
return val.toPropertyTree();
|
||||
}
|
||||
|
||||
template<>
|
||||
inline Dog_allOf fromPt<Dog_allOf>(const boost::property_tree::ptree& pt) {
|
||||
Dog_allOf ret;
|
||||
ret.fromPropertyTree(pt);
|
||||
return ret;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif /* Dog_allOf_H_ */
|
||||
@@ -0,0 +1,144 @@
|
||||
/**
|
||||
* OpenAPI Petstore
|
||||
* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
|
||||
*
|
||||
* The version of the OpenAPI document: 1.0.0
|
||||
*
|
||||
*
|
||||
* NOTE: This class is auto generated by OpenAPI-Generator 7.0.0-SNAPSHOT.
|
||||
* https://openapi-generator.tech
|
||||
* Do not edit the class manually.
|
||||
*/
|
||||
|
||||
|
||||
|
||||
#include "EnumArrays.h"
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <map>
|
||||
#include <sstream>
|
||||
#include <stdexcept>
|
||||
#include <regex>
|
||||
#include <algorithm>
|
||||
#include <boost/lexical_cast.hpp>
|
||||
#include <boost/property_tree/ptree.hpp>
|
||||
#include <boost/property_tree/json_parser.hpp>
|
||||
#include "helpers.h"
|
||||
|
||||
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 {
|
||||
|
||||
EnumArrays::EnumArrays(boost::property_tree::ptree const& pt)
|
||||
{
|
||||
fromPropertyTree(pt);
|
||||
}
|
||||
|
||||
|
||||
std::string EnumArrays::toJsonString(bool prettyJson /* = false */) const
|
||||
{
|
||||
std::stringstream ss;
|
||||
write_json(ss, this->toPropertyTree(), prettyJson);
|
||||
// workaround inspired by: https://stackoverflow.com/a/56395440
|
||||
std::regex reg("\\\"([0-9]+\\.{0,1}[0-9]*)\\\"");
|
||||
std::string result = std::regex_replace(ss.str(), reg, "$1");
|
||||
return result;
|
||||
}
|
||||
|
||||
void EnumArrays::fromJsonString(std::string const& jsonString)
|
||||
{
|
||||
std::stringstream ss(jsonString);
|
||||
ptree pt;
|
||||
read_json(ss,pt);
|
||||
this->fromPropertyTree(pt);
|
||||
}
|
||||
|
||||
ptree EnumArrays::toPropertyTree() const
|
||||
{
|
||||
ptree pt;
|
||||
ptree tmp_node;
|
||||
pt.put("just_symbol", m_Just_symbol);
|
||||
// generate tree for Array_enum
|
||||
tmp_node.clear();
|
||||
if (!m_Array_enum.empty()) {
|
||||
tmp_node = toPt(m_Array_enum);
|
||||
pt.add_child("array_enum", tmp_node);
|
||||
tmp_node.clear();
|
||||
}
|
||||
return pt;
|
||||
}
|
||||
|
||||
void EnumArrays::fromPropertyTree(ptree const &pt)
|
||||
{
|
||||
ptree tmp_node;
|
||||
setJustSymbol(pt.get("just_symbol", ""));
|
||||
// push all items of Array_enum into member
|
||||
if (pt.get_child_optional("array_enum")) {
|
||||
m_Array_enum = fromPt<std::vector<std::string>>(pt.get_child("array_enum"));
|
||||
}
|
||||
}
|
||||
|
||||
std::string EnumArrays::getJustSymbol() const
|
||||
{
|
||||
return m_Just_symbol;
|
||||
}
|
||||
|
||||
void EnumArrays::setJustSymbol(std::string value)
|
||||
{
|
||||
static const std::array<std::string, 2> allowedValues = {
|
||||
">=", "$"
|
||||
};
|
||||
|
||||
if (std::find(allowedValues.begin(), allowedValues.end(), value) != allowedValues.end()) {
|
||||
m_Just_symbol = value;
|
||||
} else {
|
||||
throw std::runtime_error("Value " + boost::lexical_cast<std::string>(value) + " not allowed");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
std::vector<std::string> EnumArrays::getArrayEnum() const
|
||||
{
|
||||
return m_Array_enum;
|
||||
}
|
||||
|
||||
void EnumArrays::setArrayEnum(std::vector<std::string> value)
|
||||
{
|
||||
static const std::array<std::string, 2> allowedValues = {
|
||||
"fish", "crab"
|
||||
};
|
||||
|
||||
for (const auto &v: value) {
|
||||
if (std::find(allowedValues.begin(), allowedValues.end(), v) == allowedValues.end()) {
|
||||
throw std::runtime_error("Value " + boost::lexical_cast<std::string>(v) + " not allowed");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
std::vector<EnumArrays> createEnumArraysVectorFromJsonString(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<EnumArrays>();
|
||||
for (const auto& child: pt) {
|
||||
vec.emplace_back(EnumArrays(child.second));
|
||||
}
|
||||
|
||||
return vec;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,98 @@
|
||||
/**
|
||||
* OpenAPI Petstore
|
||||
* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
|
||||
*
|
||||
* The version of the OpenAPI document: 1.0.0
|
||||
*
|
||||
*
|
||||
* NOTE: This class is auto generated by OpenAPI-Generator 7.0.0-SNAPSHOT.
|
||||
* https://openapi-generator.tech
|
||||
* Do not edit the class manually.
|
||||
*/
|
||||
|
||||
/*
|
||||
* EnumArrays.h
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef EnumArrays_H_
|
||||
#define EnumArrays_H_
|
||||
|
||||
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
#include <array>
|
||||
#include <boost/property_tree/ptree.hpp>
|
||||
#include "helpers.h"
|
||||
|
||||
namespace org {
|
||||
namespace openapitools {
|
||||
namespace server {
|
||||
namespace model {
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
class EnumArrays
|
||||
{
|
||||
public:
|
||||
EnumArrays() = default;
|
||||
explicit EnumArrays(boost::property_tree::ptree const& pt);
|
||||
virtual ~EnumArrays() = default;
|
||||
|
||||
EnumArrays(const EnumArrays& other) = default; // copy constructor
|
||||
EnumArrays(EnumArrays&& other) noexcept = default; // move constructor
|
||||
|
||||
EnumArrays& operator=(const EnumArrays& other) = default; // copy assignment
|
||||
EnumArrays& operator=(EnumArrays&& other) noexcept = default; // move assignment
|
||||
|
||||
std::string toJsonString(bool prettyJson = false) const;
|
||||
void fromJsonString(std::string const& jsonString);
|
||||
boost::property_tree::ptree toPropertyTree() const;
|
||||
void fromPropertyTree(boost::property_tree::ptree const& pt);
|
||||
|
||||
|
||||
/////////////////////////////////////////////
|
||||
/// EnumArrays members
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
std::string getJustSymbol() const;
|
||||
void setJustSymbol(std::string value);
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
std::vector<std::string> getArrayEnum() const;
|
||||
void setArrayEnum(std::vector<std::string> value);
|
||||
|
||||
protected:
|
||||
std::string m_Just_symbol = "";
|
||||
std::vector<std::string> m_Array_enum;
|
||||
};
|
||||
|
||||
std::vector<EnumArrays> createEnumArraysVectorFromJsonString(const std::string& json);
|
||||
|
||||
template<>
|
||||
inline boost::property_tree::ptree toPt<EnumArrays>(const EnumArrays& val) {
|
||||
return val.toPropertyTree();
|
||||
}
|
||||
|
||||
template<>
|
||||
inline EnumArrays fromPt<EnumArrays>(const boost::property_tree::ptree& pt) {
|
||||
EnumArrays ret;
|
||||
ret.fromPropertyTree(pt);
|
||||
return ret;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif /* EnumArrays_H_ */
|
||||
@@ -0,0 +1,114 @@
|
||||
/**
|
||||
* OpenAPI Petstore
|
||||
* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
|
||||
*
|
||||
* The version of the OpenAPI document: 1.0.0
|
||||
*
|
||||
*
|
||||
* NOTE: This class is auto generated by OpenAPI-Generator 7.0.0-SNAPSHOT.
|
||||
* https://openapi-generator.tech
|
||||
* Do not edit the class manually.
|
||||
*/
|
||||
|
||||
|
||||
|
||||
#include "EnumClass.h"
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <map>
|
||||
#include <sstream>
|
||||
#include <stdexcept>
|
||||
#include <regex>
|
||||
#include <boost/lexical_cast.hpp>
|
||||
#include <boost/property_tree/ptree.hpp>
|
||||
#include <boost/property_tree/json_parser.hpp>
|
||||
#include "helpers.h"
|
||||
|
||||
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 {
|
||||
|
||||
EnumClass::EnumClass(boost::property_tree::ptree const& pt)
|
||||
{
|
||||
fromPropertyTree(pt);
|
||||
}
|
||||
|
||||
|
||||
std::string EnumClass::toJsonString(bool prettyJson /* = false */) const
|
||||
{
|
||||
std::stringstream ss;
|
||||
write_json(ss, this->toPropertyTree(), prettyJson);
|
||||
// workaround inspired by: https://stackoverflow.com/a/56395440
|
||||
std::regex reg("\\\"([0-9]+\\.{0,1}[0-9]*)\\\"");
|
||||
std::string result = std::regex_replace(ss.str(), reg, "$1");
|
||||
return result;
|
||||
}
|
||||
|
||||
void EnumClass::fromJsonString(std::string const& jsonString)
|
||||
{
|
||||
std::stringstream ss(jsonString);
|
||||
ptree pt;
|
||||
read_json(ss,pt);
|
||||
this->fromPropertyTree(pt);
|
||||
}
|
||||
|
||||
ptree EnumClass::toPropertyTree() const
|
||||
{
|
||||
ptree pt;
|
||||
ptree tmp_node;
|
||||
return pt;
|
||||
}
|
||||
|
||||
void EnumClass::fromPropertyTree(ptree const &pt)
|
||||
{
|
||||
ptree tmp_node;
|
||||
}
|
||||
|
||||
std::string EnumClass::toString() const {
|
||||
return boost::lexical_cast<std::string>(getEnumValue());
|
||||
}
|
||||
|
||||
void EnumClass::fromString(const std::string& str) {
|
||||
setEnumValue(boost::lexical_cast<std::string>(str));
|
||||
}
|
||||
|
||||
std::string EnumClass::getEnumValue() const {
|
||||
return m_EnumClassEnumValue;
|
||||
}
|
||||
|
||||
void EnumClass::setEnumValue(const std::string& val) {
|
||||
static const std::array<std::string, 3> allowedValues = {
|
||||
"_abc", "-efg", "(xyz)"
|
||||
};
|
||||
if (std::find(allowedValues.begin(), allowedValues.end(), val) != allowedValues.end()) {
|
||||
m_EnumClassEnumValue = val;
|
||||
} else {
|
||||
throw std::runtime_error("Value " + boost::lexical_cast<std::string>(val) + " not allowed");
|
||||
}
|
||||
}
|
||||
|
||||
std::vector<EnumClass> createEnumClassVectorFromJsonString(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<EnumClass>();
|
||||
for (const auto& child: pt) {
|
||||
vec.emplace_back(EnumClass(child.second));
|
||||
}
|
||||
|
||||
return vec;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,86 @@
|
||||
/**
|
||||
* OpenAPI Petstore
|
||||
* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
|
||||
*
|
||||
* The version of the OpenAPI document: 1.0.0
|
||||
*
|
||||
*
|
||||
* NOTE: This class is auto generated by OpenAPI-Generator 7.0.0-SNAPSHOT.
|
||||
* https://openapi-generator.tech
|
||||
* Do not edit the class manually.
|
||||
*/
|
||||
|
||||
/*
|
||||
* EnumClass.h
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef EnumClass_H_
|
||||
#define EnumClass_H_
|
||||
|
||||
|
||||
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
#include <boost/property_tree/ptree.hpp>
|
||||
#include "helpers.h"
|
||||
|
||||
namespace org {
|
||||
namespace openapitools {
|
||||
namespace server {
|
||||
namespace model {
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
class EnumClass
|
||||
{
|
||||
public:
|
||||
EnumClass() = default;
|
||||
explicit EnumClass(boost::property_tree::ptree const& pt);
|
||||
virtual ~EnumClass() = default;
|
||||
|
||||
EnumClass(const EnumClass& other) = default; // copy constructor
|
||||
EnumClass(EnumClass&& other) noexcept = default; // move constructor
|
||||
|
||||
EnumClass& operator=(const EnumClass& other) = default; // copy assignment
|
||||
EnumClass& operator=(EnumClass&& other) noexcept = default; // move assignment
|
||||
|
||||
std::string toJsonString(bool prettyJson = false) const;
|
||||
void fromJsonString(std::string const& jsonString);
|
||||
boost::property_tree::ptree toPropertyTree() const;
|
||||
void fromPropertyTree(boost::property_tree::ptree const& pt);
|
||||
|
||||
std::string toString() const;
|
||||
void fromString(const std::string& str);
|
||||
|
||||
/////////////////////////////////////////////
|
||||
/// EnumClass members
|
||||
std::string getEnumValue() const;
|
||||
void setEnumValue(const std::string& val);
|
||||
|
||||
protected:
|
||||
std::string m_EnumClassEnumValue;
|
||||
};
|
||||
|
||||
std::vector<EnumClass> createEnumClassVectorFromJsonString(const std::string& json);
|
||||
|
||||
template<>
|
||||
inline boost::property_tree::ptree toPt<EnumClass>(const EnumClass& val) {
|
||||
return val.toPropertyTree();
|
||||
}
|
||||
|
||||
template<>
|
||||
inline EnumClass fromPt<EnumClass>(const boost::property_tree::ptree& pt) {
|
||||
EnumClass ret;
|
||||
ret.fromPropertyTree(pt);
|
||||
return ret;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif /* EnumClass_H_ */
|
||||
@@ -0,0 +1,221 @@
|
||||
/**
|
||||
* OpenAPI Petstore
|
||||
* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
|
||||
*
|
||||
* The version of the OpenAPI document: 1.0.0
|
||||
*
|
||||
*
|
||||
* NOTE: This class is auto generated by OpenAPI-Generator 7.0.0-SNAPSHOT.
|
||||
* https://openapi-generator.tech
|
||||
* Do not edit the class manually.
|
||||
*/
|
||||
|
||||
|
||||
|
||||
#include "Enum_Test.h"
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <map>
|
||||
#include <sstream>
|
||||
#include <stdexcept>
|
||||
#include <regex>
|
||||
#include <algorithm>
|
||||
#include <boost/lexical_cast.hpp>
|
||||
#include <boost/property_tree/ptree.hpp>
|
||||
#include <boost/property_tree/json_parser.hpp>
|
||||
#include "helpers.h"
|
||||
|
||||
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 {
|
||||
|
||||
Enum_Test::Enum_Test(boost::property_tree::ptree const& pt)
|
||||
{
|
||||
fromPropertyTree(pt);
|
||||
}
|
||||
|
||||
|
||||
std::string Enum_Test::toJsonString(bool prettyJson /* = false */) const
|
||||
{
|
||||
std::stringstream ss;
|
||||
write_json(ss, this->toPropertyTree(), prettyJson);
|
||||
// workaround inspired by: https://stackoverflow.com/a/56395440
|
||||
std::regex reg("\\\"([0-9]+\\.{0,1}[0-9]*)\\\"");
|
||||
std::string result = std::regex_replace(ss.str(), reg, "$1");
|
||||
return result;
|
||||
}
|
||||
|
||||
void Enum_Test::fromJsonString(std::string const& jsonString)
|
||||
{
|
||||
std::stringstream ss(jsonString);
|
||||
ptree pt;
|
||||
read_json(ss,pt);
|
||||
this->fromPropertyTree(pt);
|
||||
}
|
||||
|
||||
ptree Enum_Test::toPropertyTree() const
|
||||
{
|
||||
ptree pt;
|
||||
ptree tmp_node;
|
||||
pt.put("enum_string", m_Enum_string);
|
||||
pt.put("enum_string_required", m_Enum_string_required);
|
||||
pt.put("enum_integer", m_Enum_integer);
|
||||
pt.put("enum_number", m_Enum_number);
|
||||
return pt;
|
||||
}
|
||||
|
||||
void Enum_Test::fromPropertyTree(ptree const &pt)
|
||||
{
|
||||
ptree tmp_node;
|
||||
setEnumString(pt.get("enum_string", ""));
|
||||
setEnumStringRequired(pt.get("enum_string_required", ""));
|
||||
setEnumInteger(pt.get("enum_integer", 0));
|
||||
setEnumNumber(pt.get("enum_number", 0.0));
|
||||
}
|
||||
|
||||
std::string Enum_Test::getEnumString() const
|
||||
{
|
||||
return m_Enum_string;
|
||||
}
|
||||
|
||||
void Enum_Test::setEnumString(std::string value)
|
||||
{
|
||||
static const std::array<std::string, 3> allowedValues = {
|
||||
"UPPER", "lower", ""
|
||||
};
|
||||
|
||||
if (std::find(allowedValues.begin(), allowedValues.end(), value) != allowedValues.end()) {
|
||||
m_Enum_string = value;
|
||||
} else {
|
||||
throw std::runtime_error("Value " + boost::lexical_cast<std::string>(value) + " not allowed");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
std::string Enum_Test::getEnumStringRequired() const
|
||||
{
|
||||
return m_Enum_string_required;
|
||||
}
|
||||
|
||||
void Enum_Test::setEnumStringRequired(std::string value)
|
||||
{
|
||||
static const std::array<std::string, 3> allowedValues = {
|
||||
"UPPER", "lower", ""
|
||||
};
|
||||
|
||||
if (std::find(allowedValues.begin(), allowedValues.end(), value) != allowedValues.end()) {
|
||||
m_Enum_string_required = value;
|
||||
} else {
|
||||
throw std::runtime_error("Value " + boost::lexical_cast<std::string>(value) + " not allowed");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
int32_t Enum_Test::getEnumInteger() const
|
||||
{
|
||||
return m_Enum_integer;
|
||||
}
|
||||
|
||||
void Enum_Test::setEnumInteger(int32_t value)
|
||||
{
|
||||
static const std::array<int32_t, 2> allowedValues = {
|
||||
1, -1
|
||||
};
|
||||
|
||||
if (std::find(allowedValues.begin(), allowedValues.end(), value) != allowedValues.end()) {
|
||||
m_Enum_integer = value;
|
||||
} else {
|
||||
throw std::runtime_error("Value " + boost::lexical_cast<std::string>(value) + " not allowed");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
double Enum_Test::getEnumNumber() const
|
||||
{
|
||||
return m_Enum_number;
|
||||
}
|
||||
|
||||
void Enum_Test::setEnumNumber(double value)
|
||||
{
|
||||
static const std::array<double, 2> allowedValues = {
|
||||
1.1, -1.2
|
||||
};
|
||||
|
||||
if (std::find(allowedValues.begin(), allowedValues.end(), value) != allowedValues.end()) {
|
||||
m_Enum_number = value;
|
||||
} else {
|
||||
throw std::runtime_error("Value " + boost::lexical_cast<std::string>(value) + " not allowed");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
OuterEnum Enum_Test::getOuterEnum() const
|
||||
{
|
||||
return m_OuterEnum;
|
||||
}
|
||||
|
||||
void Enum_Test::setOuterEnum(OuterEnum value)
|
||||
{
|
||||
m_OuterEnum = value;
|
||||
}
|
||||
|
||||
|
||||
OuterEnumInteger Enum_Test::getOuterEnumInteger() const
|
||||
{
|
||||
return m_OuterEnumInteger;
|
||||
}
|
||||
|
||||
void Enum_Test::setOuterEnumInteger(OuterEnumInteger value)
|
||||
{
|
||||
m_OuterEnumInteger = value;
|
||||
}
|
||||
|
||||
|
||||
OuterEnumDefaultValue Enum_Test::getOuterEnumDefaultValue() const
|
||||
{
|
||||
return m_OuterEnumDefaultValue;
|
||||
}
|
||||
|
||||
void Enum_Test::setOuterEnumDefaultValue(OuterEnumDefaultValue value)
|
||||
{
|
||||
m_OuterEnumDefaultValue = value;
|
||||
}
|
||||
|
||||
|
||||
OuterEnumIntegerDefaultValue Enum_Test::getOuterEnumIntegerDefaultValue() const
|
||||
{
|
||||
return m_OuterEnumIntegerDefaultValue;
|
||||
}
|
||||
|
||||
void Enum_Test::setOuterEnumIntegerDefaultValue(OuterEnumIntegerDefaultValue value)
|
||||
{
|
||||
m_OuterEnumIntegerDefaultValue = value;
|
||||
}
|
||||
|
||||
|
||||
|
||||
std::vector<Enum_Test> createEnum_TestVectorFromJsonString(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<Enum_Test>();
|
||||
for (const auto& child: pt) {
|
||||
vec.emplace_back(Enum_Test(child.second));
|
||||
}
|
||||
|
||||
return vec;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,143 @@
|
||||
/**
|
||||
* OpenAPI Petstore
|
||||
* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
|
||||
*
|
||||
* The version of the OpenAPI document: 1.0.0
|
||||
*
|
||||
*
|
||||
* NOTE: This class is auto generated by OpenAPI-Generator 7.0.0-SNAPSHOT.
|
||||
* https://openapi-generator.tech
|
||||
* Do not edit the class manually.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Enum_Test.h
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef Enum_Test_H_
|
||||
#define Enum_Test_H_
|
||||
|
||||
|
||||
|
||||
#include "OuterEnumIntegerDefaultValue.h"
|
||||
#include "OuterEnumInteger.h"
|
||||
#include "OuterEnum.h"
|
||||
#include "OuterEnumDefaultValue.h"
|
||||
#include <string>
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
#include <array>
|
||||
#include <boost/property_tree/ptree.hpp>
|
||||
#include "helpers.h"
|
||||
|
||||
namespace org {
|
||||
namespace openapitools {
|
||||
namespace server {
|
||||
namespace model {
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
class Enum_Test
|
||||
{
|
||||
public:
|
||||
Enum_Test() = default;
|
||||
explicit Enum_Test(boost::property_tree::ptree const& pt);
|
||||
virtual ~Enum_Test() = default;
|
||||
|
||||
Enum_Test(const Enum_Test& other) = default; // copy constructor
|
||||
Enum_Test(Enum_Test&& other) noexcept = default; // move constructor
|
||||
|
||||
Enum_Test& operator=(const Enum_Test& other) = default; // copy assignment
|
||||
Enum_Test& operator=(Enum_Test&& other) noexcept = default; // move assignment
|
||||
|
||||
std::string toJsonString(bool prettyJson = false) const;
|
||||
void fromJsonString(std::string const& jsonString);
|
||||
boost::property_tree::ptree toPropertyTree() const;
|
||||
void fromPropertyTree(boost::property_tree::ptree const& pt);
|
||||
|
||||
|
||||
/////////////////////////////////////////////
|
||||
/// Enum_Test members
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
std::string getEnumString() const;
|
||||
void setEnumString(std::string value);
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
std::string getEnumStringRequired() const;
|
||||
void setEnumStringRequired(std::string value);
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
int32_t getEnumInteger() const;
|
||||
void setEnumInteger(int32_t value);
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
double getEnumNumber() const;
|
||||
void setEnumNumber(double value);
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
OuterEnum getOuterEnum() const;
|
||||
void setOuterEnum(OuterEnum value);
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
OuterEnumInteger getOuterEnumInteger() const;
|
||||
void setOuterEnumInteger(OuterEnumInteger value);
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
OuterEnumDefaultValue getOuterEnumDefaultValue() const;
|
||||
void setOuterEnumDefaultValue(OuterEnumDefaultValue value);
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
OuterEnumIntegerDefaultValue getOuterEnumIntegerDefaultValue() const;
|
||||
void setOuterEnumIntegerDefaultValue(OuterEnumIntegerDefaultValue value);
|
||||
|
||||
protected:
|
||||
std::string m_Enum_string = "";
|
||||
std::string m_Enum_string_required = "";
|
||||
int32_t m_Enum_integer = 0;
|
||||
double m_Enum_number = 0.0;
|
||||
OuterEnum m_OuterEnum = OuterEnum{};
|
||||
OuterEnumInteger m_OuterEnumInteger = OuterEnumInteger{};
|
||||
OuterEnumDefaultValue m_OuterEnumDefaultValue = OuterEnumDefaultValue{};
|
||||
OuterEnumIntegerDefaultValue m_OuterEnumIntegerDefaultValue = OuterEnumIntegerDefaultValue{};
|
||||
};
|
||||
|
||||
std::vector<Enum_Test> createEnum_TestVectorFromJsonString(const std::string& json);
|
||||
|
||||
template<>
|
||||
inline boost::property_tree::ptree toPt<Enum_Test>(const Enum_Test& val) {
|
||||
return val.toPropertyTree();
|
||||
}
|
||||
|
||||
template<>
|
||||
inline Enum_Test fromPt<Enum_Test>(const boost::property_tree::ptree& pt) {
|
||||
Enum_Test ret;
|
||||
ret.fromPropertyTree(pt);
|
||||
return ret;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif /* Enum_Test_H_ */
|
||||
105
samples/server/petstore/cpp-restbed/generated/3_0/model/File.cpp
Normal file
105
samples/server/petstore/cpp-restbed/generated/3_0/model/File.cpp
Normal file
@@ -0,0 +1,105 @@
|
||||
/**
|
||||
* OpenAPI Petstore
|
||||
* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
|
||||
*
|
||||
* The version of the OpenAPI document: 1.0.0
|
||||
*
|
||||
*
|
||||
* NOTE: This class is auto generated by OpenAPI-Generator 7.0.0-SNAPSHOT.
|
||||
* https://openapi-generator.tech
|
||||
* Do not edit the class manually.
|
||||
*/
|
||||
|
||||
|
||||
|
||||
#include "File.h"
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <map>
|
||||
#include <sstream>
|
||||
#include <stdexcept>
|
||||
#include <regex>
|
||||
#include <boost/lexical_cast.hpp>
|
||||
#include <boost/property_tree/ptree.hpp>
|
||||
#include <boost/property_tree/json_parser.hpp>
|
||||
#include "helpers.h"
|
||||
|
||||
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 {
|
||||
|
||||
File::File(boost::property_tree::ptree const& pt)
|
||||
{
|
||||
fromPropertyTree(pt);
|
||||
}
|
||||
|
||||
|
||||
std::string File::toJsonString(bool prettyJson /* = false */) const
|
||||
{
|
||||
std::stringstream ss;
|
||||
write_json(ss, this->toPropertyTree(), prettyJson);
|
||||
// workaround inspired by: https://stackoverflow.com/a/56395440
|
||||
std::regex reg("\\\"([0-9]+\\.{0,1}[0-9]*)\\\"");
|
||||
std::string result = std::regex_replace(ss.str(), reg, "$1");
|
||||
return result;
|
||||
}
|
||||
|
||||
void File::fromJsonString(std::string const& jsonString)
|
||||
{
|
||||
std::stringstream ss(jsonString);
|
||||
ptree pt;
|
||||
read_json(ss,pt);
|
||||
this->fromPropertyTree(pt);
|
||||
}
|
||||
|
||||
ptree File::toPropertyTree() const
|
||||
{
|
||||
ptree pt;
|
||||
ptree tmp_node;
|
||||
pt.put("sourceURI", m_SourceURI);
|
||||
return pt;
|
||||
}
|
||||
|
||||
void File::fromPropertyTree(ptree const &pt)
|
||||
{
|
||||
ptree tmp_node;
|
||||
m_SourceURI = pt.get("sourceURI", "");
|
||||
}
|
||||
|
||||
std::string File::getSourceURI() const
|
||||
{
|
||||
return m_SourceURI;
|
||||
}
|
||||
|
||||
void File::setSourceURI(std::string value)
|
||||
{
|
||||
m_SourceURI = value;
|
||||
}
|
||||
|
||||
|
||||
|
||||
std::vector<File> createFileVectorFromJsonString(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<File>();
|
||||
for (const auto& child: pt) {
|
||||
vec.emplace_back(File(child.second));
|
||||
}
|
||||
|
||||
return vec;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,89 @@
|
||||
/**
|
||||
* OpenAPI Petstore
|
||||
* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
|
||||
*
|
||||
* The version of the OpenAPI document: 1.0.0
|
||||
*
|
||||
*
|
||||
* NOTE: This class is auto generated by OpenAPI-Generator 7.0.0-SNAPSHOT.
|
||||
* https://openapi-generator.tech
|
||||
* Do not edit the class manually.
|
||||
*/
|
||||
|
||||
/*
|
||||
* File.h
|
||||
*
|
||||
* Must be named `File` for test.
|
||||
*/
|
||||
|
||||
#ifndef File_H_
|
||||
#define File_H_
|
||||
|
||||
|
||||
|
||||
#include <string>
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
#include <boost/property_tree/ptree.hpp>
|
||||
#include "helpers.h"
|
||||
|
||||
namespace org {
|
||||
namespace openapitools {
|
||||
namespace server {
|
||||
namespace model {
|
||||
|
||||
/// <summary>
|
||||
/// Must be named `File` for test.
|
||||
/// </summary>
|
||||
class File
|
||||
{
|
||||
public:
|
||||
File() = default;
|
||||
explicit File(boost::property_tree::ptree const& pt);
|
||||
virtual ~File() = default;
|
||||
|
||||
File(const File& other) = default; // copy constructor
|
||||
File(File&& other) noexcept = default; // move constructor
|
||||
|
||||
File& operator=(const File& other) = default; // copy assignment
|
||||
File& operator=(File&& other) noexcept = default; // move assignment
|
||||
|
||||
std::string toJsonString(bool prettyJson = false) const;
|
||||
void fromJsonString(std::string const& jsonString);
|
||||
boost::property_tree::ptree toPropertyTree() const;
|
||||
void fromPropertyTree(boost::property_tree::ptree const& pt);
|
||||
|
||||
|
||||
/////////////////////////////////////////////
|
||||
/// File members
|
||||
|
||||
/// <summary>
|
||||
/// Test capitalization
|
||||
/// </summary>
|
||||
std::string getSourceURI() const;
|
||||
void setSourceURI(std::string value);
|
||||
|
||||
protected:
|
||||
std::string m_SourceURI = "";
|
||||
};
|
||||
|
||||
std::vector<File> createFileVectorFromJsonString(const std::string& json);
|
||||
|
||||
template<>
|
||||
inline boost::property_tree::ptree toPt<File>(const File& val) {
|
||||
return val.toPropertyTree();
|
||||
}
|
||||
|
||||
template<>
|
||||
inline File fromPt<File>(const boost::property_tree::ptree& pt) {
|
||||
File ret;
|
||||
ret.fromPropertyTree(pt);
|
||||
return ret;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif /* File_H_ */
|
||||
@@ -0,0 +1,129 @@
|
||||
/**
|
||||
* OpenAPI Petstore
|
||||
* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
|
||||
*
|
||||
* The version of the OpenAPI document: 1.0.0
|
||||
*
|
||||
*
|
||||
* NOTE: This class is auto generated by OpenAPI-Generator 7.0.0-SNAPSHOT.
|
||||
* https://openapi-generator.tech
|
||||
* Do not edit the class manually.
|
||||
*/
|
||||
|
||||
|
||||
|
||||
#include "FileSchemaTestClass.h"
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <map>
|
||||
#include <sstream>
|
||||
#include <stdexcept>
|
||||
#include <regex>
|
||||
#include <boost/lexical_cast.hpp>
|
||||
#include <boost/property_tree/ptree.hpp>
|
||||
#include <boost/property_tree/json_parser.hpp>
|
||||
#include "helpers.h"
|
||||
|
||||
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 {
|
||||
|
||||
FileSchemaTestClass::FileSchemaTestClass(boost::property_tree::ptree const& pt)
|
||||
{
|
||||
fromPropertyTree(pt);
|
||||
}
|
||||
|
||||
|
||||
std::string FileSchemaTestClass::toJsonString(bool prettyJson /* = false */) const
|
||||
{
|
||||
std::stringstream ss;
|
||||
write_json(ss, this->toPropertyTree(), prettyJson);
|
||||
// workaround inspired by: https://stackoverflow.com/a/56395440
|
||||
std::regex reg("\\\"([0-9]+\\.{0,1}[0-9]*)\\\"");
|
||||
std::string result = std::regex_replace(ss.str(), reg, "$1");
|
||||
return result;
|
||||
}
|
||||
|
||||
void FileSchemaTestClass::fromJsonString(std::string const& jsonString)
|
||||
{
|
||||
std::stringstream ss(jsonString);
|
||||
ptree pt;
|
||||
read_json(ss,pt);
|
||||
this->fromPropertyTree(pt);
|
||||
}
|
||||
|
||||
ptree FileSchemaTestClass::toPropertyTree() const
|
||||
{
|
||||
ptree pt;
|
||||
ptree tmp_node;
|
||||
pt.add_child("file", m_file.toPropertyTree());
|
||||
// generate tree for Files
|
||||
tmp_node.clear();
|
||||
if (!m_Files.empty()) {
|
||||
tmp_node = toPt(m_Files);
|
||||
pt.add_child("files", tmp_node);
|
||||
tmp_node.clear();
|
||||
}
|
||||
return pt;
|
||||
}
|
||||
|
||||
void FileSchemaTestClass::fromPropertyTree(ptree const &pt)
|
||||
{
|
||||
ptree tmp_node;
|
||||
if (pt.get_child_optional("file")) {
|
||||
m_file = fromPt<File>(pt.get_child("file"));
|
||||
}
|
||||
// push all items of Files into member
|
||||
if (pt.get_child_optional("files")) {
|
||||
m_Files = fromPt<std::vector<File>>(pt.get_child("files"));
|
||||
}
|
||||
}
|
||||
|
||||
File FileSchemaTestClass::getFile() const
|
||||
{
|
||||
return m_file;
|
||||
}
|
||||
|
||||
void FileSchemaTestClass::setFile(File value)
|
||||
{
|
||||
m_file = value;
|
||||
}
|
||||
|
||||
|
||||
std::vector<File> FileSchemaTestClass::getFiles() const
|
||||
{
|
||||
return m_Files;
|
||||
}
|
||||
|
||||
void FileSchemaTestClass::setFiles(std::vector<File> value)
|
||||
{
|
||||
m_Files = value;
|
||||
}
|
||||
|
||||
|
||||
|
||||
std::vector<FileSchemaTestClass> createFileSchemaTestClassVectorFromJsonString(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<FileSchemaTestClass>();
|
||||
for (const auto& child: pt) {
|
||||
vec.emplace_back(FileSchemaTestClass(child.second));
|
||||
}
|
||||
|
||||
return vec;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,97 @@
|
||||
/**
|
||||
* OpenAPI Petstore
|
||||
* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
|
||||
*
|
||||
* The version of the OpenAPI document: 1.0.0
|
||||
*
|
||||
*
|
||||
* NOTE: This class is auto generated by OpenAPI-Generator 7.0.0-SNAPSHOT.
|
||||
* https://openapi-generator.tech
|
||||
* Do not edit the class manually.
|
||||
*/
|
||||
|
||||
/*
|
||||
* FileSchemaTestClass.h
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef FileSchemaTestClass_H_
|
||||
#define FileSchemaTestClass_H_
|
||||
|
||||
|
||||
|
||||
#include "File.h"
|
||||
#include <vector>
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
#include <boost/property_tree/ptree.hpp>
|
||||
#include "helpers.h"
|
||||
|
||||
namespace org {
|
||||
namespace openapitools {
|
||||
namespace server {
|
||||
namespace model {
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
class FileSchemaTestClass
|
||||
{
|
||||
public:
|
||||
FileSchemaTestClass() = default;
|
||||
explicit FileSchemaTestClass(boost::property_tree::ptree const& pt);
|
||||
virtual ~FileSchemaTestClass() = default;
|
||||
|
||||
FileSchemaTestClass(const FileSchemaTestClass& other) = default; // copy constructor
|
||||
FileSchemaTestClass(FileSchemaTestClass&& other) noexcept = default; // move constructor
|
||||
|
||||
FileSchemaTestClass& operator=(const FileSchemaTestClass& other) = default; // copy assignment
|
||||
FileSchemaTestClass& operator=(FileSchemaTestClass&& other) noexcept = default; // move assignment
|
||||
|
||||
std::string toJsonString(bool prettyJson = false) const;
|
||||
void fromJsonString(std::string const& jsonString);
|
||||
boost::property_tree::ptree toPropertyTree() const;
|
||||
void fromPropertyTree(boost::property_tree::ptree const& pt);
|
||||
|
||||
|
||||
/////////////////////////////////////////////
|
||||
/// FileSchemaTestClass members
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
File getFile() const;
|
||||
void setFile(File value);
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
std::vector<File> getFiles() const;
|
||||
void setFiles(std::vector<File> value);
|
||||
|
||||
protected:
|
||||
File m_file;
|
||||
std::vector<File> m_Files;
|
||||
};
|
||||
|
||||
std::vector<FileSchemaTestClass> createFileSchemaTestClassVectorFromJsonString(const std::string& json);
|
||||
|
||||
template<>
|
||||
inline boost::property_tree::ptree toPt<FileSchemaTestClass>(const FileSchemaTestClass& val) {
|
||||
return val.toPropertyTree();
|
||||
}
|
||||
|
||||
template<>
|
||||
inline FileSchemaTestClass fromPt<FileSchemaTestClass>(const boost::property_tree::ptree& pt) {
|
||||
FileSchemaTestClass ret;
|
||||
ret.fromPropertyTree(pt);
|
||||
return ret;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif /* FileSchemaTestClass_H_ */
|
||||
105
samples/server/petstore/cpp-restbed/generated/3_0/model/Foo.cpp
Normal file
105
samples/server/petstore/cpp-restbed/generated/3_0/model/Foo.cpp
Normal file
@@ -0,0 +1,105 @@
|
||||
/**
|
||||
* OpenAPI Petstore
|
||||
* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
|
||||
*
|
||||
* The version of the OpenAPI document: 1.0.0
|
||||
*
|
||||
*
|
||||
* NOTE: This class is auto generated by OpenAPI-Generator 7.0.0-SNAPSHOT.
|
||||
* https://openapi-generator.tech
|
||||
* Do not edit the class manually.
|
||||
*/
|
||||
|
||||
|
||||
|
||||
#include "Foo.h"
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <map>
|
||||
#include <sstream>
|
||||
#include <stdexcept>
|
||||
#include <regex>
|
||||
#include <boost/lexical_cast.hpp>
|
||||
#include <boost/property_tree/ptree.hpp>
|
||||
#include <boost/property_tree/json_parser.hpp>
|
||||
#include "helpers.h"
|
||||
|
||||
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 {
|
||||
|
||||
Foo::Foo(boost::property_tree::ptree const& pt)
|
||||
{
|
||||
fromPropertyTree(pt);
|
||||
}
|
||||
|
||||
|
||||
std::string Foo::toJsonString(bool prettyJson /* = false */) const
|
||||
{
|
||||
std::stringstream ss;
|
||||
write_json(ss, this->toPropertyTree(), prettyJson);
|
||||
// workaround inspired by: https://stackoverflow.com/a/56395440
|
||||
std::regex reg("\\\"([0-9]+\\.{0,1}[0-9]*)\\\"");
|
||||
std::string result = std::regex_replace(ss.str(), reg, "$1");
|
||||
return result;
|
||||
}
|
||||
|
||||
void Foo::fromJsonString(std::string const& jsonString)
|
||||
{
|
||||
std::stringstream ss(jsonString);
|
||||
ptree pt;
|
||||
read_json(ss,pt);
|
||||
this->fromPropertyTree(pt);
|
||||
}
|
||||
|
||||
ptree Foo::toPropertyTree() const
|
||||
{
|
||||
ptree pt;
|
||||
ptree tmp_node;
|
||||
pt.put("bar", m_Bar);
|
||||
return pt;
|
||||
}
|
||||
|
||||
void Foo::fromPropertyTree(ptree const &pt)
|
||||
{
|
||||
ptree tmp_node;
|
||||
m_Bar = pt.get("bar", "bar");
|
||||
}
|
||||
|
||||
std::string Foo::getBar() const
|
||||
{
|
||||
return m_Bar;
|
||||
}
|
||||
|
||||
void Foo::setBar(std::string value)
|
||||
{
|
||||
m_Bar = value;
|
||||
}
|
||||
|
||||
|
||||
|
||||
std::vector<Foo> createFooVectorFromJsonString(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<Foo>();
|
||||
for (const auto& child: pt) {
|
||||
vec.emplace_back(Foo(child.second));
|
||||
}
|
||||
|
||||
return vec;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,89 @@
|
||||
/**
|
||||
* OpenAPI Petstore
|
||||
* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
|
||||
*
|
||||
* The version of the OpenAPI document: 1.0.0
|
||||
*
|
||||
*
|
||||
* NOTE: This class is auto generated by OpenAPI-Generator 7.0.0-SNAPSHOT.
|
||||
* https://openapi-generator.tech
|
||||
* Do not edit the class manually.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Foo.h
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef Foo_H_
|
||||
#define Foo_H_
|
||||
|
||||
|
||||
|
||||
#include <string>
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
#include <boost/property_tree/ptree.hpp>
|
||||
#include "helpers.h"
|
||||
|
||||
namespace org {
|
||||
namespace openapitools {
|
||||
namespace server {
|
||||
namespace model {
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
class Foo
|
||||
{
|
||||
public:
|
||||
Foo() = default;
|
||||
explicit Foo(boost::property_tree::ptree const& pt);
|
||||
virtual ~Foo() = default;
|
||||
|
||||
Foo(const Foo& other) = default; // copy constructor
|
||||
Foo(Foo&& other) noexcept = default; // move constructor
|
||||
|
||||
Foo& operator=(const Foo& other) = default; // copy assignment
|
||||
Foo& operator=(Foo&& other) noexcept = default; // move assignment
|
||||
|
||||
std::string toJsonString(bool prettyJson = false) const;
|
||||
void fromJsonString(std::string const& jsonString);
|
||||
boost::property_tree::ptree toPropertyTree() const;
|
||||
void fromPropertyTree(boost::property_tree::ptree const& pt);
|
||||
|
||||
|
||||
/////////////////////////////////////////////
|
||||
/// Foo members
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
std::string getBar() const;
|
||||
void setBar(std::string value);
|
||||
|
||||
protected:
|
||||
std::string m_Bar = "bar";
|
||||
};
|
||||
|
||||
std::vector<Foo> createFooVectorFromJsonString(const std::string& json);
|
||||
|
||||
template<>
|
||||
inline boost::property_tree::ptree toPt<Foo>(const Foo& val) {
|
||||
return val.toPropertyTree();
|
||||
}
|
||||
|
||||
template<>
|
||||
inline Foo fromPt<Foo>(const boost::property_tree::ptree& pt) {
|
||||
Foo ret;
|
||||
ret.fromPropertyTree(pt);
|
||||
return ret;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif /* Foo_H_ */
|
||||
@@ -0,0 +1,294 @@
|
||||
/**
|
||||
* OpenAPI Petstore
|
||||
* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
|
||||
*
|
||||
* The version of the OpenAPI document: 1.0.0
|
||||
*
|
||||
*
|
||||
* NOTE: This class is auto generated by OpenAPI-Generator 7.0.0-SNAPSHOT.
|
||||
* https://openapi-generator.tech
|
||||
* Do not edit the class manually.
|
||||
*/
|
||||
|
||||
|
||||
|
||||
#include "Format_test.h"
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <map>
|
||||
#include <sstream>
|
||||
#include <stdexcept>
|
||||
#include <regex>
|
||||
#include <boost/lexical_cast.hpp>
|
||||
#include <boost/property_tree/ptree.hpp>
|
||||
#include <boost/property_tree/json_parser.hpp>
|
||||
#include "helpers.h"
|
||||
|
||||
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 {
|
||||
|
||||
Format_test::Format_test(boost::property_tree::ptree const& pt)
|
||||
{
|
||||
fromPropertyTree(pt);
|
||||
}
|
||||
|
||||
|
||||
std::string Format_test::toJsonString(bool prettyJson /* = false */) const
|
||||
{
|
||||
std::stringstream ss;
|
||||
write_json(ss, this->toPropertyTree(), prettyJson);
|
||||
// workaround inspired by: https://stackoverflow.com/a/56395440
|
||||
std::regex reg("\\\"([0-9]+\\.{0,1}[0-9]*)\\\"");
|
||||
std::string result = std::regex_replace(ss.str(), reg, "$1");
|
||||
return result;
|
||||
}
|
||||
|
||||
void Format_test::fromJsonString(std::string const& jsonString)
|
||||
{
|
||||
std::stringstream ss(jsonString);
|
||||
ptree pt;
|
||||
read_json(ss,pt);
|
||||
this->fromPropertyTree(pt);
|
||||
}
|
||||
|
||||
ptree Format_test::toPropertyTree() const
|
||||
{
|
||||
ptree pt;
|
||||
ptree tmp_node;
|
||||
pt.put("integer", m_integer);
|
||||
pt.put("int32", m_Int32);
|
||||
pt.put("int64", m_Int64);
|
||||
pt.put("number", m_number);
|
||||
pt.put("float", m_float);
|
||||
pt.put("double", m_double);
|
||||
pt.put("string", m_string);
|
||||
pt.put("date", m_date);
|
||||
pt.put("dateTime", m_DateTime);
|
||||
pt.put("uuid", m_Uuid);
|
||||
pt.put("password", m_Password);
|
||||
pt.put("pattern_with_digits", m_Pattern_with_digits);
|
||||
pt.put("pattern_with_digits_and_delimiter", m_Pattern_with_digits_and_delimiter);
|
||||
return pt;
|
||||
}
|
||||
|
||||
void Format_test::fromPropertyTree(ptree const &pt)
|
||||
{
|
||||
ptree tmp_node;
|
||||
m_integer = pt.get("integer", 0);
|
||||
m_Int32 = pt.get("int32", 0);
|
||||
m_Int64 = pt.get("int64", 0L);
|
||||
m_number = pt.get("number", 0.0);
|
||||
m_float = pt.get("float", 0.0f);
|
||||
m_double = pt.get("double", 0.0);
|
||||
m_string = pt.get("string", "");
|
||||
m_date = pt.get("date", "");
|
||||
m_DateTime = pt.get("dateTime", "");
|
||||
m_Uuid = pt.get("uuid", "");
|
||||
m_Password = pt.get("password", "");
|
||||
m_Pattern_with_digits = pt.get("pattern_with_digits", "");
|
||||
m_Pattern_with_digits_and_delimiter = pt.get("pattern_with_digits_and_delimiter", "");
|
||||
}
|
||||
|
||||
int32_t Format_test::getInteger() const
|
||||
{
|
||||
return m_integer;
|
||||
}
|
||||
|
||||
void Format_test::setInteger(int32_t value)
|
||||
{
|
||||
m_integer = value;
|
||||
}
|
||||
|
||||
|
||||
int32_t Format_test::getInt32() const
|
||||
{
|
||||
return m_Int32;
|
||||
}
|
||||
|
||||
void Format_test::setInt32(int32_t value)
|
||||
{
|
||||
m_Int32 = value;
|
||||
}
|
||||
|
||||
|
||||
int64_t Format_test::getInt64() const
|
||||
{
|
||||
return m_Int64;
|
||||
}
|
||||
|
||||
void Format_test::setInt64(int64_t value)
|
||||
{
|
||||
m_Int64 = value;
|
||||
}
|
||||
|
||||
|
||||
double Format_test::getNumber() const
|
||||
{
|
||||
return m_number;
|
||||
}
|
||||
|
||||
void Format_test::setNumber(double value)
|
||||
{
|
||||
m_number = value;
|
||||
}
|
||||
|
||||
|
||||
float Format_test::getFloat() const
|
||||
{
|
||||
return m_float;
|
||||
}
|
||||
|
||||
void Format_test::setFloat(float value)
|
||||
{
|
||||
m_float = value;
|
||||
}
|
||||
|
||||
|
||||
double Format_test::getDouble() const
|
||||
{
|
||||
return m_double;
|
||||
}
|
||||
|
||||
void Format_test::setDouble(double value)
|
||||
{
|
||||
m_double = value;
|
||||
}
|
||||
|
||||
|
||||
std::string Format_test::getDecimal() const
|
||||
{
|
||||
return m_decimal;
|
||||
}
|
||||
|
||||
void Format_test::setDecimal(std::string value)
|
||||
{
|
||||
m_decimal = value;
|
||||
}
|
||||
|
||||
|
||||
std::string Format_test::getString() const
|
||||
{
|
||||
return m_string;
|
||||
}
|
||||
|
||||
void Format_test::setString(std::string value)
|
||||
{
|
||||
m_string = value;
|
||||
}
|
||||
|
||||
|
||||
std::string Format_test::getByte() const
|
||||
{
|
||||
return m_Byte;
|
||||
}
|
||||
|
||||
void Format_test::setByte(std::string value)
|
||||
{
|
||||
m_Byte = value;
|
||||
}
|
||||
|
||||
|
||||
std::string Format_test::getBinary() const
|
||||
{
|
||||
return m_binary;
|
||||
}
|
||||
|
||||
void Format_test::setBinary(std::string value)
|
||||
{
|
||||
m_binary = value;
|
||||
}
|
||||
|
||||
|
||||
std::string Format_test::getDate() const
|
||||
{
|
||||
return m_date;
|
||||
}
|
||||
|
||||
void Format_test::setDate(std::string value)
|
||||
{
|
||||
m_date = value;
|
||||
}
|
||||
|
||||
|
||||
std::string Format_test::getDateTime() const
|
||||
{
|
||||
return m_DateTime;
|
||||
}
|
||||
|
||||
void Format_test::setDateTime(std::string value)
|
||||
{
|
||||
m_DateTime = value;
|
||||
}
|
||||
|
||||
|
||||
std::string Format_test::getUuid() const
|
||||
{
|
||||
return m_Uuid;
|
||||
}
|
||||
|
||||
void Format_test::setUuid(std::string value)
|
||||
{
|
||||
m_Uuid = value;
|
||||
}
|
||||
|
||||
|
||||
std::string Format_test::getPassword() const
|
||||
{
|
||||
return m_Password;
|
||||
}
|
||||
|
||||
void Format_test::setPassword(std::string value)
|
||||
{
|
||||
m_Password = value;
|
||||
}
|
||||
|
||||
|
||||
std::string Format_test::getPatternWithDigits() const
|
||||
{
|
||||
return m_Pattern_with_digits;
|
||||
}
|
||||
|
||||
void Format_test::setPatternWithDigits(std::string value)
|
||||
{
|
||||
m_Pattern_with_digits = value;
|
||||
}
|
||||
|
||||
|
||||
std::string Format_test::getPatternWithDigitsAndDelimiter() const
|
||||
{
|
||||
return m_Pattern_with_digits_and_delimiter;
|
||||
}
|
||||
|
||||
void Format_test::setPatternWithDigitsAndDelimiter(std::string value)
|
||||
{
|
||||
m_Pattern_with_digits_and_delimiter = value;
|
||||
}
|
||||
|
||||
|
||||
|
||||
std::vector<Format_test> createFormat_testVectorFromJsonString(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<Format_test>();
|
||||
for (const auto& child: pt) {
|
||||
vec.emplace_back(Format_test(child.second));
|
||||
}
|
||||
|
||||
return vec;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,194 @@
|
||||
/**
|
||||
* OpenAPI Petstore
|
||||
* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
|
||||
*
|
||||
* The version of the OpenAPI document: 1.0.0
|
||||
*
|
||||
*
|
||||
* NOTE: This class is auto generated by OpenAPI-Generator 7.0.0-SNAPSHOT.
|
||||
* https://openapi-generator.tech
|
||||
* Do not edit the class manually.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Format_test.h
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef Format_test_H_
|
||||
#define Format_test_H_
|
||||
|
||||
|
||||
|
||||
#include <string>
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
#include <boost/property_tree/ptree.hpp>
|
||||
#include "helpers.h"
|
||||
|
||||
namespace org {
|
||||
namespace openapitools {
|
||||
namespace server {
|
||||
namespace model {
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
class Format_test
|
||||
{
|
||||
public:
|
||||
Format_test() = default;
|
||||
explicit Format_test(boost::property_tree::ptree const& pt);
|
||||
virtual ~Format_test() = default;
|
||||
|
||||
Format_test(const Format_test& other) = default; // copy constructor
|
||||
Format_test(Format_test&& other) noexcept = default; // move constructor
|
||||
|
||||
Format_test& operator=(const Format_test& other) = default; // copy assignment
|
||||
Format_test& operator=(Format_test&& other) noexcept = default; // move assignment
|
||||
|
||||
std::string toJsonString(bool prettyJson = false) const;
|
||||
void fromJsonString(std::string const& jsonString);
|
||||
boost::property_tree::ptree toPropertyTree() const;
|
||||
void fromPropertyTree(boost::property_tree::ptree const& pt);
|
||||
|
||||
|
||||
/////////////////////////////////////////////
|
||||
/// Format_test members
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
int32_t getInteger() const;
|
||||
void setInteger(int32_t value);
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
int32_t getInt32() const;
|
||||
void setInt32(int32_t value);
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
int64_t getInt64() const;
|
||||
void setInt64(int64_t value);
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
double getNumber() const;
|
||||
void setNumber(double value);
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
float getFloat() const;
|
||||
void setFloat(float value);
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
double getDouble() const;
|
||||
void setDouble(double value);
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
std::string getDecimal() const;
|
||||
void setDecimal(std::string value);
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
std::string getString() const;
|
||||
void setString(std::string value);
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
std::string getByte() const;
|
||||
void setByte(std::string value);
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
std::string getBinary() const;
|
||||
void setBinary(std::string value);
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
std::string getDate() const;
|
||||
void setDate(std::string value);
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
std::string getDateTime() const;
|
||||
void setDateTime(std::string value);
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
std::string getUuid() const;
|
||||
void setUuid(std::string value);
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
std::string getPassword() const;
|
||||
void setPassword(std::string value);
|
||||
|
||||
/// <summary>
|
||||
/// A string that is a 10 digit number. Can have leading zeros.
|
||||
/// </summary>
|
||||
std::string getPatternWithDigits() const;
|
||||
void setPatternWithDigits(std::string value);
|
||||
|
||||
/// <summary>
|
||||
/// A string starting with 'image_' (case insensitive) and one to three digits following i.e. Image_01.
|
||||
/// </summary>
|
||||
std::string getPatternWithDigitsAndDelimiter() const;
|
||||
void setPatternWithDigitsAndDelimiter(std::string value);
|
||||
|
||||
protected:
|
||||
int32_t m_integer = 0;
|
||||
int32_t m_Int32 = 0;
|
||||
int64_t m_Int64 = 0L;
|
||||
double m_number = 0.0;
|
||||
float m_float = 0.0f;
|
||||
double m_double = 0.0;
|
||||
std::string m_decimal = "";
|
||||
std::string m_string = "";
|
||||
std::string m_Byte = "";
|
||||
std::string m_binary = "";
|
||||
std::string m_date = "";
|
||||
std::string m_DateTime = "";
|
||||
std::string m_Uuid = "";
|
||||
std::string m_Password = "";
|
||||
std::string m_Pattern_with_digits = "";
|
||||
std::string m_Pattern_with_digits_and_delimiter = "";
|
||||
};
|
||||
|
||||
std::vector<Format_test> createFormat_testVectorFromJsonString(const std::string& json);
|
||||
|
||||
template<>
|
||||
inline boost::property_tree::ptree toPt<Format_test>(const Format_test& val) {
|
||||
return val.toPropertyTree();
|
||||
}
|
||||
|
||||
template<>
|
||||
inline Format_test fromPt<Format_test>(const boost::property_tree::ptree& pt) {
|
||||
Format_test ret;
|
||||
ret.fromPropertyTree(pt);
|
||||
return ret;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif /* Format_test_H_ */
|
||||
@@ -0,0 +1,118 @@
|
||||
/**
|
||||
* OpenAPI Petstore
|
||||
* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
|
||||
*
|
||||
* The version of the OpenAPI document: 1.0.0
|
||||
*
|
||||
*
|
||||
* NOTE: This class is auto generated by OpenAPI-Generator 7.0.0-SNAPSHOT.
|
||||
* https://openapi-generator.tech
|
||||
* Do not edit the class manually.
|
||||
*/
|
||||
|
||||
|
||||
|
||||
#include "HasOnlyReadOnly.h"
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <map>
|
||||
#include <sstream>
|
||||
#include <stdexcept>
|
||||
#include <regex>
|
||||
#include <boost/lexical_cast.hpp>
|
||||
#include <boost/property_tree/ptree.hpp>
|
||||
#include <boost/property_tree/json_parser.hpp>
|
||||
#include "helpers.h"
|
||||
|
||||
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 {
|
||||
|
||||
HasOnlyReadOnly::HasOnlyReadOnly(boost::property_tree::ptree const& pt)
|
||||
{
|
||||
fromPropertyTree(pt);
|
||||
}
|
||||
|
||||
|
||||
std::string HasOnlyReadOnly::toJsonString(bool prettyJson /* = false */) const
|
||||
{
|
||||
std::stringstream ss;
|
||||
write_json(ss, this->toPropertyTree(), prettyJson);
|
||||
// workaround inspired by: https://stackoverflow.com/a/56395440
|
||||
std::regex reg("\\\"([0-9]+\\.{0,1}[0-9]*)\\\"");
|
||||
std::string result = std::regex_replace(ss.str(), reg, "$1");
|
||||
return result;
|
||||
}
|
||||
|
||||
void HasOnlyReadOnly::fromJsonString(std::string const& jsonString)
|
||||
{
|
||||
std::stringstream ss(jsonString);
|
||||
ptree pt;
|
||||
read_json(ss,pt);
|
||||
this->fromPropertyTree(pt);
|
||||
}
|
||||
|
||||
ptree HasOnlyReadOnly::toPropertyTree() const
|
||||
{
|
||||
ptree pt;
|
||||
ptree tmp_node;
|
||||
pt.put("bar", m_Bar);
|
||||
pt.put("foo", m_Foo);
|
||||
return pt;
|
||||
}
|
||||
|
||||
void HasOnlyReadOnly::fromPropertyTree(ptree const &pt)
|
||||
{
|
||||
ptree tmp_node;
|
||||
m_Bar = pt.get("bar", "");
|
||||
m_Foo = pt.get("foo", "");
|
||||
}
|
||||
|
||||
std::string HasOnlyReadOnly::getBar() const
|
||||
{
|
||||
return m_Bar;
|
||||
}
|
||||
|
||||
void HasOnlyReadOnly::setBar(std::string value)
|
||||
{
|
||||
m_Bar = value;
|
||||
}
|
||||
|
||||
|
||||
std::string HasOnlyReadOnly::getFoo() const
|
||||
{
|
||||
return m_Foo;
|
||||
}
|
||||
|
||||
void HasOnlyReadOnly::setFoo(std::string value)
|
||||
{
|
||||
m_Foo = value;
|
||||
}
|
||||
|
||||
|
||||
|
||||
std::vector<HasOnlyReadOnly> createHasOnlyReadOnlyVectorFromJsonString(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<HasOnlyReadOnly>();
|
||||
for (const auto& child: pt) {
|
||||
vec.emplace_back(HasOnlyReadOnly(child.second));
|
||||
}
|
||||
|
||||
return vec;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,96 @@
|
||||
/**
|
||||
* OpenAPI Petstore
|
||||
* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
|
||||
*
|
||||
* The version of the OpenAPI document: 1.0.0
|
||||
*
|
||||
*
|
||||
* NOTE: This class is auto generated by OpenAPI-Generator 7.0.0-SNAPSHOT.
|
||||
* https://openapi-generator.tech
|
||||
* Do not edit the class manually.
|
||||
*/
|
||||
|
||||
/*
|
||||
* HasOnlyReadOnly.h
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef HasOnlyReadOnly_H_
|
||||
#define HasOnlyReadOnly_H_
|
||||
|
||||
|
||||
|
||||
#include <string>
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
#include <boost/property_tree/ptree.hpp>
|
||||
#include "helpers.h"
|
||||
|
||||
namespace org {
|
||||
namespace openapitools {
|
||||
namespace server {
|
||||
namespace model {
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
class HasOnlyReadOnly
|
||||
{
|
||||
public:
|
||||
HasOnlyReadOnly() = default;
|
||||
explicit HasOnlyReadOnly(boost::property_tree::ptree const& pt);
|
||||
virtual ~HasOnlyReadOnly() = default;
|
||||
|
||||
HasOnlyReadOnly(const HasOnlyReadOnly& other) = default; // copy constructor
|
||||
HasOnlyReadOnly(HasOnlyReadOnly&& other) noexcept = default; // move constructor
|
||||
|
||||
HasOnlyReadOnly& operator=(const HasOnlyReadOnly& other) = default; // copy assignment
|
||||
HasOnlyReadOnly& operator=(HasOnlyReadOnly&& other) noexcept = default; // move assignment
|
||||
|
||||
std::string toJsonString(bool prettyJson = false) const;
|
||||
void fromJsonString(std::string const& jsonString);
|
||||
boost::property_tree::ptree toPropertyTree() const;
|
||||
void fromPropertyTree(boost::property_tree::ptree const& pt);
|
||||
|
||||
|
||||
/////////////////////////////////////////////
|
||||
/// HasOnlyReadOnly members
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
std::string getBar() const;
|
||||
void setBar(std::string value);
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
std::string getFoo() const;
|
||||
void setFoo(std::string value);
|
||||
|
||||
protected:
|
||||
std::string m_Bar = "";
|
||||
std::string m_Foo = "";
|
||||
};
|
||||
|
||||
std::vector<HasOnlyReadOnly> createHasOnlyReadOnlyVectorFromJsonString(const std::string& json);
|
||||
|
||||
template<>
|
||||
inline boost::property_tree::ptree toPt<HasOnlyReadOnly>(const HasOnlyReadOnly& val) {
|
||||
return val.toPropertyTree();
|
||||
}
|
||||
|
||||
template<>
|
||||
inline HasOnlyReadOnly fromPt<HasOnlyReadOnly>(const boost::property_tree::ptree& pt) {
|
||||
HasOnlyReadOnly ret;
|
||||
ret.fromPropertyTree(pt);
|
||||
return ret;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif /* HasOnlyReadOnly_H_ */
|
||||
@@ -0,0 +1,105 @@
|
||||
/**
|
||||
* OpenAPI Petstore
|
||||
* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
|
||||
*
|
||||
* The version of the OpenAPI document: 1.0.0
|
||||
*
|
||||
*
|
||||
* NOTE: This class is auto generated by OpenAPI-Generator 7.0.0-SNAPSHOT.
|
||||
* https://openapi-generator.tech
|
||||
* Do not edit the class manually.
|
||||
*/
|
||||
|
||||
|
||||
|
||||
#include "HealthCheckResult.h"
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <map>
|
||||
#include <sstream>
|
||||
#include <stdexcept>
|
||||
#include <regex>
|
||||
#include <boost/lexical_cast.hpp>
|
||||
#include <boost/property_tree/ptree.hpp>
|
||||
#include <boost/property_tree/json_parser.hpp>
|
||||
#include "helpers.h"
|
||||
|
||||
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 {
|
||||
|
||||
HealthCheckResult::HealthCheckResult(boost::property_tree::ptree const& pt)
|
||||
{
|
||||
fromPropertyTree(pt);
|
||||
}
|
||||
|
||||
|
||||
std::string HealthCheckResult::toJsonString(bool prettyJson /* = false */) const
|
||||
{
|
||||
std::stringstream ss;
|
||||
write_json(ss, this->toPropertyTree(), prettyJson);
|
||||
// workaround inspired by: https://stackoverflow.com/a/56395440
|
||||
std::regex reg("\\\"([0-9]+\\.{0,1}[0-9]*)\\\"");
|
||||
std::string result = std::regex_replace(ss.str(), reg, "$1");
|
||||
return result;
|
||||
}
|
||||
|
||||
void HealthCheckResult::fromJsonString(std::string const& jsonString)
|
||||
{
|
||||
std::stringstream ss(jsonString);
|
||||
ptree pt;
|
||||
read_json(ss,pt);
|
||||
this->fromPropertyTree(pt);
|
||||
}
|
||||
|
||||
ptree HealthCheckResult::toPropertyTree() const
|
||||
{
|
||||
ptree pt;
|
||||
ptree tmp_node;
|
||||
pt.put("NullableMessage", m_NullableMessage);
|
||||
return pt;
|
||||
}
|
||||
|
||||
void HealthCheckResult::fromPropertyTree(ptree const &pt)
|
||||
{
|
||||
ptree tmp_node;
|
||||
m_NullableMessage = pt.get("NullableMessage", "");
|
||||
}
|
||||
|
||||
std::string HealthCheckResult::getNullableMessage() const
|
||||
{
|
||||
return m_NullableMessage;
|
||||
}
|
||||
|
||||
void HealthCheckResult::setNullableMessage(std::string value)
|
||||
{
|
||||
m_NullableMessage = value;
|
||||
}
|
||||
|
||||
|
||||
|
||||
std::vector<HealthCheckResult> createHealthCheckResultVectorFromJsonString(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<HealthCheckResult>();
|
||||
for (const auto& child: pt) {
|
||||
vec.emplace_back(HealthCheckResult(child.second));
|
||||
}
|
||||
|
||||
return vec;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,89 @@
|
||||
/**
|
||||
* OpenAPI Petstore
|
||||
* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
|
||||
*
|
||||
* The version of the OpenAPI document: 1.0.0
|
||||
*
|
||||
*
|
||||
* NOTE: This class is auto generated by OpenAPI-Generator 7.0.0-SNAPSHOT.
|
||||
* https://openapi-generator.tech
|
||||
* Do not edit the class manually.
|
||||
*/
|
||||
|
||||
/*
|
||||
* HealthCheckResult.h
|
||||
*
|
||||
* Just a string to inform instance is up and running. Make it nullable in hope to get it as pointer in generated model.
|
||||
*/
|
||||
|
||||
#ifndef HealthCheckResult_H_
|
||||
#define HealthCheckResult_H_
|
||||
|
||||
|
||||
|
||||
#include <string>
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
#include <boost/property_tree/ptree.hpp>
|
||||
#include "helpers.h"
|
||||
|
||||
namespace org {
|
||||
namespace openapitools {
|
||||
namespace server {
|
||||
namespace model {
|
||||
|
||||
/// <summary>
|
||||
/// Just a string to inform instance is up and running. Make it nullable in hope to get it as pointer in generated model.
|
||||
/// </summary>
|
||||
class HealthCheckResult
|
||||
{
|
||||
public:
|
||||
HealthCheckResult() = default;
|
||||
explicit HealthCheckResult(boost::property_tree::ptree const& pt);
|
||||
virtual ~HealthCheckResult() = default;
|
||||
|
||||
HealthCheckResult(const HealthCheckResult& other) = default; // copy constructor
|
||||
HealthCheckResult(HealthCheckResult&& other) noexcept = default; // move constructor
|
||||
|
||||
HealthCheckResult& operator=(const HealthCheckResult& other) = default; // copy assignment
|
||||
HealthCheckResult& operator=(HealthCheckResult&& other) noexcept = default; // move assignment
|
||||
|
||||
std::string toJsonString(bool prettyJson = false) const;
|
||||
void fromJsonString(std::string const& jsonString);
|
||||
boost::property_tree::ptree toPropertyTree() const;
|
||||
void fromPropertyTree(boost::property_tree::ptree const& pt);
|
||||
|
||||
|
||||
/////////////////////////////////////////////
|
||||
/// HealthCheckResult members
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
std::string getNullableMessage() const;
|
||||
void setNullableMessage(std::string value);
|
||||
|
||||
protected:
|
||||
std::string m_NullableMessage = "";
|
||||
};
|
||||
|
||||
std::vector<HealthCheckResult> createHealthCheckResultVectorFromJsonString(const std::string& json);
|
||||
|
||||
template<>
|
||||
inline boost::property_tree::ptree toPt<HealthCheckResult>(const HealthCheckResult& val) {
|
||||
return val.toPropertyTree();
|
||||
}
|
||||
|
||||
template<>
|
||||
inline HealthCheckResult fromPt<HealthCheckResult>(const boost::property_tree::ptree& pt) {
|
||||
HealthCheckResult ret;
|
||||
ret.fromPropertyTree(pt);
|
||||
return ret;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif /* HealthCheckResult_H_ */
|
||||
105
samples/server/petstore/cpp-restbed/generated/3_0/model/List.cpp
Normal file
105
samples/server/petstore/cpp-restbed/generated/3_0/model/List.cpp
Normal file
@@ -0,0 +1,105 @@
|
||||
/**
|
||||
* OpenAPI Petstore
|
||||
* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
|
||||
*
|
||||
* The version of the OpenAPI document: 1.0.0
|
||||
*
|
||||
*
|
||||
* NOTE: This class is auto generated by OpenAPI-Generator 7.0.0-SNAPSHOT.
|
||||
* https://openapi-generator.tech
|
||||
* Do not edit the class manually.
|
||||
*/
|
||||
|
||||
|
||||
|
||||
#include "List.h"
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <map>
|
||||
#include <sstream>
|
||||
#include <stdexcept>
|
||||
#include <regex>
|
||||
#include <boost/lexical_cast.hpp>
|
||||
#include <boost/property_tree/ptree.hpp>
|
||||
#include <boost/property_tree/json_parser.hpp>
|
||||
#include "helpers.h"
|
||||
|
||||
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 {
|
||||
|
||||
List::List(boost::property_tree::ptree const& pt)
|
||||
{
|
||||
fromPropertyTree(pt);
|
||||
}
|
||||
|
||||
|
||||
std::string List::toJsonString(bool prettyJson /* = false */) const
|
||||
{
|
||||
std::stringstream ss;
|
||||
write_json(ss, this->toPropertyTree(), prettyJson);
|
||||
// workaround inspired by: https://stackoverflow.com/a/56395440
|
||||
std::regex reg("\\\"([0-9]+\\.{0,1}[0-9]*)\\\"");
|
||||
std::string result = std::regex_replace(ss.str(), reg, "$1");
|
||||
return result;
|
||||
}
|
||||
|
||||
void List::fromJsonString(std::string const& jsonString)
|
||||
{
|
||||
std::stringstream ss(jsonString);
|
||||
ptree pt;
|
||||
read_json(ss,pt);
|
||||
this->fromPropertyTree(pt);
|
||||
}
|
||||
|
||||
ptree List::toPropertyTree() const
|
||||
{
|
||||
ptree pt;
|
||||
ptree tmp_node;
|
||||
pt.put("123-list", m_r_123_list);
|
||||
return pt;
|
||||
}
|
||||
|
||||
void List::fromPropertyTree(ptree const &pt)
|
||||
{
|
||||
ptree tmp_node;
|
||||
m_r_123_list = pt.get("123-list", "");
|
||||
}
|
||||
|
||||
std::string List::getR123List() const
|
||||
{
|
||||
return m_r_123_list;
|
||||
}
|
||||
|
||||
void List::setR123List(std::string value)
|
||||
{
|
||||
m_r_123_list = value;
|
||||
}
|
||||
|
||||
|
||||
|
||||
std::vector<List> createListVectorFromJsonString(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<List>();
|
||||
for (const auto& child: pt) {
|
||||
vec.emplace_back(List(child.second));
|
||||
}
|
||||
|
||||
return vec;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,89 @@
|
||||
/**
|
||||
* OpenAPI Petstore
|
||||
* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
|
||||
*
|
||||
* The version of the OpenAPI document: 1.0.0
|
||||
*
|
||||
*
|
||||
* NOTE: This class is auto generated by OpenAPI-Generator 7.0.0-SNAPSHOT.
|
||||
* https://openapi-generator.tech
|
||||
* Do not edit the class manually.
|
||||
*/
|
||||
|
||||
/*
|
||||
* List.h
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef List_H_
|
||||
#define List_H_
|
||||
|
||||
|
||||
|
||||
#include <string>
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
#include <boost/property_tree/ptree.hpp>
|
||||
#include "helpers.h"
|
||||
|
||||
namespace org {
|
||||
namespace openapitools {
|
||||
namespace server {
|
||||
namespace model {
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
class List
|
||||
{
|
||||
public:
|
||||
List() = default;
|
||||
explicit List(boost::property_tree::ptree const& pt);
|
||||
virtual ~List() = default;
|
||||
|
||||
List(const List& other) = default; // copy constructor
|
||||
List(List&& other) noexcept = default; // move constructor
|
||||
|
||||
List& operator=(const List& other) = default; // copy assignment
|
||||
List& operator=(List&& other) noexcept = default; // move assignment
|
||||
|
||||
std::string toJsonString(bool prettyJson = false) const;
|
||||
void fromJsonString(std::string const& jsonString);
|
||||
boost::property_tree::ptree toPropertyTree() const;
|
||||
void fromPropertyTree(boost::property_tree::ptree const& pt);
|
||||
|
||||
|
||||
/////////////////////////////////////////////
|
||||
/// List members
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
std::string getR123List() const;
|
||||
void setR123List(std::string value);
|
||||
|
||||
protected:
|
||||
std::string m_r_123_list = "";
|
||||
};
|
||||
|
||||
std::vector<List> createListVectorFromJsonString(const std::string& json);
|
||||
|
||||
template<>
|
||||
inline boost::property_tree::ptree toPt<List>(const List& val) {
|
||||
return val.toPropertyTree();
|
||||
}
|
||||
|
||||
template<>
|
||||
inline List fromPt<List>(const boost::property_tree::ptree& pt) {
|
||||
List ret;
|
||||
ret.fromPropertyTree(pt);
|
||||
return ret;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif /* List_H_ */
|
||||
@@ -0,0 +1,182 @@
|
||||
/**
|
||||
* OpenAPI Petstore
|
||||
* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
|
||||
*
|
||||
* The version of the OpenAPI document: 1.0.0
|
||||
*
|
||||
*
|
||||
* NOTE: This class is auto generated by OpenAPI-Generator 7.0.0-SNAPSHOT.
|
||||
* https://openapi-generator.tech
|
||||
* Do not edit the class manually.
|
||||
*/
|
||||
|
||||
|
||||
|
||||
#include "MapTest.h"
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <map>
|
||||
#include <sstream>
|
||||
#include <stdexcept>
|
||||
#include <regex>
|
||||
#include <algorithm>
|
||||
#include <boost/lexical_cast.hpp>
|
||||
#include <boost/property_tree/ptree.hpp>
|
||||
#include <boost/property_tree/json_parser.hpp>
|
||||
#include "helpers.h"
|
||||
|
||||
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 {
|
||||
|
||||
MapTest::MapTest(boost::property_tree::ptree const& pt)
|
||||
{
|
||||
fromPropertyTree(pt);
|
||||
}
|
||||
|
||||
|
||||
std::string MapTest::toJsonString(bool prettyJson /* = false */) const
|
||||
{
|
||||
std::stringstream ss;
|
||||
write_json(ss, this->toPropertyTree(), prettyJson);
|
||||
// workaround inspired by: https://stackoverflow.com/a/56395440
|
||||
std::regex reg("\\\"([0-9]+\\.{0,1}[0-9]*)\\\"");
|
||||
std::string result = std::regex_replace(ss.str(), reg, "$1");
|
||||
return result;
|
||||
}
|
||||
|
||||
void MapTest::fromJsonString(std::string const& jsonString)
|
||||
{
|
||||
std::stringstream ss(jsonString);
|
||||
ptree pt;
|
||||
read_json(ss,pt);
|
||||
this->fromPropertyTree(pt);
|
||||
}
|
||||
|
||||
ptree MapTest::toPropertyTree() const
|
||||
{
|
||||
ptree pt;
|
||||
ptree tmp_node;
|
||||
// generate tree for Map_map_of_string
|
||||
if (!m_Map_map_of_string.empty()) {
|
||||
tmp_node = toPt(m_Map_map_of_string);
|
||||
pt.add_child("map_map_of_string", tmp_node);
|
||||
}
|
||||
tmp_node.clear();
|
||||
// generate tree for Map_of_enum_string
|
||||
if (!m_Map_of_enum_string.empty()) {
|
||||
tmp_node = toPt(m_Map_of_enum_string);
|
||||
pt.add_child("map_of_enum_string", tmp_node);
|
||||
}
|
||||
tmp_node.clear();
|
||||
// generate tree for Direct_map
|
||||
if (!m_Direct_map.empty()) {
|
||||
tmp_node = toPt(m_Direct_map);
|
||||
pt.add_child("direct_map", tmp_node);
|
||||
}
|
||||
tmp_node.clear();
|
||||
// generate tree for Indirect_map
|
||||
if (!m_Indirect_map.empty()) {
|
||||
tmp_node = toPt(m_Indirect_map);
|
||||
pt.add_child("indirect_map", tmp_node);
|
||||
}
|
||||
tmp_node.clear();
|
||||
return pt;
|
||||
}
|
||||
|
||||
void MapTest::fromPropertyTree(ptree const &pt)
|
||||
{
|
||||
ptree tmp_node;
|
||||
if (pt.get_child_optional("map_map_of_string")) {
|
||||
m_Map_map_of_string = fromPt<std::map<std::string, std::map<std::string, std::string>>>(pt.get_child("map_map_of_string"));
|
||||
}
|
||||
if (pt.get_child_optional("map_of_enum_string")) {
|
||||
m_Map_of_enum_string = fromPt<std::map<std::string, std::string>>(pt.get_child("map_of_enum_string"));
|
||||
}
|
||||
if (pt.get_child_optional("direct_map")) {
|
||||
m_Direct_map = fromPt<std::map<std::string, bool>>(pt.get_child("direct_map"));
|
||||
}
|
||||
if (pt.get_child_optional("indirect_map")) {
|
||||
m_Indirect_map = fromPt<std::map<std::string, bool>>(pt.get_child("indirect_map"));
|
||||
}
|
||||
}
|
||||
|
||||
std::map<std::string, std::map<std::string, std::string>> MapTest::getMapMapOfString() const
|
||||
{
|
||||
return m_Map_map_of_string;
|
||||
}
|
||||
|
||||
void MapTest::setMapMapOfString(std::map<std::string, std::map<std::string, std::string>> value)
|
||||
{
|
||||
m_Map_map_of_string = value;
|
||||
}
|
||||
|
||||
|
||||
std::map<std::string, std::string> MapTest::getMapOfEnumString() const
|
||||
{
|
||||
return m_Map_of_enum_string;
|
||||
}
|
||||
|
||||
void MapTest::setMapOfEnumString(std::map<std::string, std::string> value)
|
||||
{
|
||||
static const std::array<std::string, 2> allowedValues = {
|
||||
"UPPER", "lower"
|
||||
};
|
||||
|
||||
for (const auto &v: value) {
|
||||
if (std::find(allowedValues.begin(), allowedValues.end(), v.first) == allowedValues.end()) {
|
||||
throw std::runtime_error("Value " + boost::lexical_cast<std::string>(v.first) + " not allowed");
|
||||
}
|
||||
}
|
||||
m_Map_of_enum_string = value;
|
||||
}
|
||||
|
||||
|
||||
std::map<std::string, bool> MapTest::getDirectMap() const
|
||||
{
|
||||
return m_Direct_map;
|
||||
}
|
||||
|
||||
void MapTest::setDirectMap(std::map<std::string, bool> value)
|
||||
{
|
||||
m_Direct_map = value;
|
||||
}
|
||||
|
||||
|
||||
std::map<std::string, bool> MapTest::getIndirectMap() const
|
||||
{
|
||||
return m_Indirect_map;
|
||||
}
|
||||
|
||||
void MapTest::setIndirectMap(std::map<std::string, bool> value)
|
||||
{
|
||||
m_Indirect_map = value;
|
||||
}
|
||||
|
||||
|
||||
|
||||
std::vector<MapTest> createMapTestVectorFromJsonString(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<MapTest>();
|
||||
for (const auto& child: pt) {
|
||||
vec.emplace_back(MapTest(child.second));
|
||||
}
|
||||
|
||||
return vec;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,112 @@
|
||||
/**
|
||||
* OpenAPI Petstore
|
||||
* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
|
||||
*
|
||||
* The version of the OpenAPI document: 1.0.0
|
||||
*
|
||||
*
|
||||
* NOTE: This class is auto generated by OpenAPI-Generator 7.0.0-SNAPSHOT.
|
||||
* https://openapi-generator.tech
|
||||
* Do not edit the class manually.
|
||||
*/
|
||||
|
||||
/*
|
||||
* MapTest.h
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef MapTest_H_
|
||||
#define MapTest_H_
|
||||
|
||||
|
||||
|
||||
#include <string>
|
||||
#include <map>
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
#include <array>
|
||||
#include <boost/property_tree/ptree.hpp>
|
||||
#include "helpers.h"
|
||||
|
||||
namespace org {
|
||||
namespace openapitools {
|
||||
namespace server {
|
||||
namespace model {
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
class MapTest
|
||||
{
|
||||
public:
|
||||
MapTest() = default;
|
||||
explicit MapTest(boost::property_tree::ptree const& pt);
|
||||
virtual ~MapTest() = default;
|
||||
|
||||
MapTest(const MapTest& other) = default; // copy constructor
|
||||
MapTest(MapTest&& other) noexcept = default; // move constructor
|
||||
|
||||
MapTest& operator=(const MapTest& other) = default; // copy assignment
|
||||
MapTest& operator=(MapTest&& other) noexcept = default; // move assignment
|
||||
|
||||
std::string toJsonString(bool prettyJson = false) const;
|
||||
void fromJsonString(std::string const& jsonString);
|
||||
boost::property_tree::ptree toPropertyTree() const;
|
||||
void fromPropertyTree(boost::property_tree::ptree const& pt);
|
||||
|
||||
|
||||
/////////////////////////////////////////////
|
||||
/// MapTest members
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
std::map<std::string, std::map<std::string, std::string>> getMapMapOfString() const;
|
||||
void setMapMapOfString(std::map<std::string, std::map<std::string, std::string>> value);
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
std::map<std::string, std::string> getMapOfEnumString() const;
|
||||
void setMapOfEnumString(std::map<std::string, std::string> value);
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
std::map<std::string, bool> getDirectMap() const;
|
||||
void setDirectMap(std::map<std::string, bool> value);
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
std::map<std::string, bool> getIndirectMap() const;
|
||||
void setIndirectMap(std::map<std::string, bool> value);
|
||||
|
||||
protected:
|
||||
std::map<std::string, std::map<std::string, std::string>> m_Map_map_of_string;
|
||||
std::map<std::string, std::string> m_Map_of_enum_string;
|
||||
std::map<std::string, bool> m_Direct_map;
|
||||
std::map<std::string, bool> m_Indirect_map;
|
||||
};
|
||||
|
||||
std::vector<MapTest> createMapTestVectorFromJsonString(const std::string& json);
|
||||
|
||||
template<>
|
||||
inline boost::property_tree::ptree toPt<MapTest>(const MapTest& val) {
|
||||
return val.toPropertyTree();
|
||||
}
|
||||
|
||||
template<>
|
||||
inline MapTest fromPt<MapTest>(const boost::property_tree::ptree& pt) {
|
||||
MapTest ret;
|
||||
ret.fromPropertyTree(pt);
|
||||
return ret;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif /* MapTest_H_ */
|
||||
@@ -0,0 +1,138 @@
|
||||
/**
|
||||
* OpenAPI Petstore
|
||||
* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
|
||||
*
|
||||
* The version of the OpenAPI document: 1.0.0
|
||||
*
|
||||
*
|
||||
* NOTE: This class is auto generated by OpenAPI-Generator 7.0.0-SNAPSHOT.
|
||||
* https://openapi-generator.tech
|
||||
* Do not edit the class manually.
|
||||
*/
|
||||
|
||||
|
||||
|
||||
#include "MixedPropertiesAndAdditionalPropertiesClass.h"
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <map>
|
||||
#include <sstream>
|
||||
#include <stdexcept>
|
||||
#include <regex>
|
||||
#include <boost/lexical_cast.hpp>
|
||||
#include <boost/property_tree/ptree.hpp>
|
||||
#include <boost/property_tree/json_parser.hpp>
|
||||
#include "helpers.h"
|
||||
|
||||
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 {
|
||||
|
||||
MixedPropertiesAndAdditionalPropertiesClass::MixedPropertiesAndAdditionalPropertiesClass(boost::property_tree::ptree const& pt)
|
||||
{
|
||||
fromPropertyTree(pt);
|
||||
}
|
||||
|
||||
|
||||
std::string MixedPropertiesAndAdditionalPropertiesClass::toJsonString(bool prettyJson /* = false */) const
|
||||
{
|
||||
std::stringstream ss;
|
||||
write_json(ss, this->toPropertyTree(), prettyJson);
|
||||
// workaround inspired by: https://stackoverflow.com/a/56395440
|
||||
std::regex reg("\\\"([0-9]+\\.{0,1}[0-9]*)\\\"");
|
||||
std::string result = std::regex_replace(ss.str(), reg, "$1");
|
||||
return result;
|
||||
}
|
||||
|
||||
void MixedPropertiesAndAdditionalPropertiesClass::fromJsonString(std::string const& jsonString)
|
||||
{
|
||||
std::stringstream ss(jsonString);
|
||||
ptree pt;
|
||||
read_json(ss,pt);
|
||||
this->fromPropertyTree(pt);
|
||||
}
|
||||
|
||||
ptree MixedPropertiesAndAdditionalPropertiesClass::toPropertyTree() const
|
||||
{
|
||||
ptree pt;
|
||||
ptree tmp_node;
|
||||
pt.put("uuid", m_Uuid);
|
||||
pt.put("dateTime", m_DateTime);
|
||||
// generate tree for map
|
||||
if (!m_map.empty()) {
|
||||
tmp_node = toPt(m_map);
|
||||
pt.add_child("map", tmp_node);
|
||||
}
|
||||
tmp_node.clear();
|
||||
return pt;
|
||||
}
|
||||
|
||||
void MixedPropertiesAndAdditionalPropertiesClass::fromPropertyTree(ptree const &pt)
|
||||
{
|
||||
ptree tmp_node;
|
||||
m_Uuid = pt.get("uuid", "");
|
||||
m_DateTime = pt.get("dateTime", "");
|
||||
if (pt.get_child_optional("map")) {
|
||||
m_map = fromPt<std::map<std::string, Animal>>(pt.get_child("map"));
|
||||
}
|
||||
}
|
||||
|
||||
std::string MixedPropertiesAndAdditionalPropertiesClass::getUuid() const
|
||||
{
|
||||
return m_Uuid;
|
||||
}
|
||||
|
||||
void MixedPropertiesAndAdditionalPropertiesClass::setUuid(std::string value)
|
||||
{
|
||||
m_Uuid = value;
|
||||
}
|
||||
|
||||
|
||||
std::string MixedPropertiesAndAdditionalPropertiesClass::getDateTime() const
|
||||
{
|
||||
return m_DateTime;
|
||||
}
|
||||
|
||||
void MixedPropertiesAndAdditionalPropertiesClass::setDateTime(std::string value)
|
||||
{
|
||||
m_DateTime = value;
|
||||
}
|
||||
|
||||
|
||||
std::map<std::string, Animal> MixedPropertiesAndAdditionalPropertiesClass::getMap() const
|
||||
{
|
||||
return m_map;
|
||||
}
|
||||
|
||||
void MixedPropertiesAndAdditionalPropertiesClass::setMap(std::map<std::string, Animal> value)
|
||||
{
|
||||
m_map = value;
|
||||
}
|
||||
|
||||
|
||||
|
||||
std::vector<MixedPropertiesAndAdditionalPropertiesClass> createMixedPropertiesAndAdditionalPropertiesClassVectorFromJsonString(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<MixedPropertiesAndAdditionalPropertiesClass>();
|
||||
for (const auto& child: pt) {
|
||||
vec.emplace_back(MixedPropertiesAndAdditionalPropertiesClass(child.second));
|
||||
}
|
||||
|
||||
return vec;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,105 @@
|
||||
/**
|
||||
* OpenAPI Petstore
|
||||
* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
|
||||
*
|
||||
* The version of the OpenAPI document: 1.0.0
|
||||
*
|
||||
*
|
||||
* NOTE: This class is auto generated by OpenAPI-Generator 7.0.0-SNAPSHOT.
|
||||
* https://openapi-generator.tech
|
||||
* Do not edit the class manually.
|
||||
*/
|
||||
|
||||
/*
|
||||
* MixedPropertiesAndAdditionalPropertiesClass.h
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef MixedPropertiesAndAdditionalPropertiesClass_H_
|
||||
#define MixedPropertiesAndAdditionalPropertiesClass_H_
|
||||
|
||||
|
||||
|
||||
#include <string>
|
||||
#include <map>
|
||||
#include "Animal.h"
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
#include <boost/property_tree/ptree.hpp>
|
||||
#include "helpers.h"
|
||||
|
||||
namespace org {
|
||||
namespace openapitools {
|
||||
namespace server {
|
||||
namespace model {
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
class MixedPropertiesAndAdditionalPropertiesClass
|
||||
{
|
||||
public:
|
||||
MixedPropertiesAndAdditionalPropertiesClass() = default;
|
||||
explicit MixedPropertiesAndAdditionalPropertiesClass(boost::property_tree::ptree const& pt);
|
||||
virtual ~MixedPropertiesAndAdditionalPropertiesClass() = default;
|
||||
|
||||
MixedPropertiesAndAdditionalPropertiesClass(const MixedPropertiesAndAdditionalPropertiesClass& other) = default; // copy constructor
|
||||
MixedPropertiesAndAdditionalPropertiesClass(MixedPropertiesAndAdditionalPropertiesClass&& other) noexcept = default; // move constructor
|
||||
|
||||
MixedPropertiesAndAdditionalPropertiesClass& operator=(const MixedPropertiesAndAdditionalPropertiesClass& other) = default; // copy assignment
|
||||
MixedPropertiesAndAdditionalPropertiesClass& operator=(MixedPropertiesAndAdditionalPropertiesClass&& other) noexcept = default; // move assignment
|
||||
|
||||
std::string toJsonString(bool prettyJson = false) const;
|
||||
void fromJsonString(std::string const& jsonString);
|
||||
boost::property_tree::ptree toPropertyTree() const;
|
||||
void fromPropertyTree(boost::property_tree::ptree const& pt);
|
||||
|
||||
|
||||
/////////////////////////////////////////////
|
||||
/// MixedPropertiesAndAdditionalPropertiesClass members
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
std::string getUuid() const;
|
||||
void setUuid(std::string value);
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
std::string getDateTime() const;
|
||||
void setDateTime(std::string value);
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
std::map<std::string, Animal> getMap() const;
|
||||
void setMap(std::map<std::string, Animal> value);
|
||||
|
||||
protected:
|
||||
std::string m_Uuid = "";
|
||||
std::string m_DateTime = "";
|
||||
std::map<std::string, Animal> m_map;
|
||||
};
|
||||
|
||||
std::vector<MixedPropertiesAndAdditionalPropertiesClass> createMixedPropertiesAndAdditionalPropertiesClassVectorFromJsonString(const std::string& json);
|
||||
|
||||
template<>
|
||||
inline boost::property_tree::ptree toPt<MixedPropertiesAndAdditionalPropertiesClass>(const MixedPropertiesAndAdditionalPropertiesClass& val) {
|
||||
return val.toPropertyTree();
|
||||
}
|
||||
|
||||
template<>
|
||||
inline MixedPropertiesAndAdditionalPropertiesClass fromPt<MixedPropertiesAndAdditionalPropertiesClass>(const boost::property_tree::ptree& pt) {
|
||||
MixedPropertiesAndAdditionalPropertiesClass ret;
|
||||
ret.fromPropertyTree(pt);
|
||||
return ret;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif /* MixedPropertiesAndAdditionalPropertiesClass_H_ */
|
||||
144
samples/server/petstore/cpp-restbed/generated/3_0/model/Name.cpp
Normal file
144
samples/server/petstore/cpp-restbed/generated/3_0/model/Name.cpp
Normal file
@@ -0,0 +1,144 @@
|
||||
/**
|
||||
* OpenAPI Petstore
|
||||
* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
|
||||
*
|
||||
* The version of the OpenAPI document: 1.0.0
|
||||
*
|
||||
*
|
||||
* NOTE: This class is auto generated by OpenAPI-Generator 7.0.0-SNAPSHOT.
|
||||
* https://openapi-generator.tech
|
||||
* Do not edit the class manually.
|
||||
*/
|
||||
|
||||
|
||||
|
||||
#include "Name.h"
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <map>
|
||||
#include <sstream>
|
||||
#include <stdexcept>
|
||||
#include <regex>
|
||||
#include <boost/lexical_cast.hpp>
|
||||
#include <boost/property_tree/ptree.hpp>
|
||||
#include <boost/property_tree/json_parser.hpp>
|
||||
#include "helpers.h"
|
||||
|
||||
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 {
|
||||
|
||||
Name::Name(boost::property_tree::ptree const& pt)
|
||||
{
|
||||
fromPropertyTree(pt);
|
||||
}
|
||||
|
||||
|
||||
std::string Name::toJsonString(bool prettyJson /* = false */) const
|
||||
{
|
||||
std::stringstream ss;
|
||||
write_json(ss, this->toPropertyTree(), prettyJson);
|
||||
// workaround inspired by: https://stackoverflow.com/a/56395440
|
||||
std::regex reg("\\\"([0-9]+\\.{0,1}[0-9]*)\\\"");
|
||||
std::string result = std::regex_replace(ss.str(), reg, "$1");
|
||||
return result;
|
||||
}
|
||||
|
||||
void Name::fromJsonString(std::string const& jsonString)
|
||||
{
|
||||
std::stringstream ss(jsonString);
|
||||
ptree pt;
|
||||
read_json(ss,pt);
|
||||
this->fromPropertyTree(pt);
|
||||
}
|
||||
|
||||
ptree Name::toPropertyTree() const
|
||||
{
|
||||
ptree pt;
|
||||
ptree tmp_node;
|
||||
pt.put("name", m_Name);
|
||||
pt.put("snake_case", m_Snake_case);
|
||||
pt.put("property", m_Property);
|
||||
pt.put("123Number", m_r_123Number);
|
||||
return pt;
|
||||
}
|
||||
|
||||
void Name::fromPropertyTree(ptree const &pt)
|
||||
{
|
||||
ptree tmp_node;
|
||||
m_Name = pt.get("name", 0);
|
||||
m_Snake_case = pt.get("snake_case", 0);
|
||||
m_Property = pt.get("property", "");
|
||||
m_r_123Number = pt.get("123Number", 0);
|
||||
}
|
||||
|
||||
int32_t Name::getName() const
|
||||
{
|
||||
return m_Name;
|
||||
}
|
||||
|
||||
void Name::setName(int32_t value)
|
||||
{
|
||||
m_Name = value;
|
||||
}
|
||||
|
||||
|
||||
int32_t Name::getSnakeCase() const
|
||||
{
|
||||
return m_Snake_case;
|
||||
}
|
||||
|
||||
void Name::setSnakeCase(int32_t value)
|
||||
{
|
||||
m_Snake_case = value;
|
||||
}
|
||||
|
||||
|
||||
std::string Name::getProperty() const
|
||||
{
|
||||
return m_Property;
|
||||
}
|
||||
|
||||
void Name::setProperty(std::string value)
|
||||
{
|
||||
m_Property = value;
|
||||
}
|
||||
|
||||
|
||||
int32_t Name::getR123Number() const
|
||||
{
|
||||
return m_r_123Number;
|
||||
}
|
||||
|
||||
void Name::setR123Number(int32_t value)
|
||||
{
|
||||
m_r_123Number = value;
|
||||
}
|
||||
|
||||
|
||||
|
||||
std::vector<Name> createNameVectorFromJsonString(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<Name>();
|
||||
for (const auto& child: pt) {
|
||||
vec.emplace_back(Name(child.second));
|
||||
}
|
||||
|
||||
return vec;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
110
samples/server/petstore/cpp-restbed/generated/3_0/model/Name.h
Normal file
110
samples/server/petstore/cpp-restbed/generated/3_0/model/Name.h
Normal file
@@ -0,0 +1,110 @@
|
||||
/**
|
||||
* OpenAPI Petstore
|
||||
* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
|
||||
*
|
||||
* The version of the OpenAPI document: 1.0.0
|
||||
*
|
||||
*
|
||||
* NOTE: This class is auto generated by OpenAPI-Generator 7.0.0-SNAPSHOT.
|
||||
* https://openapi-generator.tech
|
||||
* Do not edit the class manually.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Name.h
|
||||
*
|
||||
* Model for testing model name same as property name
|
||||
*/
|
||||
|
||||
#ifndef Name_H_
|
||||
#define Name_H_
|
||||
|
||||
|
||||
|
||||
#include <string>
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
#include <boost/property_tree/ptree.hpp>
|
||||
#include "helpers.h"
|
||||
|
||||
namespace org {
|
||||
namespace openapitools {
|
||||
namespace server {
|
||||
namespace model {
|
||||
|
||||
/// <summary>
|
||||
/// Model for testing model name same as property name
|
||||
/// </summary>
|
||||
class Name
|
||||
{
|
||||
public:
|
||||
Name() = default;
|
||||
explicit Name(boost::property_tree::ptree const& pt);
|
||||
virtual ~Name() = default;
|
||||
|
||||
Name(const Name& other) = default; // copy constructor
|
||||
Name(Name&& other) noexcept = default; // move constructor
|
||||
|
||||
Name& operator=(const Name& other) = default; // copy assignment
|
||||
Name& operator=(Name&& other) noexcept = default; // move assignment
|
||||
|
||||
std::string toJsonString(bool prettyJson = false) const;
|
||||
void fromJsonString(std::string const& jsonString);
|
||||
boost::property_tree::ptree toPropertyTree() const;
|
||||
void fromPropertyTree(boost::property_tree::ptree const& pt);
|
||||
|
||||
|
||||
/////////////////////////////////////////////
|
||||
/// Name members
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
int32_t getName() const;
|
||||
void setName(int32_t value);
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
int32_t getSnakeCase() const;
|
||||
void setSnakeCase(int32_t value);
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
std::string getProperty() const;
|
||||
void setProperty(std::string value);
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
int32_t getR123Number() const;
|
||||
void setR123Number(int32_t value);
|
||||
|
||||
protected:
|
||||
int32_t m_Name = 0;
|
||||
int32_t m_Snake_case = 0;
|
||||
std::string m_Property = "";
|
||||
int32_t m_r_123Number = 0;
|
||||
};
|
||||
|
||||
std::vector<Name> createNameVectorFromJsonString(const std::string& json);
|
||||
|
||||
template<>
|
||||
inline boost::property_tree::ptree toPt<Name>(const Name& val) {
|
||||
return val.toPropertyTree();
|
||||
}
|
||||
|
||||
template<>
|
||||
inline Name fromPt<Name>(const boost::property_tree::ptree& pt) {
|
||||
Name ret;
|
||||
ret.fromPropertyTree(pt);
|
||||
return ret;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif /* Name_H_ */
|
||||
@@ -0,0 +1,296 @@
|
||||
/**
|
||||
* OpenAPI Petstore
|
||||
* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
|
||||
*
|
||||
* The version of the OpenAPI document: 1.0.0
|
||||
*
|
||||
*
|
||||
* NOTE: This class is auto generated by OpenAPI-Generator 7.0.0-SNAPSHOT.
|
||||
* https://openapi-generator.tech
|
||||
* Do not edit the class manually.
|
||||
*/
|
||||
|
||||
|
||||
|
||||
#include "NullableClass.h"
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <map>
|
||||
#include <sstream>
|
||||
#include <stdexcept>
|
||||
#include <regex>
|
||||
#include <boost/lexical_cast.hpp>
|
||||
#include <boost/property_tree/ptree.hpp>
|
||||
#include <boost/property_tree/json_parser.hpp>
|
||||
#include "helpers.h"
|
||||
|
||||
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 {
|
||||
|
||||
NullableClass::NullableClass(boost::property_tree::ptree const& pt)
|
||||
{
|
||||
fromPropertyTree(pt);
|
||||
}
|
||||
|
||||
|
||||
std::string NullableClass::toJsonString(bool prettyJson /* = false */) const
|
||||
{
|
||||
std::stringstream ss;
|
||||
write_json(ss, this->toPropertyTree(), prettyJson);
|
||||
// workaround inspired by: https://stackoverflow.com/a/56395440
|
||||
std::regex reg("\\\"([0-9]+\\.{0,1}[0-9]*)\\\"");
|
||||
std::string result = std::regex_replace(ss.str(), reg, "$1");
|
||||
return result;
|
||||
}
|
||||
|
||||
void NullableClass::fromJsonString(std::string const& jsonString)
|
||||
{
|
||||
std::stringstream ss(jsonString);
|
||||
ptree pt;
|
||||
read_json(ss,pt);
|
||||
this->fromPropertyTree(pt);
|
||||
}
|
||||
|
||||
ptree NullableClass::toPropertyTree() const
|
||||
{
|
||||
ptree pt;
|
||||
ptree tmp_node;
|
||||
pt.put("integer_prop", m_Integer_prop);
|
||||
pt.put("number_prop", m_Number_prop);
|
||||
pt.put("boolean_prop", m_Boolean_prop);
|
||||
pt.put("string_prop", m_String_prop);
|
||||
pt.put("date_prop", m_Date_prop);
|
||||
pt.put("datetime_prop", m_Datetime_prop);
|
||||
// generate tree for Array_nullable_prop
|
||||
tmp_node.clear();
|
||||
if (!m_Array_nullable_prop.empty()) {
|
||||
tmp_node = toPt(m_Array_nullable_prop);
|
||||
pt.add_child("array_nullable_prop", tmp_node);
|
||||
tmp_node.clear();
|
||||
}
|
||||
// generate tree for Array_and_items_nullable_prop
|
||||
tmp_node.clear();
|
||||
if (!m_Array_and_items_nullable_prop.empty()) {
|
||||
tmp_node = toPt(m_Array_and_items_nullable_prop);
|
||||
pt.add_child("array_and_items_nullable_prop", tmp_node);
|
||||
tmp_node.clear();
|
||||
}
|
||||
// generate tree for Array_items_nullable
|
||||
tmp_node.clear();
|
||||
if (!m_Array_items_nullable.empty()) {
|
||||
tmp_node = toPt(m_Array_items_nullable);
|
||||
pt.add_child("array_items_nullable", tmp_node);
|
||||
tmp_node.clear();
|
||||
}
|
||||
// generate tree for Object_nullable_prop
|
||||
if (!m_Object_nullable_prop.empty()) {
|
||||
tmp_node = toPt(m_Object_nullable_prop);
|
||||
pt.add_child("object_nullable_prop", tmp_node);
|
||||
}
|
||||
tmp_node.clear();
|
||||
// generate tree for Object_and_items_nullable_prop
|
||||
if (!m_Object_and_items_nullable_prop.empty()) {
|
||||
tmp_node = toPt(m_Object_and_items_nullable_prop);
|
||||
pt.add_child("object_and_items_nullable_prop", tmp_node);
|
||||
}
|
||||
tmp_node.clear();
|
||||
// generate tree for Object_items_nullable
|
||||
if (!m_Object_items_nullable.empty()) {
|
||||
tmp_node = toPt(m_Object_items_nullable);
|
||||
pt.add_child("object_items_nullable", tmp_node);
|
||||
}
|
||||
tmp_node.clear();
|
||||
return pt;
|
||||
}
|
||||
|
||||
void NullableClass::fromPropertyTree(ptree const &pt)
|
||||
{
|
||||
ptree tmp_node;
|
||||
m_Integer_prop = pt.get("integer_prop", 0);
|
||||
m_Number_prop = pt.get("number_prop", 0.0);
|
||||
m_Boolean_prop = pt.get("boolean_prop", false);
|
||||
m_String_prop = pt.get("string_prop", "");
|
||||
m_Date_prop = pt.get("date_prop", "");
|
||||
m_Datetime_prop = pt.get("datetime_prop", "");
|
||||
// push all items of Array_nullable_prop into member
|
||||
if (pt.get_child_optional("array_nullable_prop")) {
|
||||
m_Array_nullable_prop = fromPt<std::vector<std::string>>(pt.get_child("array_nullable_prop"));
|
||||
}
|
||||
// push all items of Array_and_items_nullable_prop into member
|
||||
if (pt.get_child_optional("array_and_items_nullable_prop")) {
|
||||
m_Array_and_items_nullable_prop = fromPt<std::vector<std::string>>(pt.get_child("array_and_items_nullable_prop"));
|
||||
}
|
||||
// push all items of Array_items_nullable into member
|
||||
if (pt.get_child_optional("array_items_nullable")) {
|
||||
m_Array_items_nullable = fromPt<std::vector<std::string>>(pt.get_child("array_items_nullable"));
|
||||
}
|
||||
if (pt.get_child_optional("object_nullable_prop")) {
|
||||
m_Object_nullable_prop = fromPt<std::map<std::string, std::string>>(pt.get_child("object_nullable_prop"));
|
||||
}
|
||||
if (pt.get_child_optional("object_and_items_nullable_prop")) {
|
||||
m_Object_and_items_nullable_prop = fromPt<std::map<std::string, std::string>>(pt.get_child("object_and_items_nullable_prop"));
|
||||
}
|
||||
if (pt.get_child_optional("object_items_nullable")) {
|
||||
m_Object_items_nullable = fromPt<std::map<std::string, std::string>>(pt.get_child("object_items_nullable"));
|
||||
}
|
||||
}
|
||||
|
||||
int32_t NullableClass::getIntegerProp() const
|
||||
{
|
||||
return m_Integer_prop;
|
||||
}
|
||||
|
||||
void NullableClass::setIntegerProp(int32_t value)
|
||||
{
|
||||
m_Integer_prop = value;
|
||||
}
|
||||
|
||||
|
||||
double NullableClass::getNumberProp() const
|
||||
{
|
||||
return m_Number_prop;
|
||||
}
|
||||
|
||||
void NullableClass::setNumberProp(double value)
|
||||
{
|
||||
m_Number_prop = value;
|
||||
}
|
||||
|
||||
|
||||
bool NullableClass::isBooleanProp() const
|
||||
{
|
||||
return m_Boolean_prop;
|
||||
}
|
||||
|
||||
void NullableClass::setBooleanProp(bool value)
|
||||
{
|
||||
m_Boolean_prop = value;
|
||||
}
|
||||
|
||||
|
||||
std::string NullableClass::getStringProp() const
|
||||
{
|
||||
return m_String_prop;
|
||||
}
|
||||
|
||||
void NullableClass::setStringProp(std::string value)
|
||||
{
|
||||
m_String_prop = value;
|
||||
}
|
||||
|
||||
|
||||
std::string NullableClass::getDateProp() const
|
||||
{
|
||||
return m_Date_prop;
|
||||
}
|
||||
|
||||
void NullableClass::setDateProp(std::string value)
|
||||
{
|
||||
m_Date_prop = value;
|
||||
}
|
||||
|
||||
|
||||
std::string NullableClass::getDatetimeProp() const
|
||||
{
|
||||
return m_Datetime_prop;
|
||||
}
|
||||
|
||||
void NullableClass::setDatetimeProp(std::string value)
|
||||
{
|
||||
m_Datetime_prop = value;
|
||||
}
|
||||
|
||||
|
||||
std::vector<std::string> NullableClass::getArrayNullableProp() const
|
||||
{
|
||||
return m_Array_nullable_prop;
|
||||
}
|
||||
|
||||
void NullableClass::setArrayNullableProp(std::vector<std::string> value)
|
||||
{
|
||||
m_Array_nullable_prop = value;
|
||||
}
|
||||
|
||||
|
||||
std::vector<std::string> NullableClass::getArrayAndItemsNullableProp() const
|
||||
{
|
||||
return m_Array_and_items_nullable_prop;
|
||||
}
|
||||
|
||||
void NullableClass::setArrayAndItemsNullableProp(std::vector<std::string> value)
|
||||
{
|
||||
m_Array_and_items_nullable_prop = value;
|
||||
}
|
||||
|
||||
|
||||
std::vector<std::string> NullableClass::getArrayItemsNullable() const
|
||||
{
|
||||
return m_Array_items_nullable;
|
||||
}
|
||||
|
||||
void NullableClass::setArrayItemsNullable(std::vector<std::string> value)
|
||||
{
|
||||
m_Array_items_nullable = value;
|
||||
}
|
||||
|
||||
|
||||
std::map<std::string, std::string> NullableClass::getObjectNullableProp() const
|
||||
{
|
||||
return m_Object_nullable_prop;
|
||||
}
|
||||
|
||||
void NullableClass::setObjectNullableProp(std::map<std::string, std::string> value)
|
||||
{
|
||||
m_Object_nullable_prop = value;
|
||||
}
|
||||
|
||||
|
||||
std::map<std::string, std::string> NullableClass::getObjectAndItemsNullableProp() const
|
||||
{
|
||||
return m_Object_and_items_nullable_prop;
|
||||
}
|
||||
|
||||
void NullableClass::setObjectAndItemsNullableProp(std::map<std::string, std::string> value)
|
||||
{
|
||||
m_Object_and_items_nullable_prop = value;
|
||||
}
|
||||
|
||||
|
||||
std::map<std::string, std::string> NullableClass::getObjectItemsNullable() const
|
||||
{
|
||||
return m_Object_items_nullable;
|
||||
}
|
||||
|
||||
void NullableClass::setObjectItemsNullable(std::map<std::string, std::string> value)
|
||||
{
|
||||
m_Object_items_nullable = value;
|
||||
}
|
||||
|
||||
|
||||
|
||||
std::vector<NullableClass> createNullableClassVectorFromJsonString(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<NullableClass>();
|
||||
for (const auto& child: pt) {
|
||||
vec.emplace_back(NullableClass(child.second));
|
||||
}
|
||||
|
||||
return vec;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,168 @@
|
||||
/**
|
||||
* OpenAPI Petstore
|
||||
* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
|
||||
*
|
||||
* The version of the OpenAPI document: 1.0.0
|
||||
*
|
||||
*
|
||||
* NOTE: This class is auto generated by OpenAPI-Generator 7.0.0-SNAPSHOT.
|
||||
* https://openapi-generator.tech
|
||||
* Do not edit the class manually.
|
||||
*/
|
||||
|
||||
/*
|
||||
* NullableClass.h
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef NullableClass_H_
|
||||
#define NullableClass_H_
|
||||
|
||||
|
||||
|
||||
#include <string>
|
||||
#include <map>
|
||||
#include <vector>
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
#include <boost/property_tree/ptree.hpp>
|
||||
#include "helpers.h"
|
||||
|
||||
namespace org {
|
||||
namespace openapitools {
|
||||
namespace server {
|
||||
namespace model {
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
class NullableClass
|
||||
{
|
||||
public:
|
||||
NullableClass() = default;
|
||||
explicit NullableClass(boost::property_tree::ptree const& pt);
|
||||
virtual ~NullableClass() = default;
|
||||
|
||||
NullableClass(const NullableClass& other) = default; // copy constructor
|
||||
NullableClass(NullableClass&& other) noexcept = default; // move constructor
|
||||
|
||||
NullableClass& operator=(const NullableClass& other) = default; // copy assignment
|
||||
NullableClass& operator=(NullableClass&& other) noexcept = default; // move assignment
|
||||
|
||||
std::string toJsonString(bool prettyJson = false) const;
|
||||
void fromJsonString(std::string const& jsonString);
|
||||
boost::property_tree::ptree toPropertyTree() const;
|
||||
void fromPropertyTree(boost::property_tree::ptree const& pt);
|
||||
|
||||
|
||||
/////////////////////////////////////////////
|
||||
/// NullableClass members
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
int32_t getIntegerProp() const;
|
||||
void setIntegerProp(int32_t value);
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
double getNumberProp() const;
|
||||
void setNumberProp(double value);
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
bool isBooleanProp() const;
|
||||
void setBooleanProp(bool value);
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
std::string getStringProp() const;
|
||||
void setStringProp(std::string value);
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
std::string getDateProp() const;
|
||||
void setDateProp(std::string value);
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
std::string getDatetimeProp() const;
|
||||
void setDatetimeProp(std::string value);
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
std::vector<std::string> getArrayNullableProp() const;
|
||||
void setArrayNullableProp(std::vector<std::string> value);
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
std::vector<std::string> getArrayAndItemsNullableProp() const;
|
||||
void setArrayAndItemsNullableProp(std::vector<std::string> value);
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
std::vector<std::string> getArrayItemsNullable() const;
|
||||
void setArrayItemsNullable(std::vector<std::string> value);
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
std::map<std::string, std::string> getObjectNullableProp() const;
|
||||
void setObjectNullableProp(std::map<std::string, std::string> value);
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
std::map<std::string, std::string> getObjectAndItemsNullableProp() const;
|
||||
void setObjectAndItemsNullableProp(std::map<std::string, std::string> value);
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
std::map<std::string, std::string> getObjectItemsNullable() const;
|
||||
void setObjectItemsNullable(std::map<std::string, std::string> value);
|
||||
|
||||
protected:
|
||||
int32_t m_Integer_prop = 0;
|
||||
double m_Number_prop = 0.0;
|
||||
bool m_Boolean_prop = false;
|
||||
std::string m_String_prop = "";
|
||||
std::string m_Date_prop = "";
|
||||
std::string m_Datetime_prop = "";
|
||||
std::vector<std::string> m_Array_nullable_prop;
|
||||
std::vector<std::string> m_Array_and_items_nullable_prop;
|
||||
std::vector<std::string> m_Array_items_nullable;
|
||||
std::map<std::string, std::string> m_Object_nullable_prop;
|
||||
std::map<std::string, std::string> m_Object_and_items_nullable_prop;
|
||||
std::map<std::string, std::string> m_Object_items_nullable;
|
||||
};
|
||||
|
||||
std::vector<NullableClass> createNullableClassVectorFromJsonString(const std::string& json);
|
||||
|
||||
template<>
|
||||
inline boost::property_tree::ptree toPt<NullableClass>(const NullableClass& val) {
|
||||
return val.toPropertyTree();
|
||||
}
|
||||
|
||||
template<>
|
||||
inline NullableClass fromPt<NullableClass>(const boost::property_tree::ptree& pt) {
|
||||
NullableClass ret;
|
||||
ret.fromPropertyTree(pt);
|
||||
return ret;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif /* NullableClass_H_ */
|
||||
@@ -0,0 +1,105 @@
|
||||
/**
|
||||
* OpenAPI Petstore
|
||||
* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
|
||||
*
|
||||
* The version of the OpenAPI document: 1.0.0
|
||||
*
|
||||
*
|
||||
* NOTE: This class is auto generated by OpenAPI-Generator 7.0.0-SNAPSHOT.
|
||||
* https://openapi-generator.tech
|
||||
* Do not edit the class manually.
|
||||
*/
|
||||
|
||||
|
||||
|
||||
#include "NumberOnly.h"
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <map>
|
||||
#include <sstream>
|
||||
#include <stdexcept>
|
||||
#include <regex>
|
||||
#include <boost/lexical_cast.hpp>
|
||||
#include <boost/property_tree/ptree.hpp>
|
||||
#include <boost/property_tree/json_parser.hpp>
|
||||
#include "helpers.h"
|
||||
|
||||
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 {
|
||||
|
||||
NumberOnly::NumberOnly(boost::property_tree::ptree const& pt)
|
||||
{
|
||||
fromPropertyTree(pt);
|
||||
}
|
||||
|
||||
|
||||
std::string NumberOnly::toJsonString(bool prettyJson /* = false */) const
|
||||
{
|
||||
std::stringstream ss;
|
||||
write_json(ss, this->toPropertyTree(), prettyJson);
|
||||
// workaround inspired by: https://stackoverflow.com/a/56395440
|
||||
std::regex reg("\\\"([0-9]+\\.{0,1}[0-9]*)\\\"");
|
||||
std::string result = std::regex_replace(ss.str(), reg, "$1");
|
||||
return result;
|
||||
}
|
||||
|
||||
void NumberOnly::fromJsonString(std::string const& jsonString)
|
||||
{
|
||||
std::stringstream ss(jsonString);
|
||||
ptree pt;
|
||||
read_json(ss,pt);
|
||||
this->fromPropertyTree(pt);
|
||||
}
|
||||
|
||||
ptree NumberOnly::toPropertyTree() const
|
||||
{
|
||||
ptree pt;
|
||||
ptree tmp_node;
|
||||
pt.put("JustNumber", m_JustNumber);
|
||||
return pt;
|
||||
}
|
||||
|
||||
void NumberOnly::fromPropertyTree(ptree const &pt)
|
||||
{
|
||||
ptree tmp_node;
|
||||
m_JustNumber = pt.get("JustNumber", 0.0);
|
||||
}
|
||||
|
||||
double NumberOnly::getJustNumber() const
|
||||
{
|
||||
return m_JustNumber;
|
||||
}
|
||||
|
||||
void NumberOnly::setJustNumber(double value)
|
||||
{
|
||||
m_JustNumber = value;
|
||||
}
|
||||
|
||||
|
||||
|
||||
std::vector<NumberOnly> createNumberOnlyVectorFromJsonString(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<NumberOnly>();
|
||||
for (const auto& child: pt) {
|
||||
vec.emplace_back(NumberOnly(child.second));
|
||||
}
|
||||
|
||||
return vec;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user