forked from loafle/openapi-generator-original
update samples
This commit is contained in:
parent
19c854b113
commit
e8742e8850
@ -75,6 +75,7 @@ public:
|
||||
static web::json::value toJson( const std::shared_ptr<HttpContent>& val );
|
||||
template<typename T>
|
||||
static web::json::value toJson( const std::shared_ptr<T>& val );
|
||||
static web::json::value toJson( const std::shared_ptr<utility::datetime>& val );
|
||||
template<typename T>
|
||||
static web::json::value toJson( const std::vector<T>& val );
|
||||
template<typename T>
|
||||
@ -91,6 +92,7 @@ public:
|
||||
static bool fromString( const utility::string_t& val, std::shared_ptr<HttpContent> & );
|
||||
template<typename T>
|
||||
static bool fromString( const utility::string_t& val, std::shared_ptr<T>& );
|
||||
static bool fromString( const utility::string_t& val, std::shared_ptr<utility::datetime>& outVal );
|
||||
template<typename T>
|
||||
static bool fromString( const utility::string_t& val, std::vector<T> & );
|
||||
template<typename T>
|
||||
@ -107,6 +109,7 @@ public:
|
||||
static bool fromJson( const web::json::value& val, std::shared_ptr<HttpContent> & );
|
||||
template<typename T>
|
||||
static bool fromJson( const web::json::value& val, std::shared_ptr<T>& );
|
||||
static bool fromJson( const web::json::value& val, std::shared_ptr<utility::datetime> &outVal );
|
||||
template<typename T>
|
||||
static bool fromJson( const web::json::value& val, std::vector<T> & );
|
||||
template<typename T>
|
||||
@ -124,6 +127,7 @@ public:
|
||||
static std::shared_ptr<HttpContent> toHttpContent( const utility::string_t& name, const std::shared_ptr<HttpContent>& );
|
||||
template <typename T>
|
||||
static std::shared_ptr<HttpContent> toHttpContent( const utility::string_t& name, const std::shared_ptr<T>& , const utility::string_t& contentType = utility::conversions::to_string_t("application/json") );
|
||||
static std::shared_ptr<HttpContent> toHttpContent(const utility::string_t& name, const std::shared_ptr<utility::datetime>& value , const utility::string_t& contentType = utility::conversions::to_string_t("application/json") );
|
||||
template <typename T>
|
||||
static std::shared_ptr<HttpContent> toHttpContent( const utility::string_t& name, const std::vector<T>& value, const utility::string_t& contentType = utility::conversions::to_string_t("") );
|
||||
template <typename T>
|
||||
|
@ -123,6 +123,15 @@ web::json::value ModelBase::toJson( const std::shared_ptr<HttpContent>& content
|
||||
}
|
||||
return value;
|
||||
}
|
||||
web::json::value ModelBase::toJson( const std::shared_ptr<utility::datetime>& val )
|
||||
{
|
||||
web::json::value retVal;
|
||||
if(val != nullptr)
|
||||
{
|
||||
retVal = toJson(*val);
|
||||
}
|
||||
return retVal;
|
||||
}
|
||||
bool ModelBase::fromString( const utility::string_t& val, bool &outVal )
|
||||
{
|
||||
utility::stringstream_t ss(val);
|
||||
@ -253,6 +262,19 @@ bool ModelBase::fromString( const utility::string_t& val, std::shared_ptr<HttpCo
|
||||
}
|
||||
return ok;
|
||||
}
|
||||
bool ModelBase::fromString( const utility::string_t& val, std::shared_ptr<utility::datetime>& outVal )
|
||||
{
|
||||
bool ok = false;
|
||||
if(outVal == nullptr)
|
||||
{
|
||||
outVal = std::shared_ptr<utility::datetime>(new utility::datetime());
|
||||
}
|
||||
if( outVal != nullptr )
|
||||
{
|
||||
ok = fromJson(web::json::value::parse(val), *outVal);
|
||||
}
|
||||
return ok;
|
||||
}
|
||||
bool ModelBase::fromJson( const web::json::value& val, bool & outVal )
|
||||
{
|
||||
outVal = !val.is_boolean() ? false : val.as_bool();
|
||||
@ -330,6 +352,19 @@ bool ModelBase::fromJson( const web::json::value& val, std::shared_ptr<HttpConte
|
||||
}
|
||||
return result;
|
||||
}
|
||||
bool ModelBase::fromJson( const web::json::value& val, std::shared_ptr<utility::datetime> &outVal )
|
||||
{
|
||||
bool ok = false;
|
||||
if(outVal == nullptr)
|
||||
{
|
||||
outVal = std::shared_ptr<utility::datetime>(new utility::datetime());
|
||||
}
|
||||
if( outVal != nullptr )
|
||||
{
|
||||
ok = fromJson(val, *outVal);
|
||||
}
|
||||
return ok;
|
||||
}
|
||||
std::shared_ptr<HttpContent> ModelBase::toHttpContent( const utility::string_t& name, bool value, const utility::string_t& contentType )
|
||||
{
|
||||
std::shared_ptr<HttpContent> content( new HttpContent );
|
||||
@ -425,6 +460,18 @@ std::shared_ptr<HttpContent> ModelBase::toHttpContent( const utility::string_t&
|
||||
}
|
||||
return content;
|
||||
}
|
||||
std::shared_ptr<HttpContent> ModelBase::toHttpContent(const utility::string_t& name, const std::shared_ptr<utility::datetime>& value , const utility::string_t& contentType )
|
||||
{
|
||||
std::shared_ptr<HttpContent> content( new HttpContent );
|
||||
if (value != nullptr )
|
||||
{
|
||||
content->setName( name );
|
||||
content->setContentDisposition( utility::conversions::to_string_t("form-data") );
|
||||
content->setContentType( contentType );
|
||||
content->setData( std::shared_ptr<std::istream>( new std::stringstream( utility::conversions::to_utf8string( toJson(*value).serialize() ) ) ) );
|
||||
}
|
||||
return content;
|
||||
}
|
||||
bool ModelBase::fromHttpContent(std::shared_ptr<HttpContent> val, bool & outVal )
|
||||
{
|
||||
utility::string_t str;
|
||||
|
Loading…
x
Reference in New Issue
Block a user