forked from loafle/openapi-generator-original
Add handling of x-www-form-urlencoded and handling float without decimal if model is declared with float/double (#8043)
This commit is contained in:
parent
cb1a620628
commit
16e9011d5b
@ -224,6 +224,10 @@ pplx::task<{{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}void{{/r
|
||||
localVarRequestHttpContentType += utility::conversions::to_string_t("; boundary=") + localVarMultipart->getBoundary();
|
||||
{{/bodyParam}}
|
||||
}
|
||||
else if (localVarConsumeHttpContentTypes.find(utility::conversions::to_string_t("application/x-www-form-urlencoded")) != localVarConsumeHttpContentTypes.end())
|
||||
{
|
||||
localVarRequestHttpContentType = utility::conversions::to_string_t("application/x-www-form-urlencoded");
|
||||
}
|
||||
else
|
||||
{
|
||||
throw ApiException(415, utility::conversions::to_string_t("{{classname}}->{{operationId}} does not consume any supported media type"));
|
||||
|
@ -126,7 +126,7 @@ public:
|
||||
static bool fromHttpContent( std::shared_ptr<HttpContent> val, utility::datetime & );
|
||||
static bool fromHttpContent( std::shared_ptr<HttpContent> val, web::json::value & );
|
||||
static bool fromHttpContent( std::shared_ptr<HttpContent> val, std::shared_ptr<HttpContent>& );
|
||||
template <typename T>
|
||||
template <typename T>
|
||||
static bool fromHttpContent( std::shared_ptr<HttpContent> val, std::shared_ptr<T>& );
|
||||
template <typename T>
|
||||
static bool fromHttpContent( std::shared_ptr<HttpContent> val, std::vector<T> & );
|
||||
|
@ -136,7 +136,12 @@ bool ModelBase::fromString( const utility::string_t& val, float &outVal )
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
success = false;
|
||||
int64_t intVal = 0;
|
||||
success = ModelBase::fromString(val, intVal);
|
||||
if(success)
|
||||
{
|
||||
outVal = static_cast<float>(intVal);
|
||||
}
|
||||
}
|
||||
return success;
|
||||
}
|
||||
@ -150,7 +155,12 @@ bool ModelBase::fromString( const utility::string_t& val, double &outVal )
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
success = false;
|
||||
int64_t intVal = 0;
|
||||
success = ModelBase::fromString(val, intVal);
|
||||
if(success)
|
||||
{
|
||||
outVal = static_cast<double>(intVal);
|
||||
}
|
||||
}
|
||||
return success;
|
||||
}
|
||||
@ -281,7 +291,7 @@ bool ModelBase::fromJson( const web::json::value& val, std::shared_ptr<HttpConte
|
||||
if(content == nullptr)
|
||||
{
|
||||
content = std::shared_ptr<HttpContent>(new HttpContent());
|
||||
}
|
||||
}
|
||||
if(val.has_field(utility::conversions::to_string_t("ContentDisposition")))
|
||||
{
|
||||
utility::string_t value;
|
||||
|
@ -147,7 +147,12 @@ bool ModelBase::fromString( const utility::string_t& val, float &outVal )
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
success = false;
|
||||
int64_t intVal = 0;
|
||||
success = ModelBase::fromString(val, intVal);
|
||||
if(success)
|
||||
{
|
||||
outVal = static_cast<float>(intVal);
|
||||
}
|
||||
}
|
||||
return success;
|
||||
}
|
||||
@ -161,7 +166,12 @@ bool ModelBase::fromString( const utility::string_t& val, double &outVal )
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
success = false;
|
||||
int64_t intVal = 0;
|
||||
success = ModelBase::fromString(val, intVal);
|
||||
if(success)
|
||||
{
|
||||
outVal = static_cast<double>(intVal);
|
||||
}
|
||||
}
|
||||
return success;
|
||||
}
|
||||
@ -292,7 +302,7 @@ bool ModelBase::fromJson( const web::json::value& val, std::shared_ptr<HttpConte
|
||||
if(content == nullptr)
|
||||
{
|
||||
content = std::shared_ptr<HttpContent>(new HttpContent());
|
||||
}
|
||||
}
|
||||
if(val.has_field(utility::conversions::to_string_t("ContentDisposition")))
|
||||
{
|
||||
utility::string_t value;
|
||||
|
@ -137,7 +137,7 @@ public:
|
||||
static bool fromHttpContent( std::shared_ptr<HttpContent> val, utility::datetime & );
|
||||
static bool fromHttpContent( std::shared_ptr<HttpContent> val, web::json::value & );
|
||||
static bool fromHttpContent( std::shared_ptr<HttpContent> val, std::shared_ptr<HttpContent>& );
|
||||
template <typename T>
|
||||
template <typename T>
|
||||
static bool fromHttpContent( std::shared_ptr<HttpContent> val, std::shared_ptr<T>& );
|
||||
template <typename T>
|
||||
static bool fromHttpContent( std::shared_ptr<HttpContent> val, std::vector<T> & );
|
||||
|
@ -113,6 +113,10 @@ pplx::task<void> PetApi::addPet(std::shared_ptr<Pet> body) const
|
||||
localVarHttpBody = localVarMultipart;
|
||||
localVarRequestHttpContentType += utility::conversions::to_string_t("; boundary=") + localVarMultipart->getBoundary();
|
||||
}
|
||||
else if (localVarConsumeHttpContentTypes.find(utility::conversions::to_string_t("application/x-www-form-urlencoded")) != localVarConsumeHttpContentTypes.end())
|
||||
{
|
||||
localVarRequestHttpContentType = utility::conversions::to_string_t("application/x-www-form-urlencoded");
|
||||
}
|
||||
else
|
||||
{
|
||||
throw ApiException(415, utility::conversions::to_string_t("PetApi->addPet does not consume any supported media type"));
|
||||
@ -219,6 +223,10 @@ pplx::task<void> PetApi::deletePet(int64_t petId, boost::optional<utility::strin
|
||||
{
|
||||
localVarRequestHttpContentType = utility::conversions::to_string_t("multipart/form-data");
|
||||
}
|
||||
else if (localVarConsumeHttpContentTypes.find(utility::conversions::to_string_t("application/x-www-form-urlencoded")) != localVarConsumeHttpContentTypes.end())
|
||||
{
|
||||
localVarRequestHttpContentType = utility::conversions::to_string_t("application/x-www-form-urlencoded");
|
||||
}
|
||||
else
|
||||
{
|
||||
throw ApiException(415, utility::conversions::to_string_t("PetApi->deletePet does not consume any supported media type"));
|
||||
@ -325,6 +333,10 @@ pplx::task<std::vector<std::shared_ptr<Pet>>> PetApi::findPetsByStatus(std::vect
|
||||
{
|
||||
localVarRequestHttpContentType = utility::conversions::to_string_t("multipart/form-data");
|
||||
}
|
||||
else if (localVarConsumeHttpContentTypes.find(utility::conversions::to_string_t("application/x-www-form-urlencoded")) != localVarConsumeHttpContentTypes.end())
|
||||
{
|
||||
localVarRequestHttpContentType = utility::conversions::to_string_t("application/x-www-form-urlencoded");
|
||||
}
|
||||
else
|
||||
{
|
||||
throw ApiException(415, utility::conversions::to_string_t("PetApi->findPetsByStatus does not consume any supported media type"));
|
||||
@ -453,6 +465,10 @@ pplx::task<std::vector<std::shared_ptr<Pet>>> PetApi::findPetsByTags(std::vector
|
||||
{
|
||||
localVarRequestHttpContentType = utility::conversions::to_string_t("multipart/form-data");
|
||||
}
|
||||
else if (localVarConsumeHttpContentTypes.find(utility::conversions::to_string_t("application/x-www-form-urlencoded")) != localVarConsumeHttpContentTypes.end())
|
||||
{
|
||||
localVarRequestHttpContentType = utility::conversions::to_string_t("application/x-www-form-urlencoded");
|
||||
}
|
||||
else
|
||||
{
|
||||
throw ApiException(415, utility::conversions::to_string_t("PetApi->findPetsByTags does not consume any supported media type"));
|
||||
@ -579,6 +595,10 @@ pplx::task<std::shared_ptr<Pet>> PetApi::getPetById(int64_t petId) const
|
||||
{
|
||||
localVarRequestHttpContentType = utility::conversions::to_string_t("multipart/form-data");
|
||||
}
|
||||
else if (localVarConsumeHttpContentTypes.find(utility::conversions::to_string_t("application/x-www-form-urlencoded")) != localVarConsumeHttpContentTypes.end())
|
||||
{
|
||||
localVarRequestHttpContentType = utility::conversions::to_string_t("application/x-www-form-urlencoded");
|
||||
}
|
||||
else
|
||||
{
|
||||
throw ApiException(415, utility::conversions::to_string_t("PetApi->getPetById does not consume any supported media type"));
|
||||
@ -728,6 +748,10 @@ pplx::task<void> PetApi::updatePet(std::shared_ptr<Pet> body) const
|
||||
localVarHttpBody = localVarMultipart;
|
||||
localVarRequestHttpContentType += utility::conversions::to_string_t("; boundary=") + localVarMultipart->getBoundary();
|
||||
}
|
||||
else if (localVarConsumeHttpContentTypes.find(utility::conversions::to_string_t("application/x-www-form-urlencoded")) != localVarConsumeHttpContentTypes.end())
|
||||
{
|
||||
localVarRequestHttpContentType = utility::conversions::to_string_t("application/x-www-form-urlencoded");
|
||||
}
|
||||
else
|
||||
{
|
||||
throw ApiException(415, utility::conversions::to_string_t("PetApi->updatePet does not consume any supported media type"));
|
||||
@ -839,6 +863,10 @@ pplx::task<void> PetApi::updatePetWithForm(int64_t petId, boost::optional<utilit
|
||||
{
|
||||
localVarRequestHttpContentType = utility::conversions::to_string_t("multipart/form-data");
|
||||
}
|
||||
else if (localVarConsumeHttpContentTypes.find(utility::conversions::to_string_t("application/x-www-form-urlencoded")) != localVarConsumeHttpContentTypes.end())
|
||||
{
|
||||
localVarRequestHttpContentType = utility::conversions::to_string_t("application/x-www-form-urlencoded");
|
||||
}
|
||||
else
|
||||
{
|
||||
throw ApiException(415, utility::conversions::to_string_t("PetApi->updatePetWithForm does not consume any supported media type"));
|
||||
@ -951,6 +979,10 @@ pplx::task<std::shared_ptr<ApiResponse>> PetApi::uploadFile(int64_t petId, boost
|
||||
{
|
||||
localVarRequestHttpContentType = utility::conversions::to_string_t("multipart/form-data");
|
||||
}
|
||||
else if (localVarConsumeHttpContentTypes.find(utility::conversions::to_string_t("application/x-www-form-urlencoded")) != localVarConsumeHttpContentTypes.end())
|
||||
{
|
||||
localVarRequestHttpContentType = utility::conversions::to_string_t("application/x-www-form-urlencoded");
|
||||
}
|
||||
else
|
||||
{
|
||||
throw ApiException(415, utility::conversions::to_string_t("PetApi->uploadFile does not consume any supported media type"));
|
||||
|
@ -90,6 +90,10 @@ pplx::task<void> StoreApi::deleteOrder(utility::string_t orderId) const
|
||||
{
|
||||
localVarRequestHttpContentType = utility::conversions::to_string_t("multipart/form-data");
|
||||
}
|
||||
else if (localVarConsumeHttpContentTypes.find(utility::conversions::to_string_t("application/x-www-form-urlencoded")) != localVarConsumeHttpContentTypes.end())
|
||||
{
|
||||
localVarRequestHttpContentType = utility::conversions::to_string_t("application/x-www-form-urlencoded");
|
||||
}
|
||||
else
|
||||
{
|
||||
throw ApiException(415, utility::conversions::to_string_t("StoreApi->deleteOrder does not consume any supported media type"));
|
||||
@ -190,6 +194,10 @@ pplx::task<std::map<utility::string_t, int32_t>> StoreApi::getInventory() const
|
||||
{
|
||||
localVarRequestHttpContentType = utility::conversions::to_string_t("multipart/form-data");
|
||||
}
|
||||
else if (localVarConsumeHttpContentTypes.find(utility::conversions::to_string_t("application/x-www-form-urlencoded")) != localVarConsumeHttpContentTypes.end())
|
||||
{
|
||||
localVarRequestHttpContentType = utility::conversions::to_string_t("application/x-www-form-urlencoded");
|
||||
}
|
||||
else
|
||||
{
|
||||
throw ApiException(415, utility::conversions::to_string_t("StoreApi->getInventory does not consume any supported media type"));
|
||||
@ -323,6 +331,10 @@ pplx::task<std::shared_ptr<Order>> StoreApi::getOrderById(int64_t orderId) const
|
||||
{
|
||||
localVarRequestHttpContentType = utility::conversions::to_string_t("multipart/form-data");
|
||||
}
|
||||
else if (localVarConsumeHttpContentTypes.find(utility::conversions::to_string_t("application/x-www-form-urlencoded")) != localVarConsumeHttpContentTypes.end())
|
||||
{
|
||||
localVarRequestHttpContentType = utility::conversions::to_string_t("application/x-www-form-urlencoded");
|
||||
}
|
||||
else
|
||||
{
|
||||
throw ApiException(415, utility::conversions::to_string_t("StoreApi->getOrderById does not consume any supported media type"));
|
||||
@ -464,6 +476,10 @@ pplx::task<std::shared_ptr<Order>> StoreApi::placeOrder(std::shared_ptr<Order> b
|
||||
localVarHttpBody = localVarMultipart;
|
||||
localVarRequestHttpContentType += utility::conversions::to_string_t("; boundary=") + localVarMultipart->getBoundary();
|
||||
}
|
||||
else if (localVarConsumeHttpContentTypes.find(utility::conversions::to_string_t("application/x-www-form-urlencoded")) != localVarConsumeHttpContentTypes.end())
|
||||
{
|
||||
localVarRequestHttpContentType = utility::conversions::to_string_t("application/x-www-form-urlencoded");
|
||||
}
|
||||
else
|
||||
{
|
||||
throw ApiException(415, utility::conversions::to_string_t("StoreApi->placeOrder does not consume any supported media type"));
|
||||
|
@ -111,6 +111,10 @@ pplx::task<void> UserApi::createUser(std::shared_ptr<User> body) const
|
||||
localVarHttpBody = localVarMultipart;
|
||||
localVarRequestHttpContentType += utility::conversions::to_string_t("; boundary=") + localVarMultipart->getBoundary();
|
||||
}
|
||||
else if (localVarConsumeHttpContentTypes.find(utility::conversions::to_string_t("application/x-www-form-urlencoded")) != localVarConsumeHttpContentTypes.end())
|
||||
{
|
||||
localVarRequestHttpContentType = utility::conversions::to_string_t("application/x-www-form-urlencoded");
|
||||
}
|
||||
else
|
||||
{
|
||||
throw ApiException(415, utility::conversions::to_string_t("UserApi->createUser does not consume any supported media type"));
|
||||
@ -237,6 +241,10 @@ pplx::task<void> UserApi::createUsersWithArrayInput(std::vector<std::shared_ptr<
|
||||
localVarHttpBody = localVarMultipart;
|
||||
localVarRequestHttpContentType += utility::conversions::to_string_t("; boundary=") + localVarMultipart->getBoundary();
|
||||
}
|
||||
else if (localVarConsumeHttpContentTypes.find(utility::conversions::to_string_t("application/x-www-form-urlencoded")) != localVarConsumeHttpContentTypes.end())
|
||||
{
|
||||
localVarRequestHttpContentType = utility::conversions::to_string_t("application/x-www-form-urlencoded");
|
||||
}
|
||||
else
|
||||
{
|
||||
throw ApiException(415, utility::conversions::to_string_t("UserApi->createUsersWithArrayInput does not consume any supported media type"));
|
||||
@ -363,6 +371,10 @@ pplx::task<void> UserApi::createUsersWithListInput(std::vector<std::shared_ptr<U
|
||||
localVarHttpBody = localVarMultipart;
|
||||
localVarRequestHttpContentType += utility::conversions::to_string_t("; boundary=") + localVarMultipart->getBoundary();
|
||||
}
|
||||
else if (localVarConsumeHttpContentTypes.find(utility::conversions::to_string_t("application/x-www-form-urlencoded")) != localVarConsumeHttpContentTypes.end())
|
||||
{
|
||||
localVarRequestHttpContentType = utility::conversions::to_string_t("application/x-www-form-urlencoded");
|
||||
}
|
||||
else
|
||||
{
|
||||
throw ApiException(415, utility::conversions::to_string_t("UserApi->createUsersWithListInput does not consume any supported media type"));
|
||||
@ -463,6 +475,10 @@ pplx::task<void> UserApi::deleteUser(utility::string_t username) const
|
||||
{
|
||||
localVarRequestHttpContentType = utility::conversions::to_string_t("multipart/form-data");
|
||||
}
|
||||
else if (localVarConsumeHttpContentTypes.find(utility::conversions::to_string_t("application/x-www-form-urlencoded")) != localVarConsumeHttpContentTypes.end())
|
||||
{
|
||||
localVarRequestHttpContentType = utility::conversions::to_string_t("application/x-www-form-urlencoded");
|
||||
}
|
||||
else
|
||||
{
|
||||
throw ApiException(415, utility::conversions::to_string_t("UserApi->deleteUser does not consume any supported media type"));
|
||||
@ -565,6 +581,10 @@ pplx::task<std::shared_ptr<User>> UserApi::getUserByName(utility::string_t usern
|
||||
{
|
||||
localVarRequestHttpContentType = utility::conversions::to_string_t("multipart/form-data");
|
||||
}
|
||||
else if (localVarConsumeHttpContentTypes.find(utility::conversions::to_string_t("application/x-www-form-urlencoded")) != localVarConsumeHttpContentTypes.end())
|
||||
{
|
||||
localVarRequestHttpContentType = utility::conversions::to_string_t("application/x-www-form-urlencoded");
|
||||
}
|
||||
else
|
||||
{
|
||||
throw ApiException(415, utility::conversions::to_string_t("UserApi->getUserByName does not consume any supported media type"));
|
||||
@ -695,6 +715,10 @@ pplx::task<utility::string_t> UserApi::loginUser(utility::string_t username, uti
|
||||
{
|
||||
localVarRequestHttpContentType = utility::conversions::to_string_t("multipart/form-data");
|
||||
}
|
||||
else if (localVarConsumeHttpContentTypes.find(utility::conversions::to_string_t("application/x-www-form-urlencoded")) != localVarConsumeHttpContentTypes.end())
|
||||
{
|
||||
localVarRequestHttpContentType = utility::conversions::to_string_t("application/x-www-form-urlencoded");
|
||||
}
|
||||
else
|
||||
{
|
||||
throw ApiException(415, utility::conversions::to_string_t("UserApi->loginUser does not consume any supported media type"));
|
||||
@ -816,6 +840,10 @@ pplx::task<void> UserApi::logoutUser() const
|
||||
{
|
||||
localVarRequestHttpContentType = utility::conversions::to_string_t("multipart/form-data");
|
||||
}
|
||||
else if (localVarConsumeHttpContentTypes.find(utility::conversions::to_string_t("application/x-www-form-urlencoded")) != localVarConsumeHttpContentTypes.end())
|
||||
{
|
||||
localVarRequestHttpContentType = utility::conversions::to_string_t("application/x-www-form-urlencoded");
|
||||
}
|
||||
else
|
||||
{
|
||||
throw ApiException(415, utility::conversions::to_string_t("UserApi->logoutUser does not consume any supported media type"));
|
||||
@ -938,6 +966,10 @@ pplx::task<void> UserApi::updateUser(utility::string_t username, std::shared_ptr
|
||||
localVarHttpBody = localVarMultipart;
|
||||
localVarRequestHttpContentType += utility::conversions::to_string_t("; boundary=") + localVarMultipart->getBoundary();
|
||||
}
|
||||
else if (localVarConsumeHttpContentTypes.find(utility::conversions::to_string_t("application/x-www-form-urlencoded")) != localVarConsumeHttpContentTypes.end())
|
||||
{
|
||||
localVarRequestHttpContentType = utility::conversions::to_string_t("application/x-www-form-urlencoded");
|
||||
}
|
||||
else
|
||||
{
|
||||
throw ApiException(415, utility::conversions::to_string_t("UserApi->updateUser does not consume any supported media type"));
|
||||
|
Loading…
x
Reference in New Issue
Block a user