Skip to content
GitLab
    • Explore Projects Groups Snippets
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • O openapi-generator
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 3,476
    • Issues 3,476
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 402
    • Merge requests 402
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Package Registry
    • Infrastructure Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • OpenAPI Tools
  • openapi-generator
  • Merge requests
  • !2653
An error occurred while fetching the assigned milestone of the selected merge_request.

[C++][Pistache] Fixed #2643

  • Review changes

  • Download
  • Email patches
  • Plain diff
Merged Administrator requested to merge github/fork/SalDiAngelus/master into master 6 years ago
  • Overview 0
  • Commits 5
  • Pipelines 0
  • Changes 37

Created by: SalDiAngelus

Refactored to/from json functions to use universal object serialization method.

PR checklist

  • Read the contribution guidelines.
  • Ran the shell script under ./bin/ to update Petstore sample so that CIs can verify the change. (For instance, only need to run ./bin/{LANG}-petstore.sh, ./bin/openapi3/{LANG}-petstore.sh if updating the {LANG} (e.g. php, ruby, python, etc) code generator or {LANG} client's mustache templates). Windows batch files can be found in .\bin\windows\.
  • Filed the PR against the correct branch: master, 3.4.x, 4.0.x. Default: master.
  • Copied the technical committee to review the pull request if your PR is targeting a particular programming language.

@ravinikam, @stkrwork, @fvarose, @etherealjoy, @MartinDelille

Description of the PR

Purpose is to fix issue #2643 (closed). While I was in there, I saw the mustache file for serialization was more complex than it needed to be so I simplified it by using the to_json and from_json functions that nlohmann/json uses to find custom types to serialize. Removed the ModelBase class because the helper functions weren't needed anymore.

Compare
  • master (base)

and
  • latest version
    b27dd4e5
    5 commits, 2 years ago

37 files
+ 269
- 935

    Preferences

    File browser
    Compare changes
modules/openapi-g‎enerator/src/main‎
java/org/openapitoo‎ls/codegen/languages‎
CppPistacheSer‎verCodegen.java‎ +0 -4
resources/cpp-‎pistache-server‎
README.‎mustache‎ +1 -1
api-sourc‎e.mustache‎ +1 -8
cmake.m‎ustache‎ +0 -1
model-head‎er.mustache‎ +4 -10
model-sour‎ce.mustache‎ +13 -113
modelbase-he‎ader.mustache‎ +0 -127
modelbase-so‎urce.mustache‎ +0 -54
samples/server/pet‎store/cpp-pistache‎
.openapi-‎generator‎
VER‎SION‎ +1 -1
a‎pi‎
PetAp‎i.cpp‎ +6 -12
PetA‎pi.h‎ +4 -4
StoreA‎pi.cpp‎ +3 -6
Store‎Api.h‎ +2 -2
UserA‎pi.cpp‎ +12 -20
User‎Api.h‎ +8 -8
im‎pl‎
PetApiI‎mpl.cpp‎ +2 -2
PetApi‎Impl.h‎ +2 -2
StoreApi‎Impl.cpp‎ +1 -1
StoreAp‎iImpl.h‎ +1 -1
UserApi‎Impl.cpp‎ +4 -4
UserAp‎iImpl.h‎ +4 -4
mo‎del‎
ApiResp‎onse.cpp‎ +21 -30
ApiRes‎ponse.h‎ +4 -10
Catego‎ry.cpp‎ +15 -23
Categ‎ory.h‎ +4 -10
ModelB‎ase.cpp‎ +0 -66
Model‎Base.h‎ +0 -139
Orde‎r.cpp‎ +40 -53
Ord‎er.h‎ +4 -10
Pet‎.cpp‎ +32 -88
Pe‎t.h‎ +4 -10
Tag‎.cpp‎ +15 -23
Ta‎g.h‎ +4 -10
User‎.cpp‎ +52 -66
Use‎r.h‎ +4 -10
CMakeLi‎sts.txt‎ +0 -1
READ‎ME.md‎ +1 -1
modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/CppPistacheServerCodegen.java
+ 0
- 4
  • View file @ b27dd4e5

  • Edit in single-file editor

  • Open in Web IDE


@@ -81,8 +81,6 @@ public class CppPistacheServerCodegen extends AbstractCppCodegen {
reservedWords = new HashSet<>();
supportingFiles.add(new SupportingFile("modelbase-header.mustache", "model", modelNamePrefix + "ModelBase.h"));
supportingFiles.add(new SupportingFile("modelbase-source.mustache", "model", modelNamePrefix + "ModelBase.cpp"));
supportingFiles.add(new SupportingFile("helpers-header.mustache", "model", modelNamePrefix + "Helpers.h"));
supportingFiles.add(new SupportingFile("helpers-source.mustache", "model", modelNamePrefix + "Helpers.cpp"));
supportingFiles.add(new SupportingFile("main-api-server.mustache", "", modelNamePrefix + "main-api-server.cpp"));
@@ -124,8 +122,6 @@ public class CppPistacheServerCodegen extends AbstractCppCodegen {
if (additionalProperties.containsKey("modelNamePrefix")) {
additionalProperties().put("prefix", modelNamePrefix);
supportingFiles.clear();
supportingFiles.add(new SupportingFile("modelbase-header.mustache", "model", modelNamePrefix + "ModelBase.h"));
supportingFiles.add(new SupportingFile("modelbase-source.mustache", "model", modelNamePrefix + "ModelBase.cpp"));
supportingFiles.add(new SupportingFile("helpers-header.mustache", "model", modelNamePrefix + "Helpers.h"));
supportingFiles.add(new SupportingFile("helpers-source.mustache", "model", modelNamePrefix + "Helpers.cpp"));
supportingFiles.add(new SupportingFile("main-api-server.mustache", "", modelNamePrefix + "main-api-server.cpp"));
modules/openapi-generator/src/main/resources/cpp-pistache-server/README.mustache
+ 1
- 1
  • View file @ b27dd4e5

  • Edit in single-file editor

  • Open in Web IDE


@@ -41,7 +41,7 @@ cd build
## Libraries required
- [pistache](http://pistache.io/quickstart)
- [JSON for Modern C++](https://github.com/nlohmann/json/#integration): Please download the `json.hpp` file and
put it under the model folder
put it under the model/nlohmann folder
## Namespaces
{{{apiPackage}}}
modules/openapi-generator/src/main/resources/cpp-pistache-server/api-source.mustache
+ 1
- 8
  • View file @ b27dd4e5

  • Edit in single-file editor

  • Open in Web IDE


@@ -70,14 +70,7 @@ void {{classname}}::{{operationIdSnakeCase}}_handler(const Pistache::Rest::Reque
try {
{{#hasBodyParam}}
{{#bodyParam}}
nlohmann::json request_body = nlohmann::json::parse(request.body());
{{^isPrimitiveType}}{{^isContainer}}
{{paramName}}.fromJson(request_body);
{{/isContainer}}{{/isPrimitiveType}}{{#isContainer}} {{paramName}} = {{#isListContainer}} {{prefix}}ArrayHelper{{/isListContainer}}{{#isMapContainer}} {{prefix}}MapHelper{{/isMapContainer}}::fromJson<{{items.baseType}}>(request_body);{{/isContainer}}
{{#isPrimitiveType}}
// The conversion is done automatically by the json library
{{paramName}} = request_body;
{{/isPrimitiveType}}
nlohmann::json::parse(request.body()).get_to({{paramName}});
{{/bodyParam}}
{{/hasBodyParam}}
this->{{operationIdSnakeCase}}({{#allParams}}{{paramName}}{{#hasMore}}, {{/hasMore}}{{/allParams}}{{#hasParams}}, {{/hasParams}}response);
modules/openapi-generator/src/main/resources/cpp-pistache-server/cmake.mustache
+ 0
- 1
  • View file @ b27dd4e5

  • Edit in single-file editor

  • Open in Web IDE


@@ -20,7 +20,6 @@ ExternalProject_Add(NLOHMANN
)
include_directories(${EXTERNAL_INSTALL_LOCATION}/include)
include_directories(${EXTERNAL_INSTALL_LOCATION}/include/nlohmann)
link_directories(${EXTERNAL_INSTALL_LOCATION}/lib)
{{/addExternalLibs}}
modules/openapi-generator/src/main/resources/cpp-pistache-server/model-header.mustache
+ 4
- 10
  • View file @ b27dd4e5

  • Edit in single-file editor

  • Open in Web IDE


@@ -9,10 +9,9 @@
#define {{classname}}_H_
{{{defaultInclude}}}
#include "{{prefix}}ModelBase.h"
{{#imports}}{{{this}}}
{{/imports}}
#include <nlohmann/json.hpp>
{{#modelNamespaceDeclarations}}
namespace {{this}} {
@@ -22,19 +21,12 @@ namespace {{this}} {
/// {{description}}
/// </summary>
class {{declspec}} {{classname}}
: public {{prefix}}ModelBase
{
public:
{{classname}}();
virtual ~{{classname}}();
/////////////////////////////////////////////
/// {{prefix}}ModelBase overrides
void validate() override;
nlohmann::json toJson() const override;
void fromJson(const nlohmann::json& json) override;
void validate();
/////////////////////////////////////////////
/// {{classname}} members
@@ -51,6 +43,8 @@ public:
{{/required}}
{{/vars}}
friend void to_json(nlohmann::json& j, const {{classname}}& o);
friend void from_json(const nlohmann::json& j, {{classname}}& o);
protected:
{{#vars}}
{{{dataType}}} m_{{name}};
modules/openapi-generator/src/main/resources/cpp-pistache-server/model-source.mustache
+ 13
- 113
  • View file @ b27dd4e5

  • Edit in single-file editor

  • Open in Web IDE


@@ -25,126 +25,26 @@ void {{classname}}::validate()
// TODO: implement validation
}
nlohmann::json {{classname}}::toJson() const
void to_json(nlohmann::json& j, const {{classname}}& o)
{
nlohmann::json val = nlohmann::json::object();
{{#vars}}{{#isPrimitiveType}}{{^isListContainer}}{{^required}}if(m_{{name}}IsSet)
{
val["{{baseName}}"] = m_{{name}};
}
{{/required}}{{#required}}val["{{baseName}}"] = m_{{name}};
{{/required}}{{/isListContainer}}{{/isPrimitiveType}}{{#isListContainer}}{
nlohmann::json jsonArray;
for( const auto& item : m_{{name}} )
{
jsonArray.push_back({{prefix}}ModelBase::toJson(item));
}
{{#required}}val["{{baseName}}"] = jsonArray;
{{/required}}{{^required}}
if(jsonArray.size() > 0)
{
val["{{baseName}}"] = jsonArray;
} {{/required}}
}
{{/isListContainer}}{{#isMapContainer}}{
nlohmann::json jsonObj;
for( const auto& item : m_{{name}} )
{ {{^items.isContainer}}
jsonObj[item.first] = {{prefix}}ModelBase::toJson(item.second);{{/items.isContainer}} {{#items.isListContainer}}
jsonObj[item.first] = {{prefix}}ArrayHelper::toJson<{{{items.items.datatype}}}>(item.second);
{{/items.isListContainer}} {{#items.isMapContainer}}
jsonObj[item.first] = {{prefix}}MapHelper::toJson<{{{items.items.datatype}}}>(item.second); {{/items.isMapContainer}}
}
{{#required}}val["{{baseName}}"] = jsonObj; {{/required}}{{^required}}
if(jsonObj.size() > 0)
{
val["{{baseName}}"] = jsonObj;
} {{/required}}
}
{{/isMapContainer}}{{^isContainer}}{{^isPrimitiveType}}{{^required}}if(m_{{name}}IsSet)
{
val["{{baseName}}"] = {{prefix}}ModelBase::toJson(m_{{name}});
}
{{/required}}{{#required}}val["{{baseName}}"] = {{prefix}}ModelBase::toJson(m_{{name}});
{{/required}}{{/isPrimitiveType}}{{/isContainer}}{{/vars}}
return val;
j = nlohmann::json();
{{#vars}}
{{#required}}j["{{baseName}}"] = o.m_{{name}};{{/required}}{{^required}}if(o.{{nameInCamelCase}}IsSet())
j["{{baseName}}"] = o.m_{{name}};{{/required}}
{{/vars}}
}
void {{classname}}::fromJson(const nlohmann::json& val)
void from_json(const nlohmann::json& j, {{classname}}& o)
{
{{#vars}}{{#isPrimitiveType}}{{^isListContainer}}{{^required}}if(val.find("{{baseName}}") != val.end())
{
{{setter}}(val.at("{{baseName}}"));
}
{{/required}}{{#required}}{{setter}}(val.at("{{baseName}}"));
{{/required}}{{/isListContainer}}{{/isPrimitiveType}}{{#isListContainer}}{
m_{{name}}.clear();
{{^required}}if(val.find("{{baseName}}") != val.end())
{
{{/required}}
for( const auto& item : val["{{baseName}}"] )
{
{{#isPrimitiveType}}m_{{name}}.push_back(item);
{{/isPrimitiveType}}{{^isPrimitiveType}}{{#items.isString}}m_{{name}}.push_back(item);
{{/items.isString}}{{^items.isString}}{{#items.isDateTime}}m_{{name}}.push_back(item);
{{/items.isDateTime}}{{^items.isDateTime}}
if(item.is_null())
{
m_{{name}}.push_back( {{{items.datatype}}}() );
}
else
{
{{{items.datatype}}} newItem;
newItem.fromJson(item);
m_{{name}}.push_back( newItem );
}
{{/items.isDateTime}}{{/items.isString}}{{/isPrimitiveType}}
}
{{^required}}
}
{{/required}}
}
{{/isListContainer}}{{#isMapContainer}}{
m_{{name}}.clear();
{{^required}}if(val.find("{{baseName}}") != val.end())
{
{{/required}}
if(val["{{baseName}}"].is_object()) { {{^items.isContainer}}
m_{{name}} = {{prefix}}MapHelper::fromJson<{{{items.datatype}}}>(val["{{baseName}}"]);
{{/items.isContainer}} {{#items.isContainer}}
for( const auto& item : val["{{baseName}}"].items() )
{ {{#items.isMapContainer}}
{{{items.datatype}}} newItem = {{prefix}}MapHelper::fromJson<{{{items.items.datatype}}}>(item.value());
{{/items.isMapContainer}}{{#items.isListContainer}}
{{{items.datatype}}} newItem = {{prefix}}ArrayHelper::fromJson<{{{items.items.datatype}}}>(item.value());
{{/items.isListContainer}}
m_{{name}}.insert(m_{{name}}.end(), std::pair< std::string, {{{items.datatype}}} >(item.key(), newItem));
} {{/items.isContainer}}
}
{{^required}}
}
{{/required}}
}
{{/isMapContainer}}{{^isContainer}}{{^isPrimitiveType}}{{^required}}if(val.find("{{baseName}}") != val.end())
{{#vars}}
{{#required}}j.at("{{baseName}}").get_to(o.m_{{name}});{{/required}}{{^required}}if(!j.at("{{baseName}}").is_null())
{
{{#isString}}{{setter}}(val.at("{{baseName}}"));{{/isString}}{{#isByteArray}}{{setter}}(val.at("{{baseName}}"));{{/isByteArray}}{{#isBinary}}{{setter}}(val.at("{{baseName}}"));
{{/isBinary}}{{^isString}}{{#isDateTime}}{{setter}}(val.at("{{baseName}}"));
{{/isDateTime}}{{^isDateTime}}{{^isByteArray}}{{^isBinary}}if(!val["{{baseName}}"].is_null())
{
{{{dataType}}} newItem;
newItem.fromJson(val["{{baseName}}"]);
{{setter}}( newItem );
}
{{/isBinary}}{{/isByteArray}}{{/isDateTime}}{{/isString}}
}
{{/required}}{{#required}}{{#isString}}{{setter}}(val.at("{{baseName}}"));
{{/isString}}{{^isString}}{{#isDateTime}}{{setter}}(val.at("{{baseName}}"));
{{/isDateTime}}{{/isString}}{{/required}}{{/isPrimitiveType}}{{/isContainer}}{{/vars}}
j.at("{{baseName}}").get_to(o.m_{{name}});
o.m_{{name}}IsSet = true;
} {{/required}}
{{/vars}}
}
{{#vars}}{{#isContainer}}{{{dataType}}}& {{classname}}::{{getter}}()
{
return m_{{name}};
modules/openapi-generator/src/main/resources/cpp-pistache-server/modelbase-header.mustache deleted 100644 → 0
+ 0
- 127
  • View file @ b426bab8

{{>licenseInfo}}
/*
* {{prefix}}ModelBase.h
*
* This is the base class for all model classes
*/
#ifndef {{prefix}}ModelBase_H_
#define {{prefix}}ModelBase_H_
{{{defaultInclude}}}
#include "json.hpp"
#include <ctime>
#include <string>
#include <vector>
#include <map>
{{#modelNamespaceDeclarations}}
namespace {{this}} {
{{/modelNamespaceDeclarations}}
class {{declspec}} {{prefix}}ModelBase
{
public:
{{prefix}}ModelBase();
virtual ~{{prefix}}ModelBase();
virtual void validate() = 0;
virtual nlohmann::json toJson() const = 0;
virtual void fromJson(const nlohmann::json& json) = 0;
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({{prefix}}ModelBase const& content );
};
class {{prefix}}ArrayHelper {
private:
template<typename T, typename std::enable_if<!std::is_base_of<ModelBase, T>::value>::value>
static void itemFromJson(T& item, const nlohmann::json& json){
item = json;
}
static void itemFromJson(ModelBase& item, const nlohmann::json& json){
item.fromJson(json);
}
template<typename T, typename std::enable_if<!std::is_base_of<ModelBase, T>::value>::value>
static nlohmann::json itemtoJson(const T& item){
return item;
}
static nlohmann::json itemtoJson(const ModelBase& item){
return item.toJson();
}
public:
template<typename T>
static std::vector<T> fromJson(const nlohmann::json& json) {
std::vector<T> val;
if (!json.empty()) {
for (const auto& item : json.items()) {
T entry;
itemFromJson(entry, item.value());
val.push_back(entry);
}
}
return val;
}
template<typename T>
static nlohmann::json toJson(const std::vector<T>& val) {
nlohmann::json json;
for(const auto& item : val){
json.push_back(itemtoJson(item));
}
return json;
}
};
class {{prefix}}MapHelper {
private:
template<typename T, typename std::enable_if<!std::is_base_of<ModelBase, T>::value>::value>
static void itemFromJson(T &item, const nlohmann::json& json){
item = json;
}
static void itemFromJson(ModelBase &item, const nlohmann::json& json){
item.fromJson(json);
}
template<typename T, typename std::enable_if<!std::is_base_of<ModelBase, T>::value>::value>
static nlohmann::json itemtoJson(const T& item){
return item;
}
static nlohmann::json itemtoJson(const ModelBase& item){
return item.toJson();
}
public:
template<typename T>
static std::map<std::string, T> fromJson(const nlohmann::json& json) {
std::map<std::string, T> val;
if (!json.empty()) {
for (const auto& item : json.items()) {
T entry;
itemfromJson(entry, item.value());
val.insert(val.end(),
std::pair<std::string, T>(item.key(), entry));
}
}
return val;
}
template<typename T>
static nlohmann::json toJson(const std::map<std::string, T>& val) {
nlohmann::json json;
for (const auto& item : val) {
nlohmann::json jitem = itemtoJson(item.second);
json[item.first] = jitem;
}
return json;
}
};
{{#modelNamespaceDeclarations}}
}
{{/modelNamespaceDeclarations}}
#endif /* {{prefix}}ModelBase_H_ */
modules/openapi-generator/src/main/resources/cpp-pistache-server/modelbase-source.mustache deleted 100644 → 0
+ 0
- 54
  • View file @ b426bab8

{{>licenseInfo}}
#include "{{prefix}}ModelBase.h"
{{#modelNamespaceDeclarations}}
namespace {{this}} {
{{/modelNamespaceDeclarations}}
{{prefix}}ModelBase::{{prefix}}ModelBase()
{
}
{{prefix}}ModelBase::~{{prefix}}ModelBase()
{
}
std::string {{prefix}}ModelBase::toJson( std::string const& value )
{
return value;
}
std::string {{prefix}}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 {{prefix}}ModelBase::toJson( int32_t const value )
{
return value;
}
int64_t {{prefix}}ModelBase::toJson( int64_t const value )
{
return value;
}
double {{prefix}}ModelBase::toJson( double const value )
{
return value;
}
bool {{prefix}}ModelBase::toJson( bool const value )
{
return value;
}
nlohmann::json {{prefix}}ModelBase::toJson({{prefix}}ModelBase const& content )
{
return content.toJson();
}
{{#modelNamespaceDeclarations}}
}
{{/modelNamespaceDeclarations}}
samples/server/petstore/cpp-pistache/.openapi-generator/VERSION
+ 1
- 1
  • View file @ b27dd4e5

  • Edit in single-file editor

  • Open in Web IDE

3.1.2-SNAPSHOT
\ No newline at end of file
4.0.0-SNAPSHOT
\ No newline at end of file
samples/server/petstore/cpp-pistache/api/PetApi.cpp
+ 6
- 12
  • View file @ b27dd4e5

  • Edit in single-file editor

  • Open in Web IDE


@@ -49,14 +49,11 @@ void PetApi::add_pet_handler(const Pistache::Rest::Request &request, Pistache::H
// Getting the body param
Pet pet;
Pet body;
try {
nlohmann::json request_body = nlohmann::json::parse(request.body());
pet.fromJson(request_body);
this->add_pet(pet, response);
nlohmann::json::parse(request.body()).get_to(body);
this->add_pet(body, response);
} catch (std::runtime_error & e) {
//send a 400 error
response.send(Pistache::Http::Code::Bad_Request, e.what());
@@ -139,14 +136,11 @@ void PetApi::update_pet_handler(const Pistache::Rest::Request &request, Pistache
// Getting the body param
Pet pet;
Pet body;
try {
nlohmann::json request_body = nlohmann::json::parse(request.body());
pet.fromJson(request_body);
this->update_pet(pet, response);
nlohmann::json::parse(request.body()).get_to(body);
this->update_pet(body, response);
} catch (std::runtime_error & e) {
//send a 400 error
response.send(Pistache::Http::Code::Bad_Request, e.what());
samples/server/petstore/cpp-pistache/api/PetApi.h
+ 4
- 4
  • View file @ b27dd4e5

  • Edit in single-file editor

  • Open in Web IDE


@@ -65,8 +65,8 @@ private:
/// <remarks>
///
/// </remarks>
/// <param name="pet">Pet object that needs to be added to the store</param>
virtual void add_pet(const Pet &pet, Pistache::Http::ResponseWriter &response) = 0;
/// <param name="body">Pet object that needs to be added to the store</param>
virtual void add_pet(const Pet &body, Pistache::Http::ResponseWriter &response) = 0;
/// <summary>
/// Deletes a pet
@@ -111,8 +111,8 @@ private:
/// <remarks>
///
/// </remarks>
/// <param name="pet">Pet object that needs to be added to the store</param>
virtual void update_pet(const Pet &pet, Pistache::Http::ResponseWriter &response) = 0;
/// <param name="body">Pet object that needs to be added to the store</param>
virtual void update_pet(const Pet &body, Pistache::Http::ResponseWriter &response) = 0;
/// <summary>
/// Updates a pet in the store with form data
samples/server/petstore/cpp-pistache/api/StoreApi.cpp
+ 3
- 6
  • View file @ b27dd4e5

  • Edit in single-file editor

  • Open in Web IDE


@@ -82,14 +82,11 @@ void StoreApi::place_order_handler(const Pistache::Rest::Request &request, Pista
// Getting the body param
Order order;
Order body;
try {
nlohmann::json request_body = nlohmann::json::parse(request.body());
order.fromJson(request_body);
this->place_order(order, response);
nlohmann::json::parse(request.body()).get_to(body);
this->place_order(body, response);
} catch (std::runtime_error & e) {
//send a 400 error
response.send(Pistache::Http::Code::Bad_Request, e.what());
0 Assignees
None
Assign to
0 Reviewers
None
Request review from
Labels
0
None
0
None
    Assign labels
  • Manage project labels

Milestone
No milestone
None
None
Time tracking
No estimate or time spent
Lock merge request
Unlocked
0
0 participants
Reference:
Source branch: github/fork/SalDiAngelus/master

Menu

Explore Projects Groups Snippets