Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,8 @@ void {{classname}}::{{setter}}({{{dataType}}} value)
{
{{#isEnum}}if (std::find(m_{{enumName}}.begin(), m_{{enumName}}.end(), value) != m_{{enumName}}.end()) {
{{/isEnum}}m_{{name}} = value;{{#isEnum}}
} else {
throw std::runtime_error("Value " + value + " not allowed");
}{{/isEnum}}
}
{{/vars}}
Expand Down
37 changes: 20 additions & 17 deletions samples/server/petstore/cpp-restbed/api/PetApi.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,23 +38,6 @@ namespace api {

using namespace org::openapitools::server::model;

class PetApi: public restbed::Service
{
public:
PetApi();
~PetApi();
void startService(int const& port);
void stopService();

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;
};


/// <summary>
/// Add a new pet to the store
/// </summary>
Expand Down Expand Up @@ -222,6 +205,26 @@ class PetApiPetPetIdUploadImageResource: public restbed::Resource
};


//
// The restbed service to actually implement the REST server
//
class PetApi: public restbed::Service
{
public:
PetApi();
~PetApi();
void startService(int const& port);
void stopService();

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;
};


}
}
}
Expand Down
33 changes: 18 additions & 15 deletions samples/server/petstore/cpp-restbed/api/StoreApi.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,21 +38,6 @@ namespace api {

using namespace org::openapitools::server::model;

class StoreApi: public restbed::Service
{
public:
StoreApi();
~StoreApi();
void startService(int const& port);
void stopService();

protected:
std::shared_ptr<StoreApiStoreOrderOrderIdResource> m_spStoreApiStoreOrderOrderIdResource;
std::shared_ptr<StoreApiStoreInventoryResource> m_spStoreApiStoreInventoryResource;
std::shared_ptr<StoreApiStoreOrderResource> m_spStoreApiStoreOrderResource;
};


/// <summary>
/// Delete purchase order by ID
/// </summary>
Expand Down Expand Up @@ -149,6 +134,24 @@ class StoreApiStoreOrderResource: public restbed::Resource
};


//
// The restbed service to actually implement the REST server
//
class StoreApi: public restbed::Service
{
public:
StoreApi();
~StoreApi();
void startService(int const& port);
void stopService();

protected:
std::shared_ptr<StoreApiStoreOrderOrderIdResource> m_spStoreApiStoreOrderOrderIdResource;
std::shared_ptr<StoreApiStoreInventoryResource> m_spStoreApiStoreInventoryResource;
std::shared_ptr<StoreApiStoreOrderResource> m_spStoreApiStoreOrderResource;
};


}
}
}
Expand Down
39 changes: 21 additions & 18 deletions samples/server/petstore/cpp-restbed/api/UserApi.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,24 +38,6 @@ namespace api {

using namespace org::openapitools::server::model;

class UserApi: public restbed::Service
{
public:
UserApi();
~UserApi();
void startService(int const& port);
void stopService();

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;
};


/// <summary>
/// Create user
/// </summary>
Expand Down Expand Up @@ -240,6 +222,27 @@ class UserApiUserLogoutResource: public restbed::Resource
};


//
// The restbed service to actually implement the REST server
//
class UserApi: public restbed::Service
{
public:
UserApi();
~UserApi();
void startService(int const& port);
void stopService();

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;
};


}
}
}
Expand Down
2 changes: 2 additions & 0 deletions samples/server/petstore/cpp-restbed/model/Order.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,8 @@ void Order::setStatus(std::string value)
{
if (std::find(m_StatusEnum.begin(), m_StatusEnum.end(), value) != m_StatusEnum.end()) {
m_Status = value;
} else {
throw std::runtime_error("Value " + value + " not allowed");
}
}
bool Order::isComplete() const
Expand Down
2 changes: 2 additions & 0 deletions samples/server/petstore/cpp-restbed/model/Pet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,8 @@ void Pet::setStatus(std::string value)
{
if (std::find(m_StatusEnum.begin(), m_StatusEnum.end(), value) != m_StatusEnum.end()) {
m_Status = value;
} else {
throw std::runtime_error("Value " + value + " not allowed");
}
}

Expand Down