forked from loafle/openapi-generator-original
[c++ pistache server] Support basic query handling (#943)
Support basic query handling Add helpers for primitive de-serialization Remove warnings due to unneeded commas Deserialize basic types in queries Add dependencies chain for external libraries Fixes wrong parameter passed to API
This commit is contained in:
@@ -11,12 +11,14 @@
|
||||
*/
|
||||
|
||||
#include "PetApi.h"
|
||||
#include "Helpers.h"
|
||||
|
||||
namespace org {
|
||||
namespace openapitools {
|
||||
namespace server {
|
||||
namespace api {
|
||||
|
||||
using namespace org::openapitools::server::helpers;
|
||||
using namespace org::openapitools::server::model;
|
||||
|
||||
PetApi::PetApi(Pistache::Address addr)
|
||||
@@ -94,7 +96,14 @@ void PetApi::delete_pet_handler(const Pistache::Rest::Request &request, Pistache
|
||||
void PetApi::find_pets_by_status_handler(const Pistache::Rest::Request &request, Pistache::Http::ResponseWriter response) {
|
||||
|
||||
// Getting the query params
|
||||
auto status = request.query().get("status");
|
||||
auto statusQuery = request.query().get("status");
|
||||
Pistache::Optional<std::vector<std::string>> status;
|
||||
if(!statusQuery.isEmpty()){
|
||||
std::vector<std::string> value;
|
||||
if(fromStringValue(statusQuery.get(), value)){
|
||||
status = Pistache::Some(value);
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
this->find_pets_by_status(status, response);
|
||||
@@ -108,7 +117,14 @@ void PetApi::find_pets_by_status_handler(const Pistache::Rest::Request &request,
|
||||
void PetApi::find_pets_by_tags_handler(const Pistache::Rest::Request &request, Pistache::Http::ResponseWriter response) {
|
||||
|
||||
// Getting the query params
|
||||
auto tags = request.query().get("tags");
|
||||
auto tagsQuery = request.query().get("tags");
|
||||
Pistache::Optional<std::vector<std::string>> tags;
|
||||
if(!tagsQuery.isEmpty()){
|
||||
std::vector<std::string> value;
|
||||
if(fromStringValue(tagsQuery.get(), value)){
|
||||
tags = Pistache::Some(value);
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
this->find_pets_by_tags(tags, response);
|
||||
|
||||
Reference in New Issue
Block a user