forked from loafle/openapi-generator-original
[C++][Pistache] Fix optional error and wrong function signatures (#264)
* Added missing includes for optional * Removed shared pointer from pistache generator * Changed Net namespace to Pistache Namespace * Clean up code and removed unnecessary lines in mustache files * Removed remaining shared pointer syntax * Code review fixes + updated samples * Added const to all model setter functions, and reference to all params in setters that are not primitives * Refactored modelbase * Removed const * Updated samples
This commit is contained in:
parent
825e4e99e3
commit
23ab5177b3
@ -1 +1 @@
|
||||
3.0.0-SNAPSHOT
|
||||
3.0.1-SNAPSHOT
|
@ -219,14 +219,14 @@ public class CppPistacheServerCodegen extends AbstractCppCodegen {
|
||||
|
||||
//TODO: This changes the info about the real type but it is needed to parse the header params
|
||||
if (param.isHeaderParam) {
|
||||
param.dataType = "Optional<Net::Http::Header::Raw>";
|
||||
param.baseType = "Optional<Net::Http::Header::Raw>";
|
||||
param.dataType = "Pistache::Optional<Pistache::Http::Header::Raw>";
|
||||
param.baseType = "Pistache::Optional<Pistache::Http::Header::Raw>";
|
||||
} else if (param.isQueryParam) {
|
||||
if (param.isPrimitiveType) {
|
||||
param.dataType = "Optional<" + param.dataType + ">";
|
||||
param.dataType = "Pistache::Optional<" + param.dataType + ">";
|
||||
} else {
|
||||
param.dataType = "Optional<" + param.baseType + ">";
|
||||
param.baseType = "Optional<" + param.baseType + ">";
|
||||
param.dataType = "Pistache::Optional<" + param.baseType + ">";
|
||||
param.baseType = "Pistache::Optional<" + param.baseType + ">";
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -299,7 +299,7 @@ public class CppPistacheServerCodegen extends AbstractCppCodegen {
|
||||
return toModelName(openAPIType);
|
||||
}
|
||||
|
||||
return "std::shared_ptr<" + openAPIType + ">";
|
||||
return openAPIType;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -326,30 +326,14 @@ public class CppPistacheServerCodegen extends AbstractCppCodegen {
|
||||
} else if (ModelUtils.isArraySchema(p)) {
|
||||
ArraySchema ap = (ArraySchema) p;
|
||||
String inner = getSchemaType(ap.getItems());
|
||||
if (!languageSpecificPrimitives.contains(inner)) {
|
||||
inner = "std::shared_ptr<" + inner + ">";
|
||||
}
|
||||
return "std::vector<" + inner + ">()";
|
||||
} else if (!StringUtils.isEmpty(p.get$ref())) { // model
|
||||
return "new " + toModelName(ModelUtils.getSimpleRef(p.get$ref())) + "()";
|
||||
return toModelName(ModelUtils.getSimpleRef(p.get$ref())) + "()";
|
||||
} else if (ModelUtils.isStringSchema(p)) {
|
||||
return "\"\"";
|
||||
}
|
||||
|
||||
return "nullptr";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void postProcessParameter(CodegenParameter parameter) {
|
||||
super.postProcessParameter(parameter);
|
||||
|
||||
boolean isPrimitiveType = parameter.isPrimitiveType == Boolean.TRUE;
|
||||
boolean isListContainer = parameter.isListContainer == Boolean.TRUE;
|
||||
boolean isString = parameter.isString == Boolean.TRUE;
|
||||
|
||||
if (!isPrimitiveType && !isListContainer && !isString && !parameter.dataType.startsWith("std::shared_ptr")) {
|
||||
parameter.dataType = "std::shared_ptr<" + parameter.dataType + ">";
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -14,6 +14,8 @@
|
||||
#include <pistache/router.h>
|
||||
#include <pistache/http_headers.h>
|
||||
|
||||
#include <pistache/optional.h>
|
||||
|
||||
{{#imports}}{{{import}}}
|
||||
{{/imports}}
|
||||
|
||||
@ -41,7 +43,7 @@ private:
|
||||
{{/operation}}
|
||||
void {{classnameSnakeLowerCase}}_default_handler(const Pistache::Rest::Request &request, Pistache::Http::ResponseWriter response);
|
||||
|
||||
std::shared_ptr<Pistache::Http::Endpoint> httpEndpoint;
|
||||
Pistache::Http::Endpoint httpEndpoint;
|
||||
Pistache::Rest::Router router;
|
||||
|
||||
{{#operation}}
|
||||
|
@ -17,6 +17,8 @@
|
||||
|
||||
#include <{{classname}}.h>
|
||||
|
||||
#include <pistache/optional.h>
|
||||
|
||||
{{#imports}}{{{import}}}
|
||||
{{/imports}}
|
||||
|
||||
|
@ -10,24 +10,24 @@ namespace {{this}} {
|
||||
using namespace {{modelNamespace}};
|
||||
|
||||
{{classname}}::{{classname}}(Pistache::Address addr)
|
||||
: httpEndpoint(std::make_shared<Pistache::Http::Endpoint>(addr))
|
||||
: httpEndpoint(addr)
|
||||
{ };
|
||||
|
||||
void {{classname}}::init(size_t thr = 2) {
|
||||
auto opts = Pistache::Http::Endpoint::options()
|
||||
.threads(thr)
|
||||
.flags(Pistache::Tcp::Options::InstallSignalHandler);
|
||||
httpEndpoint->init(opts);
|
||||
httpEndpoint.init(opts);
|
||||
setupRoutes();
|
||||
}
|
||||
|
||||
void {{classname}}::start() {
|
||||
httpEndpoint->setHandler(router.handler());
|
||||
httpEndpoint->serve();
|
||||
httpEndpoint.setHandler(router.handler());
|
||||
httpEndpoint.serve();
|
||||
}
|
||||
|
||||
void {{classname}}::shutdown() {
|
||||
httpEndpoint->shutdown();
|
||||
httpEndpoint.shutdown();
|
||||
}
|
||||
|
||||
void {{classname}}::setupRoutes() {
|
||||
|
@ -45,7 +45,7 @@ public:
|
||||
/// </summary>
|
||||
{{^isNotContainer}}{{{dataType}}}& {{getter}}();
|
||||
{{/isNotContainer}}{{#isNotContainer}}{{{dataType}}} {{getter}}() const;
|
||||
void {{setter}}({{{dataType}}} value);
|
||||
void {{setter}}({{{dataType}}} const{{^isPrimitiveType}}&{{/isPrimitiveType}} value);
|
||||
{{/isNotContainer}}{{^required}}bool {{nameInCamelCase}}IsSet() const;
|
||||
void unset{{name}}();
|
||||
{{/required}}
|
||||
|
@ -84,7 +84,7 @@ void {{classname}}::fromJson(nlohmann::json& val)
|
||||
else
|
||||
{
|
||||
{{{items.datatype}}} newItem({{{items.defaultValue}}});
|
||||
newItem->fromJson(item);
|
||||
newItem.fromJson(item);
|
||||
m_{{name}}.push_back( newItem );
|
||||
}
|
||||
{{/items.isDateTime}}{{/items.isString}}{{/isPrimitiveType}}
|
||||
@ -100,7 +100,7 @@ void {{classname}}::fromJson(nlohmann::json& val)
|
||||
{{/isDateTime}}{{^isDateTime}}if(!val["{{baseName}}"].is_null())
|
||||
{
|
||||
{{{dataType}}} newItem({{{defaultValue}}});
|
||||
newItem->fromJson(val["{{baseName}}"]);
|
||||
newItem.fromJson(val["{{baseName}}"]);
|
||||
{{setter}}( newItem );
|
||||
}
|
||||
{{/isDateTime}}{{/isString}}
|
||||
@ -119,7 +119,7 @@ void {{classname}}::fromJson(nlohmann::json& val)
|
||||
{
|
||||
return m_{{name}};
|
||||
}
|
||||
void {{classname}}::{{setter}}({{{dataType}}} value)
|
||||
void {{classname}}::{{setter}}({{{dataType}}} const{{^isPrimitiveType}}&{{/isPrimitiveType}} value)
|
||||
{
|
||||
m_{{name}} = value;
|
||||
{{^required}}m_{{name}}IsSet = true;{{/required}}
|
||||
|
@ -28,13 +28,13 @@ public:
|
||||
virtual nlohmann::json toJson() const = 0;
|
||||
virtual void fromJson(nlohmann::json& json) = 0;
|
||||
|
||||
static std::string toJson( const std::string& value );
|
||||
static std::string toJson( const std::time_t& value );
|
||||
static int32_t toJson( int32_t value );
|
||||
static int64_t toJson( int64_t value );
|
||||
static double toJson( double value );
|
||||
static bool toJson( bool value );
|
||||
static nlohmann::json toJson( std::shared_ptr<ModelBase> content );
|
||||
static std::string toJson( std::string const& value );
|
||||
static std::string toJson( std::time_t const& value );
|
||||
static int32_t toJson( int32_t const value );
|
||||
static int64_t toJson( int64_t const value );
|
||||
static double toJson( double const value );
|
||||
static bool toJson( bool const value );
|
||||
static nlohmann::json toJson(ModelBase const& content );
|
||||
|
||||
};
|
||||
|
||||
|
@ -12,41 +12,41 @@ ModelBase::~ModelBase()
|
||||
{
|
||||
}
|
||||
|
||||
std::string ModelBase::toJson( const std::string& value )
|
||||
std::string ModelBase::toJson( std::string const& value )
|
||||
{
|
||||
return value;
|
||||
}
|
||||
|
||||
std::string ModelBase::toJson( const std::time_t& value )
|
||||
std::string ModelBase::toJson( std::time_t const& value )
|
||||
{
|
||||
char buf[sizeof "2011-10-08T07:07:09Z"];
|
||||
strftime(buf, sizeof buf, "%FT%TZ", gmtime(&value));
|
||||
return buf;
|
||||
}
|
||||
|
||||
int32_t ModelBase::toJson( int32_t value )
|
||||
int32_t ModelBase::toJson( int32_t const value )
|
||||
{
|
||||
return value;
|
||||
}
|
||||
|
||||
int64_t ModelBase::toJson( int64_t value )
|
||||
int64_t ModelBase::toJson( int64_t const value )
|
||||
{
|
||||
return value;
|
||||
}
|
||||
|
||||
double ModelBase::toJson( double value )
|
||||
double ModelBase::toJson( double const value )
|
||||
{
|
||||
return value;
|
||||
}
|
||||
|
||||
bool ModelBase::toJson( bool value )
|
||||
bool ModelBase::toJson( bool const value )
|
||||
{
|
||||
return value;
|
||||
}
|
||||
|
||||
nlohmann::json ModelBase::toJson( std::shared_ptr<ModelBase> content )
|
||||
nlohmann::json ModelBase::toJson(ModelBase content )
|
||||
{
|
||||
return content.get() ? content->toJson() : nlohmann::json();
|
||||
return content.toJson();
|
||||
}
|
||||
|
||||
{{#modelNamespaceDeclarations}}
|
||||
|
@ -1 +1 @@
|
||||
3.0.0-SNAPSHOT
|
||||
3.0.2-SNAPSHOT
|
@ -20,24 +20,24 @@ namespace api {
|
||||
using namespace org::openapitools::server::model;
|
||||
|
||||
PetApi::PetApi(Pistache::Address addr)
|
||||
: httpEndpoint(std::make_shared<Pistache::Http::Endpoint>(addr))
|
||||
: httpEndpoint(addr)
|
||||
{ };
|
||||
|
||||
void PetApi::init(size_t thr = 2) {
|
||||
auto opts = Pistache::Http::Endpoint::options()
|
||||
.threads(thr)
|
||||
.flags(Pistache::Tcp::Options::InstallSignalHandler);
|
||||
httpEndpoint->init(opts);
|
||||
httpEndpoint.init(opts);
|
||||
setupRoutes();
|
||||
}
|
||||
|
||||
void PetApi::start() {
|
||||
httpEndpoint->setHandler(router.handler());
|
||||
httpEndpoint->serve();
|
||||
httpEndpoint.setHandler(router.handler());
|
||||
httpEndpoint.serve();
|
||||
}
|
||||
|
||||
void PetApi::shutdown() {
|
||||
httpEndpoint->shutdown();
|
||||
httpEndpoint.shutdown();
|
||||
}
|
||||
|
||||
void PetApi::setupRoutes() {
|
||||
|
@ -24,6 +24,8 @@
|
||||
#include <pistache/router.h>
|
||||
#include <pistache/http_headers.h>
|
||||
|
||||
#include <pistache/optional.h>
|
||||
|
||||
#include "ApiResponse.h"
|
||||
#include "Pet.h"
|
||||
#include <string>
|
||||
@ -58,7 +60,7 @@ private:
|
||||
void upload_file_handler(const Pistache::Rest::Request &request, Pistache::Http::ResponseWriter response);
|
||||
void pet_api_default_handler(const Pistache::Rest::Request &request, Pistache::Http::ResponseWriter response);
|
||||
|
||||
std::shared_ptr<Pistache::Http::Endpoint> httpEndpoint;
|
||||
Pistache::Http::Endpoint httpEndpoint;
|
||||
Pistache::Rest::Router router;
|
||||
|
||||
|
||||
@ -79,7 +81,7 @@ private:
|
||||
/// </remarks>
|
||||
/// <param name="petId">Pet id to delete</param>
|
||||
/// <param name="apiKey"> (optional)</param>
|
||||
virtual void delete_pet(const int64_t &petId, const Optional<Net::Http::Header::Raw> &apiKey, Pistache::Http::ResponseWriter &response) = 0;
|
||||
virtual void delete_pet(const int64_t &petId, const Pistache::Optional<Pistache::Http::Header::Raw> &apiKey, Pistache::Http::ResponseWriter &response) = 0;
|
||||
|
||||
/// <summary>
|
||||
/// Finds Pets by status
|
||||
@ -88,7 +90,7 @@ private:
|
||||
/// Multiple status values can be provided with comma separated strings
|
||||
/// </remarks>
|
||||
/// <param name="status">Status values that need to be considered for filter</param>
|
||||
virtual void find_pets_by_status(const Optional<std::string> &status, Pistache::Http::ResponseWriter &response) = 0;
|
||||
virtual void find_pets_by_status(const Pistache::Optional<std::string> &status, Pistache::Http::ResponseWriter &response) = 0;
|
||||
|
||||
/// <summary>
|
||||
/// Finds Pets by tags
|
||||
@ -97,7 +99,7 @@ private:
|
||||
/// Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.
|
||||
/// </remarks>
|
||||
/// <param name="tags">Tags to filter by</param>
|
||||
virtual void find_pets_by_tags(const Optional<std::string> &tags, Pistache::Http::ResponseWriter &response) = 0;
|
||||
virtual void find_pets_by_tags(const Pistache::Optional<std::string> &tags, Pistache::Http::ResponseWriter &response) = 0;
|
||||
|
||||
/// <summary>
|
||||
/// Find pet by ID
|
||||
|
@ -20,24 +20,24 @@ namespace api {
|
||||
using namespace org::openapitools::server::model;
|
||||
|
||||
StoreApi::StoreApi(Pistache::Address addr)
|
||||
: httpEndpoint(std::make_shared<Pistache::Http::Endpoint>(addr))
|
||||
: httpEndpoint(addr)
|
||||
{ };
|
||||
|
||||
void StoreApi::init(size_t thr = 2) {
|
||||
auto opts = Pistache::Http::Endpoint::options()
|
||||
.threads(thr)
|
||||
.flags(Pistache::Tcp::Options::InstallSignalHandler);
|
||||
httpEndpoint->init(opts);
|
||||
httpEndpoint.init(opts);
|
||||
setupRoutes();
|
||||
}
|
||||
|
||||
void StoreApi::start() {
|
||||
httpEndpoint->setHandler(router.handler());
|
||||
httpEndpoint->serve();
|
||||
httpEndpoint.setHandler(router.handler());
|
||||
httpEndpoint.serve();
|
||||
}
|
||||
|
||||
void StoreApi::shutdown() {
|
||||
httpEndpoint->shutdown();
|
||||
httpEndpoint.shutdown();
|
||||
}
|
||||
|
||||
void StoreApi::setupRoutes() {
|
||||
|
@ -24,6 +24,8 @@
|
||||
#include <pistache/router.h>
|
||||
#include <pistache/http_headers.h>
|
||||
|
||||
#include <pistache/optional.h>
|
||||
|
||||
#include "Order.h"
|
||||
#include <map>
|
||||
#include <string>
|
||||
@ -54,7 +56,7 @@ private:
|
||||
void place_order_handler(const Pistache::Rest::Request &request, Pistache::Http::ResponseWriter response);
|
||||
void store_api_default_handler(const Pistache::Rest::Request &request, Pistache::Http::ResponseWriter response);
|
||||
|
||||
std::shared_ptr<Pistache::Http::Endpoint> httpEndpoint;
|
||||
Pistache::Http::Endpoint httpEndpoint;
|
||||
Pistache::Rest::Router router;
|
||||
|
||||
|
||||
|
@ -20,24 +20,24 @@ namespace api {
|
||||
using namespace org::openapitools::server::model;
|
||||
|
||||
UserApi::UserApi(Pistache::Address addr)
|
||||
: httpEndpoint(std::make_shared<Pistache::Http::Endpoint>(addr))
|
||||
: httpEndpoint(addr)
|
||||
{ };
|
||||
|
||||
void UserApi::init(size_t thr = 2) {
|
||||
auto opts = Pistache::Http::Endpoint::options()
|
||||
.threads(thr)
|
||||
.flags(Pistache::Tcp::Options::InstallSignalHandler);
|
||||
httpEndpoint->init(opts);
|
||||
httpEndpoint.init(opts);
|
||||
setupRoutes();
|
||||
}
|
||||
|
||||
void UserApi::start() {
|
||||
httpEndpoint->setHandler(router.handler());
|
||||
httpEndpoint->serve();
|
||||
httpEndpoint.setHandler(router.handler());
|
||||
httpEndpoint.serve();
|
||||
}
|
||||
|
||||
void UserApi::shutdown() {
|
||||
httpEndpoint->shutdown();
|
||||
httpEndpoint.shutdown();
|
||||
}
|
||||
|
||||
void UserApi::setupRoutes() {
|
||||
|
@ -24,6 +24,8 @@
|
||||
#include <pistache/router.h>
|
||||
#include <pistache/http_headers.h>
|
||||
|
||||
#include <pistache/optional.h>
|
||||
|
||||
#include "User.h"
|
||||
#include <string>
|
||||
#include <vector>
|
||||
@ -58,7 +60,7 @@ private:
|
||||
void update_user_handler(const Pistache::Rest::Request &request, Pistache::Http::ResponseWriter response);
|
||||
void user_api_default_handler(const Pistache::Rest::Request &request, Pistache::Http::ResponseWriter response);
|
||||
|
||||
std::shared_ptr<Pistache::Http::Endpoint> httpEndpoint;
|
||||
Pistache::Http::Endpoint httpEndpoint;
|
||||
Pistache::Rest::Router router;
|
||||
|
||||
|
||||
@ -78,7 +80,7 @@ private:
|
||||
///
|
||||
/// </remarks>
|
||||
/// <param name="user">List of user object</param>
|
||||
virtual void create_users_with_array_input(const std::vector<std::shared_ptr<User>> &user, Pistache::Http::ResponseWriter &response) = 0;
|
||||
virtual void create_users_with_array_input(const std::vector<User> &user, Pistache::Http::ResponseWriter &response) = 0;
|
||||
|
||||
/// <summary>
|
||||
/// Creates list of users with given input array
|
||||
@ -87,7 +89,7 @@ private:
|
||||
///
|
||||
/// </remarks>
|
||||
/// <param name="user">List of user object</param>
|
||||
virtual void create_users_with_list_input(const std::vector<std::shared_ptr<User>> &user, Pistache::Http::ResponseWriter &response) = 0;
|
||||
virtual void create_users_with_list_input(const std::vector<User> &user, Pistache::Http::ResponseWriter &response) = 0;
|
||||
|
||||
/// <summary>
|
||||
/// Delete user
|
||||
@ -115,7 +117,7 @@ private:
|
||||
/// </remarks>
|
||||
/// <param name="username">The user name for login</param>
|
||||
/// <param name="password">The password for login in clear text</param>
|
||||
virtual void login_user(const Optional<std::string> &username, const Optional<std::string> &password, Pistache::Http::ResponseWriter &response) = 0;
|
||||
virtual void login_user(const Pistache::Optional<std::string> &username, const Pistache::Optional<std::string> &password, Pistache::Http::ResponseWriter &response) = 0;
|
||||
|
||||
/// <summary>
|
||||
/// Logs out current logged in user session
|
||||
|
@ -26,13 +26,13 @@ PetApiImpl::PetApiImpl(Pistache::Address addr)
|
||||
void PetApiImpl::add_pet(const std::shared_ptr<Pet> &pet, Pistache::Http::ResponseWriter &response) {
|
||||
response.send(Pistache::Http::Code::Ok, "Do some magic\n");
|
||||
}
|
||||
void PetApiImpl::delete_pet(const int64_t &petId, const Optional<Net::Http::Header::Raw> &apiKey, Pistache::Http::ResponseWriter &response) {
|
||||
void PetApiImpl::delete_pet(const int64_t &petId, const Pistache::Optional<Pistache::Http::Header::Raw> &apiKey, Pistache::Http::ResponseWriter &response) {
|
||||
response.send(Pistache::Http::Code::Ok, "Do some magic\n");
|
||||
}
|
||||
void PetApiImpl::find_pets_by_status(const Optional<std::string> &status, Pistache::Http::ResponseWriter &response) {
|
||||
void PetApiImpl::find_pets_by_status(const Pistache::Optional<std::string> &status, Pistache::Http::ResponseWriter &response) {
|
||||
response.send(Pistache::Http::Code::Ok, "Do some magic\n");
|
||||
}
|
||||
void PetApiImpl::find_pets_by_tags(const Optional<std::string> &tags, Pistache::Http::ResponseWriter &response) {
|
||||
void PetApiImpl::find_pets_by_tags(const Pistache::Optional<std::string> &tags, Pistache::Http::ResponseWriter &response) {
|
||||
response.send(Pistache::Http::Code::Ok, "Do some magic\n");
|
||||
}
|
||||
void PetApiImpl::get_pet_by_id(const int64_t &petId, Pistache::Http::ResponseWriter &response) {
|
||||
|
@ -27,6 +27,8 @@
|
||||
|
||||
#include <PetApi.h>
|
||||
|
||||
#include <pistache/optional.h>
|
||||
|
||||
#include "ApiResponse.h"
|
||||
#include "Pet.h"
|
||||
#include <string>
|
||||
@ -44,9 +46,9 @@ public:
|
||||
~PetApiImpl() { };
|
||||
|
||||
void add_pet(const std::shared_ptr<Pet> &pet, Pistache::Http::ResponseWriter &response);
|
||||
void delete_pet(const int64_t &petId, const Optional<Net::Http::Header::Raw> &apiKey, Pistache::Http::ResponseWriter &response);
|
||||
void find_pets_by_status(const Optional<std::string> &status, Pistache::Http::ResponseWriter &response);
|
||||
void find_pets_by_tags(const Optional<std::string> &tags, Pistache::Http::ResponseWriter &response);
|
||||
void delete_pet(const int64_t &petId, const Pistache::Optional<Pistache::Http::Header::Raw> &apiKey, Pistache::Http::ResponseWriter &response);
|
||||
void find_pets_by_status(const Pistache::Optional<std::string> &status, Pistache::Http::ResponseWriter &response);
|
||||
void find_pets_by_tags(const Pistache::Optional<std::string> &tags, Pistache::Http::ResponseWriter &response);
|
||||
void get_pet_by_id(const int64_t &petId, Pistache::Http::ResponseWriter &response);
|
||||
void update_pet(const std::shared_ptr<Pet> &pet, Pistache::Http::ResponseWriter &response);
|
||||
void update_pet_with_form(const Pistache::Rest::Request &request, Pistache::Http::ResponseWriter &response);
|
||||
|
@ -27,6 +27,8 @@
|
||||
|
||||
#include <StoreApi.h>
|
||||
|
||||
#include <pistache/optional.h>
|
||||
|
||||
#include "Order.h"
|
||||
#include <map>
|
||||
#include <string>
|
||||
|
@ -26,10 +26,10 @@ UserApiImpl::UserApiImpl(Pistache::Address addr)
|
||||
void UserApiImpl::create_user(const std::shared_ptr<User> &user, Pistache::Http::ResponseWriter &response) {
|
||||
response.send(Pistache::Http::Code::Ok, "Do some magic\n");
|
||||
}
|
||||
void UserApiImpl::create_users_with_array_input(const std::vector<std::shared_ptr<User>> &user, Pistache::Http::ResponseWriter &response) {
|
||||
void UserApiImpl::create_users_with_array_input(const std::vector<User> &user, Pistache::Http::ResponseWriter &response) {
|
||||
response.send(Pistache::Http::Code::Ok, "Do some magic\n");
|
||||
}
|
||||
void UserApiImpl::create_users_with_list_input(const std::vector<std::shared_ptr<User>> &user, Pistache::Http::ResponseWriter &response) {
|
||||
void UserApiImpl::create_users_with_list_input(const std::vector<User> &user, Pistache::Http::ResponseWriter &response) {
|
||||
response.send(Pistache::Http::Code::Ok, "Do some magic\n");
|
||||
}
|
||||
void UserApiImpl::delete_user(const std::string &username, Pistache::Http::ResponseWriter &response) {
|
||||
@ -38,7 +38,7 @@ void UserApiImpl::delete_user(const std::string &username, Pistache::Http::Respo
|
||||
void UserApiImpl::get_user_by_name(const std::string &username, Pistache::Http::ResponseWriter &response) {
|
||||
response.send(Pistache::Http::Code::Ok, "Do some magic\n");
|
||||
}
|
||||
void UserApiImpl::login_user(const Optional<std::string> &username, const Optional<std::string> &password, Pistache::Http::ResponseWriter &response) {
|
||||
void UserApiImpl::login_user(const Pistache::Optional<std::string> &username, const Pistache::Optional<std::string> &password, Pistache::Http::ResponseWriter &response) {
|
||||
response.send(Pistache::Http::Code::Ok, "Do some magic\n");
|
||||
}
|
||||
void UserApiImpl::logout_user(Pistache::Http::ResponseWriter &response) {
|
||||
|
@ -27,6 +27,8 @@
|
||||
|
||||
#include <UserApi.h>
|
||||
|
||||
#include <pistache/optional.h>
|
||||
|
||||
#include "User.h"
|
||||
#include <string>
|
||||
#include <vector>
|
||||
@ -44,11 +46,11 @@ public:
|
||||
~UserApiImpl() { };
|
||||
|
||||
void create_user(const std::shared_ptr<User> &user, Pistache::Http::ResponseWriter &response);
|
||||
void create_users_with_array_input(const std::vector<std::shared_ptr<User>> &user, Pistache::Http::ResponseWriter &response);
|
||||
void create_users_with_list_input(const std::vector<std::shared_ptr<User>> &user, Pistache::Http::ResponseWriter &response);
|
||||
void create_users_with_array_input(const std::vector<User> &user, Pistache::Http::ResponseWriter &response);
|
||||
void create_users_with_list_input(const std::vector<User> &user, Pistache::Http::ResponseWriter &response);
|
||||
void delete_user(const std::string &username, Pistache::Http::ResponseWriter &response);
|
||||
void get_user_by_name(const std::string &username, Pistache::Http::ResponseWriter &response);
|
||||
void login_user(const Optional<std::string> &username, const Optional<std::string> &password, Pistache::Http::ResponseWriter &response);
|
||||
void login_user(const Pistache::Optional<std::string> &username, const Pistache::Optional<std::string> &password, Pistache::Http::ResponseWriter &response);
|
||||
void logout_user(Pistache::Http::ResponseWriter &response);
|
||||
void update_user(const std::string &username, const std::shared_ptr<User> &user, Pistache::Http::ResponseWriter &response);
|
||||
|
||||
|
@ -83,7 +83,7 @@ int32_t ApiResponse::getCode() const
|
||||
{
|
||||
return m_Code;
|
||||
}
|
||||
void ApiResponse::setCode(int32_t value)
|
||||
void ApiResponse::setCode(int32_t const value)
|
||||
{
|
||||
m_Code = value;
|
||||
m_CodeIsSet = true;
|
||||
@ -100,7 +100,7 @@ std::string ApiResponse::getType() const
|
||||
{
|
||||
return m_Type;
|
||||
}
|
||||
void ApiResponse::setType(std::string value)
|
||||
void ApiResponse::setType(std::string const& value)
|
||||
{
|
||||
m_Type = value;
|
||||
m_TypeIsSet = true;
|
||||
@ -117,7 +117,7 @@ std::string ApiResponse::getMessage() const
|
||||
{
|
||||
return m_Message;
|
||||
}
|
||||
void ApiResponse::setMessage(std::string value)
|
||||
void ApiResponse::setMessage(std::string const& value)
|
||||
{
|
||||
m_Message = value;
|
||||
m_MessageIsSet = true;
|
||||
|
@ -53,21 +53,21 @@ public:
|
||||
///
|
||||
/// </summary>
|
||||
int32_t getCode() const;
|
||||
void setCode(int32_t value);
|
||||
void setCode(int32_t const value);
|
||||
bool codeIsSet() const;
|
||||
void unsetCode();
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
std::string getType() const;
|
||||
void setType(std::string value);
|
||||
void setType(std::string const& value);
|
||||
bool typeIsSet() const;
|
||||
void unsetType();
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
std::string getMessage() const;
|
||||
void setMessage(std::string value);
|
||||
void setMessage(std::string const& value);
|
||||
bool messageIsSet() const;
|
||||
void unsetMessage();
|
||||
|
||||
|
@ -72,7 +72,7 @@ int64_t Category::getId() const
|
||||
{
|
||||
return m_Id;
|
||||
}
|
||||
void Category::setId(int64_t value)
|
||||
void Category::setId(int64_t const value)
|
||||
{
|
||||
m_Id = value;
|
||||
m_IdIsSet = true;
|
||||
@ -89,7 +89,7 @@ std::string Category::getName() const
|
||||
{
|
||||
return m_Name;
|
||||
}
|
||||
void Category::setName(std::string value)
|
||||
void Category::setName(std::string const& value)
|
||||
{
|
||||
m_Name = value;
|
||||
m_NameIsSet = true;
|
||||
|
@ -53,14 +53,14 @@ public:
|
||||
///
|
||||
/// </summary>
|
||||
int64_t getId() const;
|
||||
void setId(int64_t value);
|
||||
void setId(int64_t const value);
|
||||
bool idIsSet() const;
|
||||
void unsetId();
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
std::string getName() const;
|
||||
void setName(std::string value);
|
||||
void setName(std::string const& value);
|
||||
bool nameIsSet() const;
|
||||
void unsetName();
|
||||
|
||||
|
@ -23,41 +23,41 @@ ModelBase::~ModelBase()
|
||||
{
|
||||
}
|
||||
|
||||
std::string ModelBase::toJson( const std::string& value )
|
||||
std::string ModelBase::toJson( std::string const& value )
|
||||
{
|
||||
return value;
|
||||
}
|
||||
|
||||
std::string ModelBase::toJson( const std::time_t& value )
|
||||
std::string ModelBase::toJson( std::time_t const& value )
|
||||
{
|
||||
char buf[sizeof "2011-10-08T07:07:09Z"];
|
||||
strftime(buf, sizeof buf, "%FT%TZ", gmtime(&value));
|
||||
return buf;
|
||||
}
|
||||
|
||||
int32_t ModelBase::toJson( int32_t value )
|
||||
int32_t ModelBase::toJson( int32_t const value )
|
||||
{
|
||||
return value;
|
||||
}
|
||||
|
||||
int64_t ModelBase::toJson( int64_t value )
|
||||
int64_t ModelBase::toJson( int64_t const value )
|
||||
{
|
||||
return value;
|
||||
}
|
||||
|
||||
double ModelBase::toJson( double value )
|
||||
double ModelBase::toJson( double const value )
|
||||
{
|
||||
return value;
|
||||
}
|
||||
|
||||
bool ModelBase::toJson( bool value )
|
||||
bool ModelBase::toJson( bool const value )
|
||||
{
|
||||
return value;
|
||||
}
|
||||
|
||||
nlohmann::json ModelBase::toJson( std::shared_ptr<ModelBase> content )
|
||||
nlohmann::json ModelBase::toJson(ModelBase content )
|
||||
{
|
||||
return content.get() ? content->toJson() : nlohmann::json();
|
||||
return content.toJson();
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -39,13 +39,13 @@ public:
|
||||
virtual nlohmann::json toJson() const = 0;
|
||||
virtual void fromJson(nlohmann::json& json) = 0;
|
||||
|
||||
static std::string toJson( const std::string& value );
|
||||
static std::string toJson( const std::time_t& value );
|
||||
static int32_t toJson( int32_t value );
|
||||
static int64_t toJson( int64_t value );
|
||||
static double toJson( double value );
|
||||
static bool toJson( bool value );
|
||||
static nlohmann::json toJson( std::shared_ptr<ModelBase> content );
|
||||
static std::string toJson( std::string const& value );
|
||||
static std::string toJson( std::time_t const& value );
|
||||
static int32_t toJson( int32_t const value );
|
||||
static int64_t toJson( int64_t const value );
|
||||
static double toJson( double const value );
|
||||
static bool toJson( bool const value );
|
||||
static nlohmann::json toJson(ModelBase const& content );
|
||||
|
||||
};
|
||||
|
||||
|
@ -113,7 +113,7 @@ int64_t Order::getId() const
|
||||
{
|
||||
return m_Id;
|
||||
}
|
||||
void Order::setId(int64_t value)
|
||||
void Order::setId(int64_t const value)
|
||||
{
|
||||
m_Id = value;
|
||||
m_IdIsSet = true;
|
||||
@ -130,7 +130,7 @@ int64_t Order::getPetId() const
|
||||
{
|
||||
return m_PetId;
|
||||
}
|
||||
void Order::setPetId(int64_t value)
|
||||
void Order::setPetId(int64_t const value)
|
||||
{
|
||||
m_PetId = value;
|
||||
m_PetIdIsSet = true;
|
||||
@ -147,7 +147,7 @@ int32_t Order::getQuantity() const
|
||||
{
|
||||
return m_Quantity;
|
||||
}
|
||||
void Order::setQuantity(int32_t value)
|
||||
void Order::setQuantity(int32_t const value)
|
||||
{
|
||||
m_Quantity = value;
|
||||
m_QuantityIsSet = true;
|
||||
@ -164,7 +164,7 @@ std::string Order::getShipDate() const
|
||||
{
|
||||
return m_ShipDate;
|
||||
}
|
||||
void Order::setShipDate(std::string value)
|
||||
void Order::setShipDate(std::string const& value)
|
||||
{
|
||||
m_ShipDate = value;
|
||||
m_ShipDateIsSet = true;
|
||||
@ -181,7 +181,7 @@ std::string Order::getStatus() const
|
||||
{
|
||||
return m_Status;
|
||||
}
|
||||
void Order::setStatus(std::string value)
|
||||
void Order::setStatus(std::string const& value)
|
||||
{
|
||||
m_Status = value;
|
||||
m_StatusIsSet = true;
|
||||
@ -198,7 +198,7 @@ bool Order::isComplete() const
|
||||
{
|
||||
return m_Complete;
|
||||
}
|
||||
void Order::setComplete(bool value)
|
||||
void Order::setComplete(bool const value)
|
||||
{
|
||||
m_Complete = value;
|
||||
m_CompleteIsSet = true;
|
||||
|
@ -53,42 +53,42 @@ public:
|
||||
///
|
||||
/// </summary>
|
||||
int64_t getId() const;
|
||||
void setId(int64_t value);
|
||||
void setId(int64_t const value);
|
||||
bool idIsSet() const;
|
||||
void unsetId();
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
int64_t getPetId() const;
|
||||
void setPetId(int64_t value);
|
||||
void setPetId(int64_t const value);
|
||||
bool petIdIsSet() const;
|
||||
void unsetPetId();
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
int32_t getQuantity() const;
|
||||
void setQuantity(int32_t value);
|
||||
void setQuantity(int32_t const value);
|
||||
bool quantityIsSet() const;
|
||||
void unsetQuantity();
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
std::string getShipDate() const;
|
||||
void setShipDate(std::string value);
|
||||
void setShipDate(std::string const& value);
|
||||
bool shipDateIsSet() const;
|
||||
void unsetShipDate();
|
||||
/// <summary>
|
||||
/// Order Status
|
||||
/// </summary>
|
||||
std::string getStatus() const;
|
||||
void setStatus(std::string value);
|
||||
void setStatus(std::string const& value);
|
||||
bool statusIsSet() const;
|
||||
void unsetStatus();
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
bool isComplete() const;
|
||||
void setComplete(bool value);
|
||||
void setComplete(bool const value);
|
||||
bool completeIsSet() const;
|
||||
void unsetComplete();
|
||||
|
||||
|
@ -91,8 +91,8 @@ void Pet::fromJson(nlohmann::json& val)
|
||||
{
|
||||
if(!val["category"].is_null())
|
||||
{
|
||||
std::shared_ptr<Category> newItem(new Category());
|
||||
newItem->fromJson(val["category"]);
|
||||
Category newItem(Category());
|
||||
newItem.fromJson(val["category"]);
|
||||
setCategory( newItem );
|
||||
}
|
||||
|
||||
@ -117,12 +117,12 @@ void Pet::fromJson(nlohmann::json& val)
|
||||
|
||||
if(item.is_null())
|
||||
{
|
||||
m_Tags.push_back( std::shared_ptr<Tag>(nullptr) );
|
||||
m_Tags.push_back( Tag(nullptr) );
|
||||
}
|
||||
else
|
||||
{
|
||||
std::shared_ptr<Tag> newItem(new Tag());
|
||||
newItem->fromJson(item);
|
||||
Tag newItem(Tag());
|
||||
newItem.fromJson(item);
|
||||
m_Tags.push_back( newItem );
|
||||
}
|
||||
|
||||
@ -142,7 +142,7 @@ int64_t Pet::getId() const
|
||||
{
|
||||
return m_Id;
|
||||
}
|
||||
void Pet::setId(int64_t value)
|
||||
void Pet::setId(int64_t const value)
|
||||
{
|
||||
m_Id = value;
|
||||
m_IdIsSet = true;
|
||||
@ -155,11 +155,11 @@ void Pet::unsetId()
|
||||
{
|
||||
m_IdIsSet = false;
|
||||
}
|
||||
std::shared_ptr<Category> Pet::getCategory() const
|
||||
Category Pet::getCategory() const
|
||||
{
|
||||
return m_Category;
|
||||
}
|
||||
void Pet::setCategory(std::shared_ptr<Category> value)
|
||||
void Pet::setCategory(Category const& value)
|
||||
{
|
||||
m_Category = value;
|
||||
m_CategoryIsSet = true;
|
||||
@ -176,7 +176,7 @@ std::string Pet::getName() const
|
||||
{
|
||||
return m_Name;
|
||||
}
|
||||
void Pet::setName(std::string value)
|
||||
void Pet::setName(std::string const& value)
|
||||
{
|
||||
m_Name = value;
|
||||
|
||||
@ -185,7 +185,7 @@ std::vector<std::string>& Pet::getPhotoUrls()
|
||||
{
|
||||
return m_PhotoUrls;
|
||||
}
|
||||
std::vector<std::shared_ptr<Tag>>& Pet::getTags()
|
||||
std::vector<Tag>& Pet::getTags()
|
||||
{
|
||||
return m_Tags;
|
||||
}
|
||||
@ -201,7 +201,7 @@ std::string Pet::getStatus() const
|
||||
{
|
||||
return m_Status;
|
||||
}
|
||||
void Pet::setStatus(std::string value)
|
||||
void Pet::setStatus(std::string const& value)
|
||||
{
|
||||
m_Status = value;
|
||||
m_StatusIsSet = true;
|
||||
|
@ -56,21 +56,21 @@ public:
|
||||
///
|
||||
/// </summary>
|
||||
int64_t getId() const;
|
||||
void setId(int64_t value);
|
||||
void setId(int64_t const value);
|
||||
bool idIsSet() const;
|
||||
void unsetId();
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
std::shared_ptr<Category> getCategory() const;
|
||||
void setCategory(std::shared_ptr<Category> value);
|
||||
Category getCategory() const;
|
||||
void setCategory(Category const& value);
|
||||
bool categoryIsSet() const;
|
||||
void unsetCategory();
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
std::string getName() const;
|
||||
void setName(std::string value);
|
||||
void setName(std::string const& value);
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
@ -78,27 +78,27 @@ public:
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
std::vector<std::shared_ptr<Tag>>& getTags();
|
||||
std::vector<Tag>& getTags();
|
||||
bool tagsIsSet() const;
|
||||
void unsetTags();
|
||||
/// <summary>
|
||||
/// pet status in the store
|
||||
/// </summary>
|
||||
std::string getStatus() const;
|
||||
void setStatus(std::string value);
|
||||
void setStatus(std::string const& value);
|
||||
bool statusIsSet() const;
|
||||
void unsetStatus();
|
||||
|
||||
protected:
|
||||
int64_t m_Id;
|
||||
bool m_IdIsSet;
|
||||
std::shared_ptr<Category> m_Category;
|
||||
Category m_Category;
|
||||
bool m_CategoryIsSet;
|
||||
std::string m_Name;
|
||||
|
||||
std::vector<std::string> m_PhotoUrls;
|
||||
|
||||
std::vector<std::shared_ptr<Tag>> m_Tags;
|
||||
std::vector<Tag> m_Tags;
|
||||
bool m_TagsIsSet;
|
||||
std::string m_Status;
|
||||
bool m_StatusIsSet;
|
||||
|
@ -72,7 +72,7 @@ int64_t Tag::getId() const
|
||||
{
|
||||
return m_Id;
|
||||
}
|
||||
void Tag::setId(int64_t value)
|
||||
void Tag::setId(int64_t const value)
|
||||
{
|
||||
m_Id = value;
|
||||
m_IdIsSet = true;
|
||||
@ -89,7 +89,7 @@ std::string Tag::getName() const
|
||||
{
|
||||
return m_Name;
|
||||
}
|
||||
void Tag::setName(std::string value)
|
||||
void Tag::setName(std::string const& value)
|
||||
{
|
||||
m_Name = value;
|
||||
m_NameIsSet = true;
|
||||
|
@ -53,14 +53,14 @@ public:
|
||||
///
|
||||
/// </summary>
|
||||
int64_t getId() const;
|
||||
void setId(int64_t value);
|
||||
void setId(int64_t const value);
|
||||
bool idIsSet() const;
|
||||
void unsetId();
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
std::string getName() const;
|
||||
void setName(std::string value);
|
||||
void setName(std::string const& value);
|
||||
bool nameIsSet() const;
|
||||
void unsetName();
|
||||
|
||||
|
@ -137,7 +137,7 @@ int64_t User::getId() const
|
||||
{
|
||||
return m_Id;
|
||||
}
|
||||
void User::setId(int64_t value)
|
||||
void User::setId(int64_t const value)
|
||||
{
|
||||
m_Id = value;
|
||||
m_IdIsSet = true;
|
||||
@ -154,7 +154,7 @@ std::string User::getUsername() const
|
||||
{
|
||||
return m_Username;
|
||||
}
|
||||
void User::setUsername(std::string value)
|
||||
void User::setUsername(std::string const& value)
|
||||
{
|
||||
m_Username = value;
|
||||
m_UsernameIsSet = true;
|
||||
@ -171,7 +171,7 @@ std::string User::getFirstName() const
|
||||
{
|
||||
return m_FirstName;
|
||||
}
|
||||
void User::setFirstName(std::string value)
|
||||
void User::setFirstName(std::string const& value)
|
||||
{
|
||||
m_FirstName = value;
|
||||
m_FirstNameIsSet = true;
|
||||
@ -188,7 +188,7 @@ std::string User::getLastName() const
|
||||
{
|
||||
return m_LastName;
|
||||
}
|
||||
void User::setLastName(std::string value)
|
||||
void User::setLastName(std::string const& value)
|
||||
{
|
||||
m_LastName = value;
|
||||
m_LastNameIsSet = true;
|
||||
@ -205,7 +205,7 @@ std::string User::getEmail() const
|
||||
{
|
||||
return m_Email;
|
||||
}
|
||||
void User::setEmail(std::string value)
|
||||
void User::setEmail(std::string const& value)
|
||||
{
|
||||
m_Email = value;
|
||||
m_EmailIsSet = true;
|
||||
@ -222,7 +222,7 @@ std::string User::getPassword() const
|
||||
{
|
||||
return m_Password;
|
||||
}
|
||||
void User::setPassword(std::string value)
|
||||
void User::setPassword(std::string const& value)
|
||||
{
|
||||
m_Password = value;
|
||||
m_PasswordIsSet = true;
|
||||
@ -239,7 +239,7 @@ std::string User::getPhone() const
|
||||
{
|
||||
return m_Phone;
|
||||
}
|
||||
void User::setPhone(std::string value)
|
||||
void User::setPhone(std::string const& value)
|
||||
{
|
||||
m_Phone = value;
|
||||
m_PhoneIsSet = true;
|
||||
@ -256,7 +256,7 @@ int32_t User::getUserStatus() const
|
||||
{
|
||||
return m_UserStatus;
|
||||
}
|
||||
void User::setUserStatus(int32_t value)
|
||||
void User::setUserStatus(int32_t const value)
|
||||
{
|
||||
m_UserStatus = value;
|
||||
m_UserStatusIsSet = true;
|
||||
|
@ -53,56 +53,56 @@ public:
|
||||
///
|
||||
/// </summary>
|
||||
int64_t getId() const;
|
||||
void setId(int64_t value);
|
||||
void setId(int64_t const value);
|
||||
bool idIsSet() const;
|
||||
void unsetId();
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
std::string getUsername() const;
|
||||
void setUsername(std::string value);
|
||||
void setUsername(std::string const& value);
|
||||
bool usernameIsSet() const;
|
||||
void unsetUsername();
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
std::string getFirstName() const;
|
||||
void setFirstName(std::string value);
|
||||
void setFirstName(std::string const& value);
|
||||
bool firstNameIsSet() const;
|
||||
void unsetFirstName();
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
std::string getLastName() const;
|
||||
void setLastName(std::string value);
|
||||
void setLastName(std::string const& value);
|
||||
bool lastNameIsSet() const;
|
||||
void unsetLastName();
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
std::string getEmail() const;
|
||||
void setEmail(std::string value);
|
||||
void setEmail(std::string const& value);
|
||||
bool emailIsSet() const;
|
||||
void unsetEmail();
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
std::string getPassword() const;
|
||||
void setPassword(std::string value);
|
||||
void setPassword(std::string const& value);
|
||||
bool passwordIsSet() const;
|
||||
void unsetPassword();
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
std::string getPhone() const;
|
||||
void setPhone(std::string value);
|
||||
void setPhone(std::string const& value);
|
||||
bool phoneIsSet() const;
|
||||
void unsetPhone();
|
||||
/// <summary>
|
||||
/// User Status
|
||||
/// </summary>
|
||||
int32_t getUserStatus() const;
|
||||
void setUserStatus(int32_t value);
|
||||
void setUserStatus(int32_t const value);
|
||||
bool userStatusIsSet() const;
|
||||
void unsetUserStatus();
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user