forked from loafle/openapi-generator-original
[CppRest] Add Object and fix modelbase includes (#6905)
* Objects are represented by `ModelBase.h`, not `Object.h` which does not exist. * Use correct relative imports for files in the `model` and `api` folders. * [CppRest] Update cpprest petstore client sample. * Implement `Object` class to support arbitrary types. * [CppRest] Update cpprest petstore client sample. * [CppRest] Add newly generated files to petstore client sample. * [CppRest] Add `Object` to CMakeLists.
This commit is contained in:
committed by
William Cheng
parent
d9cea0f97e
commit
acefe3f385
82
samples/client/petstore/cpprest/Object.cpp
Normal file
82
samples/client/petstore/cpprest/Object.cpp
Normal file
@@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user