forked from loafle/openapi-generator-original
[C++][Restbed] Add handler callback methods (#2911)
* [C++][Restbed] Add handler callback methods * [C++][Restbed] Update Petstore sample
This commit is contained in:
committed by
Stefan Krismann
parent
aae97638a9
commit
87adba9c4b
+27
@@ -10,6 +10,8 @@
|
||||
|
||||
{{{defaultInclude}}}
|
||||
#include <memory>
|
||||
#include <utility>
|
||||
|
||||
#include <corvusoft/restbed/session.hpp>
|
||||
#include <corvusoft/restbed/resource.hpp>
|
||||
#include <corvusoft/restbed/service.hpp>
|
||||
@@ -49,6 +51,31 @@ public:
|
||||
{{#vendorExtensions.x-codegen-otherMethods}}
|
||||
void {{httpMethod}}_method_handler(const std::shared_ptr<restbed::Session> session);
|
||||
{{/vendorExtensions.x-codegen-otherMethods}}
|
||||
|
||||
void set_handler_{{httpMethod}}(
|
||||
std::function<std::pair<int, std::string>(
|
||||
{{#allParams}}{{{dataType}}} const &{{#hasMore}}, {{/hasMore}}{{/allParams}}
|
||||
)> handler
|
||||
);
|
||||
|
||||
{{#vendorExtensions.x-codegen-otherMethods}}
|
||||
void set_handler_{{httpMethod}}(
|
||||
std::function<std::pair<int, std::string>(
|
||||
{{#allParams}}{{{dataType}}} const &{{#hasMore}}, {{/hasMore}}{{/allParams}}
|
||||
)> handler
|
||||
);
|
||||
{{/vendorExtensions.x-codegen-otherMethods}}
|
||||
|
||||
private:
|
||||
std::function<std::pair<int, std::string>(
|
||||
{{#allParams}}{{{dataType}}} const &{{#hasMore}}, {{/hasMore}}{{/allParams}}
|
||||
)> handler_{{httpMethod}}_;
|
||||
|
||||
{{#vendorExtensions.x-codegen-otherMethods}}
|
||||
std::function<std::pair<int, std::string>(
|
||||
{{#allParams}}{{{dataType}}} const &{{#hasMore}}, {{/hasMore}}{{/allParams}}
|
||||
)> handler_{{httpMethod}}_;
|
||||
{{/vendorExtensions.x-codegen-otherMethods}}
|
||||
};
|
||||
|
||||
{{/operation}}
|
||||
|
||||
+44
-20
@@ -54,6 +54,22 @@ void {{classname}}::stopService() {
|
||||
{
|
||||
}
|
||||
|
||||
void {{classname}}{{vendorExtensions.x-codegen-resourceName}}Resource::set_handler_{{httpMethod}}(
|
||||
std::function<std::pair<int, std::string>(
|
||||
{{#allParams}}{{{dataType}}} const &{{#hasMore}}, {{/hasMore}}{{/allParams}}
|
||||
)> handler) {
|
||||
handler_{{httpMethod}}_ = std::move(handler);
|
||||
}
|
||||
|
||||
{{#vendorExtensions.x-codegen-otherMethods}}
|
||||
void {{classname}}{{vendorExtensions.x-codegen-resourceName}}Resource::set_handler_{{httpMethod}}(
|
||||
std::function<std::pair<int, std::string>(
|
||||
{{#allParams}}{{{dataType}}} const &{{#hasMore}}, {{/hasMore}}{{/allParams}}
|
||||
)> handler) {
|
||||
handler_{{httpMethod}}_ = std::move(handler);
|
||||
}
|
||||
{{/vendorExtensions.x-codegen-otherMethods}}
|
||||
|
||||
void {{classname}}{{vendorExtensions.x-codegen-resourceName}}Resource::{{httpMethod}}_method_handler(const std::shared_ptr<restbed::Session> session) {
|
||||
|
||||
const auto request = session->get_request();
|
||||
@@ -65,12 +81,12 @@ void {{classname}}{{vendorExtensions.x-codegen-resourceName}}Resource::{{httpMet
|
||||
{
|
||||
|
||||
const auto request = session->get_request();
|
||||
std::string requestBody = restbed::String::format("%.*s\n", ( int ) body.size( ), body.data( ));
|
||||
std::string file = restbed::String::format("%.*s\n", ( int ) body.size( ), body.data( ));
|
||||
/**
|
||||
* Get body params or form params here from the requestBody string
|
||||
* Get body params or form params here from the file string
|
||||
*/
|
||||
{{/hasBodyParam}}
|
||||
|
||||
|
||||
{{#hasPathParams}}
|
||||
// Getting the path params
|
||||
{{#pathParams}}
|
||||
@@ -79,7 +95,7 @@ void {{classname}}{{vendorExtensions.x-codegen-resourceName}}Resource::{{httpMet
|
||||
{{/isPrimitiveType}}
|
||||
{{/pathParams}}
|
||||
{{/hasPathParams}}
|
||||
|
||||
|
||||
{{#hasQueryParams}}
|
||||
// Getting the query params
|
||||
{{#queryParams}}
|
||||
@@ -97,21 +113,25 @@ void {{classname}}{{vendorExtensions.x-codegen-resourceName}}Resource::{{httpMet
|
||||
{{/isPrimitiveType}}
|
||||
{{/headerParams}}
|
||||
{{/hasHeaderParams}}
|
||||
|
||||
|
||||
// Change the value of this variable to the appropriate response before sending the response
|
||||
int status_code = 200;
|
||||
|
||||
/**
|
||||
* Process the received information here
|
||||
*/
|
||||
|
||||
std::string result = "successful operation";
|
||||
|
||||
if (handler_{{httpMethod}}_)
|
||||
{
|
||||
std::tie(status_code, result) = handler_{{httpMethod}}_(
|
||||
{{#allParams}}{{paramName}}{{#hasMore}}, {{/hasMore}}{{/allParams}}
|
||||
);
|
||||
}
|
||||
|
||||
{{#responses}}
|
||||
if (status_code == {{code}}) {
|
||||
{{#headers}}
|
||||
// Description: {{description}}
|
||||
session->set_header("{{baseName}}", ""); // Change second param to your header value
|
||||
{{/headers}}
|
||||
session->close({{code}}, "{{message}}", { {"Connection", "close"} });
|
||||
session->close({{code}}, result.empty() ? "{{message}}" : std::move(result), { {"Connection", "close"} });
|
||||
return;
|
||||
}
|
||||
{{/responses}}
|
||||
@@ -133,7 +153,7 @@ void {{classname}}{{vendorExtensions.x-codegen-resourceName}}Resource::{{httpMet
|
||||
{
|
||||
|
||||
const auto request = session->get_request();
|
||||
std::string requestBody = restbed::String::format("%.*s\n", ( int ) body.size( ), body.data( ));
|
||||
std::string file = restbed::String::format("%.*s\n", ( int ) body.size( ), body.data( ));
|
||||
{{/hasBodyParam}}
|
||||
|
||||
{{#hasPathParams}}
|
||||
@@ -144,7 +164,7 @@ void {{classname}}{{vendorExtensions.x-codegen-resourceName}}Resource::{{httpMet
|
||||
{{/isPrimitiveType}}
|
||||
{{/pathParams}}
|
||||
{{/hasPathParams}}
|
||||
|
||||
|
||||
{{#hasQueryParams}}
|
||||
// Getting the query params
|
||||
{{#queryParams}}
|
||||
@@ -162,14 +182,18 @@ void {{classname}}{{vendorExtensions.x-codegen-resourceName}}Resource::{{httpMet
|
||||
{{/isPrimitiveType}}
|
||||
{{/headerParams}}
|
||||
{{/hasHeaderParams}}
|
||||
|
||||
|
||||
// Change the value of this variable to the appropriate response before sending the response
|
||||
int status_code = 200;
|
||||
|
||||
/**
|
||||
* Process the received information here
|
||||
*/
|
||||
|
||||
std::string result = "successful operation";
|
||||
|
||||
if (handler_{{httpMethod}}_)
|
||||
{
|
||||
std::tie(status_code, result) = handler_{{httpMethod}}_(
|
||||
{{#allParams}}{{paramName}}{{#hasMore}}, {{/hasMore}}{{/allParams}}
|
||||
);
|
||||
}
|
||||
|
||||
{{#responses}}
|
||||
if (status_code == {{code}}) {
|
||||
{{#baseType}}
|
||||
@@ -179,7 +203,7 @@ void {{classname}}{{vendorExtensions.x-codegen-resourceName}}Resource::{{httpMet
|
||||
// Description: {{description}}
|
||||
session->set_header("{{baseName}}", ""); // Change second param to your header value
|
||||
{{/headers}}
|
||||
session->close({{code}}, "{{message}}", { {"Connection", "close"} });
|
||||
session->close({{code}}, result.empty() ? "{{message}}" : std::move(result), { {"Connection", "close"} });
|
||||
return;
|
||||
}
|
||||
{{/responses}}
|
||||
|
||||
@@ -1 +1 @@
|
||||
3.3.1-SNAPSHOT
|
||||
4.0.1-SNAPSHOT
|
||||
@@ -2,10 +2,10 @@
|
||||
* 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.
|
||||
*
|
||||
* OpenAPI spec version: 1.0.0
|
||||
* The version of the OpenAPI document: 1.0.0
|
||||
*
|
||||
*
|
||||
* NOTE: This class is auto generated by OpenAPI-Generator 4.0.0-SNAPSHOT.
|
||||
* NOTE: This class is auto generated by OpenAPI-Generator 4.0.1-SNAPSHOT.
|
||||
* https://openapi-generator.tech
|
||||
* Do not edit the class manually.
|
||||
*/
|
||||
@@ -72,6 +72,20 @@ PetApiPetResource::~PetApiPetResource()
|
||||
{
|
||||
}
|
||||
|
||||
void PetApiPetResource::set_handler_POST(
|
||||
std::function<std::pair<int, std::string>(
|
||||
std::shared_ptr<Pet> const &
|
||||
)> handler) {
|
||||
handler_POST_ = std::move(handler);
|
||||
}
|
||||
|
||||
void PetApiPetResource::set_handler_PUT(
|
||||
std::function<std::pair<int, std::string>(
|
||||
std::shared_ptr<Pet> const &
|
||||
)> handler) {
|
||||
handler_PUT_ = std::move(handler);
|
||||
}
|
||||
|
||||
void PetApiPetResource::POST_method_handler(const std::shared_ptr<restbed::Session> session) {
|
||||
|
||||
const auto request = session->get_request();
|
||||
@@ -82,23 +96,27 @@ void PetApiPetResource::POST_method_handler(const std::shared_ptr<restbed::Sessi
|
||||
{
|
||||
|
||||
const auto request = session->get_request();
|
||||
std::string requestBody = restbed::String::format("%.*s\n", ( int ) body.size( ), body.data( ));
|
||||
std::string file = restbed::String::format("%.*s\n", ( int ) body.size( ), body.data( ));
|
||||
/**
|
||||
* Get body params or form params here from the requestBody string
|
||||
* Get body params or form params here from the file string
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// Change the value of this variable to the appropriate response before sending the response
|
||||
int status_code = 200;
|
||||
|
||||
/**
|
||||
* Process the received information here
|
||||
*/
|
||||
|
||||
std::string result = "successful operation";
|
||||
|
||||
if (handler_POST_)
|
||||
{
|
||||
std::tie(status_code, result) = handler_POST_(
|
||||
body
|
||||
);
|
||||
}
|
||||
|
||||
if (status_code == 405) {
|
||||
session->close(405, "Invalid input", { {"Connection", "close"} });
|
||||
session->close(405, result.empty() ? "Invalid input" : std::move(result), { {"Connection", "close"} });
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -115,28 +133,32 @@ void PetApiPetResource::PUT_method_handler(const std::shared_ptr<restbed::Sessio
|
||||
{
|
||||
|
||||
const auto request = session->get_request();
|
||||
std::string requestBody = restbed::String::format("%.*s\n", ( int ) body.size( ), body.data( ));
|
||||
std::string file = restbed::String::format("%.*s\n", ( int ) body.size( ), body.data( ));
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// Change the value of this variable to the appropriate response before sending the response
|
||||
int status_code = 200;
|
||||
|
||||
/**
|
||||
* Process the received information here
|
||||
*/
|
||||
|
||||
std::string result = "successful operation";
|
||||
|
||||
if (handler_PUT_)
|
||||
{
|
||||
std::tie(status_code, result) = handler_PUT_(
|
||||
body
|
||||
);
|
||||
}
|
||||
|
||||
if (status_code == 400) {
|
||||
session->close(400, "Invalid ID supplied", { {"Connection", "close"} });
|
||||
session->close(400, result.empty() ? "Invalid ID supplied" : std::move(result), { {"Connection", "close"} });
|
||||
return;
|
||||
}
|
||||
if (status_code == 404) {
|
||||
session->close(404, "Pet not found", { {"Connection", "close"} });
|
||||
session->close(404, result.empty() ? "Pet not found" : std::move(result), { {"Connection", "close"} });
|
||||
return;
|
||||
}
|
||||
if (status_code == 405) {
|
||||
session->close(405, "Validation exception", { {"Connection", "close"} });
|
||||
session->close(405, result.empty() ? "Validation exception" : std::move(result), { {"Connection", "close"} });
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -162,26 +184,50 @@ PetApiPetPetIdResource::~PetApiPetPetIdResource()
|
||||
{
|
||||
}
|
||||
|
||||
void PetApiPetPetIdResource::set_handler_DELETE(
|
||||
std::function<std::pair<int, std::string>(
|
||||
int64_t const &, std::string const &
|
||||
)> handler) {
|
||||
handler_DELETE_ = std::move(handler);
|
||||
}
|
||||
|
||||
void PetApiPetPetIdResource::set_handler_GET(
|
||||
std::function<std::pair<int, std::string>(
|
||||
int64_t const &
|
||||
)> handler) {
|
||||
handler_GET_ = std::move(handler);
|
||||
}
|
||||
void PetApiPetPetIdResource::set_handler_POST(
|
||||
std::function<std::pair<int, std::string>(
|
||||
int64_t const &, std::string const &, std::string const &
|
||||
)> handler) {
|
||||
handler_POST_ = std::move(handler);
|
||||
}
|
||||
|
||||
void PetApiPetPetIdResource::DELETE_method_handler(const std::shared_ptr<restbed::Session> session) {
|
||||
|
||||
const auto request = session->get_request();
|
||||
|
||||
|
||||
// Getting the path params
|
||||
const int64_t petId = request->get_path_parameter("petId", 0L);
|
||||
|
||||
|
||||
|
||||
// Getting the headers
|
||||
const std::string apiKey = request->get_header("apiKey", "");
|
||||
|
||||
|
||||
// Change the value of this variable to the appropriate response before sending the response
|
||||
int status_code = 200;
|
||||
|
||||
/**
|
||||
* Process the received information here
|
||||
*/
|
||||
|
||||
std::string result = "successful operation";
|
||||
|
||||
if (handler_DELETE_)
|
||||
{
|
||||
std::tie(status_code, result) = handler_DELETE_(
|
||||
petId, apiKey
|
||||
);
|
||||
}
|
||||
|
||||
if (status_code == 400) {
|
||||
session->close(400, "Invalid pet value", { {"Connection", "close"} });
|
||||
session->close(400, result.empty() ? "Invalid pet value" : std::move(result), { {"Connection", "close"} });
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -193,27 +239,31 @@ void PetApiPetPetIdResource::GET_method_handler(const std::shared_ptr<restbed::S
|
||||
|
||||
// Getting the path params
|
||||
const int64_t petId = request->get_path_parameter("petId", 0L);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// Change the value of this variable to the appropriate response before sending the response
|
||||
int status_code = 200;
|
||||
|
||||
/**
|
||||
* Process the received information here
|
||||
*/
|
||||
|
||||
std::string result = "successful operation";
|
||||
|
||||
if (handler_GET_)
|
||||
{
|
||||
std::tie(status_code, result) = handler_GET_(
|
||||
petId
|
||||
);
|
||||
}
|
||||
|
||||
if (status_code == 200) {
|
||||
std::shared_ptr<Pet> response = NULL;
|
||||
session->close(200, "successful operation", { {"Connection", "close"} });
|
||||
session->close(200, result.empty() ? "successful operation" : std::move(result), { {"Connection", "close"} });
|
||||
return;
|
||||
}
|
||||
if (status_code == 400) {
|
||||
session->close(400, "Invalid ID supplied", { {"Connection", "close"} });
|
||||
session->close(400, result.empty() ? "Invalid ID supplied" : std::move(result), { {"Connection", "close"} });
|
||||
return;
|
||||
}
|
||||
if (status_code == 404) {
|
||||
session->close(404, "Pet not found", { {"Connection", "close"} });
|
||||
session->close(404, result.empty() ? "Pet not found" : std::move(result), { {"Connection", "close"} });
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -224,18 +274,22 @@ void PetApiPetPetIdResource::POST_method_handler(const std::shared_ptr<restbed::
|
||||
|
||||
// Getting the path params
|
||||
const int64_t petId = request->get_path_parameter("petId", 0L);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// Change the value of this variable to the appropriate response before sending the response
|
||||
int status_code = 200;
|
||||
|
||||
/**
|
||||
* Process the received information here
|
||||
*/
|
||||
|
||||
std::string result = "successful operation";
|
||||
|
||||
if (handler_POST_)
|
||||
{
|
||||
std::tie(status_code, result) = handler_POST_(
|
||||
petId, name, status
|
||||
);
|
||||
}
|
||||
|
||||
if (status_code == 405) {
|
||||
session->close(405, "Invalid input", { {"Connection", "close"} });
|
||||
session->close(405, result.empty() ? "Invalid input" : std::move(result), { {"Connection", "close"} });
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -254,27 +308,39 @@ PetApiPetFindByStatusResource::~PetApiPetFindByStatusResource()
|
||||
{
|
||||
}
|
||||
|
||||
void PetApiPetFindByStatusResource::set_handler_GET(
|
||||
std::function<std::pair<int, std::string>(
|
||||
std::vector<std::string> const &
|
||||
)> handler) {
|
||||
handler_GET_ = std::move(handler);
|
||||
}
|
||||
|
||||
|
||||
void PetApiPetFindByStatusResource::GET_method_handler(const std::shared_ptr<restbed::Session> session) {
|
||||
|
||||
const auto request = session->get_request();
|
||||
|
||||
|
||||
|
||||
|
||||
// Getting the query params
|
||||
|
||||
|
||||
|
||||
// Change the value of this variable to the appropriate response before sending the response
|
||||
int status_code = 200;
|
||||
|
||||
/**
|
||||
* Process the received information here
|
||||
*/
|
||||
|
||||
std::string result = "successful operation";
|
||||
|
||||
if (handler_GET_)
|
||||
{
|
||||
std::tie(status_code, result) = handler_GET_(
|
||||
status
|
||||
);
|
||||
}
|
||||
|
||||
if (status_code == 200) {
|
||||
session->close(200, "successful operation", { {"Connection", "close"} });
|
||||
session->close(200, result.empty() ? "successful operation" : std::move(result), { {"Connection", "close"} });
|
||||
return;
|
||||
}
|
||||
if (status_code == 400) {
|
||||
session->close(400, "Invalid status value", { {"Connection", "close"} });
|
||||
session->close(400, result.empty() ? "Invalid status value" : std::move(result), { {"Connection", "close"} });
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -294,27 +360,39 @@ PetApiPetFindByTagsResource::~PetApiPetFindByTagsResource()
|
||||
{
|
||||
}
|
||||
|
||||
void PetApiPetFindByTagsResource::set_handler_GET(
|
||||
std::function<std::pair<int, std::string>(
|
||||
std::vector<std::string> const &
|
||||
)> handler) {
|
||||
handler_GET_ = std::move(handler);
|
||||
}
|
||||
|
||||
|
||||
void PetApiPetFindByTagsResource::GET_method_handler(const std::shared_ptr<restbed::Session> session) {
|
||||
|
||||
const auto request = session->get_request();
|
||||
|
||||
|
||||
|
||||
|
||||
// Getting the query params
|
||||
|
||||
|
||||
|
||||
// Change the value of this variable to the appropriate response before sending the response
|
||||
int status_code = 200;
|
||||
|
||||
/**
|
||||
* Process the received information here
|
||||
*/
|
||||
|
||||
std::string result = "successful operation";
|
||||
|
||||
if (handler_GET_)
|
||||
{
|
||||
std::tie(status_code, result) = handler_GET_(
|
||||
tags
|
||||
);
|
||||
}
|
||||
|
||||
if (status_code == 200) {
|
||||
session->close(200, "successful operation", { {"Connection", "close"} });
|
||||
session->close(200, result.empty() ? "successful operation" : std::move(result), { {"Connection", "close"} });
|
||||
return;
|
||||
}
|
||||
if (status_code == 400) {
|
||||
session->close(400, "Invalid tag value", { {"Connection", "close"} });
|
||||
session->close(400, result.empty() ? "Invalid tag value" : std::move(result), { {"Connection", "close"} });
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -334,24 +412,36 @@ PetApiPetPetIdUploadImageResource::~PetApiPetPetIdUploadImageResource()
|
||||
{
|
||||
}
|
||||
|
||||
void PetApiPetPetIdUploadImageResource::set_handler_POST(
|
||||
std::function<std::pair<int, std::string>(
|
||||
int64_t const &, std::string const &, std::string const &
|
||||
)> handler) {
|
||||
handler_POST_ = std::move(handler);
|
||||
}
|
||||
|
||||
|
||||
void PetApiPetPetIdUploadImageResource::POST_method_handler(const std::shared_ptr<restbed::Session> session) {
|
||||
|
||||
const auto request = session->get_request();
|
||||
|
||||
|
||||
// Getting the path params
|
||||
const int64_t petId = request->get_path_parameter("petId", 0L);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// Change the value of this variable to the appropriate response before sending the response
|
||||
int status_code = 200;
|
||||
|
||||
/**
|
||||
* Process the received information here
|
||||
*/
|
||||
|
||||
std::string result = "successful operation";
|
||||
|
||||
if (handler_POST_)
|
||||
{
|
||||
std::tie(status_code, result) = handler_POST_(
|
||||
petId, additionalMetadata, file
|
||||
);
|
||||
}
|
||||
|
||||
if (status_code == 200) {
|
||||
session->close(200, "successful operation", { {"Connection", "close"} });
|
||||
session->close(200, result.empty() ? "successful operation" : std::move(result), { {"Connection", "close"} });
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -2,10 +2,10 @@
|
||||
* 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.
|
||||
*
|
||||
* OpenAPI spec version: 1.0.0
|
||||
* The version of the OpenAPI document: 1.0.0
|
||||
*
|
||||
*
|
||||
* NOTE: This class is auto generated by OpenAPI-Generator 4.0.0-SNAPSHOT.
|
||||
* NOTE: This class is auto generated by OpenAPI-Generator 4.0.1-SNAPSHOT.
|
||||
* https://openapi-generator.tech
|
||||
* Do not edit the class manually.
|
||||
*/
|
||||
@@ -21,6 +21,8 @@
|
||||
|
||||
|
||||
#include <memory>
|
||||
#include <utility>
|
||||
|
||||
#include <corvusoft/restbed/session.hpp>
|
||||
#include <corvusoft/restbed/resource.hpp>
|
||||
#include <corvusoft/restbed/service.hpp>
|
||||
@@ -59,6 +61,27 @@ public:
|
||||
virtual ~PetApiPetResource();
|
||||
void POST_method_handler(const std::shared_ptr<restbed::Session> session);
|
||||
void PUT_method_handler(const std::shared_ptr<restbed::Session> session);
|
||||
|
||||
void set_handler_POST(
|
||||
std::function<std::pair<int, std::string>(
|
||||
std::shared_ptr<Pet> const &
|
||||
)> handler
|
||||
);
|
||||
|
||||
void set_handler_PUT(
|
||||
std::function<std::pair<int, std::string>(
|
||||
std::shared_ptr<Pet> const &
|
||||
)> handler
|
||||
);
|
||||
|
||||
private:
|
||||
std::function<std::pair<int, std::string>(
|
||||
std::shared_ptr<Pet> const &
|
||||
)> handler_POST_;
|
||||
|
||||
std::function<std::pair<int, std::string>(
|
||||
std::shared_ptr<Pet> const &
|
||||
)> handler_PUT_;
|
||||
};
|
||||
|
||||
/// <summary>
|
||||
@@ -75,6 +98,35 @@ public:
|
||||
void DELETE_method_handler(const std::shared_ptr<restbed::Session> session);
|
||||
void GET_method_handler(const std::shared_ptr<restbed::Session> session);
|
||||
void POST_method_handler(const std::shared_ptr<restbed::Session> session);
|
||||
|
||||
void set_handler_DELETE(
|
||||
std::function<std::pair<int, std::string>(
|
||||
int64_t const &, std::string const &
|
||||
)> handler
|
||||
);
|
||||
|
||||
void set_handler_GET(
|
||||
std::function<std::pair<int, std::string>(
|
||||
int64_t const &
|
||||
)> handler
|
||||
);
|
||||
void set_handler_POST(
|
||||
std::function<std::pair<int, std::string>(
|
||||
int64_t const &, std::string const &, std::string const &
|
||||
)> handler
|
||||
);
|
||||
|
||||
private:
|
||||
std::function<std::pair<int, std::string>(
|
||||
int64_t const &, std::string const &
|
||||
)> handler_DELETE_;
|
||||
|
||||
std::function<std::pair<int, std::string>(
|
||||
int64_t const &
|
||||
)> handler_GET_;
|
||||
std::function<std::pair<int, std::string>(
|
||||
int64_t const &, std::string const &, std::string const &
|
||||
)> handler_POST_;
|
||||
};
|
||||
|
||||
/// <summary>
|
||||
@@ -89,6 +141,19 @@ public:
|
||||
PetApiPetFindByStatusResource();
|
||||
virtual ~PetApiPetFindByStatusResource();
|
||||
void GET_method_handler(const std::shared_ptr<restbed::Session> session);
|
||||
|
||||
void set_handler_GET(
|
||||
std::function<std::pair<int, std::string>(
|
||||
std::vector<std::string> const &
|
||||
)> handler
|
||||
);
|
||||
|
||||
|
||||
private:
|
||||
std::function<std::pair<int, std::string>(
|
||||
std::vector<std::string> const &
|
||||
)> handler_GET_;
|
||||
|
||||
};
|
||||
|
||||
/// <summary>
|
||||
@@ -103,6 +168,19 @@ public:
|
||||
PetApiPetFindByTagsResource();
|
||||
virtual ~PetApiPetFindByTagsResource();
|
||||
void GET_method_handler(const std::shared_ptr<restbed::Session> session);
|
||||
|
||||
void set_handler_GET(
|
||||
std::function<std::pair<int, std::string>(
|
||||
std::vector<std::string> const &
|
||||
)> handler
|
||||
);
|
||||
|
||||
|
||||
private:
|
||||
std::function<std::pair<int, std::string>(
|
||||
std::vector<std::string> const &
|
||||
)> handler_GET_;
|
||||
|
||||
};
|
||||
|
||||
/// <summary>
|
||||
@@ -117,6 +195,19 @@ public:
|
||||
PetApiPetPetIdUploadImageResource();
|
||||
virtual ~PetApiPetPetIdUploadImageResource();
|
||||
void POST_method_handler(const std::shared_ptr<restbed::Session> session);
|
||||
|
||||
void set_handler_POST(
|
||||
std::function<std::pair<int, std::string>(
|
||||
int64_t const &, std::string const &, std::string const &
|
||||
)> handler
|
||||
);
|
||||
|
||||
|
||||
private:
|
||||
std::function<std::pair<int, std::string>(
|
||||
int64_t const &, std::string const &, std::string const &
|
||||
)> handler_POST_;
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -2,10 +2,10 @@
|
||||
* 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.
|
||||
*
|
||||
* OpenAPI spec version: 1.0.0
|
||||
* The version of the OpenAPI document: 1.0.0
|
||||
*
|
||||
*
|
||||
* NOTE: This class is auto generated by OpenAPI-Generator 4.0.0-SNAPSHOT.
|
||||
* NOTE: This class is auto generated by OpenAPI-Generator 4.0.1-SNAPSHOT.
|
||||
* https://openapi-generator.tech
|
||||
* Do not edit the class manually.
|
||||
*/
|
||||
@@ -66,28 +66,46 @@ StoreApiStoreOrderOrderIdResource::~StoreApiStoreOrderOrderIdResource()
|
||||
{
|
||||
}
|
||||
|
||||
void StoreApiStoreOrderOrderIdResource::set_handler_DELETE(
|
||||
std::function<std::pair<int, std::string>(
|
||||
std::string const &
|
||||
)> handler) {
|
||||
handler_DELETE_ = std::move(handler);
|
||||
}
|
||||
|
||||
void StoreApiStoreOrderOrderIdResource::set_handler_GET(
|
||||
std::function<std::pair<int, std::string>(
|
||||
int64_t const &
|
||||
)> handler) {
|
||||
handler_GET_ = std::move(handler);
|
||||
}
|
||||
|
||||
void StoreApiStoreOrderOrderIdResource::DELETE_method_handler(const std::shared_ptr<restbed::Session> session) {
|
||||
|
||||
const auto request = session->get_request();
|
||||
|
||||
|
||||
// Getting the path params
|
||||
const std::string orderId = request->get_path_parameter("orderId", "");
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// Change the value of this variable to the appropriate response before sending the response
|
||||
int status_code = 200;
|
||||
|
||||
/**
|
||||
* Process the received information here
|
||||
*/
|
||||
|
||||
std::string result = "successful operation";
|
||||
|
||||
if (handler_DELETE_)
|
||||
{
|
||||
std::tie(status_code, result) = handler_DELETE_(
|
||||
orderId
|
||||
);
|
||||
}
|
||||
|
||||
if (status_code == 400) {
|
||||
session->close(400, "Invalid ID supplied", { {"Connection", "close"} });
|
||||
session->close(400, result.empty() ? "Invalid ID supplied" : std::move(result), { {"Connection", "close"} });
|
||||
return;
|
||||
}
|
||||
if (status_code == 404) {
|
||||
session->close(404, "Order not found", { {"Connection", "close"} });
|
||||
session->close(404, result.empty() ? "Order not found" : std::move(result), { {"Connection", "close"} });
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -99,27 +117,31 @@ void StoreApiStoreOrderOrderIdResource::GET_method_handler(const std::shared_ptr
|
||||
|
||||
// Getting the path params
|
||||
const int64_t orderId = request->get_path_parameter("orderId", 0L);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// Change the value of this variable to the appropriate response before sending the response
|
||||
int status_code = 200;
|
||||
|
||||
/**
|
||||
* Process the received information here
|
||||
*/
|
||||
|
||||
std::string result = "successful operation";
|
||||
|
||||
if (handler_GET_)
|
||||
{
|
||||
std::tie(status_code, result) = handler_GET_(
|
||||
orderId
|
||||
);
|
||||
}
|
||||
|
||||
if (status_code == 200) {
|
||||
std::shared_ptr<Order> response = NULL;
|
||||
session->close(200, "successful operation", { {"Connection", "close"} });
|
||||
session->close(200, result.empty() ? "successful operation" : std::move(result), { {"Connection", "close"} });
|
||||
return;
|
||||
}
|
||||
if (status_code == 400) {
|
||||
session->close(400, "Invalid ID supplied", { {"Connection", "close"} });
|
||||
session->close(400, result.empty() ? "Invalid ID supplied" : std::move(result), { {"Connection", "close"} });
|
||||
return;
|
||||
}
|
||||
if (status_code == 404) {
|
||||
session->close(404, "Order not found", { {"Connection", "close"} });
|
||||
session->close(404, result.empty() ? "Order not found" : std::move(result), { {"Connection", "close"} });
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -138,22 +160,34 @@ StoreApiStoreInventoryResource::~StoreApiStoreInventoryResource()
|
||||
{
|
||||
}
|
||||
|
||||
void StoreApiStoreInventoryResource::set_handler_GET(
|
||||
std::function<std::pair<int, std::string>(
|
||||
|
||||
)> handler) {
|
||||
handler_GET_ = std::move(handler);
|
||||
}
|
||||
|
||||
|
||||
void StoreApiStoreInventoryResource::GET_method_handler(const std::shared_ptr<restbed::Session> session) {
|
||||
|
||||
const auto request = session->get_request();
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// Change the value of this variable to the appropriate response before sending the response
|
||||
int status_code = 200;
|
||||
|
||||
/**
|
||||
* Process the received information here
|
||||
*/
|
||||
|
||||
std::string result = "successful operation";
|
||||
|
||||
if (handler_GET_)
|
||||
{
|
||||
std::tie(status_code, result) = handler_GET_(
|
||||
|
||||
);
|
||||
}
|
||||
|
||||
if (status_code == 200) {
|
||||
session->close(200, "successful operation", { {"Connection", "close"} });
|
||||
session->close(200, result.empty() ? "successful operation" : std::move(result), { {"Connection", "close"} });
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -173,6 +207,14 @@ StoreApiStoreOrderResource::~StoreApiStoreOrderResource()
|
||||
{
|
||||
}
|
||||
|
||||
void StoreApiStoreOrderResource::set_handler_POST(
|
||||
std::function<std::pair<int, std::string>(
|
||||
std::shared_ptr<Order> const &
|
||||
)> handler) {
|
||||
handler_POST_ = std::move(handler);
|
||||
}
|
||||
|
||||
|
||||
void StoreApiStoreOrderResource::POST_method_handler(const std::shared_ptr<restbed::Session> session) {
|
||||
|
||||
const auto request = session->get_request();
|
||||
@@ -183,27 +225,31 @@ void StoreApiStoreOrderResource::POST_method_handler(const std::shared_ptr<restb
|
||||
{
|
||||
|
||||
const auto request = session->get_request();
|
||||
std::string requestBody = restbed::String::format("%.*s\n", ( int ) body.size( ), body.data( ));
|
||||
std::string file = restbed::String::format("%.*s\n", ( int ) body.size( ), body.data( ));
|
||||
/**
|
||||
* Get body params or form params here from the requestBody string
|
||||
* Get body params or form params here from the file string
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// Change the value of this variable to the appropriate response before sending the response
|
||||
int status_code = 200;
|
||||
|
||||
/**
|
||||
* Process the received information here
|
||||
*/
|
||||
|
||||
std::string result = "successful operation";
|
||||
|
||||
if (handler_POST_)
|
||||
{
|
||||
std::tie(status_code, result) = handler_POST_(
|
||||
body
|
||||
);
|
||||
}
|
||||
|
||||
if (status_code == 200) {
|
||||
session->close(200, "successful operation", { {"Connection", "close"} });
|
||||
session->close(200, result.empty() ? "successful operation" : std::move(result), { {"Connection", "close"} });
|
||||
return;
|
||||
}
|
||||
if (status_code == 400) {
|
||||
session->close(400, "Invalid Order", { {"Connection", "close"} });
|
||||
session->close(400, result.empty() ? "Invalid Order" : std::move(result), { {"Connection", "close"} });
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -2,10 +2,10 @@
|
||||
* 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.
|
||||
*
|
||||
* OpenAPI spec version: 1.0.0
|
||||
* The version of the OpenAPI document: 1.0.0
|
||||
*
|
||||
*
|
||||
* NOTE: This class is auto generated by OpenAPI-Generator 4.0.0-SNAPSHOT.
|
||||
* NOTE: This class is auto generated by OpenAPI-Generator 4.0.1-SNAPSHOT.
|
||||
* https://openapi-generator.tech
|
||||
* Do not edit the class manually.
|
||||
*/
|
||||
@@ -21,6 +21,8 @@
|
||||
|
||||
|
||||
#include <memory>
|
||||
#include <utility>
|
||||
|
||||
#include <corvusoft/restbed/session.hpp>
|
||||
#include <corvusoft/restbed/resource.hpp>
|
||||
#include <corvusoft/restbed/service.hpp>
|
||||
@@ -59,6 +61,27 @@ public:
|
||||
virtual ~StoreApiStoreOrderOrderIdResource();
|
||||
void DELETE_method_handler(const std::shared_ptr<restbed::Session> session);
|
||||
void GET_method_handler(const std::shared_ptr<restbed::Session> session);
|
||||
|
||||
void set_handler_DELETE(
|
||||
std::function<std::pair<int, std::string>(
|
||||
std::string const &
|
||||
)> handler
|
||||
);
|
||||
|
||||
void set_handler_GET(
|
||||
std::function<std::pair<int, std::string>(
|
||||
int64_t const &
|
||||
)> handler
|
||||
);
|
||||
|
||||
private:
|
||||
std::function<std::pair<int, std::string>(
|
||||
std::string const &
|
||||
)> handler_DELETE_;
|
||||
|
||||
std::function<std::pair<int, std::string>(
|
||||
int64_t const &
|
||||
)> handler_GET_;
|
||||
};
|
||||
|
||||
/// <summary>
|
||||
@@ -73,6 +96,19 @@ public:
|
||||
StoreApiStoreInventoryResource();
|
||||
virtual ~StoreApiStoreInventoryResource();
|
||||
void GET_method_handler(const std::shared_ptr<restbed::Session> session);
|
||||
|
||||
void set_handler_GET(
|
||||
std::function<std::pair<int, std::string>(
|
||||
|
||||
)> handler
|
||||
);
|
||||
|
||||
|
||||
private:
|
||||
std::function<std::pair<int, std::string>(
|
||||
|
||||
)> handler_GET_;
|
||||
|
||||
};
|
||||
|
||||
/// <summary>
|
||||
@@ -87,6 +123,19 @@ public:
|
||||
StoreApiStoreOrderResource();
|
||||
virtual ~StoreApiStoreOrderResource();
|
||||
void POST_method_handler(const std::shared_ptr<restbed::Session> session);
|
||||
|
||||
void set_handler_POST(
|
||||
std::function<std::pair<int, std::string>(
|
||||
std::shared_ptr<Order> const &
|
||||
)> handler
|
||||
);
|
||||
|
||||
|
||||
private:
|
||||
std::function<std::pair<int, std::string>(
|
||||
std::shared_ptr<Order> const &
|
||||
)> handler_POST_;
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -2,10 +2,10 @@
|
||||
* 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.
|
||||
*
|
||||
* OpenAPI spec version: 1.0.0
|
||||
* The version of the OpenAPI document: 1.0.0
|
||||
*
|
||||
*
|
||||
* NOTE: This class is auto generated by OpenAPI-Generator 4.0.0-SNAPSHOT.
|
||||
* NOTE: This class is auto generated by OpenAPI-Generator 4.0.1-SNAPSHOT.
|
||||
* https://openapi-generator.tech
|
||||
* Do not edit the class manually.
|
||||
*/
|
||||
@@ -72,6 +72,14 @@ UserApiUserResource::~UserApiUserResource()
|
||||
{
|
||||
}
|
||||
|
||||
void UserApiUserResource::set_handler_POST(
|
||||
std::function<std::pair<int, std::string>(
|
||||
std::shared_ptr<User> const &
|
||||
)> handler) {
|
||||
handler_POST_ = std::move(handler);
|
||||
}
|
||||
|
||||
|
||||
void UserApiUserResource::POST_method_handler(const std::shared_ptr<restbed::Session> session) {
|
||||
|
||||
const auto request = session->get_request();
|
||||
@@ -82,23 +90,27 @@ void UserApiUserResource::POST_method_handler(const std::shared_ptr<restbed::Ses
|
||||
{
|
||||
|
||||
const auto request = session->get_request();
|
||||
std::string requestBody = restbed::String::format("%.*s\n", ( int ) body.size( ), body.data( ));
|
||||
std::string file = restbed::String::format("%.*s\n", ( int ) body.size( ), body.data( ));
|
||||
/**
|
||||
* Get body params or form params here from the requestBody string
|
||||
* Get body params or form params here from the file string
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// Change the value of this variable to the appropriate response before sending the response
|
||||
int status_code = 200;
|
||||
|
||||
/**
|
||||
* Process the received information here
|
||||
*/
|
||||
|
||||
std::string result = "successful operation";
|
||||
|
||||
if (handler_POST_)
|
||||
{
|
||||
std::tie(status_code, result) = handler_POST_(
|
||||
body
|
||||
);
|
||||
}
|
||||
|
||||
if (status_code == 0) {
|
||||
session->close(0, "successful operation", { {"Connection", "close"} });
|
||||
session->close(0, result.empty() ? "successful operation" : std::move(result), { {"Connection", "close"} });
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -119,6 +131,14 @@ UserApiUserCreateWithArrayResource::~UserApiUserCreateWithArrayResource()
|
||||
{
|
||||
}
|
||||
|
||||
void UserApiUserCreateWithArrayResource::set_handler_POST(
|
||||
std::function<std::pair<int, std::string>(
|
||||
std::vector<std::shared_ptr<User>> const &
|
||||
)> handler) {
|
||||
handler_POST_ = std::move(handler);
|
||||
}
|
||||
|
||||
|
||||
void UserApiUserCreateWithArrayResource::POST_method_handler(const std::shared_ptr<restbed::Session> session) {
|
||||
|
||||
const auto request = session->get_request();
|
||||
@@ -129,23 +149,27 @@ void UserApiUserCreateWithArrayResource::POST_method_handler(const std::shared_p
|
||||
{
|
||||
|
||||
const auto request = session->get_request();
|
||||
std::string requestBody = restbed::String::format("%.*s\n", ( int ) body.size( ), body.data( ));
|
||||
std::string file = restbed::String::format("%.*s\n", ( int ) body.size( ), body.data( ));
|
||||
/**
|
||||
* Get body params or form params here from the requestBody string
|
||||
* Get body params or form params here from the file string
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// Change the value of this variable to the appropriate response before sending the response
|
||||
int status_code = 200;
|
||||
|
||||
/**
|
||||
* Process the received information here
|
||||
*/
|
||||
|
||||
std::string result = "successful operation";
|
||||
|
||||
if (handler_POST_)
|
||||
{
|
||||
std::tie(status_code, result) = handler_POST_(
|
||||
body
|
||||
);
|
||||
}
|
||||
|
||||
if (status_code == 0) {
|
||||
session->close(0, "successful operation", { {"Connection", "close"} });
|
||||
session->close(0, result.empty() ? "successful operation" : std::move(result), { {"Connection", "close"} });
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -166,6 +190,14 @@ UserApiUserCreateWithListResource::~UserApiUserCreateWithListResource()
|
||||
{
|
||||
}
|
||||
|
||||
void UserApiUserCreateWithListResource::set_handler_POST(
|
||||
std::function<std::pair<int, std::string>(
|
||||
std::vector<std::shared_ptr<User>> const &
|
||||
)> handler) {
|
||||
handler_POST_ = std::move(handler);
|
||||
}
|
||||
|
||||
|
||||
void UserApiUserCreateWithListResource::POST_method_handler(const std::shared_ptr<restbed::Session> session) {
|
||||
|
||||
const auto request = session->get_request();
|
||||
@@ -176,23 +208,27 @@ void UserApiUserCreateWithListResource::POST_method_handler(const std::shared_pt
|
||||
{
|
||||
|
||||
const auto request = session->get_request();
|
||||
std::string requestBody = restbed::String::format("%.*s\n", ( int ) body.size( ), body.data( ));
|
||||
std::string file = restbed::String::format("%.*s\n", ( int ) body.size( ), body.data( ));
|
||||
/**
|
||||
* Get body params or form params here from the requestBody string
|
||||
* Get body params or form params here from the file string
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// Change the value of this variable to the appropriate response before sending the response
|
||||
int status_code = 200;
|
||||
|
||||
/**
|
||||
* Process the received information here
|
||||
*/
|
||||
|
||||
std::string result = "successful operation";
|
||||
|
||||
if (handler_POST_)
|
||||
{
|
||||
std::tie(status_code, result) = handler_POST_(
|
||||
body
|
||||
);
|
||||
}
|
||||
|
||||
if (status_code == 0) {
|
||||
session->close(0, "successful operation", { {"Connection", "close"} });
|
||||
session->close(0, result.empty() ? "successful operation" : std::move(result), { {"Connection", "close"} });
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -219,28 +255,52 @@ UserApiUserUsernameResource::~UserApiUserUsernameResource()
|
||||
{
|
||||
}
|
||||
|
||||
void UserApiUserUsernameResource::set_handler_DELETE(
|
||||
std::function<std::pair<int, std::string>(
|
||||
std::string const &
|
||||
)> handler) {
|
||||
handler_DELETE_ = std::move(handler);
|
||||
}
|
||||
|
||||
void UserApiUserUsernameResource::set_handler_GET(
|
||||
std::function<std::pair<int, std::string>(
|
||||
std::string const &
|
||||
)> handler) {
|
||||
handler_GET_ = std::move(handler);
|
||||
}
|
||||
void UserApiUserUsernameResource::set_handler_PUT(
|
||||
std::function<std::pair<int, std::string>(
|
||||
std::string const &, std::shared_ptr<User> const &
|
||||
)> handler) {
|
||||
handler_PUT_ = std::move(handler);
|
||||
}
|
||||
|
||||
void UserApiUserUsernameResource::DELETE_method_handler(const std::shared_ptr<restbed::Session> session) {
|
||||
|
||||
const auto request = session->get_request();
|
||||
|
||||
|
||||
// Getting the path params
|
||||
const std::string username = request->get_path_parameter("username", "");
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// Change the value of this variable to the appropriate response before sending the response
|
||||
int status_code = 200;
|
||||
|
||||
/**
|
||||
* Process the received information here
|
||||
*/
|
||||
|
||||
std::string result = "successful operation";
|
||||
|
||||
if (handler_DELETE_)
|
||||
{
|
||||
std::tie(status_code, result) = handler_DELETE_(
|
||||
username
|
||||
);
|
||||
}
|
||||
|
||||
if (status_code == 400) {
|
||||
session->close(400, "Invalid username supplied", { {"Connection", "close"} });
|
||||
session->close(400, result.empty() ? "Invalid username supplied" : std::move(result), { {"Connection", "close"} });
|
||||
return;
|
||||
}
|
||||
if (status_code == 404) {
|
||||
session->close(404, "User not found", { {"Connection", "close"} });
|
||||
session->close(404, result.empty() ? "User not found" : std::move(result), { {"Connection", "close"} });
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -252,27 +312,31 @@ void UserApiUserUsernameResource::GET_method_handler(const std::shared_ptr<restb
|
||||
|
||||
// Getting the path params
|
||||
const std::string username = request->get_path_parameter("username", "");
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// Change the value of this variable to the appropriate response before sending the response
|
||||
int status_code = 200;
|
||||
|
||||
/**
|
||||
* Process the received information here
|
||||
*/
|
||||
|
||||
std::string result = "successful operation";
|
||||
|
||||
if (handler_GET_)
|
||||
{
|
||||
std::tie(status_code, result) = handler_GET_(
|
||||
username
|
||||
);
|
||||
}
|
||||
|
||||
if (status_code == 200) {
|
||||
std::shared_ptr<User> response = NULL;
|
||||
session->close(200, "successful operation", { {"Connection", "close"} });
|
||||
session->close(200, result.empty() ? "successful operation" : std::move(result), { {"Connection", "close"} });
|
||||
return;
|
||||
}
|
||||
if (status_code == 400) {
|
||||
session->close(400, "Invalid username supplied", { {"Connection", "close"} });
|
||||
session->close(400, result.empty() ? "Invalid username supplied" : std::move(result), { {"Connection", "close"} });
|
||||
return;
|
||||
}
|
||||
if (status_code == 404) {
|
||||
session->close(404, "User not found", { {"Connection", "close"} });
|
||||
session->close(404, result.empty() ? "User not found" : std::move(result), { {"Connection", "close"} });
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -287,26 +351,30 @@ void UserApiUserUsernameResource::PUT_method_handler(const std::shared_ptr<restb
|
||||
{
|
||||
|
||||
const auto request = session->get_request();
|
||||
std::string requestBody = restbed::String::format("%.*s\n", ( int ) body.size( ), body.data( ));
|
||||
std::string file = restbed::String::format("%.*s\n", ( int ) body.size( ), body.data( ));
|
||||
|
||||
// Getting the path params
|
||||
const std::string username = request->get_path_parameter("username", "");
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// Change the value of this variable to the appropriate response before sending the response
|
||||
int status_code = 200;
|
||||
|
||||
/**
|
||||
* Process the received information here
|
||||
*/
|
||||
|
||||
std::string result = "successful operation";
|
||||
|
||||
if (handler_PUT_)
|
||||
{
|
||||
std::tie(status_code, result) = handler_PUT_(
|
||||
username, body
|
||||
);
|
||||
}
|
||||
|
||||
if (status_code == 400) {
|
||||
session->close(400, "Invalid user supplied", { {"Connection", "close"} });
|
||||
session->close(400, result.empty() ? "Invalid user supplied" : std::move(result), { {"Connection", "close"} });
|
||||
return;
|
||||
}
|
||||
if (status_code == 404) {
|
||||
session->close(404, "User not found", { {"Connection", "close"} });
|
||||
session->close(404, result.empty() ? "User not found" : std::move(result), { {"Connection", "close"} });
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -326,33 +394,45 @@ UserApiUserLoginResource::~UserApiUserLoginResource()
|
||||
{
|
||||
}
|
||||
|
||||
void UserApiUserLoginResource::set_handler_GET(
|
||||
std::function<std::pair<int, std::string>(
|
||||
std::string const &, std::string const &
|
||||
)> handler) {
|
||||
handler_GET_ = std::move(handler);
|
||||
}
|
||||
|
||||
|
||||
void UserApiUserLoginResource::GET_method_handler(const std::shared_ptr<restbed::Session> session) {
|
||||
|
||||
const auto request = session->get_request();
|
||||
|
||||
|
||||
|
||||
|
||||
// Getting the query params
|
||||
const std::string username = request->get_query_parameter("username", "");
|
||||
const std::string password = request->get_query_parameter("password", "");
|
||||
|
||||
|
||||
|
||||
// Change the value of this variable to the appropriate response before sending the response
|
||||
int status_code = 200;
|
||||
|
||||
/**
|
||||
* Process the received information here
|
||||
*/
|
||||
|
||||
std::string result = "successful operation";
|
||||
|
||||
if (handler_GET_)
|
||||
{
|
||||
std::tie(status_code, result) = handler_GET_(
|
||||
username, password
|
||||
);
|
||||
}
|
||||
|
||||
if (status_code == 200) {
|
||||
// Description: calls per hour allowed by the user
|
||||
session->set_header("X-Rate-Limit", ""); // Change second param to your header value
|
||||
// Description: date in UTC when toekn expires
|
||||
session->set_header("X-Expires-After", ""); // Change second param to your header value
|
||||
session->close(200, "successful operation", { {"Connection", "close"} });
|
||||
session->close(200, result.empty() ? "successful operation" : std::move(result), { {"Connection", "close"} });
|
||||
return;
|
||||
}
|
||||
if (status_code == 400) {
|
||||
session->close(400, "Invalid username/password supplied", { {"Connection", "close"} });
|
||||
session->close(400, result.empty() ? "Invalid username/password supplied" : std::move(result), { {"Connection", "close"} });
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -372,22 +452,34 @@ UserApiUserLogoutResource::~UserApiUserLogoutResource()
|
||||
{
|
||||
}
|
||||
|
||||
void UserApiUserLogoutResource::set_handler_GET(
|
||||
std::function<std::pair<int, std::string>(
|
||||
|
||||
)> handler) {
|
||||
handler_GET_ = std::move(handler);
|
||||
}
|
||||
|
||||
|
||||
void UserApiUserLogoutResource::GET_method_handler(const std::shared_ptr<restbed::Session> session) {
|
||||
|
||||
const auto request = session->get_request();
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// Change the value of this variable to the appropriate response before sending the response
|
||||
int status_code = 200;
|
||||
|
||||
/**
|
||||
* Process the received information here
|
||||
*/
|
||||
|
||||
std::string result = "successful operation";
|
||||
|
||||
if (handler_GET_)
|
||||
{
|
||||
std::tie(status_code, result) = handler_GET_(
|
||||
|
||||
);
|
||||
}
|
||||
|
||||
if (status_code == 0) {
|
||||
session->close(0, "successful operation", { {"Connection", "close"} });
|
||||
session->close(0, result.empty() ? "successful operation" : std::move(result), { {"Connection", "close"} });
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -2,10 +2,10 @@
|
||||
* 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.
|
||||
*
|
||||
* OpenAPI spec version: 1.0.0
|
||||
* The version of the OpenAPI document: 1.0.0
|
||||
*
|
||||
*
|
||||
* NOTE: This class is auto generated by OpenAPI-Generator 4.0.0-SNAPSHOT.
|
||||
* NOTE: This class is auto generated by OpenAPI-Generator 4.0.1-SNAPSHOT.
|
||||
* https://openapi-generator.tech
|
||||
* Do not edit the class manually.
|
||||
*/
|
||||
@@ -21,6 +21,8 @@
|
||||
|
||||
|
||||
#include <memory>
|
||||
#include <utility>
|
||||
|
||||
#include <corvusoft/restbed/session.hpp>
|
||||
#include <corvusoft/restbed/resource.hpp>
|
||||
#include <corvusoft/restbed/service.hpp>
|
||||
@@ -58,6 +60,19 @@ public:
|
||||
UserApiUserResource();
|
||||
virtual ~UserApiUserResource();
|
||||
void POST_method_handler(const std::shared_ptr<restbed::Session> session);
|
||||
|
||||
void set_handler_POST(
|
||||
std::function<std::pair<int, std::string>(
|
||||
std::shared_ptr<User> const &
|
||||
)> handler
|
||||
);
|
||||
|
||||
|
||||
private:
|
||||
std::function<std::pair<int, std::string>(
|
||||
std::shared_ptr<User> const &
|
||||
)> handler_POST_;
|
||||
|
||||
};
|
||||
|
||||
/// <summary>
|
||||
@@ -72,6 +87,19 @@ public:
|
||||
UserApiUserCreateWithArrayResource();
|
||||
virtual ~UserApiUserCreateWithArrayResource();
|
||||
void POST_method_handler(const std::shared_ptr<restbed::Session> session);
|
||||
|
||||
void set_handler_POST(
|
||||
std::function<std::pair<int, std::string>(
|
||||
std::vector<std::shared_ptr<User>> const &
|
||||
)> handler
|
||||
);
|
||||
|
||||
|
||||
private:
|
||||
std::function<std::pair<int, std::string>(
|
||||
std::vector<std::shared_ptr<User>> const &
|
||||
)> handler_POST_;
|
||||
|
||||
};
|
||||
|
||||
/// <summary>
|
||||
@@ -86,6 +114,19 @@ public:
|
||||
UserApiUserCreateWithListResource();
|
||||
virtual ~UserApiUserCreateWithListResource();
|
||||
void POST_method_handler(const std::shared_ptr<restbed::Session> session);
|
||||
|
||||
void set_handler_POST(
|
||||
std::function<std::pair<int, std::string>(
|
||||
std::vector<std::shared_ptr<User>> const &
|
||||
)> handler
|
||||
);
|
||||
|
||||
|
||||
private:
|
||||
std::function<std::pair<int, std::string>(
|
||||
std::vector<std::shared_ptr<User>> const &
|
||||
)> handler_POST_;
|
||||
|
||||
};
|
||||
|
||||
/// <summary>
|
||||
@@ -102,6 +143,35 @@ public:
|
||||
void DELETE_method_handler(const std::shared_ptr<restbed::Session> session);
|
||||
void GET_method_handler(const std::shared_ptr<restbed::Session> session);
|
||||
void PUT_method_handler(const std::shared_ptr<restbed::Session> session);
|
||||
|
||||
void set_handler_DELETE(
|
||||
std::function<std::pair<int, std::string>(
|
||||
std::string const &
|
||||
)> handler
|
||||
);
|
||||
|
||||
void set_handler_GET(
|
||||
std::function<std::pair<int, std::string>(
|
||||
std::string const &
|
||||
)> handler
|
||||
);
|
||||
void set_handler_PUT(
|
||||
std::function<std::pair<int, std::string>(
|
||||
std::string const &, std::shared_ptr<User> const &
|
||||
)> handler
|
||||
);
|
||||
|
||||
private:
|
||||
std::function<std::pair<int, std::string>(
|
||||
std::string const &
|
||||
)> handler_DELETE_;
|
||||
|
||||
std::function<std::pair<int, std::string>(
|
||||
std::string const &
|
||||
)> handler_GET_;
|
||||
std::function<std::pair<int, std::string>(
|
||||
std::string const &, std::shared_ptr<User> const &
|
||||
)> handler_PUT_;
|
||||
};
|
||||
|
||||
/// <summary>
|
||||
@@ -116,6 +186,19 @@ public:
|
||||
UserApiUserLoginResource();
|
||||
virtual ~UserApiUserLoginResource();
|
||||
void GET_method_handler(const std::shared_ptr<restbed::Session> session);
|
||||
|
||||
void set_handler_GET(
|
||||
std::function<std::pair<int, std::string>(
|
||||
std::string const &, std::string const &
|
||||
)> handler
|
||||
);
|
||||
|
||||
|
||||
private:
|
||||
std::function<std::pair<int, std::string>(
|
||||
std::string const &, std::string const &
|
||||
)> handler_GET_;
|
||||
|
||||
};
|
||||
|
||||
/// <summary>
|
||||
@@ -130,6 +213,19 @@ public:
|
||||
UserApiUserLogoutResource();
|
||||
virtual ~UserApiUserLogoutResource();
|
||||
void GET_method_handler(const std::shared_ptr<restbed::Session> session);
|
||||
|
||||
void set_handler_GET(
|
||||
std::function<std::pair<int, std::string>(
|
||||
|
||||
)> handler
|
||||
);
|
||||
|
||||
|
||||
private:
|
||||
std::function<std::pair<int, std::string>(
|
||||
|
||||
)> handler_GET_;
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -2,10 +2,10 @@
|
||||
* 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.
|
||||
*
|
||||
* OpenAPI spec version: 1.0.0
|
||||
* The version of the OpenAPI document: 1.0.0
|
||||
*
|
||||
*
|
||||
* NOTE: This class is auto generated by OpenAPI-Generator 4.0.0-SNAPSHOT.
|
||||
* NOTE: This class is auto generated by OpenAPI-Generator 4.0.1-SNAPSHOT.
|
||||
* https://openapi-generator.tech
|
||||
* Do not edit the class manually.
|
||||
*/
|
||||
|
||||
@@ -2,10 +2,10 @@
|
||||
* 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.
|
||||
*
|
||||
* OpenAPI spec version: 1.0.0
|
||||
* The version of the OpenAPI document: 1.0.0
|
||||
*
|
||||
*
|
||||
* NOTE: This class is auto generated by OpenAPI-Generator 4.0.0-SNAPSHOT.
|
||||
* NOTE: This class is auto generated by OpenAPI-Generator 4.0.1-SNAPSHOT.
|
||||
* https://openapi-generator.tech
|
||||
* Do not edit the class manually.
|
||||
*/
|
||||
|
||||
@@ -2,10 +2,10 @@
|
||||
* 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.
|
||||
*
|
||||
* OpenAPI spec version: 1.0.0
|
||||
* The version of the OpenAPI document: 1.0.0
|
||||
*
|
||||
*
|
||||
* NOTE: This class is auto generated by OpenAPI-Generator 4.0.0-SNAPSHOT.
|
||||
* NOTE: This class is auto generated by OpenAPI-Generator 4.0.1-SNAPSHOT.
|
||||
* https://openapi-generator.tech
|
||||
* Do not edit the class manually.
|
||||
*/
|
||||
|
||||
@@ -2,10 +2,10 @@
|
||||
* 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.
|
||||
*
|
||||
* OpenAPI spec version: 1.0.0
|
||||
* The version of the OpenAPI document: 1.0.0
|
||||
*
|
||||
*
|
||||
* NOTE: This class is auto generated by OpenAPI-Generator 4.0.0-SNAPSHOT.
|
||||
* NOTE: This class is auto generated by OpenAPI-Generator 4.0.1-SNAPSHOT.
|
||||
* https://openapi-generator.tech
|
||||
* Do not edit the class manually.
|
||||
*/
|
||||
|
||||
@@ -2,10 +2,10 @@
|
||||
* 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.
|
||||
*
|
||||
* OpenAPI spec version: 1.0.0
|
||||
* The version of the OpenAPI document: 1.0.0
|
||||
*
|
||||
*
|
||||
* NOTE: This class is auto generated by OpenAPI-Generator 4.0.0-SNAPSHOT.
|
||||
* NOTE: This class is auto generated by OpenAPI-Generator 4.0.1-SNAPSHOT.
|
||||
* https://openapi-generator.tech
|
||||
* Do not edit the class manually.
|
||||
*/
|
||||
|
||||
@@ -2,10 +2,10 @@
|
||||
* 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.
|
||||
*
|
||||
* OpenAPI spec version: 1.0.0
|
||||
* The version of the OpenAPI document: 1.0.0
|
||||
*
|
||||
*
|
||||
* NOTE: This class is auto generated by OpenAPI-Generator 4.0.0-SNAPSHOT.
|
||||
* NOTE: This class is auto generated by OpenAPI-Generator 4.0.1-SNAPSHOT.
|
||||
* https://openapi-generator.tech
|
||||
* Do not edit the class manually.
|
||||
*/
|
||||
|
||||
@@ -2,10 +2,10 @@
|
||||
* 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.
|
||||
*
|
||||
* OpenAPI spec version: 1.0.0
|
||||
* The version of the OpenAPI document: 1.0.0
|
||||
*
|
||||
*
|
||||
* NOTE: This class is auto generated by OpenAPI-Generator 4.0.0-SNAPSHOT.
|
||||
* NOTE: This class is auto generated by OpenAPI-Generator 4.0.1-SNAPSHOT.
|
||||
* https://openapi-generator.tech
|
||||
* Do not edit the class manually.
|
||||
*/
|
||||
|
||||
@@ -2,10 +2,10 @@
|
||||
* 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.
|
||||
*
|
||||
* OpenAPI spec version: 1.0.0
|
||||
* The version of the OpenAPI document: 1.0.0
|
||||
*
|
||||
*
|
||||
* NOTE: This class is auto generated by OpenAPI-Generator 4.0.0-SNAPSHOT.
|
||||
* NOTE: This class is auto generated by OpenAPI-Generator 4.0.1-SNAPSHOT.
|
||||
* https://openapi-generator.tech
|
||||
* Do not edit the class manually.
|
||||
*/
|
||||
|
||||
@@ -2,10 +2,10 @@
|
||||
* 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.
|
||||
*
|
||||
* OpenAPI spec version: 1.0.0
|
||||
* The version of the OpenAPI document: 1.0.0
|
||||
*
|
||||
*
|
||||
* NOTE: This class is auto generated by OpenAPI-Generator 4.0.0-SNAPSHOT.
|
||||
* NOTE: This class is auto generated by OpenAPI-Generator 4.0.1-SNAPSHOT.
|
||||
* https://openapi-generator.tech
|
||||
* Do not edit the class manually.
|
||||
*/
|
||||
|
||||
@@ -2,10 +2,10 @@
|
||||
* 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.
|
||||
*
|
||||
* OpenAPI spec version: 1.0.0
|
||||
* The version of the OpenAPI document: 1.0.0
|
||||
*
|
||||
*
|
||||
* NOTE: This class is auto generated by OpenAPI-Generator 4.0.0-SNAPSHOT.
|
||||
* NOTE: This class is auto generated by OpenAPI-Generator 4.0.1-SNAPSHOT.
|
||||
* https://openapi-generator.tech
|
||||
* Do not edit the class manually.
|
||||
*/
|
||||
|
||||
@@ -2,10 +2,10 @@
|
||||
* 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.
|
||||
*
|
||||
* OpenAPI spec version: 1.0.0
|
||||
* The version of the OpenAPI document: 1.0.0
|
||||
*
|
||||
*
|
||||
* NOTE: This class is auto generated by OpenAPI-Generator 4.0.0-SNAPSHOT.
|
||||
* NOTE: This class is auto generated by OpenAPI-Generator 4.0.1-SNAPSHOT.
|
||||
* https://openapi-generator.tech
|
||||
* Do not edit the class manually.
|
||||
*/
|
||||
|
||||
@@ -2,10 +2,10 @@
|
||||
* 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.
|
||||
*
|
||||
* OpenAPI spec version: 1.0.0
|
||||
* The version of the OpenAPI document: 1.0.0
|
||||
*
|
||||
*
|
||||
* NOTE: This class is auto generated by OpenAPI-Generator 4.0.0-SNAPSHOT.
|
||||
* NOTE: This class is auto generated by OpenAPI-Generator 4.0.1-SNAPSHOT.
|
||||
* https://openapi-generator.tech
|
||||
* Do not edit the class manually.
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user