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 @@ -113,6 +113,8 @@ public CppRestClientCodegen() {

supportingFiles.add(new SupportingFile("modelbase-header.mustache", "", "ModelBase.h"));
supportingFiles.add(new SupportingFile("modelbase-source.mustache", "", "ModelBase.cpp"));
supportingFiles.add(new SupportingFile("object-header.mustache", "", "Object.h"));
supportingFiles.add(new SupportingFile("object-source.mustache", "", "Object.cpp"));
supportingFiles.add(new SupportingFile("apiclient-header.mustache", "", "ApiClient.h"));
supportingFiles.add(new SupportingFile("apiclient-source.mustache", "", "ApiClient.cpp"));
supportingFiles.add(new SupportingFile("apiconfiguration-header.mustache", "", "ApiConfiguration.h"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#define {{classname}}_H_

{{{defaultInclude}}}
#include "ApiClient.h"
#include "../ApiClient.h"

{{#imports}}{{{import}}}
{{/imports}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ endif( NOT DEFINED CPPREST_ROOT )
include_directories(${PROJECT_SOURCE_DIR} api model ${CPPREST_INCLUDE_DIR})

#SUPPORTING FILES
set(SUPPORTING_FILES "ApiClient" "ApiConfiguration" "ApiException" "HttpContent" "IHttpBody" "JsonBody" "ModelBase" "MultipartFormData")
set(SUPPORTING_FILES "ApiClient" "ApiConfiguration" "ApiException" "HttpContent" "IHttpBody" "JsonBody" "ModelBase" "MultipartFormData" "Object")
#SOURCE FILES
file(GLOB SOURCE_FILES "api/*" "model/*")

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

{{^parent}}
{{{defaultInclude}}}
#include "ModelBase.h"
#include "../ModelBase.h"
{{/parent}}

{{#imports}}{{{this}}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ public:
static utility::datetime dateFromHttpContent(std::shared_ptr<HttpContent> val);
static bool boolFromHttpContent(std::shared_ptr<HttpContent> val);
static double doubleFromHttpContent(std::shared_ptr<HttpContent> val);
static web::json::value valueFromHttpContent(std::shared_ptr<HttpContent> val);


static utility::string_t toBase64( utility::string_t value );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -355,6 +355,12 @@ double ModelBase::doubleFromHttpContent(std::shared_ptr<HttpContent> val)
return result;
}

web::json::value ModelBase::valueFromHttpContent(std::shared_ptr<HttpContent> val)
{
utility::string_t str = ModelBase::stringFromHttpContent(val);
return web::json::value::parse(str);
}

{{#modelNamespaceDeclarations}}
}
{{/modelNamespaceDeclarations}}
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
{{>licenseInfo}}
/*
* Object.h
*
* This is the implementation of a JSON object.
*/

#ifndef {{modelHeaderGuardPrefix}}_Object_H_
#define {{modelHeaderGuardPrefix}}_Object_H_

{{{defaultInclude}}}
#include "ModelBase.h"

#include <cpprest/details/basic_types.h>
#include <cpprest/json.h>

{{#modelNamespaceDeclarations}}
namespace {{this}} {
{{/modelNamespaceDeclarations}}

class {{declspec}} Object : public ModelBase
{
public:
Object();
virtual ~Object();

/////////////////////////////////////////////
/// ModelBase overrides
void validate() override;

web::json::value toJson() const override;
void fromJson(web::json::value& json) override;

void toMultipart(std::shared_ptr<MultipartFormData> multipart, const utility::string_t& namePrefix) const override;
void fromMultiPart(std::shared_ptr<MultipartFormData> multipart, const utility::string_t& namePrefix) override;

/////////////////////////////////////////////
/// Object manipulation
web::json::value getValue(const utility::string_t& key) const;
void setValue(const utility::string_t& key, const web::json::value& value);

private:
web::json::value m_object;
};

{{#modelNamespaceDeclarations}}
}
{{/modelNamespaceDeclarations}}

#endif /* {{modelHeaderGuardPrefix}}_Object_H_ */
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
{{>licenseInfo}}
#include "Object.h"

{{#modelNamespaceDeclarations}}
namespace {{this}} {
{{/modelNamespaceDeclarations}}

Object::Object()
{
m_object = web::json::value::object();
}

Object::~Object()
{
}

void Object::validate()
{
// TODO: implement validation
}

web::json::value Object::toJson() const
{
return m_object;
}

void Object::fromJson(web::json::value& val)
{
if (val.is_object())
{
m_object = val;
}
}

void Object::toMultipart(std::shared_ptr<MultipartFormData> multipart, const utility::string_t& prefix) const
{
utility::string_t namePrefix = prefix;
if(namePrefix.size() > 0 && namePrefix.substr(namePrefix.size() - 1) != utility::conversions::to_string_t("."))
{
namePrefix += utility::conversions::to_string_t(".");
}
multipart->add(ModelBase::toHttpContent(namePrefix + utility::conversions::to_string_t("object"), m_object));
}

void Object::fromMultiPart(std::shared_ptr<MultipartFormData> multipart, const utility::string_t& prefix)
{
utility::string_t namePrefix = prefix;
if(namePrefix.size() > 0 && namePrefix.substr(namePrefix.size() - 1) != utility::conversions::to_string_t("."))
{
namePrefix += utility::conversions::to_string_t(".");
}

m_object = ModelBase::valueFromHttpContent(multipart->getContent(namePrefix + utility::conversions::to_string_t("object")));
}

web::json::value Object::getValue(const utility::string_t& key) const
{
return m_object.at(key);
}


void Object::setValue(const utility::string_t& key, const web::json::value& value)
{
m_object[key] = value;
}

{{#modelNamespaceDeclarations}}
}
{{/modelNamespaceDeclarations}}
2 changes: 1 addition & 1 deletion samples/client/petstore/cpprest/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ endif( NOT DEFINED CPPREST_ROOT )
include_directories(${PROJECT_SOURCE_DIR} api model ${CPPREST_INCLUDE_DIR})

#SUPPORTING FILES
set(SUPPORTING_FILES "ApiClient" "ApiConfiguration" "ApiException" "HttpContent" "IHttpBody" "JsonBody" "ModelBase" "MultipartFormData")
set(SUPPORTING_FILES "ApiClient" "ApiConfiguration" "ApiException" "HttpContent" "IHttpBody" "JsonBody" "ModelBase" "MultipartFormData" "Object")
#SOURCE FILES
file(GLOB SOURCE_FILES "api/*" "model/*")

Expand Down
6 changes: 6 additions & 0 deletions samples/client/petstore/cpprest/ModelBase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -367,6 +367,12 @@ double ModelBase::doubleFromHttpContent(std::shared_ptr<HttpContent> val)
return result;
}

web::json::value ModelBase::valueFromHttpContent(std::shared_ptr<HttpContent> val)
{
utility::string_t str = ModelBase::stringFromHttpContent(val);
return web::json::value::parse(str);
}

}
}
}
Expand Down
1 change: 1 addition & 0 deletions samples/client/petstore/cpprest/ModelBase.h
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ class ModelBase
static utility::datetime dateFromHttpContent(std::shared_ptr<HttpContent> val);
static bool boolFromHttpContent(std::shared_ptr<HttpContent> val);
static double doubleFromHttpContent(std::shared_ptr<HttpContent> val);
static web::json::value valueFromHttpContent(std::shared_ptr<HttpContent> val);


static utility::string_t toBase64( utility::string_t value );
Expand Down
82 changes: 82 additions & 0 deletions samples/client/petstore/cpprest/Object.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
/**
* Swagger Petstore
* This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key `special-key` to test the authorization filters.
*
* OpenAPI spec version: 1.0.0
* Contact: apiteam@swagger.io
*
* NOTE: This class is auto generated by the swagger code generator 2.3.0-SNAPSHOT.
* https://github.com/swagger-api/swagger-codegen.git
* Do not edit the class manually.
*/

#include "Object.h"

namespace io {
namespace swagger {
namespace client {
namespace model {

Object::Object()
{
m_object = web::json::value::object();
}

Object::~Object()
{
}

void Object::validate()
{
// TODO: implement validation
}

web::json::value Object::toJson() const
{
return m_object;
}

void Object::fromJson(web::json::value& val)
{
if (val.is_object())
{
m_object = val;
}
}

void Object::toMultipart(std::shared_ptr<MultipartFormData> multipart, const utility::string_t& prefix) const
{
utility::string_t namePrefix = prefix;
if(namePrefix.size() > 0 && namePrefix.substr(namePrefix.size() - 1) != utility::conversions::to_string_t("."))
{
namePrefix += utility::conversions::to_string_t(".");
}
multipart->add(ModelBase::toHttpContent(namePrefix + utility::conversions::to_string_t("object"), m_object));
}

void Object::fromMultiPart(std::shared_ptr<MultipartFormData> multipart, const utility::string_t& prefix)
{
utility::string_t namePrefix = prefix;
if(namePrefix.size() > 0 && namePrefix.substr(namePrefix.size() - 1) != utility::conversions::to_string_t("."))
{
namePrefix += utility::conversions::to_string_t(".");
}

m_object = ModelBase::valueFromHttpContent(multipart->getContent(namePrefix + utility::conversions::to_string_t("object")));
}

web::json::value Object::getValue(const utility::string_t& key) const
{
return m_object.at(key);
}


void Object::setValue(const utility::string_t& key, const web::json::value& value)
{
m_object[key] = value;
}

}
}
}
}
63 changes: 63 additions & 0 deletions samples/client/petstore/cpprest/Object.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
/**
* Swagger Petstore
* This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key `special-key` to test the authorization filters.
*
* OpenAPI spec version: 1.0.0
* Contact: apiteam@swagger.io
*
* NOTE: This class is auto generated by the swagger code generator 2.3.0-SNAPSHOT.
* https://github.com/swagger-api/swagger-codegen.git
* Do not edit the class manually.
*/

/*
* Object.h
*
* This is the implementation of a JSON object.
*/

#ifndef _Object_H_
#define _Object_H_


#include "ModelBase.h"

#include <cpprest/details/basic_types.h>
#include <cpprest/json.h>

namespace io {
namespace swagger {
namespace client {
namespace model {

class Object : public ModelBase
{
public:
Object();
virtual ~Object();

/////////////////////////////////////////////
/// ModelBase overrides
void validate() override;

web::json::value toJson() const override;
void fromJson(web::json::value& json) override;

void toMultipart(std::shared_ptr<MultipartFormData> multipart, const utility::string_t& namePrefix) const override;
void fromMultiPart(std::shared_ptr<MultipartFormData> multipart, const utility::string_t& namePrefix) override;

/////////////////////////////////////////////
/// Object manipulation
web::json::value getValue(const utility::string_t& key) const;
void setValue(const utility::string_t& key, const web::json::value& value);

private:
web::json::value m_object;
};

}
}
}
}

#endif /* _Object_H_ */
2 changes: 1 addition & 1 deletion samples/client/petstore/cpprest/api/PetApi.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
#define PetApi_H_


#include "ApiClient.h"
#include "../ApiClient.h"

#include "ApiResponse.h"
#include "HttpContent.h"
Expand Down
2 changes: 1 addition & 1 deletion samples/client/petstore/cpprest/api/StoreApi.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
#define StoreApi_H_


#include "ApiClient.h"
#include "../ApiClient.h"

#include "Order.h"
#include <map>
Expand Down
2 changes: 1 addition & 1 deletion samples/client/petstore/cpprest/api/UserApi.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
#define UserApi_H_


#include "ApiClient.h"
#include "../ApiClient.h"

#include "User.h"
#include <vector>
Expand Down
2 changes: 1 addition & 1 deletion samples/client/petstore/cpprest/model/ApiResponse.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
#define ApiResponse_H_


#include "ModelBase.h"
#include "../ModelBase.h"

#include <cpprest/details/basic_types.h>

Expand Down
2 changes: 1 addition & 1 deletion samples/client/petstore/cpprest/model/Category.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
#define Category_H_


#include "ModelBase.h"
#include "../ModelBase.h"

#include <cpprest/details/basic_types.h>

Expand Down
Loading