From c2aa87d7adf11e12bb0623ab52693270462cc88b Mon Sep 17 00:00:00 2001 From: Scott Richter Date: Fri, 9 Sep 2016 22:34:48 -0400 Subject: [PATCH 01/11] Fixed errors with cpprest client generation when generating a client that uses arrays of primitive types (vector) and file responses (HttpContent). --- .../languages/CppRestClientCodegen.java | 3 +- .../cpprest/httpcontent-header.mustache | 3 ++ .../cpprest/httpcontent-source.mustache | 11 +++++ .../resources/cpprest/model-source.mustache | 44 +++++++++---------- .../cpprest/modelbase-header.mustache | 2 +- 5 files changed, 39 insertions(+), 24 deletions(-) diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/CppRestClientCodegen.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/CppRestClientCodegen.java index c6715b22fb2..c29678fc99e 100644 --- a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/CppRestClientCodegen.java +++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/CppRestClientCodegen.java @@ -289,7 +289,7 @@ public String toDefaultValue(Property p) { return "0.0"; } else if (p instanceof FloatProperty) { return "0.0f"; - } else if (p instanceof IntegerProperty) { + } else if (p instanceof IntegerProperty || p instanceof BaseIntegerProperty) { return "0"; } else if (p instanceof LongProperty) { return "0L"; @@ -310,6 +310,7 @@ public String toDefaultValue(Property p) { RefProperty rp = (RefProperty) p; return "new " + toModelName(rp.getSimpleRef()) + "()"; } + //System.out.println(p.getClass().getName()); return "nullptr"; } diff --git a/modules/swagger-codegen/src/main/resources/cpprest/httpcontent-header.mustache b/modules/swagger-codegen/src/main/resources/cpprest/httpcontent-header.mustache index e79f575061f..bc8c952f61c 100644 --- a/modules/swagger-codegen/src/main/resources/cpprest/httpcontent-header.mustache +++ b/modules/swagger-codegen/src/main/resources/cpprest/httpcontent-header.mustache @@ -13,6 +13,7 @@ #include #include +#include {{#modelNamespaceDeclarations}} namespace {{this}} { @@ -40,6 +41,8 @@ public: virtual void setData( std::shared_ptr value ); virtual void writeTo( std::ostream& stream ); + + virtual void fromJson(web::json::value& val); protected: // NOTE: no utility::string_t here because those strings can only contain ascii diff --git a/modules/swagger-codegen/src/main/resources/cpprest/httpcontent-source.mustache b/modules/swagger-codegen/src/main/resources/cpprest/httpcontent-source.mustache index 791515a205d..afe1c52d6b8 100644 --- a/modules/swagger-codegen/src/main/resources/cpprest/httpcontent-source.mustache +++ b/modules/swagger-codegen/src/main/resources/cpprest/httpcontent-source.mustache @@ -1,5 +1,6 @@ {{>licenseInfo}} #include "HttpContent.h" +#include "ModelBase.h" {{#modelNamespaceDeclarations}} namespace {{this}} { @@ -69,6 +70,16 @@ void HttpContent::writeTo( std::ostream& stream ) stream << m_Data->rdbuf(); } +void HttpContent::fromJson(web::json::value& val) +{ + std::shared_ptr toCopy = ModelBase::fileFromJson(val); + + setName(toCopy->getName()); + setFileName(toCopy->getFileName()); + setContentType(toCopy->getContentType()); + setData(toCopy->getData()); +} + {{#modelNamespaceDeclarations}} } {{/modelNamespaceDeclarations}} diff --git a/modules/swagger-codegen/src/main/resources/cpprest/model-source.mustache b/modules/swagger-codegen/src/main/resources/cpprest/model-source.mustache index a1985735d4a..2eed1b6e545 100644 --- a/modules/swagger-codegen/src/main/resources/cpprest/model-source.mustache +++ b/modules/swagger-codegen/src/main/resources/cpprest/model-source.mustache @@ -29,12 +29,12 @@ web::json::value {{classname}}::toJson() const { web::json::value val = web::json::value::object(); - {{#vars}}{{#isPrimitiveType}}{{^required}}if(m_{{name}}IsSet) + {{#vars}}{{#isPrimitiveType}}{{^isListContainer}}{{^required}}if(m_{{name}}IsSet) { val[U("{{baseName}}")] = ModelBase::toJson(m_{{name}}); } {{/required}}{{#required}}val[U("{{baseName}}")] = ModelBase::toJson(m_{{name}}); - {{/required}}{{/isPrimitiveType}}{{^isPrimitiveType}}{{#isListContainer}}{ + {{/required}}{{/isListContainer}}{{/isPrimitiveType}}{{#isListContainer}}{ std::vector jsonArray; for( auto& item : m_{{name}} ) { @@ -48,24 +48,24 @@ web::json::value {{classname}}::toJson() const } {{/required}} } - {{/isListContainer}}{{^isListContainer}}{{^required}}if(m_{{name}}IsSet) + {{/isListContainer}}{{^isListContainer}}{{^isPrimitiveType}}{{^required}}if(m_{{name}}IsSet) { val[U("{{baseName}}")] = ModelBase::toJson(m_{{name}}); } {{/required}}{{#required}}val[U("{{baseName}}")] = ModelBase::toJson(m_{{name}}); - {{/required}}{{/isListContainer}}{{/isPrimitiveType}}{{/vars}} + {{/required}}{{/isPrimitiveType}}{{/isListContainer}}{{/vars}} return val; } void {{classname}}::fromJson(web::json::value& val) { - {{#vars}}{{#isPrimitiveType}}{{^required}}if(val.has_field(U("{{baseName}}"))) + {{#vars}}{{#isPrimitiveType}}{{^isListContainer}}{{^required}}if(val.has_field(U("{{baseName}}"))) { {{setter}}(ModelBase::{{baseType}}FromJson(val[U("{{baseName}}")])); } {{/required}}{{#required}}{{setter}}(ModelBase::{{baseType}}FromJson(val[U("{{baseName}}")])); - {{/required}}{{/isPrimitiveType}}{{^isPrimitiveType}}{{#isListContainer}}{ + {{/required}}{{/isListContainer}}{{/isPrimitiveType}}{{#isListContainer}}{ m_{{name}}.clear(); std::vector jsonArray; {{^required}}if(val.has_field(U("{{baseName}}"))) @@ -73,8 +73,8 @@ void {{classname}}::fromJson(web::json::value& val) {{/required}} for( auto& item : val[U("{{baseName}}")].as_array() ) { - {{#items.isPrimitiveType}}m_{{name}}.push_back(ModelBase::{{baseType}}FromJson(item)); - {{/items.isPrimitiveType}}{{^items.isPrimitiveType}}{{#items.isString}}m_{{name}}.push_back(ModelBase::stringFromJson(item)); + {{#isPrimitiveType}}m_{{name}}.push_back(ModelBase::{{items.baseType}}FromJson(item)); + {{/isPrimitiveType}}{{^isPrimitiveType}}{{#items.isString}}m_{{name}}.push_back(ModelBase::stringFromJson(item)); {{/items.isString}}{{^items.isString}}{{#items.isDateTime}}m_{{name}}.push_back(ModelBase::dateFromJson(item)); {{/items.isDateTime}}{{^items.isDateTime}} if(item.is_null()) @@ -87,13 +87,13 @@ void {{classname}}::fromJson(web::json::value& val) newItem->fromJson(item); m_{{name}}.push_back( newItem ); } - {{/items.isDateTime}}{{/items.isString}}{{/items.isPrimitiveType}} + {{/items.isDateTime}}{{/items.isString}}{{/isPrimitiveType}} } {{^required}} } {{/required}} } - {{/isListContainer}}{{^isListContainer}}{{^required}}if(val.has_field(U("{{baseName}}"))) + {{/isListContainer}}{{^isListContainer}}{{^isPrimitiveType}}{{^required}}if(val.has_field(U("{{baseName}}"))) { {{#isString}}{{setter}}(ModelBase::stringFromJson(val[U("{{baseName}}")])); {{/isString}}{{^isString}}{{#isDateTime}}{{setter}}(ModelBase::dateFromJson(val[U("{{baseName}}")])); @@ -111,7 +111,7 @@ void {{classname}}::fromJson(web::json::value& val) {{/vendorExtensions.x-codegen-file}}{{^vendorExtensions.x-codegen-file}}{{{datatype}}} new{{name}}({{{defaultValue}}}); new{{name}}->fromJson(val[U("{{baseName}}")]); {{setter}}( newItem ); - {{/vendorExtensions.x-codegen-file}}{{/isDateTime}}{{/isString}}{{/required}}{{/isListContainer}}{{/isPrimitiveType}}{{/vars}} + {{/vendorExtensions.x-codegen-file}}{{/isDateTime}}{{/isString}}{{/required}}{{/isPrimitiveType}}{{/isListContainer}}{{/vars}} } void {{classname}}::toMultipart(std::shared_ptr multipart, const utility::string_t& prefix) const @@ -122,12 +122,12 @@ void {{classname}}::toMultipart(std::shared_ptr multipart, co namePrefix += U("."); } - {{#vars}}{{#isPrimitiveType}}{{^required}}if(m_{{name}}IsSet) + {{#vars}}{{#isPrimitiveType}}{{^isListContainer}}{{^required}}if(m_{{name}}IsSet) { multipart->add(ModelBase::toHttpContent(namePrefix + U("{{baseName}}"), m_{{name}})); } {{/required}}{{#required}}multipart->add(ModelBase::toHttpContent(namePrefix + U("{{baseName}}"), m_{{name}})); - {{/required}}{{/isPrimitiveType}}{{^isPrimitiveType}}{{#isListContainer}}{ + {{/required}}{{/isListContainer}}{{/isPrimitiveType}}{{#isListContainer}}{ std::vector jsonArray; for( auto& item : m_{{name}} ) { @@ -141,7 +141,7 @@ void {{classname}}::toMultipart(std::shared_ptr multipart, co } {{/required}} } - {{/isListContainer}}{{^isListContainer}}{{^required}}if(m_{{name}}IsSet) + {{/isListContainer}}{{^isListContainer}}{{^isPrimitiveType}}{{^required}}if(m_{{name}}IsSet) { {{#isString}}multipart->add(ModelBase::toHttpContent(namePrefix + U("{{baseName}}"), m_{{name}})); {{/isString}}{{^isString}}{{#isDateTime}}multipart->add(ModelBase::toHttpContent(namePrefix + U("{{baseName}}"), m_{{name}})); @@ -155,7 +155,7 @@ void {{classname}}::toMultipart(std::shared_ptr multipart, co {{/isString}}{{^isString}}{{#isDateTime}}multipart->add(ModelBase::toHttpContent(namePrefix + U("{{baseName}}"), m_{{name}})); {{/isDateTime}}{{^isDateTime}}{{#vendorExtensions.x-codegen-file}}multipart->add(ModelBase::toHttpContent(namePrefix + U("{{baseName}}"), m_{{name}})); {{/vendorExtensions.x-codegen-file}}{{^vendorExtensions.x-codegen-file}}m_{{name}}->toMultipart(multipart, U("{{baseName}}.")); - {{/vendorExtensions.x-codegen-file}}{{/isDateTime}}{{/isString}}{{/required}}{{/isListContainer}}{{/isPrimitiveType}}{{/vars}} + {{/vendorExtensions.x-codegen-file}}{{/isDateTime}}{{/isString}}{{/required}}{{/isPrimitiveType}}{{/isListContainer}}{{/vars}} } void {{classname}}::fromMultiPart(std::shared_ptr multipart, const utility::string_t& prefix) @@ -166,12 +166,12 @@ void {{classname}}::fromMultiPart(std::shared_ptr multipart, namePrefix += U("."); } - {{#vars}}{{#isPrimitiveType}}{{^required}}if(multipart->hasContent(U("{{baseName}}"))) + {{#vars}}{{#isPrimitiveType}}{{^isListContainer}}{{^required}}if(multipart->hasContent(U("{{baseName}}"))) { {{setter}}(ModelBase::{{baseType}}FromHttpContent(multipart->getContent(U("{{baseName}}")))); } {{/required}}{{#required}}{{setter}}(ModelBase::{{baseType}}FromHttpContent(multipart->getContent(U("{{baseName}}")))); - {{/required}}{{/isPrimitiveType}}{{^isPrimitiveType}}{{#isListContainer}}{ + {{/required}}{{/isListContainer}}{{/isPrimitiveType}}{{#isListContainer}}{ m_{{name}}.clear(); {{^required}}if(multipart->hasContent(U("{{baseName}}"))) { @@ -180,8 +180,8 @@ void {{classname}}::fromMultiPart(std::shared_ptr multipart, web::json::value jsonArray = web::json::value::parse(ModelBase::stringFromHttpContent(multipart->getContent(U("{{baseName}}")))); for( auto& item : jsonArray.as_array() ) { - {{#items.isPrimitiveType}}m_{{name}}.push_back(ModelBase::{{baseType}}FromJson(item)); - {{/items.isPrimitiveType}}{{^items.isPrimitiveType}}{{#items.isString}}m_{{name}}.push_back(ModelBase::stringFromJson(item)); + {{#isPrimitiveType}}m_{{name}}.push_back(ModelBase::{{items.baseType}}FromJson(item)); + {{/isPrimitiveType}}{{^isPrimitiveType}}{{#items.isString}}m_{{name}}.push_back(ModelBase::stringFromJson(item)); {{/items.isString}}{{^items.isString}}{{#items.isDateTime}}m_{{name}}.push_back(ModelBase::dateFromJson(item)); {{/items.isDateTime}}{{^items.isDateTime}} if(item.is_null()) @@ -194,13 +194,13 @@ void {{classname}}::fromMultiPart(std::shared_ptr multipart, newItem->fromJson(item); m_{{name}}.push_back( newItem ); } - {{/items.isDateTime}}{{/items.isString}}{{/items.isPrimitiveType}} + {{/items.isDateTime}}{{/items.isString}}{{/isPrimitiveType}} } {{^required}} } {{/required}} } - {{/isListContainer}}{{^isListContainer}}{{^required}}if(multipart->hasContent(U("{{baseName}}"))) + {{/isListContainer}}{{^isListContainer}}{{^isPrimitiveType}}{{^required}}if(multipart->hasContent(U("{{baseName}}"))) { {{#isString}}{{setter}}(ModelBase::stringFromHttpContent(multipart->getContent(U("{{baseName}}")))); {{/isString}}{{^isString}}{{#isDateTime}}{{setter}}(ModelBase::dateFromHttpContent(multipart->getContent(U("{{baseName}}")))); @@ -218,7 +218,7 @@ void {{classname}}::fromMultiPart(std::shared_ptr multipart, {{/vendorExtensions.x-codegen-file}}{{^vendorExtensions.x-codegen-file}}{{{datatype}}} new{{name}}({{{defaultValue}}}); new{{name}}->fromMultiPart(multipart, U("{{baseName}}.")); {{setter}}( new{{name}} ); - {{/vendorExtensions.x-codegen-file}}{{/isDateTime}}{{/isString}}{{/required}}{{/isListContainer}}{{/isPrimitiveType}}{{/vars}} + {{/vendorExtensions.x-codegen-file}}{{/isDateTime}}{{/isString}}{{/required}}{{/isPrimitiveType}}{{/isListContainer}}{{/vars}} } diff --git a/modules/swagger-codegen/src/main/resources/cpprest/modelbase-header.mustache b/modules/swagger-codegen/src/main/resources/cpprest/modelbase-header.mustache index 262b154acd7..204b9914540 100644 --- a/modules/swagger-codegen/src/main/resources/cpprest/modelbase-header.mustache +++ b/modules/swagger-codegen/src/main/resources/cpprest/modelbase-header.mustache @@ -40,7 +40,7 @@ public: static web::json::value toJson( int32_t value ); static web::json::value toJson( int64_t value ); static web::json::value toJson( double value ); - + static int64_t int64_tFromJson(web::json::value& val); static int32_t int32_tFromJson(web::json::value& val); static utility::string_t stringFromJson(web::json::value& val); From 055503ef55bafc201aaf9c92b4ec3555b14cfcbd Mon Sep 17 00:00:00 2001 From: Scott Richter Date: Mon, 12 Sep 2016 11:26:08 -0400 Subject: [PATCH 02/11] Updated the petstore sample using script. --- samples/client/petstore/cpprest/ApiClient.cpp | 4 +- samples/client/petstore/cpprest/ApiClient.h | 4 +- .../petstore/cpprest/ApiConfiguration.cpp | 4 +- .../petstore/cpprest/ApiConfiguration.h | 4 +- .../client/petstore/cpprest/ApiException.cpp | 4 +- .../client/petstore/cpprest/ApiException.h | 4 +- .../client/petstore/cpprest/HttpContent.cpp | 15 +++- samples/client/petstore/cpprest/HttpContent.h | 7 +- samples/client/petstore/cpprest/IHttpBody.h | 4 +- samples/client/petstore/cpprest/JsonBody.cpp | 4 +- samples/client/petstore/cpprest/JsonBody.h | 4 +- samples/client/petstore/cpprest/ModelBase.cpp | 4 +- samples/client/petstore/cpprest/ModelBase.h | 6 +- .../petstore/cpprest/MultipartFormData.cpp | 4 +- .../petstore/cpprest/MultipartFormData.h | 4 +- .../client/petstore/cpprest/api/PetApi.cpp | 73 ++++++------------- samples/client/petstore/cpprest/api/PetApi.h | 21 +++--- .../client/petstore/cpprest/api/StoreApi.cpp | 25 +++---- .../client/petstore/cpprest/api/StoreApi.h | 8 +- .../client/petstore/cpprest/api/UserApi.cpp | 48 +++++------- samples/client/petstore/cpprest/api/UserApi.h | 14 ++-- .../petstore/cpprest/model/Category.cpp | 6 +- .../client/petstore/cpprest/model/Category.h | 4 +- .../client/petstore/cpprest/model/Order.cpp | 8 +- samples/client/petstore/cpprest/model/Order.h | 4 +- samples/client/petstore/cpprest/model/Pet.cpp | 6 +- samples/client/petstore/cpprest/model/Pet.h | 8 +- samples/client/petstore/cpprest/model/Tag.cpp | 6 +- samples/client/petstore/cpprest/model/Tag.h | 4 +- .../client/petstore/cpprest/model/User.cpp | 6 +- samples/client/petstore/cpprest/model/User.h | 4 +- 31 files changed, 145 insertions(+), 176 deletions(-) diff --git a/samples/client/petstore/cpprest/ApiClient.cpp b/samples/client/petstore/cpprest/ApiClient.cpp index 59cc503734c..3ed3ddb0591 100644 --- a/samples/client/petstore/cpprest/ApiClient.cpp +++ b/samples/client/petstore/cpprest/ApiClient.cpp @@ -1,9 +1,9 @@ /** * Swagger Petstore - * This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key `special-key` to test the authorization filters. + * This is a sample server Petstore server. You can find out more about Swagger at http://swagger.io or on irc.freenode.net, #swagger. For this sample, you can use the api key \"special-key\" to test the authorization filters * * OpenAPI spec version: 1.0.0 - * Contact: apiteam@swagger.io + * Contact: apiteam@wordnik.com * * NOTE: This class is auto generated by the swagger code generator program. * https://github.com/swagger-api/swagger-codegen.git diff --git a/samples/client/petstore/cpprest/ApiClient.h b/samples/client/petstore/cpprest/ApiClient.h index 54b0158eeb5..16e5ca125ae 100644 --- a/samples/client/petstore/cpprest/ApiClient.h +++ b/samples/client/petstore/cpprest/ApiClient.h @@ -1,9 +1,9 @@ /** * Swagger Petstore - * This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key `special-key` to test the authorization filters. + * This is a sample server Petstore server. You can find out more about Swagger at http://swagger.io or on irc.freenode.net, #swagger. For this sample, you can use the api key \"special-key\" to test the authorization filters * * OpenAPI spec version: 1.0.0 - * Contact: apiteam@swagger.io + * Contact: apiteam@wordnik.com * * NOTE: This class is auto generated by the swagger code generator program. * https://github.com/swagger-api/swagger-codegen.git diff --git a/samples/client/petstore/cpprest/ApiConfiguration.cpp b/samples/client/petstore/cpprest/ApiConfiguration.cpp index 61bf1a5e16d..e85f43d848f 100644 --- a/samples/client/petstore/cpprest/ApiConfiguration.cpp +++ b/samples/client/petstore/cpprest/ApiConfiguration.cpp @@ -1,9 +1,9 @@ /** * Swagger Petstore - * This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key `special-key` to test the authorization filters. + * This is a sample server Petstore server. You can find out more about Swagger at http://swagger.io or on irc.freenode.net, #swagger. For this sample, you can use the api key \"special-key\" to test the authorization filters * * OpenAPI spec version: 1.0.0 - * Contact: apiteam@swagger.io + * Contact: apiteam@wordnik.com * * NOTE: This class is auto generated by the swagger code generator program. * https://github.com/swagger-api/swagger-codegen.git diff --git a/samples/client/petstore/cpprest/ApiConfiguration.h b/samples/client/petstore/cpprest/ApiConfiguration.h index e9742d155fd..67cd2bf0178 100644 --- a/samples/client/petstore/cpprest/ApiConfiguration.h +++ b/samples/client/petstore/cpprest/ApiConfiguration.h @@ -1,9 +1,9 @@ /** * Swagger Petstore - * This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key `special-key` to test the authorization filters. + * This is a sample server Petstore server. You can find out more about Swagger at http://swagger.io or on irc.freenode.net, #swagger. For this sample, you can use the api key \"special-key\" to test the authorization filters * * OpenAPI spec version: 1.0.0 - * Contact: apiteam@swagger.io + * Contact: apiteam@wordnik.com * * NOTE: This class is auto generated by the swagger code generator program. * https://github.com/swagger-api/swagger-codegen.git diff --git a/samples/client/petstore/cpprest/ApiException.cpp b/samples/client/petstore/cpprest/ApiException.cpp index 01ba891769e..8df3ce12400 100644 --- a/samples/client/petstore/cpprest/ApiException.cpp +++ b/samples/client/petstore/cpprest/ApiException.cpp @@ -1,9 +1,9 @@ /** * Swagger Petstore - * This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key `special-key` to test the authorization filters. + * This is a sample server Petstore server. You can find out more about Swagger at http://swagger.io or on irc.freenode.net, #swagger. For this sample, you can use the api key \"special-key\" to test the authorization filters * * OpenAPI spec version: 1.0.0 - * Contact: apiteam@swagger.io + * Contact: apiteam@wordnik.com * * NOTE: This class is auto generated by the swagger code generator program. * https://github.com/swagger-api/swagger-codegen.git diff --git a/samples/client/petstore/cpprest/ApiException.h b/samples/client/petstore/cpprest/ApiException.h index beb2b5ea7e5..ef17912974d 100644 --- a/samples/client/petstore/cpprest/ApiException.h +++ b/samples/client/petstore/cpprest/ApiException.h @@ -1,9 +1,9 @@ /** * Swagger Petstore - * This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key `special-key` to test the authorization filters. + * This is a sample server Petstore server. You can find out more about Swagger at http://swagger.io or on irc.freenode.net, #swagger. For this sample, you can use the api key \"special-key\" to test the authorization filters * * OpenAPI spec version: 1.0.0 - * Contact: apiteam@swagger.io + * Contact: apiteam@wordnik.com * * NOTE: This class is auto generated by the swagger code generator program. * https://github.com/swagger-api/swagger-codegen.git diff --git a/samples/client/petstore/cpprest/HttpContent.cpp b/samples/client/petstore/cpprest/HttpContent.cpp index a7a9b83aa59..5cb27725a56 100644 --- a/samples/client/petstore/cpprest/HttpContent.cpp +++ b/samples/client/petstore/cpprest/HttpContent.cpp @@ -1,9 +1,9 @@ /** * Swagger Petstore - * This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key `special-key` to test the authorization filters. + * This is a sample server Petstore server. You can find out more about Swagger at http://swagger.io or on irc.freenode.net, #swagger. For this sample, you can use the api key \"special-key\" to test the authorization filters * * OpenAPI spec version: 1.0.0 - * Contact: apiteam@swagger.io + * Contact: apiteam@wordnik.com * * NOTE: This class is auto generated by the swagger code generator program. * https://github.com/swagger-api/swagger-codegen.git @@ -23,6 +23,7 @@ */ #include "HttpContent.h" +#include "ModelBase.h" namespace io { namespace swagger { @@ -93,6 +94,16 @@ void HttpContent::writeTo( std::ostream& stream ) stream << m_Data->rdbuf(); } +void HttpContent::fromJson(web::json::value& val) +{ + std::shared_ptr toCopy = ModelBase::fileFromJson(val); + + setName(toCopy->getName()); + setFileName(toCopy->getFileName()); + setContentType(toCopy->getContentType()); + setData(toCopy->getData()); +} + } } } diff --git a/samples/client/petstore/cpprest/HttpContent.h b/samples/client/petstore/cpprest/HttpContent.h index 5db04412bd2..5c58f530f63 100644 --- a/samples/client/petstore/cpprest/HttpContent.h +++ b/samples/client/petstore/cpprest/HttpContent.h @@ -1,9 +1,9 @@ /** * Swagger Petstore - * This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key `special-key` to test the authorization filters. + * This is a sample server Petstore server. You can find out more about Swagger at http://swagger.io or on irc.freenode.net, #swagger. For this sample, you can use the api key \"special-key\" to test the authorization filters * * OpenAPI spec version: 1.0.0 - * Contact: apiteam@swagger.io + * Contact: apiteam@wordnik.com * * NOTE: This class is auto generated by the swagger code generator program. * https://github.com/swagger-api/swagger-codegen.git @@ -36,6 +36,7 @@ #include #include +#include namespace io { namespace swagger { @@ -64,6 +65,8 @@ class HttpContent virtual void setData( std::shared_ptr value ); virtual void writeTo( std::ostream& stream ); + + virtual void fromJson(web::json::value& val); protected: // NOTE: no utility::string_t here because those strings can only contain ascii diff --git a/samples/client/petstore/cpprest/IHttpBody.h b/samples/client/petstore/cpprest/IHttpBody.h index 365109f3dab..80090afee4a 100644 --- a/samples/client/petstore/cpprest/IHttpBody.h +++ b/samples/client/petstore/cpprest/IHttpBody.h @@ -1,9 +1,9 @@ /** * Swagger Petstore - * This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key `special-key` to test the authorization filters. + * This is a sample server Petstore server. You can find out more about Swagger at http://swagger.io or on irc.freenode.net, #swagger. For this sample, you can use the api key \"special-key\" to test the authorization filters * * OpenAPI spec version: 1.0.0 - * Contact: apiteam@swagger.io + * Contact: apiteam@wordnik.com * * NOTE: This class is auto generated by the swagger code generator program. * https://github.com/swagger-api/swagger-codegen.git diff --git a/samples/client/petstore/cpprest/JsonBody.cpp b/samples/client/petstore/cpprest/JsonBody.cpp index f152a1e98ed..349bd6bfb1e 100644 --- a/samples/client/petstore/cpprest/JsonBody.cpp +++ b/samples/client/petstore/cpprest/JsonBody.cpp @@ -1,9 +1,9 @@ /** * Swagger Petstore - * This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key `special-key` to test the authorization filters. + * This is a sample server Petstore server. You can find out more about Swagger at http://swagger.io or on irc.freenode.net, #swagger. For this sample, you can use the api key \"special-key\" to test the authorization filters * * OpenAPI spec version: 1.0.0 - * Contact: apiteam@swagger.io + * Contact: apiteam@wordnik.com * * NOTE: This class is auto generated by the swagger code generator program. * https://github.com/swagger-api/swagger-codegen.git diff --git a/samples/client/petstore/cpprest/JsonBody.h b/samples/client/petstore/cpprest/JsonBody.h index 7b139826e21..382004f6db5 100644 --- a/samples/client/petstore/cpprest/JsonBody.h +++ b/samples/client/petstore/cpprest/JsonBody.h @@ -1,9 +1,9 @@ /** * Swagger Petstore - * This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key `special-key` to test the authorization filters. + * This is a sample server Petstore server. You can find out more about Swagger at http://swagger.io or on irc.freenode.net, #swagger. For this sample, you can use the api key \"special-key\" to test the authorization filters * * OpenAPI spec version: 1.0.0 - * Contact: apiteam@swagger.io + * Contact: apiteam@wordnik.com * * NOTE: This class is auto generated by the swagger code generator program. * https://github.com/swagger-api/swagger-codegen.git diff --git a/samples/client/petstore/cpprest/ModelBase.cpp b/samples/client/petstore/cpprest/ModelBase.cpp index 74e46b31faf..626ee2ad768 100644 --- a/samples/client/petstore/cpprest/ModelBase.cpp +++ b/samples/client/petstore/cpprest/ModelBase.cpp @@ -1,9 +1,9 @@ /** * Swagger Petstore - * This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key `special-key` to test the authorization filters. + * This is a sample server Petstore server. You can find out more about Swagger at http://swagger.io or on irc.freenode.net, #swagger. For this sample, you can use the api key \"special-key\" to test the authorization filters * * OpenAPI spec version: 1.0.0 - * Contact: apiteam@swagger.io + * Contact: apiteam@wordnik.com * * NOTE: This class is auto generated by the swagger code generator program. * https://github.com/swagger-api/swagger-codegen.git diff --git a/samples/client/petstore/cpprest/ModelBase.h b/samples/client/petstore/cpprest/ModelBase.h index 8386a4ac97b..8514ec1ba8a 100644 --- a/samples/client/petstore/cpprest/ModelBase.h +++ b/samples/client/petstore/cpprest/ModelBase.h @@ -1,9 +1,9 @@ /** * Swagger Petstore - * This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key `special-key` to test the authorization filters. + * This is a sample server Petstore server. You can find out more about Swagger at http://swagger.io or on irc.freenode.net, #swagger. For this sample, you can use the api key \"special-key\" to test the authorization filters * * OpenAPI spec version: 1.0.0 - * Contact: apiteam@swagger.io + * Contact: apiteam@wordnik.com * * NOTE: This class is auto generated by the swagger code generator program. * https://github.com/swagger-api/swagger-codegen.git @@ -64,7 +64,7 @@ class ModelBase static web::json::value toJson( int32_t value ); static web::json::value toJson( int64_t value ); static web::json::value toJson( double value ); - + static int64_t int64_tFromJson(web::json::value& val); static int32_t int32_tFromJson(web::json::value& val); static utility::string_t stringFromJson(web::json::value& val); diff --git a/samples/client/petstore/cpprest/MultipartFormData.cpp b/samples/client/petstore/cpprest/MultipartFormData.cpp index 9fffdf22b02..ca4ca814ff5 100644 --- a/samples/client/petstore/cpprest/MultipartFormData.cpp +++ b/samples/client/petstore/cpprest/MultipartFormData.cpp @@ -1,9 +1,9 @@ /** * Swagger Petstore - * This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key `special-key` to test the authorization filters. + * This is a sample server Petstore server. You can find out more about Swagger at http://swagger.io or on irc.freenode.net, #swagger. For this sample, you can use the api key \"special-key\" to test the authorization filters * * OpenAPI spec version: 1.0.0 - * Contact: apiteam@swagger.io + * Contact: apiteam@wordnik.com * * NOTE: This class is auto generated by the swagger code generator program. * https://github.com/swagger-api/swagger-codegen.git diff --git a/samples/client/petstore/cpprest/MultipartFormData.h b/samples/client/petstore/cpprest/MultipartFormData.h index 8fcd71ed011..01c1e7c0e8a 100644 --- a/samples/client/petstore/cpprest/MultipartFormData.h +++ b/samples/client/petstore/cpprest/MultipartFormData.h @@ -1,9 +1,9 @@ /** * Swagger Petstore - * This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key `special-key` to test the authorization filters. + * This is a sample server Petstore server. You can find out more about Swagger at http://swagger.io or on irc.freenode.net, #swagger. For this sample, you can use the api key \"special-key\" to test the authorization filters * * OpenAPI spec version: 1.0.0 - * Contact: apiteam@swagger.io + * Contact: apiteam@wordnik.com * * NOTE: This class is auto generated by the swagger code generator program. * https://github.com/swagger-api/swagger-codegen.git diff --git a/samples/client/petstore/cpprest/api/PetApi.cpp b/samples/client/petstore/cpprest/api/PetApi.cpp index e573b9a08a6..ac0fb12c3e5 100644 --- a/samples/client/petstore/cpprest/api/PetApi.cpp +++ b/samples/client/petstore/cpprest/api/PetApi.cpp @@ -1,9 +1,9 @@ /** * Swagger Petstore - * This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key `special-key` to test the authorization filters. + * This is a sample server Petstore server. You can find out more about Swagger at http://swagger.io or on irc.freenode.net, #swagger. For this sample, you can use the api key \"special-key\" to test the authorization filters * * OpenAPI spec version: 1.0.0 - * Contact: apiteam@swagger.io + * Contact: apiteam@wordnik.com * * NOTE: This class is auto generated by the swagger code generator program. * https://github.com/swagger-api/swagger-codegen.git @@ -51,12 +51,6 @@ PetApi::~PetApi() pplx::task PetApi::addPet(std::shared_ptr body) { - // verify the required parameter 'body' is set - if (body == nullptr) - { - throw ApiException(400, U("Missing required parameter 'body' when calling PetApi->addPet")); - } - std::shared_ptr apiConfiguration( m_ApiClient->getConfiguration() ); utility::string_t path = U("/pet"); @@ -67,8 +61,8 @@ pplx::task PetApi::addPet(std::shared_ptr body) std::map> fileParams; std::unordered_set responseHttpContentTypes; - responseHttpContentTypes.insert( U("application/xml") ); -responseHttpContentTypes.insert( U("application/json") ); + responseHttpContentTypes.insert( U("application/json") ); +responseHttpContentTypes.insert( U("application/xml") ); utility::string_t responseHttpContentType; @@ -183,8 +177,8 @@ pplx::task PetApi::deletePet(int64_t petId, utility::string_t apiKey) std::map> fileParams; std::unordered_set responseHttpContentTypes; - responseHttpContentTypes.insert( U("application/xml") ); -responseHttpContentTypes.insert( U("application/json") ); + responseHttpContentTypes.insert( U("application/json") ); +responseHttpContentTypes.insert( U("application/xml") ); utility::string_t responseHttpContentType; @@ -288,8 +282,8 @@ pplx::task>> PetApi::findPetsByStatus(std::vect std::map> fileParams; std::unordered_set responseHttpContentTypes; - responseHttpContentTypes.insert( U("application/xml") ); -responseHttpContentTypes.insert( U("application/json") ); + responseHttpContentTypes.insert( U("application/json") ); +responseHttpContentTypes.insert( U("application/xml") ); utility::string_t responseHttpContentType; @@ -415,8 +409,8 @@ pplx::task>> PetApi::findPetsByTags(std::vector std::map> fileParams; std::unordered_set responseHttpContentTypes; - responseHttpContentTypes.insert( U("application/xml") ); -responseHttpContentTypes.insert( U("application/json") ); + responseHttpContentTypes.insert( U("application/json") ); +responseHttpContentTypes.insert( U("application/xml") ); utility::string_t responseHttpContentType; @@ -543,8 +537,8 @@ pplx::task> PetApi::getPetById(int64_t petId) std::map> fileParams; std::unordered_set responseHttpContentTypes; - responseHttpContentTypes.insert( U("application/xml") ); -responseHttpContentTypes.insert( U("application/json") ); + responseHttpContentTypes.insert( U("application/json") ); +responseHttpContentTypes.insert( U("application/xml") ); utility::string_t responseHttpContentType; @@ -593,6 +587,8 @@ responseHttpContentTypes.insert( U("application/json") ); throw ApiException(415, U("PetApi->getPetById does not consume any supported media type")); } + // authentication (petstore_auth) required + // oauth2 authentication is added automatically as part of the http_client_config // authentication (api_key) required { utility::string_t apiKey = apiConfiguration->getApiKey(U("api_key")); @@ -657,12 +653,6 @@ responseHttpContentTypes.insert( U("application/json") ); pplx::task PetApi::updatePet(std::shared_ptr body) { - // verify the required parameter 'body' is set - if (body == nullptr) - { - throw ApiException(400, U("Missing required parameter 'body' when calling PetApi->updatePet")); - } - std::shared_ptr apiConfiguration( m_ApiClient->getConfiguration() ); utility::string_t path = U("/pet"); @@ -673,8 +663,8 @@ pplx::task PetApi::updatePet(std::shared_ptr body) std::map> fileParams; std::unordered_set responseHttpContentTypes; - responseHttpContentTypes.insert( U("application/xml") ); -responseHttpContentTypes.insert( U("application/json") ); + responseHttpContentTypes.insert( U("application/json") ); +responseHttpContentTypes.insert( U("application/xml") ); utility::string_t responseHttpContentType; @@ -775,7 +765,7 @@ consumeHttpContentTypes.insert( U("application/xml") ); return void(); }); } -pplx::task PetApi::updatePetWithForm(int64_t petId, utility::string_t name, utility::string_t status) +pplx::task PetApi::updatePetWithForm(utility::string_t petId, utility::string_t name, utility::string_t status) { @@ -789,8 +779,8 @@ pplx::task PetApi::updatePetWithForm(int64_t petId, utility::string_t name std::map> fileParams; std::unordered_set responseHttpContentTypes; - responseHttpContentTypes.insert( U("application/xml") ); -responseHttpContentTypes.insert( U("application/json") ); + responseHttpContentTypes.insert( U("application/json") ); +responseHttpContentTypes.insert( U("application/xml") ); utility::string_t responseHttpContentType; @@ -887,7 +877,7 @@ responseHttpContentTypes.insert( U("application/json") ); return void(); }); } -pplx::task> PetApi::uploadFile(int64_t petId, utility::string_t additionalMetadata, std::shared_ptr file) +pplx::task PetApi::uploadFile(int64_t petId, utility::string_t additionalMetadata, std::shared_ptr file) { @@ -902,6 +892,7 @@ pplx::task> PetApi::uploadFile(int64_t petId, utili std::unordered_set responseHttpContentTypes; responseHttpContentTypes.insert( U("application/json") ); +responseHttpContentTypes.insert( U("application/xml") ); utility::string_t responseHttpContentType; @@ -995,26 +986,8 @@ pplx::task> PetApi::uploadFile(int64_t petId, utili }) .then([=](utility::string_t response) { - std::shared_ptr result(new ApiResponse()); - - if(responseHttpContentType == U("application/json")) - { - web::json::value json = web::json::value::parse(response); - - result->fromJson(json); - } - // else if(responseHttpContentType == U("multipart/form-data")) - // { - // TODO multipart response parsing - // } - else - { - throw ApiException(500 - , U("error calling findPetsByStatus: unsupported response type")); - } - - return result; - }); + return void(); + }); } } diff --git a/samples/client/petstore/cpprest/api/PetApi.h b/samples/client/petstore/cpprest/api/PetApi.h index 0ee2bf64fe3..e3d1b40a3a8 100644 --- a/samples/client/petstore/cpprest/api/PetApi.h +++ b/samples/client/petstore/cpprest/api/PetApi.h @@ -1,9 +1,9 @@ /** * Swagger Petstore - * This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key `special-key` to test the authorization filters. + * This is a sample server Petstore server. You can find out more about Swagger at http://swagger.io or on irc.freenode.net, #swagger. For this sample, you can use the api key \"special-key\" to test the authorization filters * * OpenAPI spec version: 1.0.0 - * Contact: apiteam@swagger.io + * Contact: apiteam@wordnik.com * * NOTE: This class is auto generated by the swagger code generator program. * https://github.com/swagger-api/swagger-codegen.git @@ -36,7 +36,6 @@ #include "Pet.h" #include -#include "ApiResponse.h" #include "HttpContent.h" namespace io { @@ -57,7 +56,7 @@ class PetApi /// /// /// - /// Pet object that needs to be added to the store + /// Pet object that needs to be added to the store (optional) pplx::task addPet(std::shared_ptr body); /// /// Deletes a pet @@ -73,7 +72,7 @@ class PetApi /// /// Multiple status values can be provided with comma separated strings /// - /// Status values that need to be considered for filter + /// Status values that need to be considered for filter (optional, default to available) pplx::task>> findPetsByStatus(std::vector status); /// /// Finds Pets by tags @@ -81,15 +80,15 @@ class PetApi /// /// Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing. /// - /// Tags to filter by + /// Tags to filter by (optional) pplx::task>> findPetsByTags(std::vector tags); /// /// Find pet by ID /// /// - /// Returns a single pet + /// Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error conditions /// - /// ID of pet to return + /// ID of pet that needs to be fetched pplx::task> getPetById(int64_t petId); /// /// Update an existing pet @@ -97,7 +96,7 @@ class PetApi /// /// /// - /// Pet object that needs to be added to the store + /// Pet object that needs to be added to the store (optional) pplx::task updatePet(std::shared_ptr body); /// /// Updates a pet in the store with form data @@ -106,7 +105,7 @@ class PetApi /// /// /// ID of pet that needs to be updated/// Updated name of the pet (optional)/// Updated status of the pet (optional) - pplx::task updatePetWithForm(int64_t petId, utility::string_t name, utility::string_t status); + pplx::task updatePetWithForm(utility::string_t petId, utility::string_t name, utility::string_t status); /// /// uploads an image /// @@ -114,7 +113,7 @@ class PetApi /// /// /// ID of pet to update/// Additional data to pass to server (optional)/// file to upload (optional) - pplx::task> uploadFile(int64_t petId, utility::string_t additionalMetadata, std::shared_ptr file); + pplx::task uploadFile(int64_t petId, utility::string_t additionalMetadata, std::shared_ptr file); protected: std::shared_ptr m_ApiClient; diff --git a/samples/client/petstore/cpprest/api/StoreApi.cpp b/samples/client/petstore/cpprest/api/StoreApi.cpp index dae3f04a985..911505c78fd 100644 --- a/samples/client/petstore/cpprest/api/StoreApi.cpp +++ b/samples/client/petstore/cpprest/api/StoreApi.cpp @@ -1,9 +1,9 @@ /** * Swagger Petstore - * This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key `special-key` to test the authorization filters. + * This is a sample server Petstore server. You can find out more about Swagger at http://swagger.io or on irc.freenode.net, #swagger. For this sample, you can use the api key \"special-key\" to test the authorization filters * * OpenAPI spec version: 1.0.0 - * Contact: apiteam@swagger.io + * Contact: apiteam@wordnik.com * * NOTE: This class is auto generated by the swagger code generator program. * https://github.com/swagger-api/swagger-codegen.git @@ -62,8 +62,8 @@ pplx::task StoreApi::deleteOrder(utility::string_t orderId) std::map> fileParams; std::unordered_set responseHttpContentTypes; - responseHttpContentTypes.insert( U("application/xml") ); -responseHttpContentTypes.insert( U("application/json") ); + responseHttpContentTypes.insert( U("application/json") ); +responseHttpContentTypes.insert( U("application/xml") ); utility::string_t responseHttpContentType; @@ -161,6 +161,7 @@ pplx::task> StoreApi::getInventory() std::unordered_set responseHttpContentTypes; responseHttpContentTypes.insert( U("application/json") ); +responseHttpContentTypes.insert( U("application/xml") ); utility::string_t responseHttpContentType; @@ -272,7 +273,7 @@ pplx::task> StoreApi::getInventory() return result; }); } -pplx::task> StoreApi::getOrderById(int64_t orderId) +pplx::task> StoreApi::getOrderById(utility::string_t orderId) { @@ -286,8 +287,8 @@ pplx::task> StoreApi::getOrderById(int64_t orderId) std::map> fileParams; std::unordered_set responseHttpContentTypes; - responseHttpContentTypes.insert( U("application/xml") ); -responseHttpContentTypes.insert( U("application/json") ); + responseHttpContentTypes.insert( U("application/json") ); +responseHttpContentTypes.insert( U("application/xml") ); utility::string_t responseHttpContentType; @@ -392,12 +393,6 @@ responseHttpContentTypes.insert( U("application/json") ); pplx::task> StoreApi::placeOrder(std::shared_ptr body) { - // verify the required parameter 'body' is set - if (body == nullptr) - { - throw ApiException(400, U("Missing required parameter 'body' when calling StoreApi->placeOrder")); - } - std::shared_ptr apiConfiguration( m_ApiClient->getConfiguration() ); utility::string_t path = U("/store/order"); @@ -408,8 +403,8 @@ pplx::task> StoreApi::placeOrder(std::shared_ptr b std::map> fileParams; std::unordered_set responseHttpContentTypes; - responseHttpContentTypes.insert( U("application/xml") ); -responseHttpContentTypes.insert( U("application/json") ); + responseHttpContentTypes.insert( U("application/json") ); +responseHttpContentTypes.insert( U("application/xml") ); utility::string_t responseHttpContentType; diff --git a/samples/client/petstore/cpprest/api/StoreApi.h b/samples/client/petstore/cpprest/api/StoreApi.h index 0b843e6e47b..e9c2ae6ca8c 100644 --- a/samples/client/petstore/cpprest/api/StoreApi.h +++ b/samples/client/petstore/cpprest/api/StoreApi.h @@ -1,9 +1,9 @@ /** * Swagger Petstore - * This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key `special-key` to test the authorization filters. + * This is a sample server Petstore server. You can find out more about Swagger at http://swagger.io or on irc.freenode.net, #swagger. For this sample, you can use the api key \"special-key\" to test the authorization filters * * OpenAPI spec version: 1.0.0 - * Contact: apiteam@swagger.io + * Contact: apiteam@wordnik.com * * NOTE: This class is auto generated by the swagger code generator program. * https://github.com/swagger-api/swagger-codegen.git @@ -73,14 +73,14 @@ class StoreApi /// For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions /// /// ID of pet that needs to be fetched - pplx::task> getOrderById(int64_t orderId); + pplx::task> getOrderById(utility::string_t orderId); /// /// Place an order for a pet /// /// /// /// - /// order placed for purchasing the pet + /// order placed for purchasing the pet (optional) pplx::task> placeOrder(std::shared_ptr body); protected: diff --git a/samples/client/petstore/cpprest/api/UserApi.cpp b/samples/client/petstore/cpprest/api/UserApi.cpp index d376311036b..3844a70f06b 100644 --- a/samples/client/petstore/cpprest/api/UserApi.cpp +++ b/samples/client/petstore/cpprest/api/UserApi.cpp @@ -1,9 +1,9 @@ /** * Swagger Petstore - * This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key `special-key` to test the authorization filters. + * This is a sample server Petstore server. You can find out more about Swagger at http://swagger.io or on irc.freenode.net, #swagger. For this sample, you can use the api key \"special-key\" to test the authorization filters * * OpenAPI spec version: 1.0.0 - * Contact: apiteam@swagger.io + * Contact: apiteam@wordnik.com * * NOTE: This class is auto generated by the swagger code generator program. * https://github.com/swagger-api/swagger-codegen.git @@ -51,12 +51,6 @@ UserApi::~UserApi() pplx::task UserApi::createUser(std::shared_ptr body) { - // verify the required parameter 'body' is set - if (body == nullptr) - { - throw ApiException(400, U("Missing required parameter 'body' when calling UserApi->createUser")); - } - std::shared_ptr apiConfiguration( m_ApiClient->getConfiguration() ); utility::string_t path = U("/user"); @@ -67,8 +61,8 @@ pplx::task UserApi::createUser(std::shared_ptr body) std::map> fileParams; std::unordered_set responseHttpContentTypes; - responseHttpContentTypes.insert( U("application/xml") ); -responseHttpContentTypes.insert( U("application/json") ); + responseHttpContentTypes.insert( U("application/json") ); +responseHttpContentTypes.insert( U("application/xml") ); utility::string_t responseHttpContentType; @@ -178,8 +172,8 @@ pplx::task UserApi::createUsersWithArrayInput(std::vector> fileParams; std::unordered_set responseHttpContentTypes; - responseHttpContentTypes.insert( U("application/xml") ); -responseHttpContentTypes.insert( U("application/json") ); + responseHttpContentTypes.insert( U("application/json") ); +responseHttpContentTypes.insert( U("application/xml") ); utility::string_t responseHttpContentType; @@ -303,8 +297,8 @@ pplx::task UserApi::createUsersWithListInput(std::vector> fileParams; std::unordered_set responseHttpContentTypes; - responseHttpContentTypes.insert( U("application/xml") ); -responseHttpContentTypes.insert( U("application/json") ); + responseHttpContentTypes.insert( U("application/json") ); +responseHttpContentTypes.insert( U("application/xml") ); utility::string_t responseHttpContentType; @@ -429,8 +423,8 @@ pplx::task UserApi::deleteUser(utility::string_t username) std::map> fileParams; std::unordered_set responseHttpContentTypes; - responseHttpContentTypes.insert( U("application/xml") ); -responseHttpContentTypes.insert( U("application/json") ); + responseHttpContentTypes.insert( U("application/json") ); +responseHttpContentTypes.insert( U("application/xml") ); utility::string_t responseHttpContentType; @@ -528,8 +522,8 @@ pplx::task> UserApi::getUserByName(utility::string_t usern std::map> fileParams; std::unordered_set responseHttpContentTypes; - responseHttpContentTypes.insert( U("application/xml") ); -responseHttpContentTypes.insert( U("application/json") ); + responseHttpContentTypes.insert( U("application/json") ); +responseHttpContentTypes.insert( U("application/xml") ); utility::string_t responseHttpContentType; @@ -644,8 +638,8 @@ pplx::task UserApi::loginUser(utility::string_t username, uti std::map> fileParams; std::unordered_set responseHttpContentTypes; - responseHttpContentTypes.insert( U("application/xml") ); -responseHttpContentTypes.insert( U("application/json") ); + responseHttpContentTypes.insert( U("application/json") ); +responseHttpContentTypes.insert( U("application/xml") ); utility::string_t responseHttpContentType; @@ -767,8 +761,8 @@ pplx::task UserApi::logoutUser() std::map> fileParams; std::unordered_set responseHttpContentTypes; - responseHttpContentTypes.insert( U("application/xml") ); -responseHttpContentTypes.insert( U("application/json") ); + responseHttpContentTypes.insert( U("application/json") ); +responseHttpContentTypes.insert( U("application/xml") ); utility::string_t responseHttpContentType; @@ -851,12 +845,6 @@ responseHttpContentTypes.insert( U("application/json") ); pplx::task UserApi::updateUser(utility::string_t username, std::shared_ptr body) { - // verify the required parameter 'body' is set - if (body == nullptr) - { - throw ApiException(400, U("Missing required parameter 'body' when calling UserApi->updateUser")); - } - std::shared_ptr apiConfiguration( m_ApiClient->getConfiguration() ); utility::string_t path = U("/user/{username}"); @@ -868,8 +856,8 @@ pplx::task UserApi::updateUser(utility::string_t username, std::shared_ptr std::map> fileParams; std::unordered_set responseHttpContentTypes; - responseHttpContentTypes.insert( U("application/xml") ); -responseHttpContentTypes.insert( U("application/json") ); + responseHttpContentTypes.insert( U("application/json") ); +responseHttpContentTypes.insert( U("application/xml") ); utility::string_t responseHttpContentType; diff --git a/samples/client/petstore/cpprest/api/UserApi.h b/samples/client/petstore/cpprest/api/UserApi.h index 5f6214f16ab..34425d67a77 100644 --- a/samples/client/petstore/cpprest/api/UserApi.h +++ b/samples/client/petstore/cpprest/api/UserApi.h @@ -1,9 +1,9 @@ /** * Swagger Petstore - * This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key `special-key` to test the authorization filters. + * This is a sample server Petstore server. You can find out more about Swagger at http://swagger.io or on irc.freenode.net, #swagger. For this sample, you can use the api key \"special-key\" to test the authorization filters * * OpenAPI spec version: 1.0.0 - * Contact: apiteam@swagger.io + * Contact: apiteam@wordnik.com * * NOTE: This class is auto generated by the swagger code generator program. * https://github.com/swagger-api/swagger-codegen.git @@ -56,7 +56,7 @@ class UserApi /// /// This can only be done by the logged in user. /// - /// Created user object + /// Created user object (optional) pplx::task createUser(std::shared_ptr body); /// /// Creates list of users with given input array @@ -64,7 +64,7 @@ class UserApi /// /// /// - /// List of user object + /// List of user object (optional) pplx::task createUsersWithArrayInput(std::vector> body); /// /// Creates list of users with given input array @@ -72,7 +72,7 @@ class UserApi /// /// /// - /// List of user object + /// List of user object (optional) pplx::task createUsersWithListInput(std::vector> body); /// /// Delete user @@ -96,7 +96,7 @@ class UserApi /// /// /// - /// The user name for login/// The password for login in clear text + /// The user name for login (optional)/// The password for login in clear text (optional) pplx::task loginUser(utility::string_t username, utility::string_t password); /// /// Logs out current logged in user session @@ -112,7 +112,7 @@ class UserApi /// /// This can only be done by the logged in user. /// - /// name that need to be deleted/// Updated user object + /// name that need to be deleted/// Updated user object (optional) pplx::task updateUser(utility::string_t username, std::shared_ptr body); protected: diff --git a/samples/client/petstore/cpprest/model/Category.cpp b/samples/client/petstore/cpprest/model/Category.cpp index 8221b52237a..f8cb2ec6bb4 100644 --- a/samples/client/petstore/cpprest/model/Category.cpp +++ b/samples/client/petstore/cpprest/model/Category.cpp @@ -1,9 +1,9 @@ /** * Swagger Petstore - * This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key `special-key` to test the authorization filters. + * This is a sample server Petstore server. You can find out more about Swagger at http://swagger.io or on irc.freenode.net, #swagger. For this sample, you can use the api key \"special-key\" to test the authorization filters * * OpenAPI spec version: 1.0.0 - * Contact: apiteam@swagger.io + * Contact: apiteam@wordnik.com * * NOTE: This class is auto generated by the swagger code generator program. * https://github.com/swagger-api/swagger-codegen.git @@ -33,7 +33,7 @@ namespace model { Category::Category() { - m_Id = 0L; + m_Id = 0; m_IdIsSet = false; m_Name = U(""); m_NameIsSet = false; diff --git a/samples/client/petstore/cpprest/model/Category.h b/samples/client/petstore/cpprest/model/Category.h index 63bf2907d31..690cf8bcf43 100644 --- a/samples/client/petstore/cpprest/model/Category.h +++ b/samples/client/petstore/cpprest/model/Category.h @@ -1,9 +1,9 @@ /** * Swagger Petstore - * This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key `special-key` to test the authorization filters. + * This is a sample server Petstore server. You can find out more about Swagger at http://swagger.io or on irc.freenode.net, #swagger. For this sample, you can use the api key \"special-key\" to test the authorization filters * * OpenAPI spec version: 1.0.0 - * Contact: apiteam@swagger.io + * Contact: apiteam@wordnik.com * * NOTE: This class is auto generated by the swagger code generator program. * https://github.com/swagger-api/swagger-codegen.git diff --git a/samples/client/petstore/cpprest/model/Order.cpp b/samples/client/petstore/cpprest/model/Order.cpp index 43105712525..0a2ffdec9fd 100644 --- a/samples/client/petstore/cpprest/model/Order.cpp +++ b/samples/client/petstore/cpprest/model/Order.cpp @@ -1,9 +1,9 @@ /** * Swagger Petstore - * This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key `special-key` to test the authorization filters. + * This is a sample server Petstore server. You can find out more about Swagger at http://swagger.io or on irc.freenode.net, #swagger. For this sample, you can use the api key \"special-key\" to test the authorization filters * * OpenAPI spec version: 1.0.0 - * Contact: apiteam@swagger.io + * Contact: apiteam@wordnik.com * * NOTE: This class is auto generated by the swagger code generator program. * https://github.com/swagger-api/swagger-codegen.git @@ -33,9 +33,9 @@ namespace model { Order::Order() { - m_Id = 0L; + m_Id = 0; m_IdIsSet = false; - m_PetId = 0L; + m_PetId = 0; m_PetIdIsSet = false; m_Quantity = 0; m_QuantityIsSet = false; diff --git a/samples/client/petstore/cpprest/model/Order.h b/samples/client/petstore/cpprest/model/Order.h index 4af8f83d2d8..3c8bd62568f 100644 --- a/samples/client/petstore/cpprest/model/Order.h +++ b/samples/client/petstore/cpprest/model/Order.h @@ -1,9 +1,9 @@ /** * Swagger Petstore - * This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key `special-key` to test the authorization filters. + * This is a sample server Petstore server. You can find out more about Swagger at http://swagger.io or on irc.freenode.net, #swagger. For this sample, you can use the api key \"special-key\" to test the authorization filters * * OpenAPI spec version: 1.0.0 - * Contact: apiteam@swagger.io + * Contact: apiteam@wordnik.com * * NOTE: This class is auto generated by the swagger code generator program. * https://github.com/swagger-api/swagger-codegen.git diff --git a/samples/client/petstore/cpprest/model/Pet.cpp b/samples/client/petstore/cpprest/model/Pet.cpp index 578570305f7..3604e63659a 100644 --- a/samples/client/petstore/cpprest/model/Pet.cpp +++ b/samples/client/petstore/cpprest/model/Pet.cpp @@ -1,9 +1,9 @@ /** * Swagger Petstore - * This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key `special-key` to test the authorization filters. + * This is a sample server Petstore server. You can find out more about Swagger at http://swagger.io or on irc.freenode.net, #swagger. For this sample, you can use the api key \"special-key\" to test the authorization filters * * OpenAPI spec version: 1.0.0 - * Contact: apiteam@swagger.io + * Contact: apiteam@wordnik.com * * NOTE: This class is auto generated by the swagger code generator program. * https://github.com/swagger-api/swagger-codegen.git @@ -33,7 +33,7 @@ namespace model { Pet::Pet() { - m_Id = 0L; + m_Id = 0; m_IdIsSet = false; m_CategoryIsSet = false; m_Name = U(""); diff --git a/samples/client/petstore/cpprest/model/Pet.h b/samples/client/petstore/cpprest/model/Pet.h index 88a6fe19f7e..8127ed16132 100644 --- a/samples/client/petstore/cpprest/model/Pet.h +++ b/samples/client/petstore/cpprest/model/Pet.h @@ -1,9 +1,9 @@ /** * Swagger Petstore - * This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key `special-key` to test the authorization filters. + * This is a sample server Petstore server. You can find out more about Swagger at http://swagger.io or on irc.freenode.net, #swagger. For this sample, you can use the api key \"special-key\" to test the authorization filters * * OpenAPI spec version: 1.0.0 - * Contact: apiteam@swagger.io + * Contact: apiteam@wordnik.com * * NOTE: This class is auto generated by the swagger code generator program. * https://github.com/swagger-api/swagger-codegen.git @@ -34,10 +34,10 @@ #include "ModelBase.h" -#include "Category.h" +#include "Tag.h" #include +#include "Category.h" #include -#include "Tag.h" namespace io { namespace swagger { diff --git a/samples/client/petstore/cpprest/model/Tag.cpp b/samples/client/petstore/cpprest/model/Tag.cpp index 3f51e7069c9..2cb33ba48cc 100644 --- a/samples/client/petstore/cpprest/model/Tag.cpp +++ b/samples/client/petstore/cpprest/model/Tag.cpp @@ -1,9 +1,9 @@ /** * Swagger Petstore - * This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key `special-key` to test the authorization filters. + * This is a sample server Petstore server. You can find out more about Swagger at http://swagger.io or on irc.freenode.net, #swagger. For this sample, you can use the api key \"special-key\" to test the authorization filters * * OpenAPI spec version: 1.0.0 - * Contact: apiteam@swagger.io + * Contact: apiteam@wordnik.com * * NOTE: This class is auto generated by the swagger code generator program. * https://github.com/swagger-api/swagger-codegen.git @@ -33,7 +33,7 @@ namespace model { Tag::Tag() { - m_Id = 0L; + m_Id = 0; m_IdIsSet = false; m_Name = U(""); m_NameIsSet = false; diff --git a/samples/client/petstore/cpprest/model/Tag.h b/samples/client/petstore/cpprest/model/Tag.h index 9a9381add81..ced6bdc5c4a 100644 --- a/samples/client/petstore/cpprest/model/Tag.h +++ b/samples/client/petstore/cpprest/model/Tag.h @@ -1,9 +1,9 @@ /** * Swagger Petstore - * This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key `special-key` to test the authorization filters. + * This is a sample server Petstore server. You can find out more about Swagger at http://swagger.io or on irc.freenode.net, #swagger. For this sample, you can use the api key \"special-key\" to test the authorization filters * * OpenAPI spec version: 1.0.0 - * Contact: apiteam@swagger.io + * Contact: apiteam@wordnik.com * * NOTE: This class is auto generated by the swagger code generator program. * https://github.com/swagger-api/swagger-codegen.git diff --git a/samples/client/petstore/cpprest/model/User.cpp b/samples/client/petstore/cpprest/model/User.cpp index 87ebe24916a..9beb9422a40 100644 --- a/samples/client/petstore/cpprest/model/User.cpp +++ b/samples/client/petstore/cpprest/model/User.cpp @@ -1,9 +1,9 @@ /** * Swagger Petstore - * This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key `special-key` to test the authorization filters. + * This is a sample server Petstore server. You can find out more about Swagger at http://swagger.io or on irc.freenode.net, #swagger. For this sample, you can use the api key \"special-key\" to test the authorization filters * * OpenAPI spec version: 1.0.0 - * Contact: apiteam@swagger.io + * Contact: apiteam@wordnik.com * * NOTE: This class is auto generated by the swagger code generator program. * https://github.com/swagger-api/swagger-codegen.git @@ -33,7 +33,7 @@ namespace model { User::User() { - m_Id = 0L; + m_Id = 0; m_IdIsSet = false; m_Username = U(""); m_UsernameIsSet = false; diff --git a/samples/client/petstore/cpprest/model/User.h b/samples/client/petstore/cpprest/model/User.h index 48fdb7d60f6..8baaeaed353 100644 --- a/samples/client/petstore/cpprest/model/User.h +++ b/samples/client/petstore/cpprest/model/User.h @@ -1,9 +1,9 @@ /** * Swagger Petstore - * This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key `special-key` to test the authorization filters. + * This is a sample server Petstore server. You can find out more about Swagger at http://swagger.io or on irc.freenode.net, #swagger. For this sample, you can use the api key \"special-key\" to test the authorization filters * * OpenAPI spec version: 1.0.0 - * Contact: apiteam@swagger.io + * Contact: apiteam@wordnik.com * * NOTE: This class is auto generated by the swagger code generator program. * https://github.com/swagger-api/swagger-codegen.git From 8151edae108645da6aaa7a57a0d62062f7a26eae Mon Sep 17 00:00:00 2001 From: Scott Richter Date: Mon, 12 Sep 2016 11:27:42 -0400 Subject: [PATCH 03/11] Removed debug code. --- .../java/io/swagger/codegen/languages/CppRestClientCodegen.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/CppRestClientCodegen.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/CppRestClientCodegen.java index c29678fc99e..9a96f687d6e 100644 --- a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/CppRestClientCodegen.java +++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/CppRestClientCodegen.java @@ -310,7 +310,7 @@ public String toDefaultValue(Property p) { RefProperty rp = (RefProperty) p; return "new " + toModelName(rp.getSimpleRef()) + "()"; } - //System.out.println(p.getClass().getName()); + return "nullptr"; } From f1eae45a72fc4502e1a6f4b93c4711e71f51ceea Mon Sep 17 00:00:00 2001 From: Scott Richter Date: Mon, 12 Sep 2016 11:36:03 -0400 Subject: [PATCH 04/11] Removed extra newline to match master. --- .../java/io/swagger/codegen/languages/CppRestClientCodegen.java | 1 - 1 file changed, 1 deletion(-) diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/CppRestClientCodegen.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/CppRestClientCodegen.java index 9a96f687d6e..0bd8b9588c8 100644 --- a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/CppRestClientCodegen.java +++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/CppRestClientCodegen.java @@ -310,7 +310,6 @@ public String toDefaultValue(Property p) { RefProperty rp = (RefProperty) p; return "new " + toModelName(rp.getSimpleRef()) + "()"; } - return "nullptr"; } From 986775dece2b6d865e281f482e267942dbb34fec Mon Sep 17 00:00:00 2001 From: Scott Richter Date: Mon, 19 Sep 2016 12:41:13 -0400 Subject: [PATCH 05/11] Fixed binary file handling in cpprest. Updated petstore samples. --- .../languages/CppRestClientCodegen.java | 15 ++- .../resources/cpprest/api-source.mustache | 25 ++++- .../cpprest/httpcontent-header.mustache | 4 +- .../cpprest/httpcontent-source.mustache | 10 -- .../cpprest/modelbase-header.mustache | 2 +- .../cpprest/modelbase-source.mustache | 4 +- .../client/petstore/cpprest/HttpContent.cpp | 4 +- samples/client/petstore/cpprest/HttpContent.h | 2 +- samples/client/petstore/cpprest/ModelBase.cpp | 4 +- samples/client/petstore/cpprest/ModelBase.h | 2 +- .../client/petstore/cpprest/api/PetApi.cpp | 98 +++++++++++-------- samples/client/petstore/cpprest/api/PetApi.h | 4 +- .../client/petstore/cpprest/api/StoreApi.cpp | 48 +++++---- .../client/petstore/cpprest/api/UserApi.cpp | 96 ++++++++++-------- 14 files changed, 186 insertions(+), 132 deletions(-) diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/CppRestClientCodegen.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/CppRestClientCodegen.java index 0bd8b9588c8..fa85a9f4b3a 100644 --- a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/CppRestClientCodegen.java +++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/CppRestClientCodegen.java @@ -110,7 +110,7 @@ public CppRestClientCodegen() { typeMapping.put("boolean", "bool"); typeMapping.put("array", "std::vector"); typeMapping.put("map", "std::map"); - typeMapping.put("file", "HttpContent"); + typeMapping.put("file", "Concurrency::streams::istream"); typeMapping.put("object", "Object"); typeMapping.put("binary", "std::string"); @@ -118,6 +118,7 @@ public CppRestClientCodegen() { importMapping.put("std::vector", "#include "); importMapping.put("std::map", "#include "); importMapping.put("std::string", "#include "); + importMapping.put("Concurrency::streams::istream", "#include "); importMapping.put("HttpContent", "#include \"HttpContent.h\""); importMapping.put("Object", "#include \"Object.h\""); importMapping.put("utility::string_t", "#include "); @@ -217,6 +218,10 @@ public CodegenOperation fromOperation(String path, String httpMethod, Operation if (methodResponse.getSchema() != null) { CodegenProperty cm = fromProperty("response", methodResponse.getSchema()); op.vendorExtensions.put("x-codegen-response", cm); + if(cm.datatype == "Concurrency::streams::istream") + { + op.vendorExtensions.put("x-codegen-response-istream", true); + } } } } @@ -232,7 +237,7 @@ public void postProcessModelProperty(CodegenModel model, CodegenProperty propert } protected boolean isFileProperty(CodegenProperty property) { - return property.baseType.equals("HttpContent"); + return property.baseType.equals("Concurrency::streams::istream"); } @Override @@ -267,7 +272,8 @@ public String getTypeDeclaration(Property p) { Property inner = mp.getAdditionalProperties(); return getSwaggerType(p) + ""; } - if (p instanceof StringProperty || p instanceof DateProperty || p instanceof DateTimeProperty + if (p instanceof StringProperty || p instanceof DateProperty + || p instanceof DateTimeProperty || p instanceof FileProperty || languageSpecificPrimitives.contains(swaggerType)) { return toModelName(swaggerType); } @@ -310,6 +316,9 @@ public String toDefaultValue(Property p) { RefProperty rp = (RefProperty) p; return "new " + toModelName(rp.getSimpleRef()) + "()"; } + else if (p instanceof FileProperty) { + return "Concurrency::streams::istream()"; + } return "nullptr"; } diff --git a/modules/swagger-codegen/src/main/resources/cpprest/api-source.mustache b/modules/swagger-codegen/src/main/resources/cpprest/api-source.mustache index b6312e37a7f..ce752307ae6 100644 --- a/modules/swagger-codegen/src/main/resources/cpprest/api-source.mustache +++ b/modules/swagger-codegen/src/main/resources/cpprest/api-source.mustache @@ -62,10 +62,19 @@ pplx::task<{{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}void{{/r { responseHttpContentType = U("multipart/form-data"); } + {{#vendorExtensions.x-codegen-response-istream}} else + { + //It's going to be binary, so just use the first one. + responseHttpContentType = *responseHttpContentTypes.begin(); + } + {{/vendorExtensions.x-codegen-response-istream}} + {{^vendorExtensions.x-codegen-response-istream}} + else { throw ApiException(400, U("{{classname}}->{{operationId}} does not produce any supported media type")); } + {{/vendorExtensions.x-codegen-response-istream}} headerParams[U("Accept")] = responseHttpContentType; @@ -201,10 +210,12 @@ pplx::task<{{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}void{{/r , std::make_shared(response.extract_utf8string(true).get())); } + utility::string_t contentType = U(""); + // check response content type if(response.headers().has(U("Content-Type"))) { - utility::string_t contentType = response.headers()[U("Content-Type")]; + contentType = response.headers()[U("Content-Type")]; if( contentType.find(responseHttpContentType) == std::string::npos ) { throw ApiException(500 @@ -212,13 +223,18 @@ pplx::task<{{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}void{{/r , std::make_shared(response.extract_utf8string(true).get())); } } - - return response.extract_string(); + + {{#vendorExtensions.x-codegen-response-istream}} + return response.body(); + {{/vendorExtensions.x-codegen-response-istream}} + {{^vendorExtensions.x-codegen-response-istream}} + return response.extract_string(); }) .then([=](utility::string_t response) { {{^returnType}}return void(); - {{/returnType}}{{#returnType}}{{#returnContainer}}{{{returnType}}} result; + {{/returnType}} + {{#returnType}}{{#returnContainer}}{{{returnType}}} result; {{/returnContainer}}{{^returnContainer}}{{{returnType}}} result({{{defaultResponse}}});{{/returnContainer}} if(responseHttpContentType == U("application/json")) @@ -259,6 +275,7 @@ pplx::task<{{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}void{{/r return result; {{/returnType}} + {{/vendorExtensions.x-codegen-response-istream}} }); } {{/operation}} diff --git a/modules/swagger-codegen/src/main/resources/cpprest/httpcontent-header.mustache b/modules/swagger-codegen/src/main/resources/cpprest/httpcontent-header.mustache index bc8c952f61c..d8bbde645fd 100644 --- a/modules/swagger-codegen/src/main/resources/cpprest/httpcontent-header.mustache +++ b/modules/swagger-codegen/src/main/resources/cpprest/httpcontent-header.mustache @@ -41,9 +41,7 @@ public: virtual void setData( std::shared_ptr value ); virtual void writeTo( std::ostream& stream ); - - virtual void fromJson(web::json::value& val); - + protected: // NOTE: no utility::string_t here because those strings can only contain ascii utility::string_t m_ContentDisposition; diff --git a/modules/swagger-codegen/src/main/resources/cpprest/httpcontent-source.mustache b/modules/swagger-codegen/src/main/resources/cpprest/httpcontent-source.mustache index afe1c52d6b8..c0f1dae71fd 100644 --- a/modules/swagger-codegen/src/main/resources/cpprest/httpcontent-source.mustache +++ b/modules/swagger-codegen/src/main/resources/cpprest/httpcontent-source.mustache @@ -70,16 +70,6 @@ void HttpContent::writeTo( std::ostream& stream ) stream << m_Data->rdbuf(); } -void HttpContent::fromJson(web::json::value& val) -{ - std::shared_ptr toCopy = ModelBase::fileFromJson(val); - - setName(toCopy->getName()); - setFileName(toCopy->getFileName()); - setContentType(toCopy->getContentType()); - setData(toCopy->getData()); -} - {{#modelNamespaceDeclarations}} } {{/modelNamespaceDeclarations}} diff --git a/modules/swagger-codegen/src/main/resources/cpprest/modelbase-header.mustache b/modules/swagger-codegen/src/main/resources/cpprest/modelbase-header.mustache index 204b9914540..33c5e45d8bf 100644 --- a/modules/swagger-codegen/src/main/resources/cpprest/modelbase-header.mustache +++ b/modules/swagger-codegen/src/main/resources/cpprest/modelbase-header.mustache @@ -47,7 +47,7 @@ public: static utility::datetime dateFromJson(web::json::value& val); static double doubleFromJson(web::json::value& val); static bool boolFromJson(web::json::value& val); - static std::shared_ptr fileFromJson(web::json::value& val); + //static std::shared_ptr fileFromJson(web::json::value& val); static std::shared_ptr toHttpContent( const utility::string_t& name, const utility::string_t& value, const utility::string_t& contentType = U("")); static std::shared_ptr toHttpContent( const utility::string_t& name, const utility::datetime& value, const utility::string_t& contentType = U("")); diff --git a/modules/swagger-codegen/src/main/resources/cpprest/modelbase-source.mustache b/modules/swagger-codegen/src/main/resources/cpprest/modelbase-source.mustache index 4d9ee6b40a0..542545ac7fc 100644 --- a/modules/swagger-codegen/src/main/resources/cpprest/modelbase-source.mustache +++ b/modules/swagger-codegen/src/main/resources/cpprest/modelbase-source.mustache @@ -43,7 +43,7 @@ web::json::value ModelBase::toJson( std::shared_ptr content ) return value; } -std::shared_ptr ModelBase::fileFromJson(web::json::value& val) +/*std::shared_ptr ModelBase::fileFromJson(web::json::value& val) { std::shared_ptr content(new HttpContent); @@ -65,7 +65,7 @@ std::shared_ptr ModelBase::fileFromJson(web::json::value& val) } return content; -} +}*/ web::json::value ModelBase::toJson( std::shared_ptr content ) { diff --git a/samples/client/petstore/cpprest/HttpContent.cpp b/samples/client/petstore/cpprest/HttpContent.cpp index 5cb27725a56..4e97d542200 100644 --- a/samples/client/petstore/cpprest/HttpContent.cpp +++ b/samples/client/petstore/cpprest/HttpContent.cpp @@ -94,7 +94,7 @@ void HttpContent::writeTo( std::ostream& stream ) stream << m_Data->rdbuf(); } -void HttpContent::fromJson(web::json::value& val) +/*void HttpContent::fromJson(web::json::value& val) { std::shared_ptr toCopy = ModelBase::fileFromJson(val); @@ -102,7 +102,7 @@ void HttpContent::fromJson(web::json::value& val) setFileName(toCopy->getFileName()); setContentType(toCopy->getContentType()); setData(toCopy->getData()); -} +}*/ } } diff --git a/samples/client/petstore/cpprest/HttpContent.h b/samples/client/petstore/cpprest/HttpContent.h index 5c58f530f63..195c4d0dc53 100644 --- a/samples/client/petstore/cpprest/HttpContent.h +++ b/samples/client/petstore/cpprest/HttpContent.h @@ -66,7 +66,7 @@ class HttpContent virtual void writeTo( std::ostream& stream ); - virtual void fromJson(web::json::value& val); + //virtual void fromJson(web::json::value& val); protected: // NOTE: no utility::string_t here because those strings can only contain ascii diff --git a/samples/client/petstore/cpprest/ModelBase.cpp b/samples/client/petstore/cpprest/ModelBase.cpp index 626ee2ad768..5ec2c9fc778 100644 --- a/samples/client/petstore/cpprest/ModelBase.cpp +++ b/samples/client/petstore/cpprest/ModelBase.cpp @@ -67,7 +67,7 @@ web::json::value ModelBase::toJson( std::shared_ptr content ) return value; } -std::shared_ptr ModelBase::fileFromJson(web::json::value& val) +/*std::shared_ptr ModelBase::fileFromJson(web::json::value& val) { std::shared_ptr content(new HttpContent); @@ -89,7 +89,7 @@ std::shared_ptr ModelBase::fileFromJson(web::json::value& val) } return content; -} +}*/ web::json::value ModelBase::toJson( std::shared_ptr content ) { diff --git a/samples/client/petstore/cpprest/ModelBase.h b/samples/client/petstore/cpprest/ModelBase.h index 8514ec1ba8a..924d8fe4dde 100644 --- a/samples/client/petstore/cpprest/ModelBase.h +++ b/samples/client/petstore/cpprest/ModelBase.h @@ -71,7 +71,7 @@ class ModelBase static utility::datetime dateFromJson(web::json::value& val); static double doubleFromJson(web::json::value& val); static bool boolFromJson(web::json::value& val); - static std::shared_ptr fileFromJson(web::json::value& val); + //static std::shared_ptr fileFromJson(web::json::value& val); static std::shared_ptr toHttpContent( const utility::string_t& name, const utility::string_t& value, const utility::string_t& contentType = U("")); static std::shared_ptr toHttpContent( const utility::string_t& name, const utility::datetime& value, const utility::string_t& contentType = U("")); diff --git a/samples/client/petstore/cpprest/api/PetApi.cpp b/samples/client/petstore/cpprest/api/PetApi.cpp index ac0fb12c3e5..824be19bd1d 100644 --- a/samples/client/petstore/cpprest/api/PetApi.cpp +++ b/samples/client/petstore/cpprest/api/PetApi.cpp @@ -76,7 +76,7 @@ responseHttpContentTypes.insert( U("application/xml") ); { responseHttpContentType = U("multipart/form-data"); } - else + else { throw ApiException(400, U("PetApi->addPet does not produce any supported media type")); } @@ -144,10 +144,12 @@ consumeHttpContentTypes.insert( U("application/xml") ); , std::make_shared(response.extract_utf8string(true).get())); } + utility::string_t contentType = U(""); + // check response content type if(response.headers().has(U("Content-Type"))) { - utility::string_t contentType = response.headers()[U("Content-Type")]; + contentType = response.headers()[U("Content-Type")]; if( contentType.find(responseHttpContentType) == std::string::npos ) { throw ApiException(500 @@ -155,13 +157,13 @@ consumeHttpContentTypes.insert( U("application/xml") ); , std::make_shared(response.extract_utf8string(true).get())); } } - - return response.extract_string(); + + return response.extract_string(); }) .then([=](utility::string_t response) { return void(); - }); + }); } pplx::task PetApi::deletePet(int64_t petId, utility::string_t apiKey) { @@ -192,7 +194,7 @@ responseHttpContentTypes.insert( U("application/xml") ); { responseHttpContentType = U("multipart/form-data"); } - else + else { throw ApiException(400, U("PetApi->deletePet does not produce any supported media type")); } @@ -250,10 +252,12 @@ responseHttpContentTypes.insert( U("application/xml") ); , std::make_shared(response.extract_utf8string(true).get())); } + utility::string_t contentType = U(""); + // check response content type if(response.headers().has(U("Content-Type"))) { - utility::string_t contentType = response.headers()[U("Content-Type")]; + contentType = response.headers()[U("Content-Type")]; if( contentType.find(responseHttpContentType) == std::string::npos ) { throw ApiException(500 @@ -261,13 +265,13 @@ responseHttpContentTypes.insert( U("application/xml") ); , std::make_shared(response.extract_utf8string(true).get())); } } - - return response.extract_string(); + + return response.extract_string(); }) .then([=](utility::string_t response) { return void(); - }); + }); } pplx::task>> PetApi::findPetsByStatus(std::vector status) { @@ -297,7 +301,7 @@ responseHttpContentTypes.insert( U("application/xml") ); { responseHttpContentType = U("multipart/form-data"); } - else + else { throw ApiException(400, U("PetApi->findPetsByStatus does not produce any supported media type")); } @@ -351,10 +355,12 @@ responseHttpContentTypes.insert( U("application/xml") ); , std::make_shared(response.extract_utf8string(true).get())); } + utility::string_t contentType = U(""); + // check response content type if(response.headers().has(U("Content-Type"))) { - utility::string_t contentType = response.headers()[U("Content-Type")]; + contentType = response.headers()[U("Content-Type")]; if( contentType.find(responseHttpContentType) == std::string::npos ) { throw ApiException(500 @@ -362,12 +368,12 @@ responseHttpContentTypes.insert( U("application/xml") ); , std::make_shared(response.extract_utf8string(true).get())); } } - - return response.extract_string(); + + return response.extract_string(); }) .then([=](utility::string_t response) { - std::vector> result; + std::vector> result; if(responseHttpContentType == U("application/json")) @@ -424,7 +430,7 @@ responseHttpContentTypes.insert( U("application/xml") ); { responseHttpContentType = U("multipart/form-data"); } - else + else { throw ApiException(400, U("PetApi->findPetsByTags does not produce any supported media type")); } @@ -478,10 +484,12 @@ responseHttpContentTypes.insert( U("application/xml") ); , std::make_shared(response.extract_utf8string(true).get())); } + utility::string_t contentType = U(""); + // check response content type if(response.headers().has(U("Content-Type"))) { - utility::string_t contentType = response.headers()[U("Content-Type")]; + contentType = response.headers()[U("Content-Type")]; if( contentType.find(responseHttpContentType) == std::string::npos ) { throw ApiException(500 @@ -489,12 +497,12 @@ responseHttpContentTypes.insert( U("application/xml") ); , std::make_shared(response.extract_utf8string(true).get())); } } - - return response.extract_string(); + + return response.extract_string(); }) .then([=](utility::string_t response) { - std::vector> result; + std::vector> result; if(responseHttpContentType == U("application/json")) @@ -552,7 +560,7 @@ responseHttpContentTypes.insert( U("application/xml") ); { responseHttpContentType = U("multipart/form-data"); } - else + else { throw ApiException(400, U("PetApi->getPetById does not produce any supported media type")); } @@ -613,10 +621,12 @@ responseHttpContentTypes.insert( U("application/xml") ); , std::make_shared(response.extract_utf8string(true).get())); } + utility::string_t contentType = U(""); + // check response content type if(response.headers().has(U("Content-Type"))) { - utility::string_t contentType = response.headers()[U("Content-Type")]; + contentType = response.headers()[U("Content-Type")]; if( contentType.find(responseHttpContentType) == std::string::npos ) { throw ApiException(500 @@ -624,12 +634,12 @@ responseHttpContentTypes.insert( U("application/xml") ); , std::make_shared(response.extract_utf8string(true).get())); } } - - return response.extract_string(); + + return response.extract_string(); }) .then([=](utility::string_t response) { - std::shared_ptr result(new Pet()); + std::shared_ptr result(new Pet()); if(responseHttpContentType == U("application/json")) { @@ -678,7 +688,7 @@ responseHttpContentTypes.insert( U("application/xml") ); { responseHttpContentType = U("multipart/form-data"); } - else + else { throw ApiException(400, U("PetApi->updatePet does not produce any supported media type")); } @@ -746,10 +756,12 @@ consumeHttpContentTypes.insert( U("application/xml") ); , std::make_shared(response.extract_utf8string(true).get())); } + utility::string_t contentType = U(""); + // check response content type if(response.headers().has(U("Content-Type"))) { - utility::string_t contentType = response.headers()[U("Content-Type")]; + contentType = response.headers()[U("Content-Type")]; if( contentType.find(responseHttpContentType) == std::string::npos ) { throw ApiException(500 @@ -757,13 +769,13 @@ consumeHttpContentTypes.insert( U("application/xml") ); , std::make_shared(response.extract_utf8string(true).get())); } } - - return response.extract_string(); + + return response.extract_string(); }) .then([=](utility::string_t response) { return void(); - }); + }); } pplx::task PetApi::updatePetWithForm(utility::string_t petId, utility::string_t name, utility::string_t status) { @@ -794,7 +806,7 @@ responseHttpContentTypes.insert( U("application/xml") ); { responseHttpContentType = U("multipart/form-data"); } - else + else { throw ApiException(400, U("PetApi->updatePetWithForm does not produce any supported media type")); } @@ -858,10 +870,12 @@ responseHttpContentTypes.insert( U("application/xml") ); , std::make_shared(response.extract_utf8string(true).get())); } + utility::string_t contentType = U(""); + // check response content type if(response.headers().has(U("Content-Type"))) { - utility::string_t contentType = response.headers()[U("Content-Type")]; + contentType = response.headers()[U("Content-Type")]; if( contentType.find(responseHttpContentType) == std::string::npos ) { throw ApiException(500 @@ -869,15 +883,15 @@ responseHttpContentTypes.insert( U("application/xml") ); , std::make_shared(response.extract_utf8string(true).get())); } } - - return response.extract_string(); + + return response.extract_string(); }) .then([=](utility::string_t response) { return void(); - }); + }); } -pplx::task PetApi::uploadFile(int64_t petId, utility::string_t additionalMetadata, std::shared_ptr file) +pplx::task PetApi::uploadFile(int64_t petId, utility::string_t additionalMetadata, std::shared_ptr file) { @@ -906,7 +920,7 @@ responseHttpContentTypes.insert( U("application/xml") ); { responseHttpContentType = U("multipart/form-data"); } - else + else { throw ApiException(400, U("PetApi->uploadFile does not produce any supported media type")); } @@ -970,10 +984,12 @@ responseHttpContentTypes.insert( U("application/xml") ); , std::make_shared(response.extract_utf8string(true).get())); } + utility::string_t contentType = U(""); + // check response content type if(response.headers().has(U("Content-Type"))) { - utility::string_t contentType = response.headers()[U("Content-Type")]; + contentType = response.headers()[U("Content-Type")]; if( contentType.find(responseHttpContentType) == std::string::npos ) { throw ApiException(500 @@ -981,13 +997,13 @@ responseHttpContentTypes.insert( U("application/xml") ); , std::make_shared(response.extract_utf8string(true).get())); } } - - return response.extract_string(); + + return response.extract_string(); }) .then([=](utility::string_t response) { return void(); - }); + }); } } diff --git a/samples/client/petstore/cpprest/api/PetApi.h b/samples/client/petstore/cpprest/api/PetApi.h index e3d1b40a3a8..f5d38fda67d 100644 --- a/samples/client/petstore/cpprest/api/PetApi.h +++ b/samples/client/petstore/cpprest/api/PetApi.h @@ -36,7 +36,7 @@ #include "Pet.h" #include -#include "HttpContent.h" +#include namespace io { namespace swagger { @@ -113,7 +113,7 @@ class PetApi /// /// /// ID of pet to update/// Additional data to pass to server (optional)/// file to upload (optional) - pplx::task uploadFile(int64_t petId, utility::string_t additionalMetadata, std::shared_ptr file); + pplx::task uploadFile(int64_t petId, utility::string_t additionalMetadata, std::shared_ptr file); protected: std::shared_ptr m_ApiClient; diff --git a/samples/client/petstore/cpprest/api/StoreApi.cpp b/samples/client/petstore/cpprest/api/StoreApi.cpp index 911505c78fd..ce88ac9c988 100644 --- a/samples/client/petstore/cpprest/api/StoreApi.cpp +++ b/samples/client/petstore/cpprest/api/StoreApi.cpp @@ -77,7 +77,7 @@ responseHttpContentTypes.insert( U("application/xml") ); { responseHttpContentType = U("multipart/form-data"); } - else + else { throw ApiException(400, U("StoreApi->deleteOrder does not produce any supported media type")); } @@ -128,10 +128,12 @@ responseHttpContentTypes.insert( U("application/xml") ); , std::make_shared(response.extract_utf8string(true).get())); } + utility::string_t contentType = U(""); + // check response content type if(response.headers().has(U("Content-Type"))) { - utility::string_t contentType = response.headers()[U("Content-Type")]; + contentType = response.headers()[U("Content-Type")]; if( contentType.find(responseHttpContentType) == std::string::npos ) { throw ApiException(500 @@ -139,13 +141,13 @@ responseHttpContentTypes.insert( U("application/xml") ); , std::make_shared(response.extract_utf8string(true).get())); } } - - return response.extract_string(); + + return response.extract_string(); }) .then([=](utility::string_t response) { return void(); - }); + }); } pplx::task> StoreApi::getInventory() { @@ -175,7 +177,7 @@ responseHttpContentTypes.insert( U("application/xml") ); { responseHttpContentType = U("multipart/form-data"); } - else + else { throw ApiException(400, U("StoreApi->getInventory does not produce any supported media type")); } @@ -230,10 +232,12 @@ responseHttpContentTypes.insert( U("application/xml") ); , std::make_shared(response.extract_utf8string(true).get())); } + utility::string_t contentType = U(""); + // check response content type if(response.headers().has(U("Content-Type"))) { - utility::string_t contentType = response.headers()[U("Content-Type")]; + contentType = response.headers()[U("Content-Type")]; if( contentType.find(responseHttpContentType) == std::string::npos ) { throw ApiException(500 @@ -241,12 +245,12 @@ responseHttpContentTypes.insert( U("application/xml") ); , std::make_shared(response.extract_utf8string(true).get())); } } - - return response.extract_string(); + + return response.extract_string(); }) .then([=](utility::string_t response) { - std::map result; + std::map result; if(responseHttpContentType == U("application/json")) @@ -302,7 +306,7 @@ responseHttpContentTypes.insert( U("application/xml") ); { responseHttpContentType = U("multipart/form-data"); } - else + else { throw ApiException(400, U("StoreApi->getOrderById does not produce any supported media type")); } @@ -353,10 +357,12 @@ responseHttpContentTypes.insert( U("application/xml") ); , std::make_shared(response.extract_utf8string(true).get())); } + utility::string_t contentType = U(""); + // check response content type if(response.headers().has(U("Content-Type"))) { - utility::string_t contentType = response.headers()[U("Content-Type")]; + contentType = response.headers()[U("Content-Type")]; if( contentType.find(responseHttpContentType) == std::string::npos ) { throw ApiException(500 @@ -364,12 +370,12 @@ responseHttpContentTypes.insert( U("application/xml") ); , std::make_shared(response.extract_utf8string(true).get())); } } - - return response.extract_string(); + + return response.extract_string(); }) .then([=](utility::string_t response) { - std::shared_ptr result(new Order()); + std::shared_ptr result(new Order()); if(responseHttpContentType == U("application/json")) { @@ -418,7 +424,7 @@ responseHttpContentTypes.insert( U("application/xml") ); { responseHttpContentType = U("multipart/form-data"); } - else + else { throw ApiException(400, U("StoreApi->placeOrder does not produce any supported media type")); } @@ -482,10 +488,12 @@ responseHttpContentTypes.insert( U("application/xml") ); , std::make_shared(response.extract_utf8string(true).get())); } + utility::string_t contentType = U(""); + // check response content type if(response.headers().has(U("Content-Type"))) { - utility::string_t contentType = response.headers()[U("Content-Type")]; + contentType = response.headers()[U("Content-Type")]; if( contentType.find(responseHttpContentType) == std::string::npos ) { throw ApiException(500 @@ -493,12 +501,12 @@ responseHttpContentTypes.insert( U("application/xml") ); , std::make_shared(response.extract_utf8string(true).get())); } } - - return response.extract_string(); + + return response.extract_string(); }) .then([=](utility::string_t response) { - std::shared_ptr result(new Order()); + std::shared_ptr result(new Order()); if(responseHttpContentType == U("application/json")) { diff --git a/samples/client/petstore/cpprest/api/UserApi.cpp b/samples/client/petstore/cpprest/api/UserApi.cpp index 3844a70f06b..d2d7ee3390b 100644 --- a/samples/client/petstore/cpprest/api/UserApi.cpp +++ b/samples/client/petstore/cpprest/api/UserApi.cpp @@ -76,7 +76,7 @@ responseHttpContentTypes.insert( U("application/xml") ); { responseHttpContentType = U("multipart/form-data"); } - else + else { throw ApiException(400, U("UserApi->createUser does not produce any supported media type")); } @@ -140,10 +140,12 @@ responseHttpContentTypes.insert( U("application/xml") ); , std::make_shared(response.extract_utf8string(true).get())); } + utility::string_t contentType = U(""); + // check response content type if(response.headers().has(U("Content-Type"))) { - utility::string_t contentType = response.headers()[U("Content-Type")]; + contentType = response.headers()[U("Content-Type")]; if( contentType.find(responseHttpContentType) == std::string::npos ) { throw ApiException(500 @@ -151,13 +153,13 @@ responseHttpContentTypes.insert( U("application/xml") ); , std::make_shared(response.extract_utf8string(true).get())); } } - - return response.extract_string(); + + return response.extract_string(); }) .then([=](utility::string_t response) { return void(); - }); + }); } pplx::task UserApi::createUsersWithArrayInput(std::vector> body) { @@ -187,7 +189,7 @@ responseHttpContentTypes.insert( U("application/xml") ); { responseHttpContentType = U("multipart/form-data"); } - else + else { throw ApiException(400, U("UserApi->createUsersWithArrayInput does not produce any supported media type")); } @@ -265,10 +267,12 @@ responseHttpContentTypes.insert( U("application/xml") ); , std::make_shared(response.extract_utf8string(true).get())); } + utility::string_t contentType = U(""); + // check response content type if(response.headers().has(U("Content-Type"))) { - utility::string_t contentType = response.headers()[U("Content-Type")]; + contentType = response.headers()[U("Content-Type")]; if( contentType.find(responseHttpContentType) == std::string::npos ) { throw ApiException(500 @@ -276,13 +280,13 @@ responseHttpContentTypes.insert( U("application/xml") ); , std::make_shared(response.extract_utf8string(true).get())); } } - - return response.extract_string(); + + return response.extract_string(); }) .then([=](utility::string_t response) { return void(); - }); + }); } pplx::task UserApi::createUsersWithListInput(std::vector> body) { @@ -312,7 +316,7 @@ responseHttpContentTypes.insert( U("application/xml") ); { responseHttpContentType = U("multipart/form-data"); } - else + else { throw ApiException(400, U("UserApi->createUsersWithListInput does not produce any supported media type")); } @@ -390,10 +394,12 @@ responseHttpContentTypes.insert( U("application/xml") ); , std::make_shared(response.extract_utf8string(true).get())); } + utility::string_t contentType = U(""); + // check response content type if(response.headers().has(U("Content-Type"))) { - utility::string_t contentType = response.headers()[U("Content-Type")]; + contentType = response.headers()[U("Content-Type")]; if( contentType.find(responseHttpContentType) == std::string::npos ) { throw ApiException(500 @@ -401,13 +407,13 @@ responseHttpContentTypes.insert( U("application/xml") ); , std::make_shared(response.extract_utf8string(true).get())); } } - - return response.extract_string(); + + return response.extract_string(); }) .then([=](utility::string_t response) { return void(); - }); + }); } pplx::task UserApi::deleteUser(utility::string_t username) { @@ -438,7 +444,7 @@ responseHttpContentTypes.insert( U("application/xml") ); { responseHttpContentType = U("multipart/form-data"); } - else + else { throw ApiException(400, U("UserApi->deleteUser does not produce any supported media type")); } @@ -489,10 +495,12 @@ responseHttpContentTypes.insert( U("application/xml") ); , std::make_shared(response.extract_utf8string(true).get())); } + utility::string_t contentType = U(""); + // check response content type if(response.headers().has(U("Content-Type"))) { - utility::string_t contentType = response.headers()[U("Content-Type")]; + contentType = response.headers()[U("Content-Type")]; if( contentType.find(responseHttpContentType) == std::string::npos ) { throw ApiException(500 @@ -500,13 +508,13 @@ responseHttpContentTypes.insert( U("application/xml") ); , std::make_shared(response.extract_utf8string(true).get())); } } - - return response.extract_string(); + + return response.extract_string(); }) .then([=](utility::string_t response) { return void(); - }); + }); } pplx::task> UserApi::getUserByName(utility::string_t username) { @@ -537,7 +545,7 @@ responseHttpContentTypes.insert( U("application/xml") ); { responseHttpContentType = U("multipart/form-data"); } - else + else { throw ApiException(400, U("UserApi->getUserByName does not produce any supported media type")); } @@ -588,10 +596,12 @@ responseHttpContentTypes.insert( U("application/xml") ); , std::make_shared(response.extract_utf8string(true).get())); } + utility::string_t contentType = U(""); + // check response content type if(response.headers().has(U("Content-Type"))) { - utility::string_t contentType = response.headers()[U("Content-Type")]; + contentType = response.headers()[U("Content-Type")]; if( contentType.find(responseHttpContentType) == std::string::npos ) { throw ApiException(500 @@ -599,12 +609,12 @@ responseHttpContentTypes.insert( U("application/xml") ); , std::make_shared(response.extract_utf8string(true).get())); } } - - return response.extract_string(); + + return response.extract_string(); }) .then([=](utility::string_t response) { - std::shared_ptr result(new User()); + std::shared_ptr result(new User()); if(responseHttpContentType == U("application/json")) { @@ -653,7 +663,7 @@ responseHttpContentTypes.insert( U("application/xml") ); { responseHttpContentType = U("multipart/form-data"); } - else + else { throw ApiException(400, U("UserApi->loginUser does not produce any supported media type")); } @@ -710,10 +720,12 @@ responseHttpContentTypes.insert( U("application/xml") ); , std::make_shared(response.extract_utf8string(true).get())); } + utility::string_t contentType = U(""); + // check response content type if(response.headers().has(U("Content-Type"))) { - utility::string_t contentType = response.headers()[U("Content-Type")]; + contentType = response.headers()[U("Content-Type")]; if( contentType.find(responseHttpContentType) == std::string::npos ) { throw ApiException(500 @@ -721,12 +733,12 @@ responseHttpContentTypes.insert( U("application/xml") ); , std::make_shared(response.extract_utf8string(true).get())); } } - - return response.extract_string(); + + return response.extract_string(); }) .then([=](utility::string_t response) { - utility::string_t result(U("")); + utility::string_t result(U("")); if(responseHttpContentType == U("application/json")) { @@ -776,7 +788,7 @@ responseHttpContentTypes.insert( U("application/xml") ); { responseHttpContentType = U("multipart/form-data"); } - else + else { throw ApiException(400, U("UserApi->logoutUser does not produce any supported media type")); } @@ -823,10 +835,12 @@ responseHttpContentTypes.insert( U("application/xml") ); , std::make_shared(response.extract_utf8string(true).get())); } + utility::string_t contentType = U(""); + // check response content type if(response.headers().has(U("Content-Type"))) { - utility::string_t contentType = response.headers()[U("Content-Type")]; + contentType = response.headers()[U("Content-Type")]; if( contentType.find(responseHttpContentType) == std::string::npos ) { throw ApiException(500 @@ -834,13 +848,13 @@ responseHttpContentTypes.insert( U("application/xml") ); , std::make_shared(response.extract_utf8string(true).get())); } } - - return response.extract_string(); + + return response.extract_string(); }) .then([=](utility::string_t response) { return void(); - }); + }); } pplx::task UserApi::updateUser(utility::string_t username, std::shared_ptr body) { @@ -871,7 +885,7 @@ responseHttpContentTypes.insert( U("application/xml") ); { responseHttpContentType = U("multipart/form-data"); } - else + else { throw ApiException(400, U("UserApi->updateUser does not produce any supported media type")); } @@ -939,10 +953,12 @@ responseHttpContentTypes.insert( U("application/xml") ); , std::make_shared(response.extract_utf8string(true).get())); } + utility::string_t contentType = U(""); + // check response content type if(response.headers().has(U("Content-Type"))) { - utility::string_t contentType = response.headers()[U("Content-Type")]; + contentType = response.headers()[U("Content-Type")]; if( contentType.find(responseHttpContentType) == std::string::npos ) { throw ApiException(500 @@ -950,13 +966,13 @@ responseHttpContentTypes.insert( U("application/xml") ); , std::make_shared(response.extract_utf8string(true).get())); } } - - return response.extract_string(); + + return response.extract_string(); }) .then([=](utility::string_t response) { return void(); - }); + }); } } From b985618e6fcbf7d8a439a6c8c7b9a45a4851ac84 Mon Sep 17 00:00:00 2001 From: Scott Richter Date: Mon, 19 Sep 2016 13:29:51 -0400 Subject: [PATCH 06/11] Update readme to add Cummins to list --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index ce865a03ce2..33c28f94001 100644 --- a/README.md +++ b/README.md @@ -753,6 +753,7 @@ Here are some companies/projects using Swagger Codegen in production. To add you - [Cachet Financial](http://www.cachetfinancial.com/) - [CloudBoost](https://www.CloudBoost.io/) - [Conplement](http://www.conplement.de/) +- [Cummins] (http://www.cummins.com/) - [Cupix](http://www.cupix.com) - [DBBest Technologies](https://www.dbbest.com) - [DecentFoX](http://decentfox.com/) From 3898e01865e81f14f8bfda14fc45a9352fc6c1ef Mon Sep 17 00:00:00 2001 From: Scott Richter Date: Mon, 19 Sep 2016 14:49:31 -0400 Subject: [PATCH 07/11] Cleaning up for pull. Removing unnecessary changes. --- .../resources/cpprest/api-source.mustache | 9 +-- .../cpprest/httpcontent-header.mustache | 3 +- .../cpprest/httpcontent-source.mustache | 1 - .../cpprest/modelbase-header.mustache | 2 +- .../cpprest/modelbase-source.mustache | 4 +- .../client/petstore/cpprest/HttpContent.cpp | 11 ---- samples/client/petstore/cpprest/HttpContent.h | 3 - samples/client/petstore/cpprest/ModelBase.cpp | 4 +- samples/client/petstore/cpprest/ModelBase.h | 2 +- .../client/petstore/cpprest/api/PetApi.cpp | 64 +++++++------------ .../client/petstore/cpprest/api/StoreApi.cpp | 32 ++++------ .../client/petstore/cpprest/api/UserApi.cpp | 64 +++++++------------ 12 files changed, 70 insertions(+), 129 deletions(-) diff --git a/modules/swagger-codegen/src/main/resources/cpprest/api-source.mustache b/modules/swagger-codegen/src/main/resources/cpprest/api-source.mustache index ce752307ae6..4cc5b9c2a39 100644 --- a/modules/swagger-codegen/src/main/resources/cpprest/api-source.mustache +++ b/modules/swagger-codegen/src/main/resources/cpprest/api-source.mustache @@ -210,12 +210,10 @@ pplx::task<{{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}void{{/r , std::make_shared(response.extract_utf8string(true).get())); } - utility::string_t contentType = U(""); - - // check response content type + // check response content type if(response.headers().has(U("Content-Type"))) { - contentType = response.headers()[U("Content-Type")]; + utility::string_t contentType = response.headers()[U("Content-Type")]; if( contentType.find(responseHttpContentType) == std::string::npos ) { throw ApiException(500 @@ -233,8 +231,7 @@ pplx::task<{{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}void{{/r .then([=](utility::string_t response) { {{^returnType}}return void(); - {{/returnType}} - {{#returnType}}{{#returnContainer}}{{{returnType}}} result; + {{/returnType}}{{#returnType}}{{#returnContainer}}{{{returnType}}} result; {{/returnContainer}}{{^returnContainer}}{{{returnType}}} result({{{defaultResponse}}});{{/returnContainer}} if(responseHttpContentType == U("application/json")) diff --git a/modules/swagger-codegen/src/main/resources/cpprest/httpcontent-header.mustache b/modules/swagger-codegen/src/main/resources/cpprest/httpcontent-header.mustache index d8bbde645fd..622e4227f8e 100644 --- a/modules/swagger-codegen/src/main/resources/cpprest/httpcontent-header.mustache +++ b/modules/swagger-codegen/src/main/resources/cpprest/httpcontent-header.mustache @@ -13,7 +13,6 @@ #include #include -#include {{#modelNamespaceDeclarations}} namespace {{this}} { @@ -41,7 +40,7 @@ public: virtual void setData( std::shared_ptr value ); virtual void writeTo( std::ostream& stream ); - + protected: // NOTE: no utility::string_t here because those strings can only contain ascii utility::string_t m_ContentDisposition; diff --git a/modules/swagger-codegen/src/main/resources/cpprest/httpcontent-source.mustache b/modules/swagger-codegen/src/main/resources/cpprest/httpcontent-source.mustache index c0f1dae71fd..791515a205d 100644 --- a/modules/swagger-codegen/src/main/resources/cpprest/httpcontent-source.mustache +++ b/modules/swagger-codegen/src/main/resources/cpprest/httpcontent-source.mustache @@ -1,6 +1,5 @@ {{>licenseInfo}} #include "HttpContent.h" -#include "ModelBase.h" {{#modelNamespaceDeclarations}} namespace {{this}} { diff --git a/modules/swagger-codegen/src/main/resources/cpprest/modelbase-header.mustache b/modules/swagger-codegen/src/main/resources/cpprest/modelbase-header.mustache index 33c5e45d8bf..204b9914540 100644 --- a/modules/swagger-codegen/src/main/resources/cpprest/modelbase-header.mustache +++ b/modules/swagger-codegen/src/main/resources/cpprest/modelbase-header.mustache @@ -47,7 +47,7 @@ public: static utility::datetime dateFromJson(web::json::value& val); static double doubleFromJson(web::json::value& val); static bool boolFromJson(web::json::value& val); - //static std::shared_ptr fileFromJson(web::json::value& val); + static std::shared_ptr fileFromJson(web::json::value& val); static std::shared_ptr toHttpContent( const utility::string_t& name, const utility::string_t& value, const utility::string_t& contentType = U("")); static std::shared_ptr toHttpContent( const utility::string_t& name, const utility::datetime& value, const utility::string_t& contentType = U("")); diff --git a/modules/swagger-codegen/src/main/resources/cpprest/modelbase-source.mustache b/modules/swagger-codegen/src/main/resources/cpprest/modelbase-source.mustache index 542545ac7fc..4d9ee6b40a0 100644 --- a/modules/swagger-codegen/src/main/resources/cpprest/modelbase-source.mustache +++ b/modules/swagger-codegen/src/main/resources/cpprest/modelbase-source.mustache @@ -43,7 +43,7 @@ web::json::value ModelBase::toJson( std::shared_ptr content ) return value; } -/*std::shared_ptr ModelBase::fileFromJson(web::json::value& val) +std::shared_ptr ModelBase::fileFromJson(web::json::value& val) { std::shared_ptr content(new HttpContent); @@ -65,7 +65,7 @@ web::json::value ModelBase::toJson( std::shared_ptr content ) } return content; -}*/ +} web::json::value ModelBase::toJson( std::shared_ptr content ) { diff --git a/samples/client/petstore/cpprest/HttpContent.cpp b/samples/client/petstore/cpprest/HttpContent.cpp index 4e97d542200..2079be25aa4 100644 --- a/samples/client/petstore/cpprest/HttpContent.cpp +++ b/samples/client/petstore/cpprest/HttpContent.cpp @@ -23,7 +23,6 @@ */ #include "HttpContent.h" -#include "ModelBase.h" namespace io { namespace swagger { @@ -94,16 +93,6 @@ void HttpContent::writeTo( std::ostream& stream ) stream << m_Data->rdbuf(); } -/*void HttpContent::fromJson(web::json::value& val) -{ - std::shared_ptr toCopy = ModelBase::fileFromJson(val); - - setName(toCopy->getName()); - setFileName(toCopy->getFileName()); - setContentType(toCopy->getContentType()); - setData(toCopy->getData()); -}*/ - } } } diff --git a/samples/client/petstore/cpprest/HttpContent.h b/samples/client/petstore/cpprest/HttpContent.h index 195c4d0dc53..72545bf8ba5 100644 --- a/samples/client/petstore/cpprest/HttpContent.h +++ b/samples/client/petstore/cpprest/HttpContent.h @@ -36,7 +36,6 @@ #include #include -#include namespace io { namespace swagger { @@ -66,8 +65,6 @@ class HttpContent virtual void writeTo( std::ostream& stream ); - //virtual void fromJson(web::json::value& val); - protected: // NOTE: no utility::string_t here because those strings can only contain ascii utility::string_t m_ContentDisposition; diff --git a/samples/client/petstore/cpprest/ModelBase.cpp b/samples/client/petstore/cpprest/ModelBase.cpp index 5ec2c9fc778..626ee2ad768 100644 --- a/samples/client/petstore/cpprest/ModelBase.cpp +++ b/samples/client/petstore/cpprest/ModelBase.cpp @@ -67,7 +67,7 @@ web::json::value ModelBase::toJson( std::shared_ptr content ) return value; } -/*std::shared_ptr ModelBase::fileFromJson(web::json::value& val) +std::shared_ptr ModelBase::fileFromJson(web::json::value& val) { std::shared_ptr content(new HttpContent); @@ -89,7 +89,7 @@ web::json::value ModelBase::toJson( std::shared_ptr content ) } return content; -}*/ +} web::json::value ModelBase::toJson( std::shared_ptr content ) { diff --git a/samples/client/petstore/cpprest/ModelBase.h b/samples/client/petstore/cpprest/ModelBase.h index 924d8fe4dde..8514ec1ba8a 100644 --- a/samples/client/petstore/cpprest/ModelBase.h +++ b/samples/client/petstore/cpprest/ModelBase.h @@ -71,7 +71,7 @@ class ModelBase static utility::datetime dateFromJson(web::json::value& val); static double doubleFromJson(web::json::value& val); static bool boolFromJson(web::json::value& val); - //static std::shared_ptr fileFromJson(web::json::value& val); + static std::shared_ptr fileFromJson(web::json::value& val); static std::shared_ptr toHttpContent( const utility::string_t& name, const utility::string_t& value, const utility::string_t& contentType = U("")); static std::shared_ptr toHttpContent( const utility::string_t& name, const utility::datetime& value, const utility::string_t& contentType = U("")); diff --git a/samples/client/petstore/cpprest/api/PetApi.cpp b/samples/client/petstore/cpprest/api/PetApi.cpp index 824be19bd1d..e67656e9cf3 100644 --- a/samples/client/petstore/cpprest/api/PetApi.cpp +++ b/samples/client/petstore/cpprest/api/PetApi.cpp @@ -144,12 +144,10 @@ consumeHttpContentTypes.insert( U("application/xml") ); , std::make_shared(response.extract_utf8string(true).get())); } - utility::string_t contentType = U(""); - - // check response content type + // check response content type if(response.headers().has(U("Content-Type"))) { - contentType = response.headers()[U("Content-Type")]; + utility::string_t contentType = response.headers()[U("Content-Type")]; if( contentType.find(responseHttpContentType) == std::string::npos ) { throw ApiException(500 @@ -163,7 +161,7 @@ consumeHttpContentTypes.insert( U("application/xml") ); .then([=](utility::string_t response) { return void(); - }); + }); } pplx::task PetApi::deletePet(int64_t petId, utility::string_t apiKey) { @@ -252,12 +250,10 @@ responseHttpContentTypes.insert( U("application/xml") ); , std::make_shared(response.extract_utf8string(true).get())); } - utility::string_t contentType = U(""); - - // check response content type + // check response content type if(response.headers().has(U("Content-Type"))) { - contentType = response.headers()[U("Content-Type")]; + utility::string_t contentType = response.headers()[U("Content-Type")]; if( contentType.find(responseHttpContentType) == std::string::npos ) { throw ApiException(500 @@ -271,7 +267,7 @@ responseHttpContentTypes.insert( U("application/xml") ); .then([=](utility::string_t response) { return void(); - }); + }); } pplx::task>> PetApi::findPetsByStatus(std::vector status) { @@ -355,12 +351,10 @@ responseHttpContentTypes.insert( U("application/xml") ); , std::make_shared(response.extract_utf8string(true).get())); } - utility::string_t contentType = U(""); - - // check response content type + // check response content type if(response.headers().has(U("Content-Type"))) { - contentType = response.headers()[U("Content-Type")]; + utility::string_t contentType = response.headers()[U("Content-Type")]; if( contentType.find(responseHttpContentType) == std::string::npos ) { throw ApiException(500 @@ -373,7 +367,7 @@ responseHttpContentTypes.insert( U("application/xml") ); }) .then([=](utility::string_t response) { - std::vector> result; + std::vector> result; if(responseHttpContentType == U("application/json")) @@ -484,12 +478,10 @@ responseHttpContentTypes.insert( U("application/xml") ); , std::make_shared(response.extract_utf8string(true).get())); } - utility::string_t contentType = U(""); - - // check response content type + // check response content type if(response.headers().has(U("Content-Type"))) { - contentType = response.headers()[U("Content-Type")]; + utility::string_t contentType = response.headers()[U("Content-Type")]; if( contentType.find(responseHttpContentType) == std::string::npos ) { throw ApiException(500 @@ -502,7 +494,7 @@ responseHttpContentTypes.insert( U("application/xml") ); }) .then([=](utility::string_t response) { - std::vector> result; + std::vector> result; if(responseHttpContentType == U("application/json")) @@ -621,12 +613,10 @@ responseHttpContentTypes.insert( U("application/xml") ); , std::make_shared(response.extract_utf8string(true).get())); } - utility::string_t contentType = U(""); - - // check response content type + // check response content type if(response.headers().has(U("Content-Type"))) { - contentType = response.headers()[U("Content-Type")]; + utility::string_t contentType = response.headers()[U("Content-Type")]; if( contentType.find(responseHttpContentType) == std::string::npos ) { throw ApiException(500 @@ -639,7 +629,7 @@ responseHttpContentTypes.insert( U("application/xml") ); }) .then([=](utility::string_t response) { - std::shared_ptr result(new Pet()); + std::shared_ptr result(new Pet()); if(responseHttpContentType == U("application/json")) { @@ -756,12 +746,10 @@ consumeHttpContentTypes.insert( U("application/xml") ); , std::make_shared(response.extract_utf8string(true).get())); } - utility::string_t contentType = U(""); - - // check response content type + // check response content type if(response.headers().has(U("Content-Type"))) { - contentType = response.headers()[U("Content-Type")]; + utility::string_t contentType = response.headers()[U("Content-Type")]; if( contentType.find(responseHttpContentType) == std::string::npos ) { throw ApiException(500 @@ -775,7 +763,7 @@ consumeHttpContentTypes.insert( U("application/xml") ); .then([=](utility::string_t response) { return void(); - }); + }); } pplx::task PetApi::updatePetWithForm(utility::string_t petId, utility::string_t name, utility::string_t status) { @@ -870,12 +858,10 @@ responseHttpContentTypes.insert( U("application/xml") ); , std::make_shared(response.extract_utf8string(true).get())); } - utility::string_t contentType = U(""); - - // check response content type + // check response content type if(response.headers().has(U("Content-Type"))) { - contentType = response.headers()[U("Content-Type")]; + utility::string_t contentType = response.headers()[U("Content-Type")]; if( contentType.find(responseHttpContentType) == std::string::npos ) { throw ApiException(500 @@ -889,7 +875,7 @@ responseHttpContentTypes.insert( U("application/xml") ); .then([=](utility::string_t response) { return void(); - }); + }); } pplx::task PetApi::uploadFile(int64_t petId, utility::string_t additionalMetadata, std::shared_ptr file) { @@ -984,12 +970,10 @@ responseHttpContentTypes.insert( U("application/xml") ); , std::make_shared(response.extract_utf8string(true).get())); } - utility::string_t contentType = U(""); - - // check response content type + // check response content type if(response.headers().has(U("Content-Type"))) { - contentType = response.headers()[U("Content-Type")]; + utility::string_t contentType = response.headers()[U("Content-Type")]; if( contentType.find(responseHttpContentType) == std::string::npos ) { throw ApiException(500 @@ -1003,7 +987,7 @@ responseHttpContentTypes.insert( U("application/xml") ); .then([=](utility::string_t response) { return void(); - }); + }); } } diff --git a/samples/client/petstore/cpprest/api/StoreApi.cpp b/samples/client/petstore/cpprest/api/StoreApi.cpp index ce88ac9c988..406e6d0a909 100644 --- a/samples/client/petstore/cpprest/api/StoreApi.cpp +++ b/samples/client/petstore/cpprest/api/StoreApi.cpp @@ -128,12 +128,10 @@ responseHttpContentTypes.insert( U("application/xml") ); , std::make_shared(response.extract_utf8string(true).get())); } - utility::string_t contentType = U(""); - - // check response content type + // check response content type if(response.headers().has(U("Content-Type"))) { - contentType = response.headers()[U("Content-Type")]; + utility::string_t contentType = response.headers()[U("Content-Type")]; if( contentType.find(responseHttpContentType) == std::string::npos ) { throw ApiException(500 @@ -147,7 +145,7 @@ responseHttpContentTypes.insert( U("application/xml") ); .then([=](utility::string_t response) { return void(); - }); + }); } pplx::task> StoreApi::getInventory() { @@ -232,12 +230,10 @@ responseHttpContentTypes.insert( U("application/xml") ); , std::make_shared(response.extract_utf8string(true).get())); } - utility::string_t contentType = U(""); - - // check response content type + // check response content type if(response.headers().has(U("Content-Type"))) { - contentType = response.headers()[U("Content-Type")]; + utility::string_t contentType = response.headers()[U("Content-Type")]; if( contentType.find(responseHttpContentType) == std::string::npos ) { throw ApiException(500 @@ -250,7 +246,7 @@ responseHttpContentTypes.insert( U("application/xml") ); }) .then([=](utility::string_t response) { - std::map result; + std::map result; if(responseHttpContentType == U("application/json")) @@ -357,12 +353,10 @@ responseHttpContentTypes.insert( U("application/xml") ); , std::make_shared(response.extract_utf8string(true).get())); } - utility::string_t contentType = U(""); - - // check response content type + // check response content type if(response.headers().has(U("Content-Type"))) { - contentType = response.headers()[U("Content-Type")]; + utility::string_t contentType = response.headers()[U("Content-Type")]; if( contentType.find(responseHttpContentType) == std::string::npos ) { throw ApiException(500 @@ -375,7 +369,7 @@ responseHttpContentTypes.insert( U("application/xml") ); }) .then([=](utility::string_t response) { - std::shared_ptr result(new Order()); + std::shared_ptr result(new Order()); if(responseHttpContentType == U("application/json")) { @@ -488,12 +482,10 @@ responseHttpContentTypes.insert( U("application/xml") ); , std::make_shared(response.extract_utf8string(true).get())); } - utility::string_t contentType = U(""); - - // check response content type + // check response content type if(response.headers().has(U("Content-Type"))) { - contentType = response.headers()[U("Content-Type")]; + utility::string_t contentType = response.headers()[U("Content-Type")]; if( contentType.find(responseHttpContentType) == std::string::npos ) { throw ApiException(500 @@ -506,7 +498,7 @@ responseHttpContentTypes.insert( U("application/xml") ); }) .then([=](utility::string_t response) { - std::shared_ptr result(new Order()); + std::shared_ptr result(new Order()); if(responseHttpContentType == U("application/json")) { diff --git a/samples/client/petstore/cpprest/api/UserApi.cpp b/samples/client/petstore/cpprest/api/UserApi.cpp index d2d7ee3390b..8259ef6ef9b 100644 --- a/samples/client/petstore/cpprest/api/UserApi.cpp +++ b/samples/client/petstore/cpprest/api/UserApi.cpp @@ -140,12 +140,10 @@ responseHttpContentTypes.insert( U("application/xml") ); , std::make_shared(response.extract_utf8string(true).get())); } - utility::string_t contentType = U(""); - - // check response content type + // check response content type if(response.headers().has(U("Content-Type"))) { - contentType = response.headers()[U("Content-Type")]; + utility::string_t contentType = response.headers()[U("Content-Type")]; if( contentType.find(responseHttpContentType) == std::string::npos ) { throw ApiException(500 @@ -159,7 +157,7 @@ responseHttpContentTypes.insert( U("application/xml") ); .then([=](utility::string_t response) { return void(); - }); + }); } pplx::task UserApi::createUsersWithArrayInput(std::vector> body) { @@ -267,12 +265,10 @@ responseHttpContentTypes.insert( U("application/xml") ); , std::make_shared(response.extract_utf8string(true).get())); } - utility::string_t contentType = U(""); - - // check response content type + // check response content type if(response.headers().has(U("Content-Type"))) { - contentType = response.headers()[U("Content-Type")]; + utility::string_t contentType = response.headers()[U("Content-Type")]; if( contentType.find(responseHttpContentType) == std::string::npos ) { throw ApiException(500 @@ -286,7 +282,7 @@ responseHttpContentTypes.insert( U("application/xml") ); .then([=](utility::string_t response) { return void(); - }); + }); } pplx::task UserApi::createUsersWithListInput(std::vector> body) { @@ -394,12 +390,10 @@ responseHttpContentTypes.insert( U("application/xml") ); , std::make_shared(response.extract_utf8string(true).get())); } - utility::string_t contentType = U(""); - - // check response content type + // check response content type if(response.headers().has(U("Content-Type"))) { - contentType = response.headers()[U("Content-Type")]; + utility::string_t contentType = response.headers()[U("Content-Type")]; if( contentType.find(responseHttpContentType) == std::string::npos ) { throw ApiException(500 @@ -413,7 +407,7 @@ responseHttpContentTypes.insert( U("application/xml") ); .then([=](utility::string_t response) { return void(); - }); + }); } pplx::task UserApi::deleteUser(utility::string_t username) { @@ -495,12 +489,10 @@ responseHttpContentTypes.insert( U("application/xml") ); , std::make_shared(response.extract_utf8string(true).get())); } - utility::string_t contentType = U(""); - - // check response content type + // check response content type if(response.headers().has(U("Content-Type"))) { - contentType = response.headers()[U("Content-Type")]; + utility::string_t contentType = response.headers()[U("Content-Type")]; if( contentType.find(responseHttpContentType) == std::string::npos ) { throw ApiException(500 @@ -514,7 +506,7 @@ responseHttpContentTypes.insert( U("application/xml") ); .then([=](utility::string_t response) { return void(); - }); + }); } pplx::task> UserApi::getUserByName(utility::string_t username) { @@ -596,12 +588,10 @@ responseHttpContentTypes.insert( U("application/xml") ); , std::make_shared(response.extract_utf8string(true).get())); } - utility::string_t contentType = U(""); - - // check response content type + // check response content type if(response.headers().has(U("Content-Type"))) { - contentType = response.headers()[U("Content-Type")]; + utility::string_t contentType = response.headers()[U("Content-Type")]; if( contentType.find(responseHttpContentType) == std::string::npos ) { throw ApiException(500 @@ -614,7 +604,7 @@ responseHttpContentTypes.insert( U("application/xml") ); }) .then([=](utility::string_t response) { - std::shared_ptr result(new User()); + std::shared_ptr result(new User()); if(responseHttpContentType == U("application/json")) { @@ -720,12 +710,10 @@ responseHttpContentTypes.insert( U("application/xml") ); , std::make_shared(response.extract_utf8string(true).get())); } - utility::string_t contentType = U(""); - - // check response content type + // check response content type if(response.headers().has(U("Content-Type"))) { - contentType = response.headers()[U("Content-Type")]; + utility::string_t contentType = response.headers()[U("Content-Type")]; if( contentType.find(responseHttpContentType) == std::string::npos ) { throw ApiException(500 @@ -738,7 +726,7 @@ responseHttpContentTypes.insert( U("application/xml") ); }) .then([=](utility::string_t response) { - utility::string_t result(U("")); + utility::string_t result(U("")); if(responseHttpContentType == U("application/json")) { @@ -835,12 +823,10 @@ responseHttpContentTypes.insert( U("application/xml") ); , std::make_shared(response.extract_utf8string(true).get())); } - utility::string_t contentType = U(""); - - // check response content type + // check response content type if(response.headers().has(U("Content-Type"))) { - contentType = response.headers()[U("Content-Type")]; + utility::string_t contentType = response.headers()[U("Content-Type")]; if( contentType.find(responseHttpContentType) == std::string::npos ) { throw ApiException(500 @@ -854,7 +840,7 @@ responseHttpContentTypes.insert( U("application/xml") ); .then([=](utility::string_t response) { return void(); - }); + }); } pplx::task UserApi::updateUser(utility::string_t username, std::shared_ptr body) { @@ -953,12 +939,10 @@ responseHttpContentTypes.insert( U("application/xml") ); , std::make_shared(response.extract_utf8string(true).get())); } - utility::string_t contentType = U(""); - - // check response content type + // check response content type if(response.headers().has(U("Content-Type"))) { - contentType = response.headers()[U("Content-Type")]; + utility::string_t contentType = response.headers()[U("Content-Type")]; if( contentType.find(responseHttpContentType) == std::string::npos ) { throw ApiException(500 @@ -972,7 +956,7 @@ responseHttpContentTypes.insert( U("application/xml") ); .then([=](utility::string_t response) { return void(); - }); + }); } } From 3449747e58a5027fd6cc2bc29552f0aea43c0da8 Mon Sep 17 00:00:00 2001 From: Scott Richter Date: Mon, 26 Sep 2016 13:45:41 -0400 Subject: [PATCH 08/11] Fixing petstore --- .../languages/CppRestClientCodegen.java | 13 +++++---- .../resources/cpprest/api-source.mustache | 27 ++++++++++++------- .../client/petstore/cpprest/api/PetApi.cpp | 2 +- samples/client/petstore/cpprest/api/PetApi.h | 4 +-- 4 files changed, 27 insertions(+), 19 deletions(-) diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/CppRestClientCodegen.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/CppRestClientCodegen.java index fa85a9f4b3a..eee9619466d 100644 --- a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/CppRestClientCodegen.java +++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/CppRestClientCodegen.java @@ -110,7 +110,7 @@ public CppRestClientCodegen() { typeMapping.put("boolean", "bool"); typeMapping.put("array", "std::vector"); typeMapping.put("map", "std::map"); - typeMapping.put("file", "Concurrency::streams::istream"); + typeMapping.put("file", "HttpContent"); typeMapping.put("object", "Object"); typeMapping.put("binary", "std::string"); @@ -118,8 +118,7 @@ public CppRestClientCodegen() { importMapping.put("std::vector", "#include "); importMapping.put("std::map", "#include "); importMapping.put("std::string", "#include "); - importMapping.put("Concurrency::streams::istream", "#include "); - importMapping.put("HttpContent", "#include \"HttpContent.h\""); + importMapping.put("HttpContent", "#include \"HttpContent.h\""); importMapping.put("Object", "#include \"Object.h\""); importMapping.put("utility::string_t", "#include "); importMapping.put("utility::datetime", "#include "); @@ -218,9 +217,9 @@ public CodegenOperation fromOperation(String path, String httpMethod, Operation if (methodResponse.getSchema() != null) { CodegenProperty cm = fromProperty("response", methodResponse.getSchema()); op.vendorExtensions.put("x-codegen-response", cm); - if(cm.datatype == "Concurrency::streams::istream") + if(cm.datatype == "HttpContent") { - op.vendorExtensions.put("x-codegen-response-istream", true); + op.vendorExtensions.put("x-codegen-response-ishttpcontent", true); } } } @@ -237,7 +236,7 @@ public void postProcessModelProperty(CodegenModel model, CodegenProperty propert } protected boolean isFileProperty(CodegenProperty property) { - return property.baseType.equals("Concurrency::streams::istream"); + return property.baseType.equals("HttpContent"); } @Override @@ -317,7 +316,7 @@ public String toDefaultValue(Property p) { return "new " + toModelName(rp.getSimpleRef()) + "()"; } else if (p instanceof FileProperty) { - return "Concurrency::streams::istream()"; + return ""; } return "nullptr"; } diff --git a/modules/swagger-codegen/src/main/resources/cpprest/api-source.mustache b/modules/swagger-codegen/src/main/resources/cpprest/api-source.mustache index 4cc5b9c2a39..eb9c0bbae5b 100644 --- a/modules/swagger-codegen/src/main/resources/cpprest/api-source.mustache +++ b/modules/swagger-codegen/src/main/resources/cpprest/api-source.mustache @@ -62,19 +62,19 @@ pplx::task<{{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}void{{/r { responseHttpContentType = U("multipart/form-data"); } - {{#vendorExtensions.x-codegen-response-istream}} + {{#vendorExtensions.x-codegen-response-ishttpcontent}} else { //It's going to be binary, so just use the first one. responseHttpContentType = *responseHttpContentTypes.begin(); } - {{/vendorExtensions.x-codegen-response-istream}} - {{^vendorExtensions.x-codegen-response-istream}} + {{/vendorExtensions.x-codegen-response-ishttpcontent}} + {{^vendorExtensions.x-codegen-response-ishttpcontent}} else { throw ApiException(400, U("{{classname}}->{{operationId}} does not produce any supported media type")); } - {{/vendorExtensions.x-codegen-response-istream}} + {{/vendorExtensions.x-codegen-response-ishttpcontent}} headerParams[U("Accept")] = responseHttpContentType; @@ -222,10 +222,19 @@ pplx::task<{{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}void{{/r } } - {{#vendorExtensions.x-codegen-response-istream}} - return response.body(); - {{/vendorExtensions.x-codegen-response-istream}} - {{^vendorExtensions.x-codegen-response-istream}} + {{#vendorExtensions.x-codegen-response-ishttpcontent}} + return response.extract_vector(); + }) + .then([=](std::vector response) + { + HttpContent result; + std::shared_ptr stream = std::make_shared(); + std::copy( response.begin(), response.end(), std::ostreambuf_iterator( *stream.get() ) ); + result.setData(stream); + return result; + {{/returnType}} + {{/vendorExtensions.x-codegen-response-ishttpcontent}} + {{^vendorExtensions.x-codegen-response-ishttpcontent}} return response.extract_string(); }) .then([=](utility::string_t response) @@ -272,7 +281,7 @@ pplx::task<{{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}void{{/r return result; {{/returnType}} - {{/vendorExtensions.x-codegen-response-istream}} + {{/vendorExtensions.x-codegen-response-ishttpcontent}} }); } {{/operation}} diff --git a/samples/client/petstore/cpprest/api/PetApi.cpp b/samples/client/petstore/cpprest/api/PetApi.cpp index e67656e9cf3..9da8a514ef7 100644 --- a/samples/client/petstore/cpprest/api/PetApi.cpp +++ b/samples/client/petstore/cpprest/api/PetApi.cpp @@ -877,7 +877,7 @@ responseHttpContentTypes.insert( U("application/xml") ); return void(); }); } -pplx::task PetApi::uploadFile(int64_t petId, utility::string_t additionalMetadata, std::shared_ptr file) +pplx::task PetApi::uploadFile(int64_t petId, utility::string_t additionalMetadata, std::shared_ptr file) { diff --git a/samples/client/petstore/cpprest/api/PetApi.h b/samples/client/petstore/cpprest/api/PetApi.h index f5d38fda67d..e3d1b40a3a8 100644 --- a/samples/client/petstore/cpprest/api/PetApi.h +++ b/samples/client/petstore/cpprest/api/PetApi.h @@ -36,7 +36,7 @@ #include "Pet.h" #include -#include +#include "HttpContent.h" namespace io { namespace swagger { @@ -113,7 +113,7 @@ class PetApi /// /// /// ID of pet to update/// Additional data to pass to server (optional)/// file to upload (optional) - pplx::task uploadFile(int64_t petId, utility::string_t additionalMetadata, std::shared_ptr file); + pplx::task uploadFile(int64_t petId, utility::string_t additionalMetadata, std::shared_ptr file); protected: std::shared_ptr m_ApiClient; From 2aaa314163b0f8f7dc23d5de42bff65e5facffda Mon Sep 17 00:00:00 2001 From: Scott Richter Date: Mon, 26 Sep 2016 14:18:35 -0400 Subject: [PATCH 09/11] Fixing error in build. --- .../io/swagger/codegen/languages/CppRestClientCodegen.java | 3 --- .../src/main/resources/cpprest/api-source.mustache | 1 - 2 files changed, 4 deletions(-) diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/CppRestClientCodegen.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/CppRestClientCodegen.java index eee9619466d..5661cd9dde6 100644 --- a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/CppRestClientCodegen.java +++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/CppRestClientCodegen.java @@ -315,9 +315,6 @@ public String toDefaultValue(Property p) { RefProperty rp = (RefProperty) p; return "new " + toModelName(rp.getSimpleRef()) + "()"; } - else if (p instanceof FileProperty) { - return ""; - } return "nullptr"; } diff --git a/modules/swagger-codegen/src/main/resources/cpprest/api-source.mustache b/modules/swagger-codegen/src/main/resources/cpprest/api-source.mustache index eb9c0bbae5b..a1a2b33cc5e 100644 --- a/modules/swagger-codegen/src/main/resources/cpprest/api-source.mustache +++ b/modules/swagger-codegen/src/main/resources/cpprest/api-source.mustache @@ -232,7 +232,6 @@ pplx::task<{{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}void{{/r std::copy( response.begin(), response.end(), std::ostreambuf_iterator( *stream.get() ) ); result.setData(stream); return result; - {{/returnType}} {{/vendorExtensions.x-codegen-response-ishttpcontent}} {{^vendorExtensions.x-codegen-response-ishttpcontent}} return response.extract_string(); From d17f8ce1ce774cd5e281092ecc9152ca8a9599cb Mon Sep 17 00:00:00 2001 From: Scott Richter Date: Mon, 26 Sep 2016 16:41:30 -0400 Subject: [PATCH 10/11] Fixed error in stream copy for binary data --- .../src/main/resources/cpprest/api-source.mustache | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/modules/swagger-codegen/src/main/resources/cpprest/api-source.mustache b/modules/swagger-codegen/src/main/resources/cpprest/api-source.mustache index a1a2b33cc5e..21f7af71a5d 100644 --- a/modules/swagger-codegen/src/main/resources/cpprest/api-source.mustache +++ b/modules/swagger-codegen/src/main/resources/cpprest/api-source.mustache @@ -225,11 +225,10 @@ pplx::task<{{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}void{{/r {{#vendorExtensions.x-codegen-response-ishttpcontent}} return response.extract_vector(); }) - .then([=](std::vector response) + .then([=](std::vector response) { HttpContent result; - std::shared_ptr stream = std::make_shared(); - std::copy( response.begin(), response.end(), std::ostreambuf_iterator( *stream.get() ) ); + std::shared_ptr stream = std::make_shared(std::string(response.begin(), response.end())); result.setData(stream); return result; {{/vendorExtensions.x-codegen-response-ishttpcontent}} From 79d478716b3b1385161b31b530696ae5b6dc2850 Mon Sep 17 00:00:00 2001 From: Scott Richter Date: Thu, 29 Sep 2016 16:22:54 -0400 Subject: [PATCH 11/11] Replaced tab with 4 spaces in all modified files. Replaced tab with 4 spaces in all modified files. --- .../languages/CppRestClientCodegen.java | 12 +-- .../resources/cpprest/api-source.mustache | 74 +++++++++---------- .../cpprest/httpcontent-header.mustache | 2 +- .../resources/cpprest/model-source.mustache | 26 +++---- .../cpprest/modelbase-header.mustache | 2 +- 5 files changed, 58 insertions(+), 58 deletions(-) diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/CppRestClientCodegen.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/CppRestClientCodegen.java index 5661cd9dde6..4c7cc7c1f0b 100644 --- a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/CppRestClientCodegen.java +++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/CppRestClientCodegen.java @@ -118,7 +118,7 @@ public CppRestClientCodegen() { importMapping.put("std::vector", "#include "); importMapping.put("std::map", "#include "); importMapping.put("std::string", "#include "); - importMapping.put("HttpContent", "#include \"HttpContent.h\""); + importMapping.put("HttpContent", "#include \"HttpContent.h\""); importMapping.put("Object", "#include \"Object.h\""); importMapping.put("utility::string_t", "#include "); importMapping.put("utility::datetime", "#include "); @@ -217,10 +217,10 @@ public CodegenOperation fromOperation(String path, String httpMethod, Operation if (methodResponse.getSchema() != null) { CodegenProperty cm = fromProperty("response", methodResponse.getSchema()); op.vendorExtensions.put("x-codegen-response", cm); - if(cm.datatype == "HttpContent") - { - op.vendorExtensions.put("x-codegen-response-ishttpcontent", true); - } + if(cm.datatype == "HttpContent") + { + op.vendorExtensions.put("x-codegen-response-ishttpcontent", true); + } } } } @@ -272,7 +272,7 @@ public String getTypeDeclaration(Property p) { return getSwaggerType(p) + ""; } if (p instanceof StringProperty || p instanceof DateProperty - || p instanceof DateTimeProperty || p instanceof FileProperty + || p instanceof DateTimeProperty || p instanceof FileProperty || languageSpecificPrimitives.contains(swaggerType)) { return toModelName(swaggerType); } diff --git a/modules/swagger-codegen/src/main/resources/cpprest/api-source.mustache b/modules/swagger-codegen/src/main/resources/cpprest/api-source.mustache index 21f7af71a5d..21c5eff5553 100644 --- a/modules/swagger-codegen/src/main/resources/cpprest/api-source.mustache +++ b/modules/swagger-codegen/src/main/resources/cpprest/api-source.mustache @@ -62,19 +62,19 @@ pplx::task<{{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}void{{/r { responseHttpContentType = U("multipart/form-data"); } - {{#vendorExtensions.x-codegen-response-ishttpcontent}} + {{#vendorExtensions.x-codegen-response-ishttpcontent}} + else + { + //It's going to be binary, so just use the first one. + responseHttpContentType = *responseHttpContentTypes.begin(); + } + {{/vendorExtensions.x-codegen-response-ishttpcontent}} + {{^vendorExtensions.x-codegen-response-ishttpcontent}} else - { - //It's going to be binary, so just use the first one. - responseHttpContentType = *responseHttpContentTypes.begin(); - } - {{/vendorExtensions.x-codegen-response-ishttpcontent}} - {{^vendorExtensions.x-codegen-response-ishttpcontent}} - else { throw ApiException(400, U("{{classname}}->{{operationId}} does not produce any supported media type")); } - {{/vendorExtensions.x-codegen-response-ishttpcontent}} + {{/vendorExtensions.x-codegen-response-ishttpcontent}} headerParams[U("Accept")] = responseHttpContentType; @@ -198,19 +198,19 @@ pplx::task<{{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}void{{/r return m_ApiClient->callApi(path, U("{{httpMethod}}"), queryParams, httpBody, headerParams, formParams, fileParams, requestHttpContentType) .then([=](web::http::http_response response) { - // 1xx - informational : OK - // 2xx - successful : OK - // 3xx - redirection : OK - // 4xx - client error : not OK - // 5xx - client error : not OK - if (response.status_code() >= 400) - { - throw ApiException(response.status_code() - , U("error calling {{operationId}}: ") + response.reason_phrase() - , std::make_shared(response.extract_utf8string(true).get())); - } + // 1xx - informational : OK + // 2xx - successful : OK + // 3xx - redirection : OK + // 4xx - client error : not OK + // 5xx - client error : not OK + if (response.status_code() >= 400) + { + throw ApiException(response.status_code() + , U("error calling {{operationId}}: ") + response.reason_phrase() + , std::make_shared(response.extract_utf8string(true).get())); + } - // check response content type + // check response content type if(response.headers().has(U("Content-Type"))) { utility::string_t contentType = response.headers()[U("Content-Type")]; @@ -221,19 +221,19 @@ pplx::task<{{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}void{{/r , std::make_shared(response.extract_utf8string(true).get())); } } - - {{#vendorExtensions.x-codegen-response-ishttpcontent}} - return response.extract_vector(); - }) - .then([=](std::vector response) - { - HttpContent result; - std::shared_ptr stream = std::make_shared(std::string(response.begin(), response.end())); - result.setData(stream); - return result; - {{/vendorExtensions.x-codegen-response-ishttpcontent}} - {{^vendorExtensions.x-codegen-response-ishttpcontent}} - return response.extract_string(); + + {{#vendorExtensions.x-codegen-response-ishttpcontent}} + return response.extract_vector(); + }) + .then([=](std::vector response) + { + HttpContent result; + std::shared_ptr stream = std::make_shared(std::string(response.begin(), response.end())); + result.setData(stream); + return result; + {{/vendorExtensions.x-codegen-response-ishttpcontent}} + {{^vendorExtensions.x-codegen-response-ishttpcontent}} + return response.extract_string(); }) .then([=](utility::string_t response) { @@ -273,13 +273,13 @@ pplx::task<{{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}void{{/r // } else { - throw ApiException(500 - , U("error calling findPetsByStatus: unsupported response type")); + throw ApiException(500 + , U("error calling findPetsByStatus: unsupported response type")); } return result; {{/returnType}} - {{/vendorExtensions.x-codegen-response-ishttpcontent}} + {{/vendorExtensions.x-codegen-response-ishttpcontent}} }); } {{/operation}} diff --git a/modules/swagger-codegen/src/main/resources/cpprest/httpcontent-header.mustache b/modules/swagger-codegen/src/main/resources/cpprest/httpcontent-header.mustache index 622e4227f8e..27f53b8e0c1 100644 --- a/modules/swagger-codegen/src/main/resources/cpprest/httpcontent-header.mustache +++ b/modules/swagger-codegen/src/main/resources/cpprest/httpcontent-header.mustache @@ -42,7 +42,7 @@ public: virtual void writeTo( std::ostream& stream ); protected: - // NOTE: no utility::string_t here because those strings can only contain ascii + // NOTE: no utility::string_t here because those strings can only contain ascii utility::string_t m_ContentDisposition; utility::string_t m_Name; utility::string_t m_FileName; diff --git a/modules/swagger-codegen/src/main/resources/cpprest/model-source.mustache b/modules/swagger-codegen/src/main/resources/cpprest/model-source.mustache index 2eed1b6e545..26970c20d8d 100644 --- a/modules/swagger-codegen/src/main/resources/cpprest/model-source.mustache +++ b/modules/swagger-codegen/src/main/resources/cpprest/model-source.mustache @@ -29,7 +29,7 @@ web::json::value {{classname}}::toJson() const { web::json::value val = web::json::value::object(); - {{#vars}}{{#isPrimitiveType}}{{^isListContainer}}{{^required}}if(m_{{name}}IsSet) + {{#vars}}{{#isPrimitiveType}}{{^isListContainer}}{{^required}}if(m_{{name}}IsSet) { val[U("{{baseName}}")] = ModelBase::toJson(m_{{name}}); } @@ -117,12 +117,12 @@ void {{classname}}::fromJson(web::json::value& val) void {{classname}}::toMultipart(std::shared_ptr multipart, const utility::string_t& prefix) const { utility::string_t namePrefix = prefix; - if(namePrefix.size() > 0 && namePrefix[namePrefix.size() - 1] != U('.')) - { - namePrefix += U("."); - } + if(namePrefix.size() > 0 && namePrefix[namePrefix.size() - 1] != U('.')) + { + namePrefix += U("."); + } - {{#vars}}{{#isPrimitiveType}}{{^isListContainer}}{{^required}}if(m_{{name}}IsSet) + {{#vars}}{{#isPrimitiveType}}{{^isListContainer}}{{^required}}if(m_{{name}}IsSet) { multipart->add(ModelBase::toHttpContent(namePrefix + U("{{baseName}}"), m_{{name}})); } @@ -161,10 +161,10 @@ void {{classname}}::toMultipart(std::shared_ptr multipart, co void {{classname}}::fromMultiPart(std::shared_ptr multipart, const utility::string_t& prefix) { utility::string_t namePrefix = prefix; - if(namePrefix.size() > 0 && namePrefix[namePrefix.size() - 1] != U('.')) - { - namePrefix += U("."); - } + if(namePrefix.size() > 0 && namePrefix[namePrefix.size() - 1] != U('.')) + { + namePrefix += U("."); + } {{#vars}}{{#isPrimitiveType}}{{^isListContainer}}{{^required}}if(multipart->hasContent(U("{{baseName}}"))) { @@ -224,15 +224,15 @@ void {{classname}}::fromMultiPart(std::shared_ptr multipart, {{#vars}}{{^isNotContainer}}{{{datatype}}}& {{classname}}::{{getter}}() { - return m_{{name}}; + return m_{{name}}; } {{/isNotContainer}}{{#isNotContainer}}{{{datatype}}} {{classname}}::{{getter}}() const { - return m_{{name}}; + return m_{{name}}; } void {{classname}}::{{setter}}({{{datatype}}} value) { - m_{{name}} = value; + m_{{name}} = value; {{^required}}m_{{name}}IsSet = true;{{/required}} } {{/isNotContainer}} diff --git a/modules/swagger-codegen/src/main/resources/cpprest/modelbase-header.mustache b/modules/swagger-codegen/src/main/resources/cpprest/modelbase-header.mustache index 204b9914540..262b154acd7 100644 --- a/modules/swagger-codegen/src/main/resources/cpprest/modelbase-header.mustache +++ b/modules/swagger-codegen/src/main/resources/cpprest/modelbase-header.mustache @@ -40,7 +40,7 @@ public: static web::json::value toJson( int32_t value ); static web::json::value toJson( int64_t value ); static web::json::value toJson( double value ); - + static int64_t int64_tFromJson(web::json::value& val); static int32_t int32_tFromJson(web::json::value& val); static utility::string_t stringFromJson(web::json::value& val);