add tests for cpp-restsdk client (#21305)

This commit is contained in:
William Cheng 2025-05-20 16:45:49 +08:00 committed by GitHub
parent cdef985ca7
commit 5ec4e4c8f1
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 67 additions and 0 deletions

View File

@ -865,4 +865,13 @@ components:
perPage: perPage:
type: integer type: integer
format: int32 format: int32
reference_test:
type: array
readOnly: true
items:
$ref: "#/components/schemas/UUID"
UUID:
format: "uuid"
pattern: "[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}"
type: "string"

View File

@ -21,6 +21,8 @@
#include "CppRestPetstoreClient/ModelBase.h" #include "CppRestPetstoreClient/ModelBase.h"
#include <cpprest/details/basic_types.h>
#include <vector>
namespace org { namespace org {
namespace openapitools { namespace openapitools {
@ -62,6 +64,11 @@ public:
void unsetPerPage(); void unsetPerPage();
void setPerPage(int32_t value); void setPerPage(int32_t value);
std::vector<utility::string_t> getReferenceTest() const;
bool referenceTestIsSet() const;
void unsetReference_test();
void setReferenceTest(const std::vector<utility::string_t>& value);
protected: protected:
int32_t m_Page; int32_t m_Page;
@ -70,6 +77,9 @@ protected:
int32_t m_PerPage; int32_t m_PerPage;
bool m_PerPageIsSet; bool m_PerPageIsSet;
std::vector<utility::string_t> m_Reference_test;
bool m_Reference_testIsSet;
}; };

View File

@ -24,6 +24,7 @@ Page::Page()
m_PageIsSet = false; m_PageIsSet = false;
m_PerPage = 0; m_PerPage = 0;
m_PerPageIsSet = false; m_PerPageIsSet = false;
m_Reference_testIsSet = false;
} }
Page::~Page() Page::~Page()
@ -48,6 +49,11 @@ web::json::value Page::toJson() const
val[utility::conversions::to_string_t(_XPLATSTR("perPage"))] = ModelBase::toJson(m_PerPage); val[utility::conversions::to_string_t(_XPLATSTR("perPage"))] = ModelBase::toJson(m_PerPage);
} }
if(m_Reference_testIsSet)
{
val[utility::conversions::to_string_t(_XPLATSTR("reference_test"))] = ModelBase::toJson(m_Reference_test);
}
return val; return val;
} }
@ -77,6 +83,17 @@ bool Page::fromJson(const web::json::value& val)
} }
} }
if(val.has_field(utility::conversions::to_string_t(_XPLATSTR("reference_test"))))
{
const web::json::value& fieldValue = val.at(utility::conversions::to_string_t(_XPLATSTR("reference_test")));
if(!fieldValue.is_null())
{
std::vector<utility::string_t> refVal_setReferenceTest;
ok &= ModelBase::fromJson(fieldValue, refVal_setReferenceTest);
setReferenceTest(refVal_setReferenceTest);
}
}
return ok; return ok;
} }
@ -95,6 +112,10 @@ void Page::toMultipart(std::shared_ptr<MultipartFormData> multipart, const utili
{ {
multipart->add(ModelBase::toHttpContent(namePrefix + utility::conversions::to_string_t(_XPLATSTR("perPage")), m_PerPage)); multipart->add(ModelBase::toHttpContent(namePrefix + utility::conversions::to_string_t(_XPLATSTR("perPage")), m_PerPage));
} }
if(m_Reference_testIsSet)
{
multipart->add(ModelBase::toHttpContent(namePrefix + utility::conversions::to_string_t(_XPLATSTR("reference_test")), m_Reference_test));
}
} }
bool Page::fromMultiPart(std::shared_ptr<MultipartFormData> multipart, const utility::string_t& prefix) bool Page::fromMultiPart(std::shared_ptr<MultipartFormData> multipart, const utility::string_t& prefix)
@ -118,6 +139,12 @@ bool Page::fromMultiPart(std::shared_ptr<MultipartFormData> multipart, const uti
ok &= ModelBase::fromHttpContent(multipart->getContent(utility::conversions::to_string_t(_XPLATSTR("perPage"))), refVal_setPerPage ); ok &= ModelBase::fromHttpContent(multipart->getContent(utility::conversions::to_string_t(_XPLATSTR("perPage"))), refVal_setPerPage );
setPerPage(refVal_setPerPage); setPerPage(refVal_setPerPage);
} }
if(multipart->hasContent(utility::conversions::to_string_t(_XPLATSTR("reference_test"))))
{
std::vector<utility::string_t> refVal_setReferenceTest;
ok &= ModelBase::fromHttpContent(multipart->getContent(utility::conversions::to_string_t(_XPLATSTR("reference_test"))), refVal_setReferenceTest );
setReferenceTest(refVal_setReferenceTest);
}
return ok; return ok;
} }
@ -162,6 +189,27 @@ void Page::unsetPerPage()
{ {
m_PerPageIsSet = false; m_PerPageIsSet = false;
} }
std::vector<utility::string_t> Page::getReferenceTest() const
{
return m_Reference_test;
}
void Page::setReferenceTest(const std::vector<utility::string_t>& value)
{
m_Reference_test = value;
m_Reference_testIsSet = true;
}
bool Page::referenceTestIsSet() const
{
return m_Reference_testIsSet;
}
void Page::unsetReference_test()
{
m_Reference_testIsSet = false;
}
} }
} }