Skip to content

Add tests for cpp-restsdk client #21305

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 20, 2025
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 @@ -865,4 +865,13 @@ components:
perPage:
type: integer
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"

Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@

#include "CppRestPetstoreClient/ModelBase.h"

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

namespace org {
namespace openapitools {
Expand Down Expand Up @@ -62,6 +64,11 @@ class Page
void unsetPerPage();
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:
int32_t m_Page;
Expand All @@ -70,6 +77,9 @@ class Page
int32_t m_PerPage;
bool m_PerPageIsSet;

std::vector<utility::string_t> m_Reference_test;
bool m_Reference_testIsSet;

};


Expand Down
48 changes: 48 additions & 0 deletions samples/client/petstore/cpp-restsdk/client/src/model/Page.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ Page::Page()
m_PageIsSet = false;
m_PerPage = 0;
m_PerPageIsSet = false;
m_Reference_testIsSet = false;
}

Page::~Page()
Expand All @@ -48,6 +49,11 @@ web::json::value Page::toJson() const

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;
}
Expand Down Expand Up @@ -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;
}

Expand All @@ -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));
}
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)
Expand All @@ -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 );
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;
}

Expand Down Expand Up @@ -162,6 +189,27 @@ void Page::unsetPerPage()
{
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;
}

}
}
Expand Down
Loading