Skip to content
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

Fix multiple bugs in generated cpprest client code #9905

Merged
merged 5 commits into from
Dec 13, 2019
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 @@ -36,6 +36,7 @@ public:
void setConfiguration(std::shared_ptr<ApiConfiguration> configuration);

static utility::string_t parameterToString(utility::string_t value);
static utility::string_t parameterToString(bool value);
static utility::string_t parameterToString(int32_t value);
static utility::string_t parameterToString(int64_t value);
static utility::string_t parameterToString(float value);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,14 @@ utility::string_t ApiClient::parameterToString(utility::string_t value)
{
return value;
}

utility::string_t ApiClient::parameterToString(bool value)
{
std::stringstream valueAsStringStream;
valueAsStringStream << (value ? "true" : "false");
return utility::conversions::to_string_t(valueAsStringStream.str());
}

utility::string_t ApiClient::parameterToString(int64_t value)
{
std::stringstream valueAsStringStream;
Expand Down Expand Up @@ -132,7 +140,20 @@ pplx::task<web::http::http_response> ApiClient::callApi(
if (!formParams.empty())
{
request.set_body(body_data);
}
}
}
else if (contentType == utility::conversions::to_string_t("multipart/form-data"))
{
MultipartFormData uploadData;
for (auto& kvp : formParams)
{
uploadData.add(ModelBase::toHttpContent(kvp.first, kvp.second));
}
std::stringstream data;
uploadData.writeTo(data);
auto bodyString = data.str();
auto length = bodyString.size();
request.set_body(concurrency::streams::bytestream::open_istream(std::move(bodyString)), length, utility::conversions::to_string_t("multipart/form-data; boundary=") + uploadData.getBoundary());
}
else
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ void MultipartFormData::writeTo( std::ostream& target )
std::shared_ptr<HttpContent> content = m_Contents[i];

// boundary
target << "\r\n" << "--" << utility::conversions::to_utf8string( m_Boundary ) << "\r\n";
target << (i > 0 ? "\r\n" : "") << "--" << utility::conversions::to_utf8string( m_Boundary ) << "\r\n";

// headers
target << "Content-Disposition: " << utility::conversions::to_utf8string( content->getContentDisposition() );
Expand Down
2 changes: 1 addition & 1 deletion samples/client/petstore/cpprest/.swagger-codegen/VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.4.3-SNAPSHOT
2.4.11-SNAPSHOT
25 changes: 23 additions & 2 deletions samples/client/petstore/cpprest/ApiClient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* OpenAPI spec version: 1.0.0
* Contact: [email protected]
*
* NOTE: This class is auto generated by the swagger code generator 2.4.3-SNAPSHOT.
* NOTE: This class is auto generated by the swagger code generator 2.4.11-SNAPSHOT.
* https://github.com/swagger-api/swagger-codegen.git
* Do not edit the class manually.
*/
Expand Down Expand Up @@ -43,6 +43,14 @@ utility::string_t ApiClient::parameterToString(utility::string_t value)
{
return value;
}

utility::string_t ApiClient::parameterToString(bool value)
{
std::stringstream valueAsStringStream;
valueAsStringStream << (value ? "true" : "false");
return utility::conversions::to_string_t(valueAsStringStream.str());
}

utility::string_t ApiClient::parameterToString(int64_t value)
{
std::stringstream valueAsStringStream;
Expand Down Expand Up @@ -144,7 +152,20 @@ pplx::task<web::http::http_response> ApiClient::callApi(
if (!formParams.empty())
{
request.set_body(body_data);
}
}
}
else if (contentType == utility::conversions::to_string_t("multipart/form-data"))
{
MultipartFormData uploadData;
for (auto& kvp : formParams)
{
uploadData.add(ModelBase::toHttpContent(kvp.first, kvp.second));
}
std::stringstream data;
uploadData.writeTo(data);
auto bodyString = data.str();
auto length = bodyString.size();
request.set_body(concurrency::streams::bytestream::open_istream(std::move(bodyString)), length, utility::conversions::to_string_t("multipart/form-data; boundary=") + uploadData.getBoundary());
}
else
{
Expand Down
3 changes: 2 additions & 1 deletion samples/client/petstore/cpprest/ApiClient.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* OpenAPI spec version: 1.0.0
* Contact: [email protected]
*
* NOTE: This class is auto generated by the swagger code generator 2.4.3-SNAPSHOT.
* NOTE: This class is auto generated by the swagger code generator 2.4.11-SNAPSHOT.
* https://github.com/swagger-api/swagger-codegen.git
* Do not edit the class manually.
*/
Expand Down Expand Up @@ -48,6 +48,7 @@ class ApiClient
void setConfiguration(std::shared_ptr<ApiConfiguration> configuration);

static utility::string_t parameterToString(utility::string_t value);
static utility::string_t parameterToString(bool value);
static utility::string_t parameterToString(int32_t value);
static utility::string_t parameterToString(int64_t value);
static utility::string_t parameterToString(float value);
Expand Down
2 changes: 1 addition & 1 deletion samples/client/petstore/cpprest/ApiConfiguration.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* OpenAPI spec version: 1.0.0
* Contact: [email protected]
*
* NOTE: This class is auto generated by the swagger code generator 2.4.3-SNAPSHOT.
* NOTE: This class is auto generated by the swagger code generator 2.4.11-SNAPSHOT.
* https://github.com/swagger-api/swagger-codegen.git
* Do not edit the class manually.
*/
Expand Down
2 changes: 1 addition & 1 deletion samples/client/petstore/cpprest/ApiConfiguration.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* OpenAPI spec version: 1.0.0
* Contact: [email protected]
*
* NOTE: This class is auto generated by the swagger code generator 2.4.3-SNAPSHOT.
* NOTE: This class is auto generated by the swagger code generator 2.4.11-SNAPSHOT.
* https://github.com/swagger-api/swagger-codegen.git
* Do not edit the class manually.
*/
Expand Down
2 changes: 1 addition & 1 deletion samples/client/petstore/cpprest/ApiException.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* OpenAPI spec version: 1.0.0
* Contact: [email protected]
*
* NOTE: This class is auto generated by the swagger code generator 2.4.3-SNAPSHOT.
* NOTE: This class is auto generated by the swagger code generator 2.4.11-SNAPSHOT.
* https://github.com/swagger-api/swagger-codegen.git
* Do not edit the class manually.
*/
Expand Down
2 changes: 1 addition & 1 deletion samples/client/petstore/cpprest/ApiException.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* OpenAPI spec version: 1.0.0
* Contact: [email protected]
*
* NOTE: This class is auto generated by the swagger code generator 2.4.3-SNAPSHOT.
* NOTE: This class is auto generated by the swagger code generator 2.4.11-SNAPSHOT.
* https://github.com/swagger-api/swagger-codegen.git
* Do not edit the class manually.
*/
Expand Down
2 changes: 1 addition & 1 deletion samples/client/petstore/cpprest/HttpContent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* OpenAPI spec version: 1.0.0
* Contact: [email protected]
*
* NOTE: This class is auto generated by the swagger code generator 2.4.3-SNAPSHOT.
* NOTE: This class is auto generated by the swagger code generator 2.4.11-SNAPSHOT.
* https://github.com/swagger-api/swagger-codegen.git
* Do not edit the class manually.
*/
Expand Down
2 changes: 1 addition & 1 deletion samples/client/petstore/cpprest/HttpContent.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* OpenAPI spec version: 1.0.0
* Contact: [email protected]
*
* NOTE: This class is auto generated by the swagger code generator 2.4.3-SNAPSHOT.
* NOTE: This class is auto generated by the swagger code generator 2.4.11-SNAPSHOT.
* https://github.com/swagger-api/swagger-codegen.git
* Do not edit the class manually.
*/
Expand Down
2 changes: 1 addition & 1 deletion samples/client/petstore/cpprest/IHttpBody.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* OpenAPI spec version: 1.0.0
* Contact: [email protected]
*
* NOTE: This class is auto generated by the swagger code generator 2.4.3-SNAPSHOT.
* NOTE: This class is auto generated by the swagger code generator 2.4.11-SNAPSHOT.
* https://github.com/swagger-api/swagger-codegen.git
* Do not edit the class manually.
*/
Expand Down
2 changes: 1 addition & 1 deletion samples/client/petstore/cpprest/JsonBody.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* OpenAPI spec version: 1.0.0
* Contact: [email protected]
*
* NOTE: This class is auto generated by the swagger code generator 2.4.3-SNAPSHOT.
* NOTE: This class is auto generated by the swagger code generator 2.4.11-SNAPSHOT.
* https://github.com/swagger-api/swagger-codegen.git
* Do not edit the class manually.
*/
Expand Down
2 changes: 1 addition & 1 deletion samples/client/petstore/cpprest/JsonBody.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* OpenAPI spec version: 1.0.0
* Contact: [email protected]
*
* NOTE: This class is auto generated by the swagger code generator 2.4.3-SNAPSHOT.
* NOTE: This class is auto generated by the swagger code generator 2.4.11-SNAPSHOT.
* https://github.com/swagger-api/swagger-codegen.git
* Do not edit the class manually.
*/
Expand Down
2 changes: 1 addition & 1 deletion samples/client/petstore/cpprest/ModelBase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* OpenAPI spec version: 1.0.0
* Contact: [email protected]
*
* NOTE: This class is auto generated by the swagger code generator 2.4.3-SNAPSHOT.
* NOTE: This class is auto generated by the swagger code generator 2.4.11-SNAPSHOT.
* https://github.com/swagger-api/swagger-codegen.git
* Do not edit the class manually.
*/
Expand Down
2 changes: 1 addition & 1 deletion samples/client/petstore/cpprest/ModelBase.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* OpenAPI spec version: 1.0.0
* Contact: [email protected]
*
* NOTE: This class is auto generated by the swagger code generator 2.4.3-SNAPSHOT.
* NOTE: This class is auto generated by the swagger code generator 2.4.11-SNAPSHOT.
* https://github.com/swagger-api/swagger-codegen.git
* Do not edit the class manually.
*/
Expand Down
4 changes: 2 additions & 2 deletions samples/client/petstore/cpprest/MultipartFormData.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* OpenAPI spec version: 1.0.0
* Contact: [email protected]
*
* NOTE: This class is auto generated by the swagger code generator 2.4.3-SNAPSHOT.
* NOTE: This class is auto generated by the swagger code generator 2.4.11-SNAPSHOT.
* https://github.com/swagger-api/swagger-codegen.git
* Do not edit the class manually.
*/
Expand Down Expand Up @@ -71,7 +71,7 @@ void MultipartFormData::writeTo( std::ostream& target )
std::shared_ptr<HttpContent> content = m_Contents[i];

// boundary
target << "\r\n" << "--" << utility::conversions::to_utf8string( m_Boundary ) << "\r\n";
target << (i > 0 ? "\r\n" : "") << "--" << utility::conversions::to_utf8string( m_Boundary ) << "\r\n";

// headers
target << "Content-Disposition: " << utility::conversions::to_utf8string( content->getContentDisposition() );
Expand Down
2 changes: 1 addition & 1 deletion samples/client/petstore/cpprest/MultipartFormData.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* OpenAPI spec version: 1.0.0
* Contact: [email protected]
*
* NOTE: This class is auto generated by the swagger code generator 2.4.3-SNAPSHOT.
* NOTE: This class is auto generated by the swagger code generator 2.4.11-SNAPSHOT.
* https://github.com/swagger-api/swagger-codegen.git
* Do not edit the class manually.
*/
Expand Down
2 changes: 1 addition & 1 deletion samples/client/petstore/cpprest/Object.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* OpenAPI spec version: 1.0.0
* Contact: [email protected]
*
* NOTE: This class is auto generated by the swagger code generator 2.4.3-SNAPSHOT.
* NOTE: This class is auto generated by the swagger code generator 2.4.11-SNAPSHOT.
* https://github.com/swagger-api/swagger-codegen.git
* Do not edit the class manually.
*/
Expand Down
2 changes: 1 addition & 1 deletion samples/client/petstore/cpprest/Object.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* OpenAPI spec version: 1.0.0
* Contact: [email protected]
*
* NOTE: This class is auto generated by the swagger code generator 2.4.3-SNAPSHOT.
* NOTE: This class is auto generated by the swagger code generator 2.4.11-SNAPSHOT.
* https://github.com/swagger-api/swagger-codegen.git
* Do not edit the class manually.
*/
Expand Down
2 changes: 1 addition & 1 deletion samples/client/petstore/cpprest/api/PetApi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* OpenAPI spec version: 1.0.0
* Contact: [email protected]
*
* NOTE: This class is auto generated by the swagger code generator 2.4.3-SNAPSHOT.
* NOTE: This class is auto generated by the swagger code generator 2.4.11-SNAPSHOT.
* https://github.com/swagger-api/swagger-codegen.git
* Do not edit the class manually.
*/
Expand Down
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 @@ -5,7 +5,7 @@
* OpenAPI spec version: 1.0.0
* Contact: [email protected]
*
* NOTE: This class is auto generated by the swagger code generator 2.4.3-SNAPSHOT.
* NOTE: This class is auto generated by the swagger code generator 2.4.11-SNAPSHOT.
* https://github.com/swagger-api/swagger-codegen.git
* Do not edit the class manually.
*/
Expand Down
2 changes: 1 addition & 1 deletion samples/client/petstore/cpprest/api/StoreApi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* OpenAPI spec version: 1.0.0
* Contact: [email protected]
*
* NOTE: This class is auto generated by the swagger code generator 2.4.3-SNAPSHOT.
* NOTE: This class is auto generated by the swagger code generator 2.4.11-SNAPSHOT.
* https://github.com/swagger-api/swagger-codegen.git
* Do not edit the class manually.
*/
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 @@ -5,7 +5,7 @@
* OpenAPI spec version: 1.0.0
* Contact: [email protected]
*
* NOTE: This class is auto generated by the swagger code generator 2.4.3-SNAPSHOT.
* NOTE: This class is auto generated by the swagger code generator 2.4.11-SNAPSHOT.
* https://github.com/swagger-api/swagger-codegen.git
* Do not edit the class manually.
*/
Expand Down
2 changes: 1 addition & 1 deletion samples/client/petstore/cpprest/api/UserApi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* OpenAPI spec version: 1.0.0
* Contact: [email protected]
*
* NOTE: This class is auto generated by the swagger code generator 2.4.3-SNAPSHOT.
* NOTE: This class is auto generated by the swagger code generator 2.4.11-SNAPSHOT.
* https://github.com/swagger-api/swagger-codegen.git
* Do not edit the class manually.
*/
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 @@ -5,7 +5,7 @@
* OpenAPI spec version: 1.0.0
* Contact: [email protected]
*
* NOTE: This class is auto generated by the swagger code generator 2.4.3-SNAPSHOT.
* NOTE: This class is auto generated by the swagger code generator 2.4.11-SNAPSHOT.
* https://github.com/swagger-api/swagger-codegen.git
* Do not edit the class manually.
*/
Expand Down
2 changes: 1 addition & 1 deletion samples/client/petstore/cpprest/model/Amount.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* OpenAPI spec version: 1.0.0
* Contact: [email protected]
*
* NOTE: This class is auto generated by the swagger code generator 2.4.3-SNAPSHOT.
* NOTE: This class is auto generated by the swagger code generator 2.4.11-SNAPSHOT.
* https://github.com/swagger-api/swagger-codegen.git
* Do not edit the class manually.
*/
Expand Down
2 changes: 1 addition & 1 deletion samples/client/petstore/cpprest/model/Amount.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* OpenAPI spec version: 1.0.0
* Contact: [email protected]
*
* NOTE: This class is auto generated by the swagger code generator 2.4.3-SNAPSHOT.
* NOTE: This class is auto generated by the swagger code generator 2.4.11-SNAPSHOT.
* https://github.com/swagger-api/swagger-codegen.git
* Do not edit the class manually.
*/
Expand Down
2 changes: 1 addition & 1 deletion samples/client/petstore/cpprest/model/ApiResponse.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* OpenAPI spec version: 1.0.0
* Contact: [email protected]
*
* NOTE: This class is auto generated by the swagger code generator 2.4.3-SNAPSHOT.
* NOTE: This class is auto generated by the swagger code generator 2.4.11-SNAPSHOT.
* https://github.com/swagger-api/swagger-codegen.git
* Do not edit the class manually.
*/
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 @@ -5,7 +5,7 @@
* OpenAPI spec version: 1.0.0
* Contact: [email protected]
*
* NOTE: This class is auto generated by the swagger code generator 2.4.3-SNAPSHOT.
* NOTE: This class is auto generated by the swagger code generator 2.4.11-SNAPSHOT.
* https://github.com/swagger-api/swagger-codegen.git
* Do not edit the class manually.
*/
Expand Down
2 changes: 1 addition & 1 deletion samples/client/petstore/cpprest/model/Category.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* OpenAPI spec version: 1.0.0
* Contact: [email protected]
*
* NOTE: This class is auto generated by the swagger code generator 2.4.3-SNAPSHOT.
* NOTE: This class is auto generated by the swagger code generator 2.4.11-SNAPSHOT.
* https://github.com/swagger-api/swagger-codegen.git
* Do not edit the class manually.
*/
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 @@ -5,7 +5,7 @@
* OpenAPI spec version: 1.0.0
* Contact: [email protected]
*
* NOTE: This class is auto generated by the swagger code generator 2.4.3-SNAPSHOT.
* NOTE: This class is auto generated by the swagger code generator 2.4.11-SNAPSHOT.
* https://github.com/swagger-api/swagger-codegen.git
* Do not edit the class manually.
*/
Expand Down
2 changes: 1 addition & 1 deletion samples/client/petstore/cpprest/model/Currency.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* OpenAPI spec version: 1.0.0
* Contact: [email protected]
*
* NOTE: This class is auto generated by the swagger code generator 2.4.3-SNAPSHOT.
* NOTE: This class is auto generated by the swagger code generator 2.4.11-SNAPSHOT.
* https://github.com/swagger-api/swagger-codegen.git
* Do not edit the class manually.
*/
Expand Down
2 changes: 1 addition & 1 deletion samples/client/petstore/cpprest/model/Currency.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* OpenAPI spec version: 1.0.0
* Contact: [email protected]
*
* NOTE: This class is auto generated by the swagger code generator 2.4.3-SNAPSHOT.
* NOTE: This class is auto generated by the swagger code generator 2.4.11-SNAPSHOT.
* https://github.com/swagger-api/swagger-codegen.git
* Do not edit the class manually.
*/
Expand Down
Loading