From 30145fee8aa139928e2cf698af6a93d10c3d4097 Mon Sep 17 00:00:00 2001 From: Michael Kotten Date: Thu, 16 Aug 2018 08:29:57 +0200 Subject: [PATCH 01/15] use contextPath variable for RestApplication templates --- .../main/resources/JavaJaxRS/cxf-cdi/RestApplication.mustache | 2 +- .../main/resources/JavaJaxRS/resteasy/RestApplication.mustache | 2 +- .../resources/JavaJaxRS/resteasy/eap/RestApplication.mustache | 2 +- .../src/main/resources/JavaJaxRS/spec/RestApplication.mustache | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/modules/openapi-generator/src/main/resources/JavaJaxRS/cxf-cdi/RestApplication.mustache b/modules/openapi-generator/src/main/resources/JavaJaxRS/cxf-cdi/RestApplication.mustache index d3d8b238d726..784f227d7616 100644 --- a/modules/openapi-generator/src/main/resources/JavaJaxRS/cxf-cdi/RestApplication.mustache +++ b/modules/openapi-generator/src/main/resources/JavaJaxRS/cxf-cdi/RestApplication.mustache @@ -3,7 +3,7 @@ package {{invokerPackage}}; import javax.ws.rs.ApplicationPath; import javax.ws.rs.core.Application; -@ApplicationPath("/") +@ApplicationPath("{{contextPath}}") public class RestApplication extends Application { // Add implementation-specific details here } \ No newline at end of file diff --git a/modules/openapi-generator/src/main/resources/JavaJaxRS/resteasy/RestApplication.mustache b/modules/openapi-generator/src/main/resources/JavaJaxRS/resteasy/RestApplication.mustache index df9a31434b6a..0a7f9a266be9 100644 --- a/modules/openapi-generator/src/main/resources/JavaJaxRS/resteasy/RestApplication.mustache +++ b/modules/openapi-generator/src/main/resources/JavaJaxRS/resteasy/RestApplication.mustache @@ -3,7 +3,7 @@ package {{invokerPackage}}; import javax.ws.rs.ApplicationPath; import javax.ws.rs.core.Application; -@ApplicationPath("/") +@ApplicationPath("{{contextPath}}") public class RestApplication extends Application { } \ No newline at end of file diff --git a/modules/openapi-generator/src/main/resources/JavaJaxRS/resteasy/eap/RestApplication.mustache b/modules/openapi-generator/src/main/resources/JavaJaxRS/resteasy/eap/RestApplication.mustache index cdab3c0830be..87d9741afe6d 100644 --- a/modules/openapi-generator/src/main/resources/JavaJaxRS/resteasy/eap/RestApplication.mustache +++ b/modules/openapi-generator/src/main/resources/JavaJaxRS/resteasy/eap/RestApplication.mustache @@ -15,7 +15,7 @@ import {{package}}.impl.{{classname}}ServiceImpl; {{/apis}} {{/apiInfo}} -@ApplicationPath("/") +@ApplicationPath("{{contextPath}}") public class RestApplication extends Application { {{#useSwaggerFeature}} diff --git a/modules/openapi-generator/src/main/resources/JavaJaxRS/spec/RestApplication.mustache b/modules/openapi-generator/src/main/resources/JavaJaxRS/spec/RestApplication.mustache index 82b8d9533e07..5aac196c1af5 100644 --- a/modules/openapi-generator/src/main/resources/JavaJaxRS/spec/RestApplication.mustache +++ b/modules/openapi-generator/src/main/resources/JavaJaxRS/spec/RestApplication.mustache @@ -3,7 +3,7 @@ package {{invokerPackage}}; import javax.ws.rs.ApplicationPath; import javax.ws.rs.core.Application; -@ApplicationPath("/") +@ApplicationPath("{{contextPath}}") public class RestApplication extends Application { } From 8684d15f38a277010943d0d6e48783e4ab21d4d9 Mon Sep 17 00:00:00 2001 From: Michael Kotten Date: Thu, 16 Aug 2018 09:07:00 +0200 Subject: [PATCH 02/15] update Petstore sample for jaxrs so that CIs can verify the change --- .../petstore/jaxrs-cxf-client/.openapi-generator/VERSION | 2 +- .../src/gen/java/org/openapitools/model/Order.java | 5 ++--- .../src/gen/java/org/openapitools/model/Pet.java | 3 +-- .../src/main/java/org/openapitools/api/RestApplication.java | 2 +- .../src/main/java/org/openapitools/api/RestApplication.java | 2 +- .../src/main/java/org/openapitools/api/RestApplication.java | 2 +- .../jaxrs-spec-interface-response/.openapi-generator/VERSION | 2 +- .../org/openapitools/model/AdditionalPropertiesClass.java | 2 ++ .../src/gen/java/org/openapitools/model/Animal.java | 2 ++ .../org/openapitools/model/ArrayOfArrayOfNumberOnly.java | 2 ++ .../gen/java/org/openapitools/model/ArrayOfNumberOnly.java | 2 ++ .../src/gen/java/org/openapitools/model/ArrayTest.java | 2 ++ .../src/gen/java/org/openapitools/model/Capitalization.java | 2 ++ .../src/gen/java/org/openapitools/model/Cat.java | 2 ++ .../src/gen/java/org/openapitools/model/Category.java | 2 ++ .../src/gen/java/org/openapitools/model/ClassModel.java | 1 + .../src/gen/java/org/openapitools/model/Client.java | 2 ++ .../src/gen/java/org/openapitools/model/Dog.java | 2 ++ .../src/gen/java/org/openapitools/model/EnumArrays.java | 2 ++ .../src/gen/java/org/openapitools/model/EnumTest.java | 2 ++ .../gen/java/org/openapitools/model/FileSchemaTestClass.java | 2 ++ .../src/gen/java/org/openapitools/model/FormatTest.java | 2 ++ .../src/gen/java/org/openapitools/model/HasOnlyReadOnly.java | 2 ++ .../src/gen/java/org/openapitools/model/MapTest.java | 2 ++ .../model/MixedPropertiesAndAdditionalPropertiesClass.java | 2 ++ .../gen/java/org/openapitools/model/Model200Response.java | 1 + .../gen/java/org/openapitools/model/ModelApiResponse.java | 2 ++ .../src/gen/java/org/openapitools/model/ModelReturn.java | 1 + .../src/gen/java/org/openapitools/model/Name.java | 1 + .../src/gen/java/org/openapitools/model/NumberOnly.java | 2 ++ .../src/gen/java/org/openapitools/model/Order.java | 2 ++ .../src/gen/java/org/openapitools/model/OuterComposite.java | 2 ++ .../src/gen/java/org/openapitools/model/Pet.java | 2 ++ .../src/gen/java/org/openapitools/model/ReadOnlyFirst.java | 2 ++ .../gen/java/org/openapitools/model/SpecialModelName.java | 2 ++ .../src/gen/java/org/openapitools/model/Tag.java | 2 ++ .../src/gen/java/org/openapitools/model/User.java | 2 ++ 37 files changed, 64 insertions(+), 10 deletions(-) diff --git a/samples/client/petstore/jaxrs-cxf-client/.openapi-generator/VERSION b/samples/client/petstore/jaxrs-cxf-client/.openapi-generator/VERSION index 096bf47efe31..105bb87d77b3 100644 --- a/samples/client/petstore/jaxrs-cxf-client/.openapi-generator/VERSION +++ b/samples/client/petstore/jaxrs-cxf-client/.openapi-generator/VERSION @@ -1 +1 @@ -3.0.0-SNAPSHOT \ No newline at end of file +3.2.2-SNAPSHOT \ No newline at end of file diff --git a/samples/client/petstore/jaxrs-cxf-client/src/gen/java/org/openapitools/model/Order.java b/samples/client/petstore/jaxrs-cxf-client/src/gen/java/org/openapitools/model/Order.java index 3aa2ec3d55c3..b2725e076bc9 100644 --- a/samples/client/petstore/jaxrs-cxf-client/src/gen/java/org/openapitools/model/Order.java +++ b/samples/client/petstore/jaxrs-cxf-client/src/gen/java/org/openapitools/model/Order.java @@ -31,7 +31,6 @@ public class Order { @ApiModelProperty(value = "") private Date shipDate = null; - @XmlType(name="StatusEnum") @XmlEnum(String.class) public enum StatusEnum { @@ -60,7 +59,7 @@ public static StatusEnum fromValue(String v) { return b; } } - return null; + throw new IllegalArgumentException("Unexpected value '" + v + "'"); } } @@ -170,7 +169,7 @@ public Order status(StatusEnum status) { * @return complete **/ @JsonProperty("complete") - public Boolean isComplete() { + public Boolean getComplete() { return complete; } diff --git a/samples/client/petstore/jaxrs-cxf-client/src/gen/java/org/openapitools/model/Pet.java b/samples/client/petstore/jaxrs-cxf-client/src/gen/java/org/openapitools/model/Pet.java index c7e7cda691e2..f6faecaf750d 100644 --- a/samples/client/petstore/jaxrs-cxf-client/src/gen/java/org/openapitools/model/Pet.java +++ b/samples/client/petstore/jaxrs-cxf-client/src/gen/java/org/openapitools/model/Pet.java @@ -37,7 +37,6 @@ public class Pet { @ApiModelProperty(value = "") private List tags = null; - @XmlType(name="StatusEnum") @XmlEnum(String.class) public enum StatusEnum { @@ -66,7 +65,7 @@ public static StatusEnum fromValue(String v) { return b; } } - return null; + throw new IllegalArgumentException("Unexpected value '" + v + "'"); } } diff --git a/samples/server/petstore/jaxrs-resteasy/eap-java8/src/main/java/org/openapitools/api/RestApplication.java b/samples/server/petstore/jaxrs-resteasy/eap-java8/src/main/java/org/openapitools/api/RestApplication.java index 14822d371798..4b18e7088cb1 100644 --- a/samples/server/petstore/jaxrs-resteasy/eap-java8/src/main/java/org/openapitools/api/RestApplication.java +++ b/samples/server/petstore/jaxrs-resteasy/eap-java8/src/main/java/org/openapitools/api/RestApplication.java @@ -10,7 +10,7 @@ import org.openapitools.api.impl.StoreApiServiceImpl; import org.openapitools.api.impl.UserApiServiceImpl; -@ApplicationPath("/") +@ApplicationPath("/v2") public class RestApplication extends Application { diff --git a/samples/server/petstore/jaxrs-resteasy/eap-joda/src/main/java/org/openapitools/api/RestApplication.java b/samples/server/petstore/jaxrs-resteasy/eap-joda/src/main/java/org/openapitools/api/RestApplication.java index 14822d371798..4b18e7088cb1 100644 --- a/samples/server/petstore/jaxrs-resteasy/eap-joda/src/main/java/org/openapitools/api/RestApplication.java +++ b/samples/server/petstore/jaxrs-resteasy/eap-joda/src/main/java/org/openapitools/api/RestApplication.java @@ -10,7 +10,7 @@ import org.openapitools.api.impl.StoreApiServiceImpl; import org.openapitools.api.impl.UserApiServiceImpl; -@ApplicationPath("/") +@ApplicationPath("/v2") public class RestApplication extends Application { diff --git a/samples/server/petstore/jaxrs-resteasy/eap/src/main/java/org/openapitools/api/RestApplication.java b/samples/server/petstore/jaxrs-resteasy/eap/src/main/java/org/openapitools/api/RestApplication.java index 14822d371798..4b18e7088cb1 100644 --- a/samples/server/petstore/jaxrs-resteasy/eap/src/main/java/org/openapitools/api/RestApplication.java +++ b/samples/server/petstore/jaxrs-resteasy/eap/src/main/java/org/openapitools/api/RestApplication.java @@ -10,7 +10,7 @@ import org.openapitools.api.impl.StoreApiServiceImpl; import org.openapitools.api.impl.UserApiServiceImpl; -@ApplicationPath("/") +@ApplicationPath("/v2") public class RestApplication extends Application { diff --git a/samples/server/petstore/jaxrs-spec-interface-response/.openapi-generator/VERSION b/samples/server/petstore/jaxrs-spec-interface-response/.openapi-generator/VERSION index 4395ff592326..105bb87d77b3 100644 --- a/samples/server/petstore/jaxrs-spec-interface-response/.openapi-generator/VERSION +++ b/samples/server/petstore/jaxrs-spec-interface-response/.openapi-generator/VERSION @@ -1 +1 @@ -3.2.0-SNAPSHOT \ No newline at end of file +3.2.2-SNAPSHOT \ No newline at end of file diff --git a/samples/server/petstore/jaxrs-spec-interface-response/src/gen/java/org/openapitools/model/AdditionalPropertiesClass.java b/samples/server/petstore/jaxrs-spec-interface-response/src/gen/java/org/openapitools/model/AdditionalPropertiesClass.java index 9ffada31ae87..58abe9915cb2 100644 --- a/samples/server/petstore/jaxrs-spec-interface-response/src/gen/java/org/openapitools/model/AdditionalPropertiesClass.java +++ b/samples/server/petstore/jaxrs-spec-interface-response/src/gen/java/org/openapitools/model/AdditionalPropertiesClass.java @@ -1,5 +1,7 @@ package org.openapitools.model; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; import java.util.HashMap; import java.util.List; import java.util.Map; diff --git a/samples/server/petstore/jaxrs-spec-interface-response/src/gen/java/org/openapitools/model/Animal.java b/samples/server/petstore/jaxrs-spec-interface-response/src/gen/java/org/openapitools/model/Animal.java index f5d49a3c4b21..3ea215fd3de3 100644 --- a/samples/server/petstore/jaxrs-spec-interface-response/src/gen/java/org/openapitools/model/Animal.java +++ b/samples/server/petstore/jaxrs-spec-interface-response/src/gen/java/org/openapitools/model/Animal.java @@ -2,6 +2,8 @@ import com.fasterxml.jackson.annotation.JsonSubTypes; import com.fasterxml.jackson.annotation.JsonTypeInfo; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; import java.io.Serializable; import javax.validation.constraints.*; import javax.validation.Valid; diff --git a/samples/server/petstore/jaxrs-spec-interface-response/src/gen/java/org/openapitools/model/ArrayOfArrayOfNumberOnly.java b/samples/server/petstore/jaxrs-spec-interface-response/src/gen/java/org/openapitools/model/ArrayOfArrayOfNumberOnly.java index 19b4fb8672a3..43d65d72f381 100644 --- a/samples/server/petstore/jaxrs-spec-interface-response/src/gen/java/org/openapitools/model/ArrayOfArrayOfNumberOnly.java +++ b/samples/server/petstore/jaxrs-spec-interface-response/src/gen/java/org/openapitools/model/ArrayOfArrayOfNumberOnly.java @@ -1,5 +1,7 @@ package org.openapitools.model; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; import java.math.BigDecimal; import java.util.ArrayList; import java.util.List; diff --git a/samples/server/petstore/jaxrs-spec-interface-response/src/gen/java/org/openapitools/model/ArrayOfNumberOnly.java b/samples/server/petstore/jaxrs-spec-interface-response/src/gen/java/org/openapitools/model/ArrayOfNumberOnly.java index 67f1a62787a7..f29bd99493ae 100644 --- a/samples/server/petstore/jaxrs-spec-interface-response/src/gen/java/org/openapitools/model/ArrayOfNumberOnly.java +++ b/samples/server/petstore/jaxrs-spec-interface-response/src/gen/java/org/openapitools/model/ArrayOfNumberOnly.java @@ -1,5 +1,7 @@ package org.openapitools.model; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; import java.math.BigDecimal; import java.util.ArrayList; import java.util.List; diff --git a/samples/server/petstore/jaxrs-spec-interface-response/src/gen/java/org/openapitools/model/ArrayTest.java b/samples/server/petstore/jaxrs-spec-interface-response/src/gen/java/org/openapitools/model/ArrayTest.java index 6c812b8b6844..249f75701bef 100644 --- a/samples/server/petstore/jaxrs-spec-interface-response/src/gen/java/org/openapitools/model/ArrayTest.java +++ b/samples/server/petstore/jaxrs-spec-interface-response/src/gen/java/org/openapitools/model/ArrayTest.java @@ -1,5 +1,7 @@ package org.openapitools.model; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; import java.util.ArrayList; import java.util.List; import org.openapitools.model.ReadOnlyFirst; diff --git a/samples/server/petstore/jaxrs-spec-interface-response/src/gen/java/org/openapitools/model/Capitalization.java b/samples/server/petstore/jaxrs-spec-interface-response/src/gen/java/org/openapitools/model/Capitalization.java index b2cc76b7b8d3..db53f3c49bd1 100644 --- a/samples/server/petstore/jaxrs-spec-interface-response/src/gen/java/org/openapitools/model/Capitalization.java +++ b/samples/server/petstore/jaxrs-spec-interface-response/src/gen/java/org/openapitools/model/Capitalization.java @@ -1,5 +1,7 @@ package org.openapitools.model; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; import java.io.Serializable; import javax.validation.constraints.*; import javax.validation.Valid; diff --git a/samples/server/petstore/jaxrs-spec-interface-response/src/gen/java/org/openapitools/model/Cat.java b/samples/server/petstore/jaxrs-spec-interface-response/src/gen/java/org/openapitools/model/Cat.java index 134779f46fcb..501e9c7d2c22 100644 --- a/samples/server/petstore/jaxrs-spec-interface-response/src/gen/java/org/openapitools/model/Cat.java +++ b/samples/server/petstore/jaxrs-spec-interface-response/src/gen/java/org/openapitools/model/Cat.java @@ -1,5 +1,7 @@ package org.openapitools.model; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; import org.openapitools.model.Animal; import java.io.Serializable; import javax.validation.constraints.*; diff --git a/samples/server/petstore/jaxrs-spec-interface-response/src/gen/java/org/openapitools/model/Category.java b/samples/server/petstore/jaxrs-spec-interface-response/src/gen/java/org/openapitools/model/Category.java index 4eb21f49a584..b31e9f551c84 100644 --- a/samples/server/petstore/jaxrs-spec-interface-response/src/gen/java/org/openapitools/model/Category.java +++ b/samples/server/petstore/jaxrs-spec-interface-response/src/gen/java/org/openapitools/model/Category.java @@ -1,5 +1,7 @@ package org.openapitools.model; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; import java.io.Serializable; import javax.validation.constraints.*; import javax.validation.Valid; diff --git a/samples/server/petstore/jaxrs-spec-interface-response/src/gen/java/org/openapitools/model/ClassModel.java b/samples/server/petstore/jaxrs-spec-interface-response/src/gen/java/org/openapitools/model/ClassModel.java index 373ea29aa253..87a1c546c192 100644 --- a/samples/server/petstore/jaxrs-spec-interface-response/src/gen/java/org/openapitools/model/ClassModel.java +++ b/samples/server/petstore/jaxrs-spec-interface-response/src/gen/java/org/openapitools/model/ClassModel.java @@ -1,6 +1,7 @@ package org.openapitools.model; import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; import java.io.Serializable; import javax.validation.constraints.*; import javax.validation.Valid; diff --git a/samples/server/petstore/jaxrs-spec-interface-response/src/gen/java/org/openapitools/model/Client.java b/samples/server/petstore/jaxrs-spec-interface-response/src/gen/java/org/openapitools/model/Client.java index 83c5ac4e1821..56914b24020a 100644 --- a/samples/server/petstore/jaxrs-spec-interface-response/src/gen/java/org/openapitools/model/Client.java +++ b/samples/server/petstore/jaxrs-spec-interface-response/src/gen/java/org/openapitools/model/Client.java @@ -1,5 +1,7 @@ package org.openapitools.model; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; import java.io.Serializable; import javax.validation.constraints.*; import javax.validation.Valid; diff --git a/samples/server/petstore/jaxrs-spec-interface-response/src/gen/java/org/openapitools/model/Dog.java b/samples/server/petstore/jaxrs-spec-interface-response/src/gen/java/org/openapitools/model/Dog.java index 3cf495a7b151..79c4f948f92a 100644 --- a/samples/server/petstore/jaxrs-spec-interface-response/src/gen/java/org/openapitools/model/Dog.java +++ b/samples/server/petstore/jaxrs-spec-interface-response/src/gen/java/org/openapitools/model/Dog.java @@ -1,5 +1,7 @@ package org.openapitools.model; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; import org.openapitools.model.Animal; import java.io.Serializable; import javax.validation.constraints.*; diff --git a/samples/server/petstore/jaxrs-spec-interface-response/src/gen/java/org/openapitools/model/EnumArrays.java b/samples/server/petstore/jaxrs-spec-interface-response/src/gen/java/org/openapitools/model/EnumArrays.java index 7a93f0b748b9..a2003eef8b9b 100644 --- a/samples/server/petstore/jaxrs-spec-interface-response/src/gen/java/org/openapitools/model/EnumArrays.java +++ b/samples/server/petstore/jaxrs-spec-interface-response/src/gen/java/org/openapitools/model/EnumArrays.java @@ -1,5 +1,7 @@ package org.openapitools.model; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; import java.util.ArrayList; import java.util.List; import java.io.Serializable; diff --git a/samples/server/petstore/jaxrs-spec-interface-response/src/gen/java/org/openapitools/model/EnumTest.java b/samples/server/petstore/jaxrs-spec-interface-response/src/gen/java/org/openapitools/model/EnumTest.java index 42348dcdc918..ce852c9d3e0d 100644 --- a/samples/server/petstore/jaxrs-spec-interface-response/src/gen/java/org/openapitools/model/EnumTest.java +++ b/samples/server/petstore/jaxrs-spec-interface-response/src/gen/java/org/openapitools/model/EnumTest.java @@ -1,5 +1,7 @@ package org.openapitools.model; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; import org.openapitools.model.OuterEnum; import java.io.Serializable; import javax.validation.constraints.*; diff --git a/samples/server/petstore/jaxrs-spec-interface-response/src/gen/java/org/openapitools/model/FileSchemaTestClass.java b/samples/server/petstore/jaxrs-spec-interface-response/src/gen/java/org/openapitools/model/FileSchemaTestClass.java index 3acdf4471023..0ba22995c7a2 100644 --- a/samples/server/petstore/jaxrs-spec-interface-response/src/gen/java/org/openapitools/model/FileSchemaTestClass.java +++ b/samples/server/petstore/jaxrs-spec-interface-response/src/gen/java/org/openapitools/model/FileSchemaTestClass.java @@ -1,5 +1,7 @@ package org.openapitools.model; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; import java.util.ArrayList; import java.util.List; import java.io.Serializable; diff --git a/samples/server/petstore/jaxrs-spec-interface-response/src/gen/java/org/openapitools/model/FormatTest.java b/samples/server/petstore/jaxrs-spec-interface-response/src/gen/java/org/openapitools/model/FormatTest.java index 62bac3f66256..2d4ff70310f6 100644 --- a/samples/server/petstore/jaxrs-spec-interface-response/src/gen/java/org/openapitools/model/FormatTest.java +++ b/samples/server/petstore/jaxrs-spec-interface-response/src/gen/java/org/openapitools/model/FormatTest.java @@ -1,5 +1,7 @@ package org.openapitools.model; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; import java.io.File; import java.math.BigDecimal; import java.util.Date; diff --git a/samples/server/petstore/jaxrs-spec-interface-response/src/gen/java/org/openapitools/model/HasOnlyReadOnly.java b/samples/server/petstore/jaxrs-spec-interface-response/src/gen/java/org/openapitools/model/HasOnlyReadOnly.java index 40af19634263..221814463303 100644 --- a/samples/server/petstore/jaxrs-spec-interface-response/src/gen/java/org/openapitools/model/HasOnlyReadOnly.java +++ b/samples/server/petstore/jaxrs-spec-interface-response/src/gen/java/org/openapitools/model/HasOnlyReadOnly.java @@ -1,5 +1,7 @@ package org.openapitools.model; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; import java.io.Serializable; import javax.validation.constraints.*; import javax.validation.Valid; diff --git a/samples/server/petstore/jaxrs-spec-interface-response/src/gen/java/org/openapitools/model/MapTest.java b/samples/server/petstore/jaxrs-spec-interface-response/src/gen/java/org/openapitools/model/MapTest.java index 2961088997d7..d0e0137e2107 100644 --- a/samples/server/petstore/jaxrs-spec-interface-response/src/gen/java/org/openapitools/model/MapTest.java +++ b/samples/server/petstore/jaxrs-spec-interface-response/src/gen/java/org/openapitools/model/MapTest.java @@ -1,5 +1,7 @@ package org.openapitools.model; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; import java.util.HashMap; import java.util.List; import java.util.Map; diff --git a/samples/server/petstore/jaxrs-spec-interface-response/src/gen/java/org/openapitools/model/MixedPropertiesAndAdditionalPropertiesClass.java b/samples/server/petstore/jaxrs-spec-interface-response/src/gen/java/org/openapitools/model/MixedPropertiesAndAdditionalPropertiesClass.java index cc446a6fce48..627a928a17b0 100644 --- a/samples/server/petstore/jaxrs-spec-interface-response/src/gen/java/org/openapitools/model/MixedPropertiesAndAdditionalPropertiesClass.java +++ b/samples/server/petstore/jaxrs-spec-interface-response/src/gen/java/org/openapitools/model/MixedPropertiesAndAdditionalPropertiesClass.java @@ -1,5 +1,7 @@ package org.openapitools.model; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; import java.util.Date; import java.util.HashMap; import java.util.List; diff --git a/samples/server/petstore/jaxrs-spec-interface-response/src/gen/java/org/openapitools/model/Model200Response.java b/samples/server/petstore/jaxrs-spec-interface-response/src/gen/java/org/openapitools/model/Model200Response.java index c5fbe95d9f64..362ea187e754 100644 --- a/samples/server/petstore/jaxrs-spec-interface-response/src/gen/java/org/openapitools/model/Model200Response.java +++ b/samples/server/petstore/jaxrs-spec-interface-response/src/gen/java/org/openapitools/model/Model200Response.java @@ -1,6 +1,7 @@ package org.openapitools.model; import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; import java.io.Serializable; import javax.validation.constraints.*; import javax.validation.Valid; diff --git a/samples/server/petstore/jaxrs-spec-interface-response/src/gen/java/org/openapitools/model/ModelApiResponse.java b/samples/server/petstore/jaxrs-spec-interface-response/src/gen/java/org/openapitools/model/ModelApiResponse.java index 339ae0912fdf..57705be9cd50 100644 --- a/samples/server/petstore/jaxrs-spec-interface-response/src/gen/java/org/openapitools/model/ModelApiResponse.java +++ b/samples/server/petstore/jaxrs-spec-interface-response/src/gen/java/org/openapitools/model/ModelApiResponse.java @@ -1,5 +1,7 @@ package org.openapitools.model; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; import java.io.Serializable; import javax.validation.constraints.*; import javax.validation.Valid; diff --git a/samples/server/petstore/jaxrs-spec-interface-response/src/gen/java/org/openapitools/model/ModelReturn.java b/samples/server/petstore/jaxrs-spec-interface-response/src/gen/java/org/openapitools/model/ModelReturn.java index e5585db2da5e..4d0ad8278e49 100644 --- a/samples/server/petstore/jaxrs-spec-interface-response/src/gen/java/org/openapitools/model/ModelReturn.java +++ b/samples/server/petstore/jaxrs-spec-interface-response/src/gen/java/org/openapitools/model/ModelReturn.java @@ -1,6 +1,7 @@ package org.openapitools.model; import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; import java.io.Serializable; import javax.validation.constraints.*; import javax.validation.Valid; diff --git a/samples/server/petstore/jaxrs-spec-interface-response/src/gen/java/org/openapitools/model/Name.java b/samples/server/petstore/jaxrs-spec-interface-response/src/gen/java/org/openapitools/model/Name.java index 6fa1ec2f4c81..7dfe13b2cb9a 100644 --- a/samples/server/petstore/jaxrs-spec-interface-response/src/gen/java/org/openapitools/model/Name.java +++ b/samples/server/petstore/jaxrs-spec-interface-response/src/gen/java/org/openapitools/model/Name.java @@ -1,6 +1,7 @@ package org.openapitools.model; import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; import java.io.Serializable; import javax.validation.constraints.*; import javax.validation.Valid; diff --git a/samples/server/petstore/jaxrs-spec-interface-response/src/gen/java/org/openapitools/model/NumberOnly.java b/samples/server/petstore/jaxrs-spec-interface-response/src/gen/java/org/openapitools/model/NumberOnly.java index 9aa6bc737497..bec8bbd4669f 100644 --- a/samples/server/petstore/jaxrs-spec-interface-response/src/gen/java/org/openapitools/model/NumberOnly.java +++ b/samples/server/petstore/jaxrs-spec-interface-response/src/gen/java/org/openapitools/model/NumberOnly.java @@ -1,5 +1,7 @@ package org.openapitools.model; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; import java.math.BigDecimal; import java.io.Serializable; import javax.validation.constraints.*; diff --git a/samples/server/petstore/jaxrs-spec-interface-response/src/gen/java/org/openapitools/model/Order.java b/samples/server/petstore/jaxrs-spec-interface-response/src/gen/java/org/openapitools/model/Order.java index f2b772249aef..4351bf390984 100644 --- a/samples/server/petstore/jaxrs-spec-interface-response/src/gen/java/org/openapitools/model/Order.java +++ b/samples/server/petstore/jaxrs-spec-interface-response/src/gen/java/org/openapitools/model/Order.java @@ -1,5 +1,7 @@ package org.openapitools.model; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; import java.util.Date; import java.io.Serializable; import javax.validation.constraints.*; diff --git a/samples/server/petstore/jaxrs-spec-interface-response/src/gen/java/org/openapitools/model/OuterComposite.java b/samples/server/petstore/jaxrs-spec-interface-response/src/gen/java/org/openapitools/model/OuterComposite.java index c4c046c8953b..37d163744cbb 100644 --- a/samples/server/petstore/jaxrs-spec-interface-response/src/gen/java/org/openapitools/model/OuterComposite.java +++ b/samples/server/petstore/jaxrs-spec-interface-response/src/gen/java/org/openapitools/model/OuterComposite.java @@ -1,5 +1,7 @@ package org.openapitools.model; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; import java.math.BigDecimal; import java.io.Serializable; import javax.validation.constraints.*; diff --git a/samples/server/petstore/jaxrs-spec-interface-response/src/gen/java/org/openapitools/model/Pet.java b/samples/server/petstore/jaxrs-spec-interface-response/src/gen/java/org/openapitools/model/Pet.java index bdb345ac05fd..6b669e30995a 100644 --- a/samples/server/petstore/jaxrs-spec-interface-response/src/gen/java/org/openapitools/model/Pet.java +++ b/samples/server/petstore/jaxrs-spec-interface-response/src/gen/java/org/openapitools/model/Pet.java @@ -1,5 +1,7 @@ package org.openapitools.model; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; import java.util.ArrayList; import java.util.List; import org.openapitools.model.Category; diff --git a/samples/server/petstore/jaxrs-spec-interface-response/src/gen/java/org/openapitools/model/ReadOnlyFirst.java b/samples/server/petstore/jaxrs-spec-interface-response/src/gen/java/org/openapitools/model/ReadOnlyFirst.java index b7349f0a2567..02c8630a47f6 100644 --- a/samples/server/petstore/jaxrs-spec-interface-response/src/gen/java/org/openapitools/model/ReadOnlyFirst.java +++ b/samples/server/petstore/jaxrs-spec-interface-response/src/gen/java/org/openapitools/model/ReadOnlyFirst.java @@ -1,5 +1,7 @@ package org.openapitools.model; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; import java.io.Serializable; import javax.validation.constraints.*; import javax.validation.Valid; diff --git a/samples/server/petstore/jaxrs-spec-interface-response/src/gen/java/org/openapitools/model/SpecialModelName.java b/samples/server/petstore/jaxrs-spec-interface-response/src/gen/java/org/openapitools/model/SpecialModelName.java index 5668baa8c702..d57dd6da2b2e 100644 --- a/samples/server/petstore/jaxrs-spec-interface-response/src/gen/java/org/openapitools/model/SpecialModelName.java +++ b/samples/server/petstore/jaxrs-spec-interface-response/src/gen/java/org/openapitools/model/SpecialModelName.java @@ -1,5 +1,7 @@ package org.openapitools.model; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; import java.io.Serializable; import javax.validation.constraints.*; import javax.validation.Valid; diff --git a/samples/server/petstore/jaxrs-spec-interface-response/src/gen/java/org/openapitools/model/Tag.java b/samples/server/petstore/jaxrs-spec-interface-response/src/gen/java/org/openapitools/model/Tag.java index ced9e763c59e..3c8f6153974f 100644 --- a/samples/server/petstore/jaxrs-spec-interface-response/src/gen/java/org/openapitools/model/Tag.java +++ b/samples/server/petstore/jaxrs-spec-interface-response/src/gen/java/org/openapitools/model/Tag.java @@ -1,5 +1,7 @@ package org.openapitools.model; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; import java.io.Serializable; import javax.validation.constraints.*; import javax.validation.Valid; diff --git a/samples/server/petstore/jaxrs-spec-interface-response/src/gen/java/org/openapitools/model/User.java b/samples/server/petstore/jaxrs-spec-interface-response/src/gen/java/org/openapitools/model/User.java index 47bd2cde5d3c..2e0a3d033218 100644 --- a/samples/server/petstore/jaxrs-spec-interface-response/src/gen/java/org/openapitools/model/User.java +++ b/samples/server/petstore/jaxrs-spec-interface-response/src/gen/java/org/openapitools/model/User.java @@ -1,5 +1,7 @@ package org.openapitools.model; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; import java.io.Serializable; import javax.validation.constraints.*; import javax.validation.Valid; From 1c6ab3f831d517ce89fae2adc4cb7bab65c3a199 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rytis=20Karpu=C5=A1ka?= Date: Thu, 16 Aug 2018 13:16:58 +0300 Subject: [PATCH 03/15] Add localVar prefix to parameterized functions variables in cpprestsdk in order to make name clashing less probable. (#731) --- .../cpp-rest-sdk-client/api-source.mustache | 214 +++--- .../petstore/cpp-restsdk/api/PetApi.cpp | 702 +++++++++--------- .../petstore/cpp-restsdk/api/StoreApi.cpp | 352 ++++----- .../petstore/cpp-restsdk/api/UserApi.cpp | 690 ++++++++--------- 4 files changed, 979 insertions(+), 979 deletions(-) diff --git a/modules/openapi-generator/src/main/resources/cpp-rest-sdk-client/api-source.mustache b/modules/openapi-generator/src/main/resources/cpp-rest-sdk-client/api-source.mustache index 81df5d1ff56c..d00fcdeb6e3a 100644 --- a/modules/openapi-generator/src/main/resources/cpp-rest-sdk-client/api-source.mustache +++ b/modules/openapi-generator/src/main/resources/cpp-rest-sdk-client/api-source.mustache @@ -36,55 +36,55 @@ pplx::task<{{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}void{{/r } {{/isContainer}}{{/isPrimitiveType}}{{/required}}{{/allParams}} - std::shared_ptr apiConfiguration( m_ApiClient->getConfiguration() ); - utility::string_t path = utility::conversions::to_string_t("{{{path}}}"); - {{#pathParams}}boost::replace_all(path, utility::conversions::to_string_t("{") + utility::conversions::to_string_t("{{baseName}}") + utility::conversions::to_string_t("}"), ApiClient::parameterToString({{{paramName}}})); + std::shared_ptr localVarApiConfiguration( m_ApiClient->getConfiguration() ); + utility::string_t localVarPath = utility::conversions::to_string_t("{{{path}}}"); + {{#pathParams}}boost::replace_all(localVarPath, utility::conversions::to_string_t("{") + utility::conversions::to_string_t("{{baseName}}") + utility::conversions::to_string_t("}"), ApiClient::parameterToString({{{paramName}}})); {{/pathParams}} - std::map queryParams; - std::map headerParams( apiConfiguration->getDefaultHeaders() ); - std::map formParams; - std::map> fileParams; + std::map localVarQueryParams; + std::map localVarHeaderParams( localVarApiConfiguration->getDefaultHeaders() ); + std::map localVarFormParams; + std::map> localVarFileParams; - std::unordered_set responseHttpContentTypes; + std::unordered_set localVarResponseHttpContentTypes; {{#produces}} - responseHttpContentTypes.insert( utility::conversions::to_string_t("{{{mediaType}}}") ); + localVarResponseHttpContentTypes.insert( utility::conversions::to_string_t("{{{mediaType}}}") ); {{/produces}} - utility::string_t responseHttpContentType; + utility::string_t localVarResponseHttpContentType; // use JSON if possible - if ( responseHttpContentTypes.size() == 0 ) + if ( localVarResponseHttpContentTypes.size() == 0 ) { {{#vendorExtensions.x-codegen-response.isString}} - responseHttpContentType = utility::conversions::to_string_t("text/plain"); + localVarResponseHttpContentType = utility::conversions::to_string_t("text/plain"); {{/vendorExtensions.x-codegen-response.isString}} {{^vendorExtensions.x-codegen-response.isString}} - responseHttpContentType = utility::conversions::to_string_t("application/json"); + localVarResponseHttpContentType = utility::conversions::to_string_t("application/json"); {{/vendorExtensions.x-codegen-response.isString}} } // JSON - else if ( responseHttpContentTypes.find(utility::conversions::to_string_t("application/json")) != responseHttpContentTypes.end() ) + else if ( localVarResponseHttpContentTypes.find(utility::conversions::to_string_t("application/json")) != localVarResponseHttpContentTypes.end() ) { - responseHttpContentType = utility::conversions::to_string_t("application/json"); + localVarResponseHttpContentType = utility::conversions::to_string_t("application/json"); } // multipart formdata - else if( responseHttpContentTypes.find(utility::conversions::to_string_t("multipart/form-data")) != responseHttpContentTypes.end() ) + else if( localVarResponseHttpContentTypes.find(utility::conversions::to_string_t("multipart/form-data")) != localVarResponseHttpContentTypes.end() ) { - responseHttpContentType = utility::conversions::to_string_t("multipart/form-data"); + localVarResponseHttpContentType = utility::conversions::to_string_t("multipart/form-data"); } {{#vendorExtensions.x-codegen-response.isString}} // plain text - else if( responseHttpContentTypes.find(utility::conversions::to_string_t("text/plain")) != responseHttpContentTypes.end() ) + else if( localVarResponseHttpContentTypes.find(utility::conversions::to_string_t("text/plain")) != localVarResponseHttpContentTypes.end() ) { - responseHttpContentType = utility::conversions::to_string_t("text/plain"); + localVarResponseHttpContentType = utility::conversions::to_string_t("text/plain"); } {{/vendorExtensions.x-codegen-response.isString}} {{#vendorExtensions.x-codegen-response-ishttpcontent}} else { //It's going to be binary, so just use the first one. - responseHttpContentType = *responseHttpContentTypes.begin(); + localVarResponseHttpContentType = *localVarResponseHttpContentTypes.begin(); } {{/vendorExtensions.x-codegen-response-ishttpcontent}} {{^vendorExtensions.x-codegen-response-ishttpcontent}} @@ -94,11 +94,11 @@ pplx::task<{{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}void{{/r } {{/vendorExtensions.x-codegen-response-ishttpcontent}} - headerParams[utility::conversions::to_string_t("Accept")] = responseHttpContentType; + localVarHeaderParams[utility::conversions::to_string_t("Accept")] = localVarResponseHttpContentType; - std::unordered_set consumeHttpContentTypes; + std::unordered_set localVarConsumeHttpContentTypes; {{#consumes}} - consumeHttpContentTypes.insert( utility::conversions::to_string_t("{{{mediaType}}}") ); + localVarConsumeHttpContentTypes.insert( utility::conversions::to_string_t("{{{mediaType}}}") ); {{/consumes}} {{#allParams}} @@ -131,17 +131,17 @@ pplx::task<{{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}void{{/r {{/required}} { {{#isQueryParam}} - queryParams[utility::conversions::to_string_t("{{baseName}}")] = ApiClient::parameterToString({{^required}}*{{/required}}{{paramName}}); + localVarQueryParams[utility::conversions::to_string_t("{{baseName}}")] = ApiClient::parameterToString({{^required}}*{{/required}}{{paramName}}); {{/isQueryParam}} {{#isHeaderParam}} - headerParams[utility::conversions::to_string_t("{{baseName}}")] = ApiClient::parameterToString({{^required}}*{{/required}}{{paramName}}); + localVarHeaderParams[utility::conversions::to_string_t("{{baseName}}")] = ApiClient::parameterToString({{^required}}*{{/required}}{{paramName}}); {{/isHeaderParam}} {{#isFormParam}} {{#isFile}} - fileParams[ utility::conversions::to_string_t("{{baseName}}") ] = {{^required}}*{{/required}}{{paramName}}; + localVarFileParams[ utility::conversions::to_string_t("{{baseName}}") ] = {{^required}}*{{/required}}{{paramName}}; {{/isFile}} {{^isFile}} - formParams[ utility::conversions::to_string_t("{{baseName}}") ] = ApiClient::parameterToString({{^required}}*{{/required}}{{paramName}}); + localVarFormParams[ utility::conversions::to_string_t("{{baseName}}") ] = ApiClient::parameterToString({{^required}}*{{/required}}{{paramName}}); {{/isFile}} {{/isFormParam}} } @@ -149,77 +149,77 @@ pplx::task<{{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}void{{/r {{/isBodyParam}} {{/allParams}} - std::shared_ptr httpBody; - utility::string_t requestHttpContentType; + std::shared_ptr localVarHttpBody; + utility::string_t localVarRequestHttpContentType; // use JSON if possible - if ( consumeHttpContentTypes.size() == 0 || consumeHttpContentTypes.find(utility::conversions::to_string_t("application/json")) != consumeHttpContentTypes.end() ) + if ( localVarConsumeHttpContentTypes.size() == 0 || localVarConsumeHttpContentTypes.find(utility::conversions::to_string_t("application/json")) != localVarConsumeHttpContentTypes.end() ) { - requestHttpContentType = utility::conversions::to_string_t("application/json"); + localVarRequestHttpContentType = utility::conversions::to_string_t("application/json"); {{#bodyParam}} - web::json::value json; + web::json::value localVarJson; {{#isPrimitiveType}} - json = ModelBase::toJson({{paramName}}); + localVarJson = ModelBase::toJson({{paramName}}); {{/isPrimitiveType}} {{^isPrimitiveType}} {{#isListContainer}} { - std::vector jsonArray; - for( auto& item : {{paramName}} ) + std::vector localVarJsonArray; + for( auto& localVarItem : {{paramName}} ) { - {{#items.isPrimitiveType}}jsonArray.push_back(ModelBase::toJson(item)); - {{/items.isPrimitiveType}}{{^items.isPrimitiveType}}{{#items.isString}}jsonArray.push_back(ModelBase::toJson(item)); - {{/items.isString}}{{^items.isString}}{{#items.isDateTime}}jsonArray.push_back(ModelBase::toJson(item)); - {{/items.isDateTime}}{{^items.isDateTime}}jsonArray.push_back( item.get() ? item->toJson() : web::json::value::null() ); + {{#items.isPrimitiveType}}localVarJsonArray.push_back(ModelBase::toJson(localVarItem)); + {{/items.isPrimitiveType}}{{^items.isPrimitiveType}}{{#items.isString}}localVarJsonArray.push_back(ModelBase::toJson(localVarItem)); + {{/items.isString}}{{^items.isString}}{{#items.isDateTime}}localVarJsonArray.push_back(ModelBase::toJson(localVarItem)); + {{/items.isDateTime}}{{^items.isDateTime}}localVarJsonArray.push_back( localVarItem.get() ? localVarItem->toJson() : web::json::value::null() ); {{/items.isDateTime}}{{/items.isString}}{{/items.isPrimitiveType}} } - json = web::json::value::array(jsonArray); + localVarJson = web::json::value::array(localVarJsonArray); } {{/isListContainer}} - {{^isListContainer}}{{#required}}json = ModelBase::toJson({{paramName}}); + {{^isListContainer}}{{#required}}localVarJson = ModelBase::toJson({{paramName}}); {{/required}}{{^required}}if ({{paramName}}) - json = ModelBase::toJson(*{{paramName}});{{/required}} + localVarJson = ModelBase::toJson(*{{paramName}});{{/required}} {{/isListContainer}} {{/isPrimitiveType}} - httpBody = std::shared_ptr( new JsonBody( json ) ); + localVarHttpBody = std::shared_ptr( new JsonBody( localVarJson ) ); {{/bodyParam}} } // multipart formdata - else if( consumeHttpContentTypes.find(utility::conversions::to_string_t("multipart/form-data")) != consumeHttpContentTypes.end() ) + else if( localVarConsumeHttpContentTypes.find(utility::conversions::to_string_t("multipart/form-data")) != localVarConsumeHttpContentTypes.end() ) { - requestHttpContentType = utility::conversions::to_string_t("multipart/form-data"); + localVarRequestHttpContentType = utility::conversions::to_string_t("multipart/form-data"); {{#bodyParam}} - std::shared_ptr multipart(new MultipartFormData); + std::shared_ptr localVarMultipart(new MultipartFormData); {{#isPrimitiveType}} - multipart->add(ModelBase::toHttpContent("{{paramName}}", {{paramName}})); + localVarMultipart->add(ModelBase::toHttpContent("{{paramName}}", {{paramName}})); {{/isPrimitiveType}} {{^isPrimitiveType}} {{#isListContainer}} { - std::vector jsonArray; - for( auto& item : {{paramName}} ) + std::vector localVarJsonArray; + for( auto& localVarItem : {{paramName}} ) { - {{#items.isPrimitiveType}}jsonArray.push_back(ModelBase::toJson(item)); - {{/items.isPrimitiveType}}{{^items.isPrimitiveType}}{{#items.isString}}jsonArray.push_back(ModelBase::toJson(item)); - {{/items.isString}}{{^items.isString}}{{#items.isDateTime}}jsonArray.push_back(ModelBase::toJson(item)); - {{/items.isDateTime}}{{^items.isDateTime}}jsonArray.push_back( item.get() ? item->toJson() : web::json::value::null() ); + {{#items.isPrimitiveType}}localVarJsonArray.push_back(ModelBase::toJson(localVarItem)); + {{/items.isPrimitiveType}}{{^items.isPrimitiveType}}{{#items.isString}}localVarJsonArray.push_back(ModelBase::toJson(localVarItem)); + {{/items.isString}}{{^items.isString}}{{#items.isDateTime}}localVarJsonArray.push_back(ModelBase::toJson(localVarItem)); + {{/items.isDateTime}}{{^items.isDateTime}}localVarJsonArray.push_back( localVarItem.get() ? localVarItem->toJson() : web::json::value::null() ); {{/items.isDateTime}}{{/items.isString}}{{/items.isPrimitiveType}} } - multipart->add(ModelBase::toHttpContent(utility::conversions::to_string_t("{{paramName}}"), web::json::value::array(jsonArray), utility::conversions::to_string_t("application/json"))); + localVarMultipart->add(ModelBase::toHttpContent(utility::conversions::to_string_t("{{paramName}}"), web::json::value::array(localVarJsonArray), utility::conversions::to_string_t("application/json"))); }{{/isListContainer}} - {{^isListContainer}}{{#isString}}multipart->add(ModelBase::toHttpContent(utility::conversions::to_string_t("{{paramName}}"), {{paramName}})); + {{^isListContainer}}{{#isString}}localVarMultipart->add(ModelBase::toHttpContent(utility::conversions::to_string_t("{{paramName}}"), {{paramName}})); {{/isString}}{{^isString}}if({{^required}}{{paramName}} && (*{{paramName}}){{/required}}{{#required}}{{paramName}}{{/required}}.get()) { - {{^required}}(*{{/required}}{{paramName}}{{^required}}){{/required}}->toMultipart(multipart, utility::conversions::to_string_t("{{paramName}}")); + {{^required}}(*{{/required}}{{paramName}}{{^required}}){{/required}}->toMultipart(localVarMultipart, utility::conversions::to_string_t("{{paramName}}")); } {{/isString}} {{/isListContainer}} {{/isPrimitiveType}} - httpBody = multipart; - requestHttpContentType += utility::conversions::to_string_t("; boundary=") + multipart->getBoundary(); + localVarHttpBody = localVarMultipart; + localVarRequestHttpContentType += utility::conversions::to_string_t("; boundary=") + localVarMultipart->getBoundary(); {{/bodyParam}} } else @@ -232,19 +232,19 @@ pplx::task<{{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}void{{/r {{#isApiKey}} {{#isKeyInHeader}} { - utility::string_t apiKey = apiConfiguration->getApiKey(utility::conversions::to_string_t("{{keyParamName}}")); - if ( apiKey.size() > 0 ) + utility::string_t localVarApiKey = localVarApiConfiguration->getApiKey(utility::conversions::to_string_t("{{keyParamName}}")); + if ( localVarApiKey.size() > 0 ) { - headerParams[utility::conversions::to_string_t("{{keyParamName}}")] = apiKey; + localVarHeaderParams[utility::conversions::to_string_t("{{keyParamName}}")] = localVarApiKey; } } {{/isKeyInHeader}} {{#isKeyInQuery}} { - utility::string_t apiKey = apiConfiguration->getApiKey(utility::conversions::to_string_t("{{keyParamName}}")); - if ( apiKey.size() > 0 ) + utility::string_t localVarApiKey = localVarApiConfiguration->getApiKey(utility::conversions::to_string_t("{{keyParamName}}")); + if ( localVarApiKey.size() > 0 ) { - queryParams[utility::conversions::to_string_t("{{keyParamName}}")] = apiKey; + localVarQueryParams[utility::conversions::to_string_t("{{keyParamName}}")] = localVarApiKey; } } {{/isKeyInQuery}} @@ -257,91 +257,91 @@ pplx::task<{{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}void{{/r {{/isOAuth}} {{/authMethods}} - return m_ApiClient->callApi(path, utility::conversions::to_string_t("{{httpMethod}}"), queryParams, httpBody, headerParams, formParams, fileParams, requestHttpContentType) - .then([=](web::http::http_response response) + return m_ApiClient->callApi(localVarPath, utility::conversions::to_string_t("{{httpMethod}}"), localVarQueryParams, localVarHttpBody, localVarHeaderParams, localVarFormParams, localVarFileParams, localVarRequestHttpContentType) + .then([=](web::http::http_response localVarResponse) { // 1xx - informational : OK // 2xx - successful : OK // 3xx - redirection : OK // 4xx - client error : not OK // 5xx - client error : not OK - if (response.status_code() >= 400) + if (localVarResponse.status_code() >= 400) { - throw ApiException(response.status_code() - , utility::conversions::to_string_t("error calling {{operationId}}: ") + response.reason_phrase() - , std::make_shared(response.extract_utf8string(true).get())); + throw ApiException(localVarResponse.status_code() + , utility::conversions::to_string_t("error calling {{operationId}}: ") + localVarResponse.reason_phrase() + , std::make_shared(localVarResponse.extract_utf8string(true).get())); } // check response content type - if(response.headers().has(utility::conversions::to_string_t("Content-Type"))) + if(localVarResponse.headers().has(utility::conversions::to_string_t("Content-Type"))) { - utility::string_t contentType = response.headers()[utility::conversions::to_string_t("Content-Type")]; - if( contentType.find(responseHttpContentType) == std::string::npos ) + utility::string_t localVarContentType = localVarResponse.headers()[utility::conversions::to_string_t("Content-Type")]; + if( localVarContentType.find(localVarResponseHttpContentType) == std::string::npos ) { throw ApiException(500 - , utility::conversions::to_string_t("error calling {{operationId}}: unexpected response type: ") + contentType - , std::make_shared(response.extract_utf8string(true).get())); + , utility::conversions::to_string_t("error calling {{operationId}}: unexpected response type: ") + localVarContentType + , std::make_shared(localVarResponse.extract_utf8string(true).get())); } } {{#vendorExtensions.x-codegen-response-ishttpcontent}} - return response.extract_vector(); + return localVarResponse.extract_vector(); }) - .then([=](std::vector response) + .then([=](std::vector localVarResponse) { - HttpContent result; - std::shared_ptr stream = std::make_shared(std::string(response.begin(), response.end())); - result.setData(stream); - return result; + HttpContent localVarResult; + std::shared_ptr stream = std::make_shared(std::string(localVarResponse.begin(), localVarResponse.end())); + localVarResult.setData(stream); + return localVarResult; {{/vendorExtensions.x-codegen-response-ishttpcontent}} {{^vendorExtensions.x-codegen-response-ishttpcontent}} - return response.extract_string(); + return localVarResponse.extract_string(); }) - .then([=](utility::string_t response) + .then([=](utility::string_t localVarResponse) { {{^returnType}} return void(); {{/returnType}} {{#returnType}} {{#returnContainer}} - {{{returnType}}} result; + {{{returnType}}} localVarResult; {{/returnContainer}} {{^returnContainer}} - {{{returnType}}} result({{{defaultResponse}}}); + {{{returnType}}} localVarResult({{{defaultResponse}}}); {{/returnContainer}} - if(responseHttpContentType == utility::conversions::to_string_t("application/json")) + if(localVarResponseHttpContentType == utility::conversions::to_string_t("application/json")) { - web::json::value json = web::json::value::parse(response); + web::json::value localVarJson = web::json::value::parse(localVarResponse); - {{#isListContainer}}for( auto& item : json.as_array() ) + {{#isListContainer}}for( auto& localVarItem : localVarJson.as_array() ) { - {{#vendorExtensions.x-codegen-response.items.isPrimitiveType}}result.push_back(ModelBase::{{vendorExtensions.x-codegen-response.items.datatype}}FromJson(item)); - {{/vendorExtensions.x-codegen-response.items.isPrimitiveType}}{{^vendorExtensions.x-codegen-response.items.isPrimitiveType}}{{#vendorExtensions.x-codegen-response.items.isString}}result.push_back(ModelBase::stringFromJson(item)); - {{/vendorExtensions.x-codegen-response.items.isString}}{{^vendorExtensions.x-codegen-response.items.isString}}{{{vendorExtensions.x-codegen-response.items.datatype}}} itemObj({{{vendorExtensions.x-codegen-response.items.defaultValue}}}); - itemObj->fromJson(item); - result.push_back(itemObj); + {{#vendorExtensions.x-codegen-response.items.isPrimitiveType}}localVarResult.push_back(ModelBase::{{vendorExtensions.x-codegen-response.items.datatype}}FromJson(localVarItem)); + {{/vendorExtensions.x-codegen-response.items.isPrimitiveType}}{{^vendorExtensions.x-codegen-response.items.isPrimitiveType}}{{#vendorExtensions.x-codegen-response.items.isString}}localVarResult.push_back(ModelBase::stringFromJson(localVarItem)); + {{/vendorExtensions.x-codegen-response.items.isString}}{{^vendorExtensions.x-codegen-response.items.isString}}{{{vendorExtensions.x-codegen-response.items.datatype}}} localVarItemObj({{{vendorExtensions.x-codegen-response.items.defaultValue}}}); + localVarItemObj->fromJson(localVarItem); + localVarResult.push_back(localVarItemObj); {{/vendorExtensions.x-codegen-response.items.isString}}{{/vendorExtensions.x-codegen-response.items.isPrimitiveType}} } - {{/isListContainer}}{{^isListContainer}}{{#isMapContainer}}for( auto& item : json.as_object() ) + {{/isListContainer}}{{^isListContainer}}{{#isMapContainer}}for( auto& localVarItem : localVarJson.as_object() ) { - {{#vendorExtensions.x-codegen-response.items.isPrimitiveType}}result[item.first] = ModelBase::{{vendorExtensions.x-codegen-response.items.datatype}}FromJson(item.second); - {{/vendorExtensions.x-codegen-response.items.isPrimitiveType}}{{^vendorExtensions.x-codegen-response.items.isPrimitiveType}}{{#vendorExtensions.x-codegen-response.items.isString}}result[item.first] = ModelBase::stringFromJson(item.second); - {{/vendorExtensions.x-codegen-response.items.isString}}{{^vendorExtensions.x-codegen-response.items.isString}}{{{vendorExtensions.x-codegen-response.items.datatype}}} itemObj({{{vendorExtensions.x-codegen-response.items.defaultValue}}}); - itemObj->fromJson(item.second); - result[item.first] = itemObj; + {{#vendorExtensions.x-codegen-response.items.isPrimitiveType}}localVarResult[localVarItem.first] = ModelBase::{{vendorExtensions.x-codegen-response.items.datatype}}FromJson(localVarItem.second); + {{/vendorExtensions.x-codegen-response.items.isPrimitiveType}}{{^vendorExtensions.x-codegen-response.items.isPrimitiveType}}{{#vendorExtensions.x-codegen-response.items.isString}}localVarResult[localVarItem.first] = ModelBase::stringFromJson(localVarItem.second); + {{/vendorExtensions.x-codegen-response.items.isString}}{{^vendorExtensions.x-codegen-response.items.isString}}{{{vendorExtensions.x-codegen-response.items.datatype}}} localVarItemObj({{{vendorExtensions.x-codegen-response.items.defaultValue}}}); + localVarItemObj->fromJson(localVarItem.second); + localVarResult[localVarItem.first] = localVarItemObj; {{/vendorExtensions.x-codegen-response.items.isString}}{{/vendorExtensions.x-codegen-response.items.isPrimitiveType}} } - {{/isMapContainer}}{{^isMapContainer}}{{#vendorExtensions.x-codegen-response.isPrimitiveType}}{{#vendorExtensions.x-codegen-response.items.datatype}}result = ModelBase::{{vendorExtensions.x-codegen-response.items.datatype}}FromJson(json); - {{/vendorExtensions.x-codegen-response.items.datatype}}{{^vendorExtensions.x-codegen-response.items.datatype}}result = ModelBase::{{vendorExtensions.x-codegen-response.datatype}}FromJson(json); - {{/vendorExtensions.x-codegen-response.items.datatype}}{{/vendorExtensions.x-codegen-response.isPrimitiveType}}{{^vendorExtensions.x-codegen-response.isPrimitiveType}}{{#vendorExtensions.x-codegen-response.isString}}result = ModelBase::stringFromJson(json); - {{/vendorExtensions.x-codegen-response.isString}}{{^vendorExtensions.x-codegen-response.isString}}result->fromJson(json);{{/vendorExtensions.x-codegen-response.isString}}{{/vendorExtensions.x-codegen-response.isPrimitiveType}}{{/isMapContainer}}{{/isListContainer}} + {{/isMapContainer}}{{^isMapContainer}}{{#vendorExtensions.x-codegen-response.isPrimitiveType}}{{#vendorExtensions.x-codegen-response.items.datatype}}localVarResult = ModelBase::{{vendorExtensions.x-codegen-response.items.datatype}}FromJson(localVarJson); + {{/vendorExtensions.x-codegen-response.items.datatype}}{{^vendorExtensions.x-codegen-response.items.datatype}}localVarResult = ModelBase::{{vendorExtensions.x-codegen-response.datatype}}FromJson(localVarJson); + {{/vendorExtensions.x-codegen-response.items.datatype}}{{/vendorExtensions.x-codegen-response.isPrimitiveType}}{{^vendorExtensions.x-codegen-response.isPrimitiveType}}{{#vendorExtensions.x-codegen-response.isString}}localVarResult = ModelBase::stringFromJson(localVarJson); + {{/vendorExtensions.x-codegen-response.isString}}{{^vendorExtensions.x-codegen-response.isString}}localVarResult->fromJson(localVarJson);{{/vendorExtensions.x-codegen-response.isString}}{{/vendorExtensions.x-codegen-response.isPrimitiveType}}{{/isMapContainer}}{{/isListContainer}} }{{#vendorExtensions.x-codegen-response.isString}} - else if(responseHttpContentType == utility::conversions::to_string_t("text/plain")) + else if(localVarResponseHttpContentType == utility::conversions::to_string_t("text/plain")) { - result = response; + localVarResult = localVarResponse; }{{/vendorExtensions.x-codegen-response.isString}} - // else if(responseHttpContentType == utility::conversions::to_string_t("multipart/form-data")) + // else if(localVarResponseHttpContentType == utility::conversions::to_string_t("multipart/form-data")) // { // TODO multipart response parsing // } @@ -351,7 +351,7 @@ pplx::task<{{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}void{{/r , utility::conversions::to_string_t("error calling {{operationId}}: unsupported response type")); } - return result; + return localVarResult; {{/returnType}} {{/vendorExtensions.x-codegen-response-ishttpcontent}} }); diff --git a/samples/client/petstore/cpp-restsdk/api/PetApi.cpp b/samples/client/petstore/cpp-restsdk/api/PetApi.cpp index c2f9a7f99f73..8d99e86ca8ad 100644 --- a/samples/client/petstore/cpp-restsdk/api/PetApi.cpp +++ b/samples/client/petstore/cpp-restsdk/api/PetApi.cpp @@ -45,72 +45,72 @@ pplx::task PetApi::addPet(std::shared_ptr pet) } - std::shared_ptr apiConfiguration( m_ApiClient->getConfiguration() ); - utility::string_t path = utility::conversions::to_string_t("/pet"); + std::shared_ptr localVarApiConfiguration( m_ApiClient->getConfiguration() ); + utility::string_t localVarPath = utility::conversions::to_string_t("/pet"); - std::map queryParams; - std::map headerParams( apiConfiguration->getDefaultHeaders() ); - std::map formParams; - std::map> fileParams; + std::map localVarQueryParams; + std::map localVarHeaderParams( localVarApiConfiguration->getDefaultHeaders() ); + std::map localVarFormParams; + std::map> localVarFileParams; - std::unordered_set responseHttpContentTypes; + std::unordered_set localVarResponseHttpContentTypes; - utility::string_t responseHttpContentType; + utility::string_t localVarResponseHttpContentType; // use JSON if possible - if ( responseHttpContentTypes.size() == 0 ) + if ( localVarResponseHttpContentTypes.size() == 0 ) { - responseHttpContentType = utility::conversions::to_string_t("application/json"); + localVarResponseHttpContentType = utility::conversions::to_string_t("application/json"); } // JSON - else if ( responseHttpContentTypes.find(utility::conversions::to_string_t("application/json")) != responseHttpContentTypes.end() ) + else if ( localVarResponseHttpContentTypes.find(utility::conversions::to_string_t("application/json")) != localVarResponseHttpContentTypes.end() ) { - responseHttpContentType = utility::conversions::to_string_t("application/json"); + localVarResponseHttpContentType = utility::conversions::to_string_t("application/json"); } // multipart formdata - else if( responseHttpContentTypes.find(utility::conversions::to_string_t("multipart/form-data")) != responseHttpContentTypes.end() ) + else if( localVarResponseHttpContentTypes.find(utility::conversions::to_string_t("multipart/form-data")) != localVarResponseHttpContentTypes.end() ) { - responseHttpContentType = utility::conversions::to_string_t("multipart/form-data"); + localVarResponseHttpContentType = utility::conversions::to_string_t("multipart/form-data"); } else { throw ApiException(400, utility::conversions::to_string_t("PetApi->addPet does not produce any supported media type")); } - headerParams[utility::conversions::to_string_t("Accept")] = responseHttpContentType; + localVarHeaderParams[utility::conversions::to_string_t("Accept")] = localVarResponseHttpContentType; - std::unordered_set consumeHttpContentTypes; - consumeHttpContentTypes.insert( utility::conversions::to_string_t("application/json") ); - consumeHttpContentTypes.insert( utility::conversions::to_string_t("application/xml") ); + std::unordered_set localVarConsumeHttpContentTypes; + localVarConsumeHttpContentTypes.insert( utility::conversions::to_string_t("application/json") ); + localVarConsumeHttpContentTypes.insert( utility::conversions::to_string_t("application/xml") ); - std::shared_ptr httpBody; - utility::string_t requestHttpContentType; + std::shared_ptr localVarHttpBody; + utility::string_t localVarRequestHttpContentType; // use JSON if possible - if ( consumeHttpContentTypes.size() == 0 || consumeHttpContentTypes.find(utility::conversions::to_string_t("application/json")) != consumeHttpContentTypes.end() ) + if ( localVarConsumeHttpContentTypes.size() == 0 || localVarConsumeHttpContentTypes.find(utility::conversions::to_string_t("application/json")) != localVarConsumeHttpContentTypes.end() ) { - requestHttpContentType = utility::conversions::to_string_t("application/json"); - web::json::value json; + localVarRequestHttpContentType = utility::conversions::to_string_t("application/json"); + web::json::value localVarJson; - json = ModelBase::toJson(pet); + localVarJson = ModelBase::toJson(pet); - httpBody = std::shared_ptr( new JsonBody( json ) ); + localVarHttpBody = std::shared_ptr( new JsonBody( localVarJson ) ); } // multipart formdata - else if( consumeHttpContentTypes.find(utility::conversions::to_string_t("multipart/form-data")) != consumeHttpContentTypes.end() ) + else if( localVarConsumeHttpContentTypes.find(utility::conversions::to_string_t("multipart/form-data")) != localVarConsumeHttpContentTypes.end() ) { - requestHttpContentType = utility::conversions::to_string_t("multipart/form-data"); - std::shared_ptr multipart(new MultipartFormData); + localVarRequestHttpContentType = utility::conversions::to_string_t("multipart/form-data"); + std::shared_ptr localVarMultipart(new MultipartFormData); if(pet.get()) { - pet->toMultipart(multipart, utility::conversions::to_string_t("pet")); + pet->toMultipart(localVarMultipart, utility::conversions::to_string_t("pet")); } - httpBody = multipart; - requestHttpContentType += utility::conversions::to_string_t("; boundary=") + multipart->getBoundary(); + localVarHttpBody = localVarMultipart; + localVarRequestHttpContentType += utility::conversions::to_string_t("; boundary=") + localVarMultipart->getBoundary(); } else { @@ -120,36 +120,36 @@ pplx::task PetApi::addPet(std::shared_ptr pet) // authentication (petstore_auth) required // oauth2 authentication is added automatically as part of the http_client_config - return m_ApiClient->callApi(path, utility::conversions::to_string_t("POST"), queryParams, httpBody, headerParams, formParams, fileParams, requestHttpContentType) - .then([=](web::http::http_response response) + return m_ApiClient->callApi(localVarPath, utility::conversions::to_string_t("POST"), localVarQueryParams, localVarHttpBody, localVarHeaderParams, localVarFormParams, localVarFileParams, localVarRequestHttpContentType) + .then([=](web::http::http_response localVarResponse) { // 1xx - informational : OK // 2xx - successful : OK // 3xx - redirection : OK // 4xx - client error : not OK // 5xx - client error : not OK - if (response.status_code() >= 400) + if (localVarResponse.status_code() >= 400) { - throw ApiException(response.status_code() - , utility::conversions::to_string_t("error calling addPet: ") + response.reason_phrase() - , std::make_shared(response.extract_utf8string(true).get())); + throw ApiException(localVarResponse.status_code() + , utility::conversions::to_string_t("error calling addPet: ") + localVarResponse.reason_phrase() + , std::make_shared(localVarResponse.extract_utf8string(true).get())); } // check response content type - if(response.headers().has(utility::conversions::to_string_t("Content-Type"))) + if(localVarResponse.headers().has(utility::conversions::to_string_t("Content-Type"))) { - utility::string_t contentType = response.headers()[utility::conversions::to_string_t("Content-Type")]; - if( contentType.find(responseHttpContentType) == std::string::npos ) + utility::string_t localVarContentType = localVarResponse.headers()[utility::conversions::to_string_t("Content-Type")]; + if( localVarContentType.find(localVarResponseHttpContentType) == std::string::npos ) { throw ApiException(500 - , utility::conversions::to_string_t("error calling addPet: unexpected response type: ") + contentType - , std::make_shared(response.extract_utf8string(true).get())); + , utility::conversions::to_string_t("error calling addPet: unexpected response type: ") + localVarContentType + , std::make_shared(localVarResponse.extract_utf8string(true).get())); } } - return response.extract_string(); + return localVarResponse.extract_string(); }) - .then([=](utility::string_t response) + .then([=](utility::string_t localVarResponse) { return void(); }); @@ -158,60 +158,60 @@ pplx::task PetApi::deletePet(int64_t petId, boost::optional apiConfiguration( m_ApiClient->getConfiguration() ); - utility::string_t path = utility::conversions::to_string_t("/pet/{petId}"); - boost::replace_all(path, utility::conversions::to_string_t("{") + utility::conversions::to_string_t("petId") + utility::conversions::to_string_t("}"), ApiClient::parameterToString(petId)); + std::shared_ptr localVarApiConfiguration( m_ApiClient->getConfiguration() ); + utility::string_t localVarPath = utility::conversions::to_string_t("/pet/{petId}"); + boost::replace_all(localVarPath, utility::conversions::to_string_t("{") + utility::conversions::to_string_t("petId") + utility::conversions::to_string_t("}"), ApiClient::parameterToString(petId)); - std::map queryParams; - std::map headerParams( apiConfiguration->getDefaultHeaders() ); - std::map formParams; - std::map> fileParams; + std::map localVarQueryParams; + std::map localVarHeaderParams( localVarApiConfiguration->getDefaultHeaders() ); + std::map localVarFormParams; + std::map> localVarFileParams; - std::unordered_set responseHttpContentTypes; + std::unordered_set localVarResponseHttpContentTypes; - utility::string_t responseHttpContentType; + utility::string_t localVarResponseHttpContentType; // use JSON if possible - if ( responseHttpContentTypes.size() == 0 ) + if ( localVarResponseHttpContentTypes.size() == 0 ) { - responseHttpContentType = utility::conversions::to_string_t("application/json"); + localVarResponseHttpContentType = utility::conversions::to_string_t("application/json"); } // JSON - else if ( responseHttpContentTypes.find(utility::conversions::to_string_t("application/json")) != responseHttpContentTypes.end() ) + else if ( localVarResponseHttpContentTypes.find(utility::conversions::to_string_t("application/json")) != localVarResponseHttpContentTypes.end() ) { - responseHttpContentType = utility::conversions::to_string_t("application/json"); + localVarResponseHttpContentType = utility::conversions::to_string_t("application/json"); } // multipart formdata - else if( responseHttpContentTypes.find(utility::conversions::to_string_t("multipart/form-data")) != responseHttpContentTypes.end() ) + else if( localVarResponseHttpContentTypes.find(utility::conversions::to_string_t("multipart/form-data")) != localVarResponseHttpContentTypes.end() ) { - responseHttpContentType = utility::conversions::to_string_t("multipart/form-data"); + localVarResponseHttpContentType = utility::conversions::to_string_t("multipart/form-data"); } else { throw ApiException(400, utility::conversions::to_string_t("PetApi->deletePet does not produce any supported media type")); } - headerParams[utility::conversions::to_string_t("Accept")] = responseHttpContentType; + localVarHeaderParams[utility::conversions::to_string_t("Accept")] = localVarResponseHttpContentType; - std::unordered_set consumeHttpContentTypes; + std::unordered_set localVarConsumeHttpContentTypes; if (apiKey) { - headerParams[utility::conversions::to_string_t("api_key")] = ApiClient::parameterToString(*apiKey); + localVarHeaderParams[utility::conversions::to_string_t("api_key")] = ApiClient::parameterToString(*apiKey); } - std::shared_ptr httpBody; - utility::string_t requestHttpContentType; + std::shared_ptr localVarHttpBody; + utility::string_t localVarRequestHttpContentType; // use JSON if possible - if ( consumeHttpContentTypes.size() == 0 || consumeHttpContentTypes.find(utility::conversions::to_string_t("application/json")) != consumeHttpContentTypes.end() ) + if ( localVarConsumeHttpContentTypes.size() == 0 || localVarConsumeHttpContentTypes.find(utility::conversions::to_string_t("application/json")) != localVarConsumeHttpContentTypes.end() ) { - requestHttpContentType = utility::conversions::to_string_t("application/json"); + localVarRequestHttpContentType = utility::conversions::to_string_t("application/json"); } // multipart formdata - else if( consumeHttpContentTypes.find(utility::conversions::to_string_t("multipart/form-data")) != consumeHttpContentTypes.end() ) + else if( localVarConsumeHttpContentTypes.find(utility::conversions::to_string_t("multipart/form-data")) != localVarConsumeHttpContentTypes.end() ) { - requestHttpContentType = utility::conversions::to_string_t("multipart/form-data"); + localVarRequestHttpContentType = utility::conversions::to_string_t("multipart/form-data"); } else { @@ -221,36 +221,36 @@ pplx::task PetApi::deletePet(int64_t petId, boost::optionalcallApi(path, utility::conversions::to_string_t("DELETE"), queryParams, httpBody, headerParams, formParams, fileParams, requestHttpContentType) - .then([=](web::http::http_response response) + return m_ApiClient->callApi(localVarPath, utility::conversions::to_string_t("DELETE"), localVarQueryParams, localVarHttpBody, localVarHeaderParams, localVarFormParams, localVarFileParams, localVarRequestHttpContentType) + .then([=](web::http::http_response localVarResponse) { // 1xx - informational : OK // 2xx - successful : OK // 3xx - redirection : OK // 4xx - client error : not OK // 5xx - client error : not OK - if (response.status_code() >= 400) + if (localVarResponse.status_code() >= 400) { - throw ApiException(response.status_code() - , utility::conversions::to_string_t("error calling deletePet: ") + response.reason_phrase() - , std::make_shared(response.extract_utf8string(true).get())); + throw ApiException(localVarResponse.status_code() + , utility::conversions::to_string_t("error calling deletePet: ") + localVarResponse.reason_phrase() + , std::make_shared(localVarResponse.extract_utf8string(true).get())); } // check response content type - if(response.headers().has(utility::conversions::to_string_t("Content-Type"))) + if(localVarResponse.headers().has(utility::conversions::to_string_t("Content-Type"))) { - utility::string_t contentType = response.headers()[utility::conversions::to_string_t("Content-Type")]; - if( contentType.find(responseHttpContentType) == std::string::npos ) + utility::string_t localVarContentType = localVarResponse.headers()[utility::conversions::to_string_t("Content-Type")]; + if( localVarContentType.find(localVarResponseHttpContentType) == std::string::npos ) { throw ApiException(500 - , utility::conversions::to_string_t("error calling deletePet: unexpected response type: ") + contentType - , std::make_shared(response.extract_utf8string(true).get())); + , utility::conversions::to_string_t("error calling deletePet: unexpected response type: ") + localVarContentType + , std::make_shared(localVarResponse.extract_utf8string(true).get())); } } - return response.extract_string(); + return localVarResponse.extract_string(); }) - .then([=](utility::string_t response) + .then([=](utility::string_t localVarResponse) { return void(); }); @@ -259,60 +259,60 @@ pplx::task>> PetApi::findPetsByStatus(std::vect { - std::shared_ptr apiConfiguration( m_ApiClient->getConfiguration() ); - utility::string_t path = utility::conversions::to_string_t("/pet/findByStatus"); + std::shared_ptr localVarApiConfiguration( m_ApiClient->getConfiguration() ); + utility::string_t localVarPath = utility::conversions::to_string_t("/pet/findByStatus"); - std::map queryParams; - std::map headerParams( apiConfiguration->getDefaultHeaders() ); - std::map formParams; - std::map> fileParams; + std::map localVarQueryParams; + std::map localVarHeaderParams( localVarApiConfiguration->getDefaultHeaders() ); + std::map localVarFormParams; + std::map> localVarFileParams; - std::unordered_set responseHttpContentTypes; - responseHttpContentTypes.insert( utility::conversions::to_string_t("application/xml") ); - responseHttpContentTypes.insert( utility::conversions::to_string_t("application/json") ); + std::unordered_set localVarResponseHttpContentTypes; + localVarResponseHttpContentTypes.insert( utility::conversions::to_string_t("application/xml") ); + localVarResponseHttpContentTypes.insert( utility::conversions::to_string_t("application/json") ); - utility::string_t responseHttpContentType; + utility::string_t localVarResponseHttpContentType; // use JSON if possible - if ( responseHttpContentTypes.size() == 0 ) + if ( localVarResponseHttpContentTypes.size() == 0 ) { - responseHttpContentType = utility::conversions::to_string_t("application/json"); + localVarResponseHttpContentType = utility::conversions::to_string_t("application/json"); } // JSON - else if ( responseHttpContentTypes.find(utility::conversions::to_string_t("application/json")) != responseHttpContentTypes.end() ) + else if ( localVarResponseHttpContentTypes.find(utility::conversions::to_string_t("application/json")) != localVarResponseHttpContentTypes.end() ) { - responseHttpContentType = utility::conversions::to_string_t("application/json"); + localVarResponseHttpContentType = utility::conversions::to_string_t("application/json"); } // multipart formdata - else if( responseHttpContentTypes.find(utility::conversions::to_string_t("multipart/form-data")) != responseHttpContentTypes.end() ) + else if( localVarResponseHttpContentTypes.find(utility::conversions::to_string_t("multipart/form-data")) != localVarResponseHttpContentTypes.end() ) { - responseHttpContentType = utility::conversions::to_string_t("multipart/form-data"); + localVarResponseHttpContentType = utility::conversions::to_string_t("multipart/form-data"); } else { throw ApiException(400, utility::conversions::to_string_t("PetApi->findPetsByStatus does not produce any supported media type")); } - headerParams[utility::conversions::to_string_t("Accept")] = responseHttpContentType; + localVarHeaderParams[utility::conversions::to_string_t("Accept")] = localVarResponseHttpContentType; - std::unordered_set consumeHttpContentTypes; + std::unordered_set localVarConsumeHttpContentTypes; { - queryParams[utility::conversions::to_string_t("status")] = ApiClient::parameterToString(status); + localVarQueryParams[utility::conversions::to_string_t("status")] = ApiClient::parameterToString(status); } - std::shared_ptr httpBody; - utility::string_t requestHttpContentType; + std::shared_ptr localVarHttpBody; + utility::string_t localVarRequestHttpContentType; // use JSON if possible - if ( consumeHttpContentTypes.size() == 0 || consumeHttpContentTypes.find(utility::conversions::to_string_t("application/json")) != consumeHttpContentTypes.end() ) + if ( localVarConsumeHttpContentTypes.size() == 0 || localVarConsumeHttpContentTypes.find(utility::conversions::to_string_t("application/json")) != localVarConsumeHttpContentTypes.end() ) { - requestHttpContentType = utility::conversions::to_string_t("application/json"); + localVarRequestHttpContentType = utility::conversions::to_string_t("application/json"); } // multipart formdata - else if( consumeHttpContentTypes.find(utility::conversions::to_string_t("multipart/form-data")) != consumeHttpContentTypes.end() ) + else if( localVarConsumeHttpContentTypes.find(utility::conversions::to_string_t("multipart/form-data")) != localVarConsumeHttpContentTypes.end() ) { - requestHttpContentType = utility::conversions::to_string_t("multipart/form-data"); + localVarRequestHttpContentType = utility::conversions::to_string_t("multipart/form-data"); } else { @@ -322,53 +322,53 @@ pplx::task>> PetApi::findPetsByStatus(std::vect // authentication (petstore_auth) required // oauth2 authentication is added automatically as part of the http_client_config - return m_ApiClient->callApi(path, utility::conversions::to_string_t("GET"), queryParams, httpBody, headerParams, formParams, fileParams, requestHttpContentType) - .then([=](web::http::http_response response) + return m_ApiClient->callApi(localVarPath, utility::conversions::to_string_t("GET"), localVarQueryParams, localVarHttpBody, localVarHeaderParams, localVarFormParams, localVarFileParams, localVarRequestHttpContentType) + .then([=](web::http::http_response localVarResponse) { // 1xx - informational : OK // 2xx - successful : OK // 3xx - redirection : OK // 4xx - client error : not OK // 5xx - client error : not OK - if (response.status_code() >= 400) + if (localVarResponse.status_code() >= 400) { - throw ApiException(response.status_code() - , utility::conversions::to_string_t("error calling findPetsByStatus: ") + response.reason_phrase() - , std::make_shared(response.extract_utf8string(true).get())); + throw ApiException(localVarResponse.status_code() + , utility::conversions::to_string_t("error calling findPetsByStatus: ") + localVarResponse.reason_phrase() + , std::make_shared(localVarResponse.extract_utf8string(true).get())); } // check response content type - if(response.headers().has(utility::conversions::to_string_t("Content-Type"))) + if(localVarResponse.headers().has(utility::conversions::to_string_t("Content-Type"))) { - utility::string_t contentType = response.headers()[utility::conversions::to_string_t("Content-Type")]; - if( contentType.find(responseHttpContentType) == std::string::npos ) + utility::string_t localVarContentType = localVarResponse.headers()[utility::conversions::to_string_t("Content-Type")]; + if( localVarContentType.find(localVarResponseHttpContentType) == std::string::npos ) { throw ApiException(500 - , utility::conversions::to_string_t("error calling findPetsByStatus: unexpected response type: ") + contentType - , std::make_shared(response.extract_utf8string(true).get())); + , utility::conversions::to_string_t("error calling findPetsByStatus: unexpected response type: ") + localVarContentType + , std::make_shared(localVarResponse.extract_utf8string(true).get())); } } - return response.extract_string(); + return localVarResponse.extract_string(); }) - .then([=](utility::string_t response) + .then([=](utility::string_t localVarResponse) { - std::vector> result; + std::vector> localVarResult; - if(responseHttpContentType == utility::conversions::to_string_t("application/json")) + if(localVarResponseHttpContentType == utility::conversions::to_string_t("application/json")) { - web::json::value json = web::json::value::parse(response); + web::json::value localVarJson = web::json::value::parse(localVarResponse); - for( auto& item : json.as_array() ) + for( auto& localVarItem : localVarJson.as_array() ) { - std::shared_ptr itemObj(new Pet()); - itemObj->fromJson(item); - result.push_back(itemObj); + std::shared_ptr localVarItemObj(new Pet()); + localVarItemObj->fromJson(localVarItem); + localVarResult.push_back(localVarItemObj); } } - // else if(responseHttpContentType == utility::conversions::to_string_t("multipart/form-data")) + // else if(localVarResponseHttpContentType == utility::conversions::to_string_t("multipart/form-data")) // { // TODO multipart response parsing // } @@ -378,67 +378,67 @@ pplx::task>> PetApi::findPetsByStatus(std::vect , utility::conversions::to_string_t("error calling findPetsByStatus: unsupported response type")); } - return result; + return localVarResult; }); } pplx::task>> PetApi::findPetsByTags(std::vector tags) { - std::shared_ptr apiConfiguration( m_ApiClient->getConfiguration() ); - utility::string_t path = utility::conversions::to_string_t("/pet/findByTags"); + std::shared_ptr localVarApiConfiguration( m_ApiClient->getConfiguration() ); + utility::string_t localVarPath = utility::conversions::to_string_t("/pet/findByTags"); - std::map queryParams; - std::map headerParams( apiConfiguration->getDefaultHeaders() ); - std::map formParams; - std::map> fileParams; + std::map localVarQueryParams; + std::map localVarHeaderParams( localVarApiConfiguration->getDefaultHeaders() ); + std::map localVarFormParams; + std::map> localVarFileParams; - std::unordered_set responseHttpContentTypes; - responseHttpContentTypes.insert( utility::conversions::to_string_t("application/xml") ); - responseHttpContentTypes.insert( utility::conversions::to_string_t("application/json") ); + std::unordered_set localVarResponseHttpContentTypes; + localVarResponseHttpContentTypes.insert( utility::conversions::to_string_t("application/xml") ); + localVarResponseHttpContentTypes.insert( utility::conversions::to_string_t("application/json") ); - utility::string_t responseHttpContentType; + utility::string_t localVarResponseHttpContentType; // use JSON if possible - if ( responseHttpContentTypes.size() == 0 ) + if ( localVarResponseHttpContentTypes.size() == 0 ) { - responseHttpContentType = utility::conversions::to_string_t("application/json"); + localVarResponseHttpContentType = utility::conversions::to_string_t("application/json"); } // JSON - else if ( responseHttpContentTypes.find(utility::conversions::to_string_t("application/json")) != responseHttpContentTypes.end() ) + else if ( localVarResponseHttpContentTypes.find(utility::conversions::to_string_t("application/json")) != localVarResponseHttpContentTypes.end() ) { - responseHttpContentType = utility::conversions::to_string_t("application/json"); + localVarResponseHttpContentType = utility::conversions::to_string_t("application/json"); } // multipart formdata - else if( responseHttpContentTypes.find(utility::conversions::to_string_t("multipart/form-data")) != responseHttpContentTypes.end() ) + else if( localVarResponseHttpContentTypes.find(utility::conversions::to_string_t("multipart/form-data")) != localVarResponseHttpContentTypes.end() ) { - responseHttpContentType = utility::conversions::to_string_t("multipart/form-data"); + localVarResponseHttpContentType = utility::conversions::to_string_t("multipart/form-data"); } else { throw ApiException(400, utility::conversions::to_string_t("PetApi->findPetsByTags does not produce any supported media type")); } - headerParams[utility::conversions::to_string_t("Accept")] = responseHttpContentType; + localVarHeaderParams[utility::conversions::to_string_t("Accept")] = localVarResponseHttpContentType; - std::unordered_set consumeHttpContentTypes; + std::unordered_set localVarConsumeHttpContentTypes; { - queryParams[utility::conversions::to_string_t("tags")] = ApiClient::parameterToString(tags); + localVarQueryParams[utility::conversions::to_string_t("tags")] = ApiClient::parameterToString(tags); } - std::shared_ptr httpBody; - utility::string_t requestHttpContentType; + std::shared_ptr localVarHttpBody; + utility::string_t localVarRequestHttpContentType; // use JSON if possible - if ( consumeHttpContentTypes.size() == 0 || consumeHttpContentTypes.find(utility::conversions::to_string_t("application/json")) != consumeHttpContentTypes.end() ) + if ( localVarConsumeHttpContentTypes.size() == 0 || localVarConsumeHttpContentTypes.find(utility::conversions::to_string_t("application/json")) != localVarConsumeHttpContentTypes.end() ) { - requestHttpContentType = utility::conversions::to_string_t("application/json"); + localVarRequestHttpContentType = utility::conversions::to_string_t("application/json"); } // multipart formdata - else if( consumeHttpContentTypes.find(utility::conversions::to_string_t("multipart/form-data")) != consumeHttpContentTypes.end() ) + else if( localVarConsumeHttpContentTypes.find(utility::conversions::to_string_t("multipart/form-data")) != localVarConsumeHttpContentTypes.end() ) { - requestHttpContentType = utility::conversions::to_string_t("multipart/form-data"); + localVarRequestHttpContentType = utility::conversions::to_string_t("multipart/form-data"); } else { @@ -448,53 +448,53 @@ pplx::task>> PetApi::findPetsByTags(std::vector // authentication (petstore_auth) required // oauth2 authentication is added automatically as part of the http_client_config - return m_ApiClient->callApi(path, utility::conversions::to_string_t("GET"), queryParams, httpBody, headerParams, formParams, fileParams, requestHttpContentType) - .then([=](web::http::http_response response) + return m_ApiClient->callApi(localVarPath, utility::conversions::to_string_t("GET"), localVarQueryParams, localVarHttpBody, localVarHeaderParams, localVarFormParams, localVarFileParams, localVarRequestHttpContentType) + .then([=](web::http::http_response localVarResponse) { // 1xx - informational : OK // 2xx - successful : OK // 3xx - redirection : OK // 4xx - client error : not OK // 5xx - client error : not OK - if (response.status_code() >= 400) + if (localVarResponse.status_code() >= 400) { - throw ApiException(response.status_code() - , utility::conversions::to_string_t("error calling findPetsByTags: ") + response.reason_phrase() - , std::make_shared(response.extract_utf8string(true).get())); + throw ApiException(localVarResponse.status_code() + , utility::conversions::to_string_t("error calling findPetsByTags: ") + localVarResponse.reason_phrase() + , std::make_shared(localVarResponse.extract_utf8string(true).get())); } // check response content type - if(response.headers().has(utility::conversions::to_string_t("Content-Type"))) + if(localVarResponse.headers().has(utility::conversions::to_string_t("Content-Type"))) { - utility::string_t contentType = response.headers()[utility::conversions::to_string_t("Content-Type")]; - if( contentType.find(responseHttpContentType) == std::string::npos ) + utility::string_t localVarContentType = localVarResponse.headers()[utility::conversions::to_string_t("Content-Type")]; + if( localVarContentType.find(localVarResponseHttpContentType) == std::string::npos ) { throw ApiException(500 - , utility::conversions::to_string_t("error calling findPetsByTags: unexpected response type: ") + contentType - , std::make_shared(response.extract_utf8string(true).get())); + , utility::conversions::to_string_t("error calling findPetsByTags: unexpected response type: ") + localVarContentType + , std::make_shared(localVarResponse.extract_utf8string(true).get())); } } - return response.extract_string(); + return localVarResponse.extract_string(); }) - .then([=](utility::string_t response) + .then([=](utility::string_t localVarResponse) { - std::vector> result; + std::vector> localVarResult; - if(responseHttpContentType == utility::conversions::to_string_t("application/json")) + if(localVarResponseHttpContentType == utility::conversions::to_string_t("application/json")) { - web::json::value json = web::json::value::parse(response); + web::json::value localVarJson = web::json::value::parse(localVarResponse); - for( auto& item : json.as_array() ) + for( auto& localVarItem : localVarJson.as_array() ) { - std::shared_ptr itemObj(new Pet()); - itemObj->fromJson(item); - result.push_back(itemObj); + std::shared_ptr localVarItemObj(new Pet()); + localVarItemObj->fromJson(localVarItem); + localVarResult.push_back(localVarItemObj); } } - // else if(responseHttpContentType == utility::conversions::to_string_t("multipart/form-data")) + // else if(localVarResponseHttpContentType == utility::conversions::to_string_t("multipart/form-data")) // { // TODO multipart response parsing // } @@ -504,65 +504,65 @@ pplx::task>> PetApi::findPetsByTags(std::vector , utility::conversions::to_string_t("error calling findPetsByTags: unsupported response type")); } - return result; + return localVarResult; }); } pplx::task> PetApi::getPetById(int64_t petId) { - std::shared_ptr apiConfiguration( m_ApiClient->getConfiguration() ); - utility::string_t path = utility::conversions::to_string_t("/pet/{petId}"); - boost::replace_all(path, utility::conversions::to_string_t("{") + utility::conversions::to_string_t("petId") + utility::conversions::to_string_t("}"), ApiClient::parameterToString(petId)); + std::shared_ptr localVarApiConfiguration( m_ApiClient->getConfiguration() ); + utility::string_t localVarPath = utility::conversions::to_string_t("/pet/{petId}"); + boost::replace_all(localVarPath, utility::conversions::to_string_t("{") + utility::conversions::to_string_t("petId") + utility::conversions::to_string_t("}"), ApiClient::parameterToString(petId)); - std::map queryParams; - std::map headerParams( apiConfiguration->getDefaultHeaders() ); - std::map formParams; - std::map> fileParams; + std::map localVarQueryParams; + std::map localVarHeaderParams( localVarApiConfiguration->getDefaultHeaders() ); + std::map localVarFormParams; + std::map> localVarFileParams; - std::unordered_set responseHttpContentTypes; - responseHttpContentTypes.insert( utility::conversions::to_string_t("application/xml") ); - responseHttpContentTypes.insert( utility::conversions::to_string_t("application/json") ); + std::unordered_set localVarResponseHttpContentTypes; + localVarResponseHttpContentTypes.insert( utility::conversions::to_string_t("application/xml") ); + localVarResponseHttpContentTypes.insert( utility::conversions::to_string_t("application/json") ); - utility::string_t responseHttpContentType; + utility::string_t localVarResponseHttpContentType; // use JSON if possible - if ( responseHttpContentTypes.size() == 0 ) + if ( localVarResponseHttpContentTypes.size() == 0 ) { - responseHttpContentType = utility::conversions::to_string_t("application/json"); + localVarResponseHttpContentType = utility::conversions::to_string_t("application/json"); } // JSON - else if ( responseHttpContentTypes.find(utility::conversions::to_string_t("application/json")) != responseHttpContentTypes.end() ) + else if ( localVarResponseHttpContentTypes.find(utility::conversions::to_string_t("application/json")) != localVarResponseHttpContentTypes.end() ) { - responseHttpContentType = utility::conversions::to_string_t("application/json"); + localVarResponseHttpContentType = utility::conversions::to_string_t("application/json"); } // multipart formdata - else if( responseHttpContentTypes.find(utility::conversions::to_string_t("multipart/form-data")) != responseHttpContentTypes.end() ) + else if( localVarResponseHttpContentTypes.find(utility::conversions::to_string_t("multipart/form-data")) != localVarResponseHttpContentTypes.end() ) { - responseHttpContentType = utility::conversions::to_string_t("multipart/form-data"); + localVarResponseHttpContentType = utility::conversions::to_string_t("multipart/form-data"); } else { throw ApiException(400, utility::conversions::to_string_t("PetApi->getPetById does not produce any supported media type")); } - headerParams[utility::conversions::to_string_t("Accept")] = responseHttpContentType; + localVarHeaderParams[utility::conversions::to_string_t("Accept")] = localVarResponseHttpContentType; - std::unordered_set consumeHttpContentTypes; + std::unordered_set localVarConsumeHttpContentTypes; - std::shared_ptr httpBody; - utility::string_t requestHttpContentType; + std::shared_ptr localVarHttpBody; + utility::string_t localVarRequestHttpContentType; // use JSON if possible - if ( consumeHttpContentTypes.size() == 0 || consumeHttpContentTypes.find(utility::conversions::to_string_t("application/json")) != consumeHttpContentTypes.end() ) + if ( localVarConsumeHttpContentTypes.size() == 0 || localVarConsumeHttpContentTypes.find(utility::conversions::to_string_t("application/json")) != localVarConsumeHttpContentTypes.end() ) { - requestHttpContentType = utility::conversions::to_string_t("application/json"); + localVarRequestHttpContentType = utility::conversions::to_string_t("application/json"); } // multipart formdata - else if( consumeHttpContentTypes.find(utility::conversions::to_string_t("multipart/form-data")) != consumeHttpContentTypes.end() ) + else if( localVarConsumeHttpContentTypes.find(utility::conversions::to_string_t("multipart/form-data")) != localVarConsumeHttpContentTypes.end() ) { - requestHttpContentType = utility::conversions::to_string_t("multipart/form-data"); + localVarRequestHttpContentType = utility::conversions::to_string_t("multipart/form-data"); } else { @@ -571,53 +571,53 @@ pplx::task> PetApi::getPetById(int64_t petId) // authentication (api_key) required { - utility::string_t apiKey = apiConfiguration->getApiKey(utility::conversions::to_string_t("api_key")); - if ( apiKey.size() > 0 ) + utility::string_t localVarApiKey = localVarApiConfiguration->getApiKey(utility::conversions::to_string_t("api_key")); + if ( localVarApiKey.size() > 0 ) { - headerParams[utility::conversions::to_string_t("api_key")] = apiKey; + localVarHeaderParams[utility::conversions::to_string_t("api_key")] = localVarApiKey; } } - return m_ApiClient->callApi(path, utility::conversions::to_string_t("GET"), queryParams, httpBody, headerParams, formParams, fileParams, requestHttpContentType) - .then([=](web::http::http_response response) + return m_ApiClient->callApi(localVarPath, utility::conversions::to_string_t("GET"), localVarQueryParams, localVarHttpBody, localVarHeaderParams, localVarFormParams, localVarFileParams, localVarRequestHttpContentType) + .then([=](web::http::http_response localVarResponse) { // 1xx - informational : OK // 2xx - successful : OK // 3xx - redirection : OK // 4xx - client error : not OK // 5xx - client error : not OK - if (response.status_code() >= 400) + if (localVarResponse.status_code() >= 400) { - throw ApiException(response.status_code() - , utility::conversions::to_string_t("error calling getPetById: ") + response.reason_phrase() - , std::make_shared(response.extract_utf8string(true).get())); + throw ApiException(localVarResponse.status_code() + , utility::conversions::to_string_t("error calling getPetById: ") + localVarResponse.reason_phrase() + , std::make_shared(localVarResponse.extract_utf8string(true).get())); } // check response content type - if(response.headers().has(utility::conversions::to_string_t("Content-Type"))) + if(localVarResponse.headers().has(utility::conversions::to_string_t("Content-Type"))) { - utility::string_t contentType = response.headers()[utility::conversions::to_string_t("Content-Type")]; - if( contentType.find(responseHttpContentType) == std::string::npos ) + utility::string_t localVarContentType = localVarResponse.headers()[utility::conversions::to_string_t("Content-Type")]; + if( localVarContentType.find(localVarResponseHttpContentType) == std::string::npos ) { throw ApiException(500 - , utility::conversions::to_string_t("error calling getPetById: unexpected response type: ") + contentType - , std::make_shared(response.extract_utf8string(true).get())); + , utility::conversions::to_string_t("error calling getPetById: unexpected response type: ") + localVarContentType + , std::make_shared(localVarResponse.extract_utf8string(true).get())); } } - return response.extract_string(); + return localVarResponse.extract_string(); }) - .then([=](utility::string_t response) + .then([=](utility::string_t localVarResponse) { - std::shared_ptr result(new Pet()); + std::shared_ptr localVarResult(new Pet()); - if(responseHttpContentType == utility::conversions::to_string_t("application/json")) + if(localVarResponseHttpContentType == utility::conversions::to_string_t("application/json")) { - web::json::value json = web::json::value::parse(response); + web::json::value localVarJson = web::json::value::parse(localVarResponse); - result->fromJson(json); + localVarResult->fromJson(localVarJson); } - // else if(responseHttpContentType == utility::conversions::to_string_t("multipart/form-data")) + // else if(localVarResponseHttpContentType == utility::conversions::to_string_t("multipart/form-data")) // { // TODO multipart response parsing // } @@ -627,7 +627,7 @@ pplx::task> PetApi::getPetById(int64_t petId) , utility::conversions::to_string_t("error calling getPetById: unsupported response type")); } - return result; + return localVarResult; }); } pplx::task PetApi::updatePet(std::shared_ptr pet) @@ -640,72 +640,72 @@ pplx::task PetApi::updatePet(std::shared_ptr pet) } - std::shared_ptr apiConfiguration( m_ApiClient->getConfiguration() ); - utility::string_t path = utility::conversions::to_string_t("/pet"); + std::shared_ptr localVarApiConfiguration( m_ApiClient->getConfiguration() ); + utility::string_t localVarPath = utility::conversions::to_string_t("/pet"); - std::map queryParams; - std::map headerParams( apiConfiguration->getDefaultHeaders() ); - std::map formParams; - std::map> fileParams; + std::map localVarQueryParams; + std::map localVarHeaderParams( localVarApiConfiguration->getDefaultHeaders() ); + std::map localVarFormParams; + std::map> localVarFileParams; - std::unordered_set responseHttpContentTypes; + std::unordered_set localVarResponseHttpContentTypes; - utility::string_t responseHttpContentType; + utility::string_t localVarResponseHttpContentType; // use JSON if possible - if ( responseHttpContentTypes.size() == 0 ) + if ( localVarResponseHttpContentTypes.size() == 0 ) { - responseHttpContentType = utility::conversions::to_string_t("application/json"); + localVarResponseHttpContentType = utility::conversions::to_string_t("application/json"); } // JSON - else if ( responseHttpContentTypes.find(utility::conversions::to_string_t("application/json")) != responseHttpContentTypes.end() ) + else if ( localVarResponseHttpContentTypes.find(utility::conversions::to_string_t("application/json")) != localVarResponseHttpContentTypes.end() ) { - responseHttpContentType = utility::conversions::to_string_t("application/json"); + localVarResponseHttpContentType = utility::conversions::to_string_t("application/json"); } // multipart formdata - else if( responseHttpContentTypes.find(utility::conversions::to_string_t("multipart/form-data")) != responseHttpContentTypes.end() ) + else if( localVarResponseHttpContentTypes.find(utility::conversions::to_string_t("multipart/form-data")) != localVarResponseHttpContentTypes.end() ) { - responseHttpContentType = utility::conversions::to_string_t("multipart/form-data"); + localVarResponseHttpContentType = utility::conversions::to_string_t("multipart/form-data"); } else { throw ApiException(400, utility::conversions::to_string_t("PetApi->updatePet does not produce any supported media type")); } - headerParams[utility::conversions::to_string_t("Accept")] = responseHttpContentType; + localVarHeaderParams[utility::conversions::to_string_t("Accept")] = localVarResponseHttpContentType; - std::unordered_set consumeHttpContentTypes; - consumeHttpContentTypes.insert( utility::conversions::to_string_t("application/json") ); - consumeHttpContentTypes.insert( utility::conversions::to_string_t("application/xml") ); + std::unordered_set localVarConsumeHttpContentTypes; + localVarConsumeHttpContentTypes.insert( utility::conversions::to_string_t("application/json") ); + localVarConsumeHttpContentTypes.insert( utility::conversions::to_string_t("application/xml") ); - std::shared_ptr httpBody; - utility::string_t requestHttpContentType; + std::shared_ptr localVarHttpBody; + utility::string_t localVarRequestHttpContentType; // use JSON if possible - if ( consumeHttpContentTypes.size() == 0 || consumeHttpContentTypes.find(utility::conversions::to_string_t("application/json")) != consumeHttpContentTypes.end() ) + if ( localVarConsumeHttpContentTypes.size() == 0 || localVarConsumeHttpContentTypes.find(utility::conversions::to_string_t("application/json")) != localVarConsumeHttpContentTypes.end() ) { - requestHttpContentType = utility::conversions::to_string_t("application/json"); - web::json::value json; + localVarRequestHttpContentType = utility::conversions::to_string_t("application/json"); + web::json::value localVarJson; - json = ModelBase::toJson(pet); + localVarJson = ModelBase::toJson(pet); - httpBody = std::shared_ptr( new JsonBody( json ) ); + localVarHttpBody = std::shared_ptr( new JsonBody( localVarJson ) ); } // multipart formdata - else if( consumeHttpContentTypes.find(utility::conversions::to_string_t("multipart/form-data")) != consumeHttpContentTypes.end() ) + else if( localVarConsumeHttpContentTypes.find(utility::conversions::to_string_t("multipart/form-data")) != localVarConsumeHttpContentTypes.end() ) { - requestHttpContentType = utility::conversions::to_string_t("multipart/form-data"); - std::shared_ptr multipart(new MultipartFormData); + localVarRequestHttpContentType = utility::conversions::to_string_t("multipart/form-data"); + std::shared_ptr localVarMultipart(new MultipartFormData); if(pet.get()) { - pet->toMultipart(multipart, utility::conversions::to_string_t("pet")); + pet->toMultipart(localVarMultipart, utility::conversions::to_string_t("pet")); } - httpBody = multipart; - requestHttpContentType += utility::conversions::to_string_t("; boundary=") + multipart->getBoundary(); + localVarHttpBody = localVarMultipart; + localVarRequestHttpContentType += utility::conversions::to_string_t("; boundary=") + localVarMultipart->getBoundary(); } else { @@ -715,36 +715,36 @@ pplx::task PetApi::updatePet(std::shared_ptr pet) // authentication (petstore_auth) required // oauth2 authentication is added automatically as part of the http_client_config - return m_ApiClient->callApi(path, utility::conversions::to_string_t("PUT"), queryParams, httpBody, headerParams, formParams, fileParams, requestHttpContentType) - .then([=](web::http::http_response response) + return m_ApiClient->callApi(localVarPath, utility::conversions::to_string_t("PUT"), localVarQueryParams, localVarHttpBody, localVarHeaderParams, localVarFormParams, localVarFileParams, localVarRequestHttpContentType) + .then([=](web::http::http_response localVarResponse) { // 1xx - informational : OK // 2xx - successful : OK // 3xx - redirection : OK // 4xx - client error : not OK // 5xx - client error : not OK - if (response.status_code() >= 400) + if (localVarResponse.status_code() >= 400) { - throw ApiException(response.status_code() - , utility::conversions::to_string_t("error calling updatePet: ") + response.reason_phrase() - , std::make_shared(response.extract_utf8string(true).get())); + throw ApiException(localVarResponse.status_code() + , utility::conversions::to_string_t("error calling updatePet: ") + localVarResponse.reason_phrase() + , std::make_shared(localVarResponse.extract_utf8string(true).get())); } // check response content type - if(response.headers().has(utility::conversions::to_string_t("Content-Type"))) + if(localVarResponse.headers().has(utility::conversions::to_string_t("Content-Type"))) { - utility::string_t contentType = response.headers()[utility::conversions::to_string_t("Content-Type")]; - if( contentType.find(responseHttpContentType) == std::string::npos ) + utility::string_t localVarContentType = localVarResponse.headers()[utility::conversions::to_string_t("Content-Type")]; + if( localVarContentType.find(localVarResponseHttpContentType) == std::string::npos ) { throw ApiException(500 - , utility::conversions::to_string_t("error calling updatePet: unexpected response type: ") + contentType - , std::make_shared(response.extract_utf8string(true).get())); + , utility::conversions::to_string_t("error calling updatePet: unexpected response type: ") + localVarContentType + , std::make_shared(localVarResponse.extract_utf8string(true).get())); } } - return response.extract_string(); + return localVarResponse.extract_string(); }) - .then([=](utility::string_t response) + .then([=](utility::string_t localVarResponse) { return void(); }); @@ -753,65 +753,65 @@ pplx::task PetApi::updatePetWithForm(int64_t petId, boost::optional apiConfiguration( m_ApiClient->getConfiguration() ); - utility::string_t path = utility::conversions::to_string_t("/pet/{petId}"); - boost::replace_all(path, utility::conversions::to_string_t("{") + utility::conversions::to_string_t("petId") + utility::conversions::to_string_t("}"), ApiClient::parameterToString(petId)); + std::shared_ptr localVarApiConfiguration( m_ApiClient->getConfiguration() ); + utility::string_t localVarPath = utility::conversions::to_string_t("/pet/{petId}"); + boost::replace_all(localVarPath, utility::conversions::to_string_t("{") + utility::conversions::to_string_t("petId") + utility::conversions::to_string_t("}"), ApiClient::parameterToString(petId)); - std::map queryParams; - std::map headerParams( apiConfiguration->getDefaultHeaders() ); - std::map formParams; - std::map> fileParams; + std::map localVarQueryParams; + std::map localVarHeaderParams( localVarApiConfiguration->getDefaultHeaders() ); + std::map localVarFormParams; + std::map> localVarFileParams; - std::unordered_set responseHttpContentTypes; + std::unordered_set localVarResponseHttpContentTypes; - utility::string_t responseHttpContentType; + utility::string_t localVarResponseHttpContentType; // use JSON if possible - if ( responseHttpContentTypes.size() == 0 ) + if ( localVarResponseHttpContentTypes.size() == 0 ) { - responseHttpContentType = utility::conversions::to_string_t("application/json"); + localVarResponseHttpContentType = utility::conversions::to_string_t("application/json"); } // JSON - else if ( responseHttpContentTypes.find(utility::conversions::to_string_t("application/json")) != responseHttpContentTypes.end() ) + else if ( localVarResponseHttpContentTypes.find(utility::conversions::to_string_t("application/json")) != localVarResponseHttpContentTypes.end() ) { - responseHttpContentType = utility::conversions::to_string_t("application/json"); + localVarResponseHttpContentType = utility::conversions::to_string_t("application/json"); } // multipart formdata - else if( responseHttpContentTypes.find(utility::conversions::to_string_t("multipart/form-data")) != responseHttpContentTypes.end() ) + else if( localVarResponseHttpContentTypes.find(utility::conversions::to_string_t("multipart/form-data")) != localVarResponseHttpContentTypes.end() ) { - responseHttpContentType = utility::conversions::to_string_t("multipart/form-data"); + localVarResponseHttpContentType = utility::conversions::to_string_t("multipart/form-data"); } else { throw ApiException(400, utility::conversions::to_string_t("PetApi->updatePetWithForm does not produce any supported media type")); } - headerParams[utility::conversions::to_string_t("Accept")] = responseHttpContentType; + localVarHeaderParams[utility::conversions::to_string_t("Accept")] = localVarResponseHttpContentType; - std::unordered_set consumeHttpContentTypes; - consumeHttpContentTypes.insert( utility::conversions::to_string_t("application/x-www-form-urlencoded") ); + std::unordered_set localVarConsumeHttpContentTypes; + localVarConsumeHttpContentTypes.insert( utility::conversions::to_string_t("application/x-www-form-urlencoded") ); if (name) { - formParams[ utility::conversions::to_string_t("name") ] = ApiClient::parameterToString(*name); + localVarFormParams[ utility::conversions::to_string_t("name") ] = ApiClient::parameterToString(*name); } if (status) { - formParams[ utility::conversions::to_string_t("status") ] = ApiClient::parameterToString(*status); + localVarFormParams[ utility::conversions::to_string_t("status") ] = ApiClient::parameterToString(*status); } - std::shared_ptr httpBody; - utility::string_t requestHttpContentType; + std::shared_ptr localVarHttpBody; + utility::string_t localVarRequestHttpContentType; // use JSON if possible - if ( consumeHttpContentTypes.size() == 0 || consumeHttpContentTypes.find(utility::conversions::to_string_t("application/json")) != consumeHttpContentTypes.end() ) + if ( localVarConsumeHttpContentTypes.size() == 0 || localVarConsumeHttpContentTypes.find(utility::conversions::to_string_t("application/json")) != localVarConsumeHttpContentTypes.end() ) { - requestHttpContentType = utility::conversions::to_string_t("application/json"); + localVarRequestHttpContentType = utility::conversions::to_string_t("application/json"); } // multipart formdata - else if( consumeHttpContentTypes.find(utility::conversions::to_string_t("multipart/form-data")) != consumeHttpContentTypes.end() ) + else if( localVarConsumeHttpContentTypes.find(utility::conversions::to_string_t("multipart/form-data")) != localVarConsumeHttpContentTypes.end() ) { - requestHttpContentType = utility::conversions::to_string_t("multipart/form-data"); + localVarRequestHttpContentType = utility::conversions::to_string_t("multipart/form-data"); } else { @@ -821,36 +821,36 @@ pplx::task PetApi::updatePetWithForm(int64_t petId, boost::optionalcallApi(path, utility::conversions::to_string_t("POST"), queryParams, httpBody, headerParams, formParams, fileParams, requestHttpContentType) - .then([=](web::http::http_response response) + return m_ApiClient->callApi(localVarPath, utility::conversions::to_string_t("POST"), localVarQueryParams, localVarHttpBody, localVarHeaderParams, localVarFormParams, localVarFileParams, localVarRequestHttpContentType) + .then([=](web::http::http_response localVarResponse) { // 1xx - informational : OK // 2xx - successful : OK // 3xx - redirection : OK // 4xx - client error : not OK // 5xx - client error : not OK - if (response.status_code() >= 400) + if (localVarResponse.status_code() >= 400) { - throw ApiException(response.status_code() - , utility::conversions::to_string_t("error calling updatePetWithForm: ") + response.reason_phrase() - , std::make_shared(response.extract_utf8string(true).get())); + throw ApiException(localVarResponse.status_code() + , utility::conversions::to_string_t("error calling updatePetWithForm: ") + localVarResponse.reason_phrase() + , std::make_shared(localVarResponse.extract_utf8string(true).get())); } // check response content type - if(response.headers().has(utility::conversions::to_string_t("Content-Type"))) + if(localVarResponse.headers().has(utility::conversions::to_string_t("Content-Type"))) { - utility::string_t contentType = response.headers()[utility::conversions::to_string_t("Content-Type")]; - if( contentType.find(responseHttpContentType) == std::string::npos ) + utility::string_t localVarContentType = localVarResponse.headers()[utility::conversions::to_string_t("Content-Type")]; + if( localVarContentType.find(localVarResponseHttpContentType) == std::string::npos ) { throw ApiException(500 - , utility::conversions::to_string_t("error calling updatePetWithForm: unexpected response type: ") + contentType - , std::make_shared(response.extract_utf8string(true).get())); + , utility::conversions::to_string_t("error calling updatePetWithForm: unexpected response type: ") + localVarContentType + , std::make_shared(localVarResponse.extract_utf8string(true).get())); } } - return response.extract_string(); + return localVarResponse.extract_string(); }) - .then([=](utility::string_t response) + .then([=](utility::string_t localVarResponse) { return void(); }); @@ -859,66 +859,66 @@ pplx::task> PetApi::uploadFile(int64_t petId, boost { - std::shared_ptr apiConfiguration( m_ApiClient->getConfiguration() ); - utility::string_t path = utility::conversions::to_string_t("/pet/{petId}/uploadImage"); - boost::replace_all(path, utility::conversions::to_string_t("{") + utility::conversions::to_string_t("petId") + utility::conversions::to_string_t("}"), ApiClient::parameterToString(petId)); + std::shared_ptr localVarApiConfiguration( m_ApiClient->getConfiguration() ); + utility::string_t localVarPath = utility::conversions::to_string_t("/pet/{petId}/uploadImage"); + boost::replace_all(localVarPath, utility::conversions::to_string_t("{") + utility::conversions::to_string_t("petId") + utility::conversions::to_string_t("}"), ApiClient::parameterToString(petId)); - std::map queryParams; - std::map headerParams( apiConfiguration->getDefaultHeaders() ); - std::map formParams; - std::map> fileParams; + std::map localVarQueryParams; + std::map localVarHeaderParams( localVarApiConfiguration->getDefaultHeaders() ); + std::map localVarFormParams; + std::map> localVarFileParams; - std::unordered_set responseHttpContentTypes; - responseHttpContentTypes.insert( utility::conversions::to_string_t("application/json") ); + std::unordered_set localVarResponseHttpContentTypes; + localVarResponseHttpContentTypes.insert( utility::conversions::to_string_t("application/json") ); - utility::string_t responseHttpContentType; + utility::string_t localVarResponseHttpContentType; // use JSON if possible - if ( responseHttpContentTypes.size() == 0 ) + if ( localVarResponseHttpContentTypes.size() == 0 ) { - responseHttpContentType = utility::conversions::to_string_t("application/json"); + localVarResponseHttpContentType = utility::conversions::to_string_t("application/json"); } // JSON - else if ( responseHttpContentTypes.find(utility::conversions::to_string_t("application/json")) != responseHttpContentTypes.end() ) + else if ( localVarResponseHttpContentTypes.find(utility::conversions::to_string_t("application/json")) != localVarResponseHttpContentTypes.end() ) { - responseHttpContentType = utility::conversions::to_string_t("application/json"); + localVarResponseHttpContentType = utility::conversions::to_string_t("application/json"); } // multipart formdata - else if( responseHttpContentTypes.find(utility::conversions::to_string_t("multipart/form-data")) != responseHttpContentTypes.end() ) + else if( localVarResponseHttpContentTypes.find(utility::conversions::to_string_t("multipart/form-data")) != localVarResponseHttpContentTypes.end() ) { - responseHttpContentType = utility::conversions::to_string_t("multipart/form-data"); + localVarResponseHttpContentType = utility::conversions::to_string_t("multipart/form-data"); } else { throw ApiException(400, utility::conversions::to_string_t("PetApi->uploadFile does not produce any supported media type")); } - headerParams[utility::conversions::to_string_t("Accept")] = responseHttpContentType; + localVarHeaderParams[utility::conversions::to_string_t("Accept")] = localVarResponseHttpContentType; - std::unordered_set consumeHttpContentTypes; - consumeHttpContentTypes.insert( utility::conversions::to_string_t("multipart/form-data") ); + std::unordered_set localVarConsumeHttpContentTypes; + localVarConsumeHttpContentTypes.insert( utility::conversions::to_string_t("multipart/form-data") ); if (additionalMetadata) { - formParams[ utility::conversions::to_string_t("additionalMetadata") ] = ApiClient::parameterToString(*additionalMetadata); + localVarFormParams[ utility::conversions::to_string_t("additionalMetadata") ] = ApiClient::parameterToString(*additionalMetadata); } if (file && *file != nullptr) { - fileParams[ utility::conversions::to_string_t("file") ] = *file; + localVarFileParams[ utility::conversions::to_string_t("file") ] = *file; } - std::shared_ptr httpBody; - utility::string_t requestHttpContentType; + std::shared_ptr localVarHttpBody; + utility::string_t localVarRequestHttpContentType; // use JSON if possible - if ( consumeHttpContentTypes.size() == 0 || consumeHttpContentTypes.find(utility::conversions::to_string_t("application/json")) != consumeHttpContentTypes.end() ) + if ( localVarConsumeHttpContentTypes.size() == 0 || localVarConsumeHttpContentTypes.find(utility::conversions::to_string_t("application/json")) != localVarConsumeHttpContentTypes.end() ) { - requestHttpContentType = utility::conversions::to_string_t("application/json"); + localVarRequestHttpContentType = utility::conversions::to_string_t("application/json"); } // multipart formdata - else if( consumeHttpContentTypes.find(utility::conversions::to_string_t("multipart/form-data")) != consumeHttpContentTypes.end() ) + else if( localVarConsumeHttpContentTypes.find(utility::conversions::to_string_t("multipart/form-data")) != localVarConsumeHttpContentTypes.end() ) { - requestHttpContentType = utility::conversions::to_string_t("multipart/form-data"); + localVarRequestHttpContentType = utility::conversions::to_string_t("multipart/form-data"); } else { @@ -928,46 +928,46 @@ pplx::task> PetApi::uploadFile(int64_t petId, boost // authentication (petstore_auth) required // oauth2 authentication is added automatically as part of the http_client_config - return m_ApiClient->callApi(path, utility::conversions::to_string_t("POST"), queryParams, httpBody, headerParams, formParams, fileParams, requestHttpContentType) - .then([=](web::http::http_response response) + return m_ApiClient->callApi(localVarPath, utility::conversions::to_string_t("POST"), localVarQueryParams, localVarHttpBody, localVarHeaderParams, localVarFormParams, localVarFileParams, localVarRequestHttpContentType) + .then([=](web::http::http_response localVarResponse) { // 1xx - informational : OK // 2xx - successful : OK // 3xx - redirection : OK // 4xx - client error : not OK // 5xx - client error : not OK - if (response.status_code() >= 400) + if (localVarResponse.status_code() >= 400) { - throw ApiException(response.status_code() - , utility::conversions::to_string_t("error calling uploadFile: ") + response.reason_phrase() - , std::make_shared(response.extract_utf8string(true).get())); + throw ApiException(localVarResponse.status_code() + , utility::conversions::to_string_t("error calling uploadFile: ") + localVarResponse.reason_phrase() + , std::make_shared(localVarResponse.extract_utf8string(true).get())); } // check response content type - if(response.headers().has(utility::conversions::to_string_t("Content-Type"))) + if(localVarResponse.headers().has(utility::conversions::to_string_t("Content-Type"))) { - utility::string_t contentType = response.headers()[utility::conversions::to_string_t("Content-Type")]; - if( contentType.find(responseHttpContentType) == std::string::npos ) + utility::string_t localVarContentType = localVarResponse.headers()[utility::conversions::to_string_t("Content-Type")]; + if( localVarContentType.find(localVarResponseHttpContentType) == std::string::npos ) { throw ApiException(500 - , utility::conversions::to_string_t("error calling uploadFile: unexpected response type: ") + contentType - , std::make_shared(response.extract_utf8string(true).get())); + , utility::conversions::to_string_t("error calling uploadFile: unexpected response type: ") + localVarContentType + , std::make_shared(localVarResponse.extract_utf8string(true).get())); } } - return response.extract_string(); + return localVarResponse.extract_string(); }) - .then([=](utility::string_t response) + .then([=](utility::string_t localVarResponse) { - std::shared_ptr result(new ApiResponse()); + std::shared_ptr localVarResult(new ApiResponse()); - if(responseHttpContentType == utility::conversions::to_string_t("application/json")) + if(localVarResponseHttpContentType == utility::conversions::to_string_t("application/json")) { - web::json::value json = web::json::value::parse(response); + web::json::value localVarJson = web::json::value::parse(localVarResponse); - result->fromJson(json); + localVarResult->fromJson(localVarJson); } - // else if(responseHttpContentType == utility::conversions::to_string_t("multipart/form-data")) + // else if(localVarResponseHttpContentType == utility::conversions::to_string_t("multipart/form-data")) // { // TODO multipart response parsing // } @@ -977,7 +977,7 @@ pplx::task> PetApi::uploadFile(int64_t petId, boost , utility::conversions::to_string_t("error calling uploadFile: unsupported response type")); } - return result; + return localVarResult; }); } diff --git a/samples/client/petstore/cpp-restsdk/api/StoreApi.cpp b/samples/client/petstore/cpp-restsdk/api/StoreApi.cpp index ca188d173289..c690f2be5112 100644 --- a/samples/client/petstore/cpp-restsdk/api/StoreApi.cpp +++ b/samples/client/petstore/cpp-restsdk/api/StoreApi.cpp @@ -39,56 +39,56 @@ pplx::task StoreApi::deleteOrder(utility::string_t orderId) { - std::shared_ptr apiConfiguration( m_ApiClient->getConfiguration() ); - utility::string_t path = utility::conversions::to_string_t("/store/order/{orderId}"); - boost::replace_all(path, utility::conversions::to_string_t("{") + utility::conversions::to_string_t("orderId") + utility::conversions::to_string_t("}"), ApiClient::parameterToString(orderId)); + std::shared_ptr localVarApiConfiguration( m_ApiClient->getConfiguration() ); + utility::string_t localVarPath = utility::conversions::to_string_t("/store/order/{orderId}"); + boost::replace_all(localVarPath, utility::conversions::to_string_t("{") + utility::conversions::to_string_t("orderId") + utility::conversions::to_string_t("}"), ApiClient::parameterToString(orderId)); - std::map queryParams; - std::map headerParams( apiConfiguration->getDefaultHeaders() ); - std::map formParams; - std::map> fileParams; + std::map localVarQueryParams; + std::map localVarHeaderParams( localVarApiConfiguration->getDefaultHeaders() ); + std::map localVarFormParams; + std::map> localVarFileParams; - std::unordered_set responseHttpContentTypes; + std::unordered_set localVarResponseHttpContentTypes; - utility::string_t responseHttpContentType; + utility::string_t localVarResponseHttpContentType; // use JSON if possible - if ( responseHttpContentTypes.size() == 0 ) + if ( localVarResponseHttpContentTypes.size() == 0 ) { - responseHttpContentType = utility::conversions::to_string_t("application/json"); + localVarResponseHttpContentType = utility::conversions::to_string_t("application/json"); } // JSON - else if ( responseHttpContentTypes.find(utility::conversions::to_string_t("application/json")) != responseHttpContentTypes.end() ) + else if ( localVarResponseHttpContentTypes.find(utility::conversions::to_string_t("application/json")) != localVarResponseHttpContentTypes.end() ) { - responseHttpContentType = utility::conversions::to_string_t("application/json"); + localVarResponseHttpContentType = utility::conversions::to_string_t("application/json"); } // multipart formdata - else if( responseHttpContentTypes.find(utility::conversions::to_string_t("multipart/form-data")) != responseHttpContentTypes.end() ) + else if( localVarResponseHttpContentTypes.find(utility::conversions::to_string_t("multipart/form-data")) != localVarResponseHttpContentTypes.end() ) { - responseHttpContentType = utility::conversions::to_string_t("multipart/form-data"); + localVarResponseHttpContentType = utility::conversions::to_string_t("multipart/form-data"); } else { throw ApiException(400, utility::conversions::to_string_t("StoreApi->deleteOrder does not produce any supported media type")); } - headerParams[utility::conversions::to_string_t("Accept")] = responseHttpContentType; + localVarHeaderParams[utility::conversions::to_string_t("Accept")] = localVarResponseHttpContentType; - std::unordered_set consumeHttpContentTypes; + std::unordered_set localVarConsumeHttpContentTypes; - std::shared_ptr httpBody; - utility::string_t requestHttpContentType; + std::shared_ptr localVarHttpBody; + utility::string_t localVarRequestHttpContentType; // use JSON if possible - if ( consumeHttpContentTypes.size() == 0 || consumeHttpContentTypes.find(utility::conversions::to_string_t("application/json")) != consumeHttpContentTypes.end() ) + if ( localVarConsumeHttpContentTypes.size() == 0 || localVarConsumeHttpContentTypes.find(utility::conversions::to_string_t("application/json")) != localVarConsumeHttpContentTypes.end() ) { - requestHttpContentType = utility::conversions::to_string_t("application/json"); + localVarRequestHttpContentType = utility::conversions::to_string_t("application/json"); } // multipart formdata - else if( consumeHttpContentTypes.find(utility::conversions::to_string_t("multipart/form-data")) != consumeHttpContentTypes.end() ) + else if( localVarConsumeHttpContentTypes.find(utility::conversions::to_string_t("multipart/form-data")) != localVarConsumeHttpContentTypes.end() ) { - requestHttpContentType = utility::conversions::to_string_t("multipart/form-data"); + localVarRequestHttpContentType = utility::conversions::to_string_t("multipart/form-data"); } else { @@ -96,36 +96,36 @@ pplx::task StoreApi::deleteOrder(utility::string_t orderId) } - return m_ApiClient->callApi(path, utility::conversions::to_string_t("DELETE"), queryParams, httpBody, headerParams, formParams, fileParams, requestHttpContentType) - .then([=](web::http::http_response response) + return m_ApiClient->callApi(localVarPath, utility::conversions::to_string_t("DELETE"), localVarQueryParams, localVarHttpBody, localVarHeaderParams, localVarFormParams, localVarFileParams, localVarRequestHttpContentType) + .then([=](web::http::http_response localVarResponse) { // 1xx - informational : OK // 2xx - successful : OK // 3xx - redirection : OK // 4xx - client error : not OK // 5xx - client error : not OK - if (response.status_code() >= 400) + if (localVarResponse.status_code() >= 400) { - throw ApiException(response.status_code() - , utility::conversions::to_string_t("error calling deleteOrder: ") + response.reason_phrase() - , std::make_shared(response.extract_utf8string(true).get())); + throw ApiException(localVarResponse.status_code() + , utility::conversions::to_string_t("error calling deleteOrder: ") + localVarResponse.reason_phrase() + , std::make_shared(localVarResponse.extract_utf8string(true).get())); } // check response content type - if(response.headers().has(utility::conversions::to_string_t("Content-Type"))) + if(localVarResponse.headers().has(utility::conversions::to_string_t("Content-Type"))) { - utility::string_t contentType = response.headers()[utility::conversions::to_string_t("Content-Type")]; - if( contentType.find(responseHttpContentType) == std::string::npos ) + utility::string_t localVarContentType = localVarResponse.headers()[utility::conversions::to_string_t("Content-Type")]; + if( localVarContentType.find(localVarResponseHttpContentType) == std::string::npos ) { throw ApiException(500 - , utility::conversions::to_string_t("error calling deleteOrder: unexpected response type: ") + contentType - , std::make_shared(response.extract_utf8string(true).get())); + , utility::conversions::to_string_t("error calling deleteOrder: unexpected response type: ") + localVarContentType + , std::make_shared(localVarResponse.extract_utf8string(true).get())); } } - return response.extract_string(); + return localVarResponse.extract_string(); }) - .then([=](utility::string_t response) + .then([=](utility::string_t localVarResponse) { return void(); }); @@ -134,56 +134,56 @@ pplx::task> StoreApi::getInventory() { - std::shared_ptr apiConfiguration( m_ApiClient->getConfiguration() ); - utility::string_t path = utility::conversions::to_string_t("/store/inventory"); + std::shared_ptr localVarApiConfiguration( m_ApiClient->getConfiguration() ); + utility::string_t localVarPath = utility::conversions::to_string_t("/store/inventory"); - std::map queryParams; - std::map headerParams( apiConfiguration->getDefaultHeaders() ); - std::map formParams; - std::map> fileParams; + std::map localVarQueryParams; + std::map localVarHeaderParams( localVarApiConfiguration->getDefaultHeaders() ); + std::map localVarFormParams; + std::map> localVarFileParams; - std::unordered_set responseHttpContentTypes; - responseHttpContentTypes.insert( utility::conversions::to_string_t("application/json") ); + std::unordered_set localVarResponseHttpContentTypes; + localVarResponseHttpContentTypes.insert( utility::conversions::to_string_t("application/json") ); - utility::string_t responseHttpContentType; + utility::string_t localVarResponseHttpContentType; // use JSON if possible - if ( responseHttpContentTypes.size() == 0 ) + if ( localVarResponseHttpContentTypes.size() == 0 ) { - responseHttpContentType = utility::conversions::to_string_t("application/json"); + localVarResponseHttpContentType = utility::conversions::to_string_t("application/json"); } // JSON - else if ( responseHttpContentTypes.find(utility::conversions::to_string_t("application/json")) != responseHttpContentTypes.end() ) + else if ( localVarResponseHttpContentTypes.find(utility::conversions::to_string_t("application/json")) != localVarResponseHttpContentTypes.end() ) { - responseHttpContentType = utility::conversions::to_string_t("application/json"); + localVarResponseHttpContentType = utility::conversions::to_string_t("application/json"); } // multipart formdata - else if( responseHttpContentTypes.find(utility::conversions::to_string_t("multipart/form-data")) != responseHttpContentTypes.end() ) + else if( localVarResponseHttpContentTypes.find(utility::conversions::to_string_t("multipart/form-data")) != localVarResponseHttpContentTypes.end() ) { - responseHttpContentType = utility::conversions::to_string_t("multipart/form-data"); + localVarResponseHttpContentType = utility::conversions::to_string_t("multipart/form-data"); } else { throw ApiException(400, utility::conversions::to_string_t("StoreApi->getInventory does not produce any supported media type")); } - headerParams[utility::conversions::to_string_t("Accept")] = responseHttpContentType; + localVarHeaderParams[utility::conversions::to_string_t("Accept")] = localVarResponseHttpContentType; - std::unordered_set consumeHttpContentTypes; + std::unordered_set localVarConsumeHttpContentTypes; - std::shared_ptr httpBody; - utility::string_t requestHttpContentType; + std::shared_ptr localVarHttpBody; + utility::string_t localVarRequestHttpContentType; // use JSON if possible - if ( consumeHttpContentTypes.size() == 0 || consumeHttpContentTypes.find(utility::conversions::to_string_t("application/json")) != consumeHttpContentTypes.end() ) + if ( localVarConsumeHttpContentTypes.size() == 0 || localVarConsumeHttpContentTypes.find(utility::conversions::to_string_t("application/json")) != localVarConsumeHttpContentTypes.end() ) { - requestHttpContentType = utility::conversions::to_string_t("application/json"); + localVarRequestHttpContentType = utility::conversions::to_string_t("application/json"); } // multipart formdata - else if( consumeHttpContentTypes.find(utility::conversions::to_string_t("multipart/form-data")) != consumeHttpContentTypes.end() ) + else if( localVarConsumeHttpContentTypes.find(utility::conversions::to_string_t("multipart/form-data")) != localVarConsumeHttpContentTypes.end() ) { - requestHttpContentType = utility::conversions::to_string_t("multipart/form-data"); + localVarRequestHttpContentType = utility::conversions::to_string_t("multipart/form-data"); } else { @@ -192,58 +192,58 @@ pplx::task> StoreApi::getInventory() // authentication (api_key) required { - utility::string_t apiKey = apiConfiguration->getApiKey(utility::conversions::to_string_t("api_key")); - if ( apiKey.size() > 0 ) + utility::string_t localVarApiKey = localVarApiConfiguration->getApiKey(utility::conversions::to_string_t("api_key")); + if ( localVarApiKey.size() > 0 ) { - headerParams[utility::conversions::to_string_t("api_key")] = apiKey; + localVarHeaderParams[utility::conversions::to_string_t("api_key")] = localVarApiKey; } } - return m_ApiClient->callApi(path, utility::conversions::to_string_t("GET"), queryParams, httpBody, headerParams, formParams, fileParams, requestHttpContentType) - .then([=](web::http::http_response response) + return m_ApiClient->callApi(localVarPath, utility::conversions::to_string_t("GET"), localVarQueryParams, localVarHttpBody, localVarHeaderParams, localVarFormParams, localVarFileParams, localVarRequestHttpContentType) + .then([=](web::http::http_response localVarResponse) { // 1xx - informational : OK // 2xx - successful : OK // 3xx - redirection : OK // 4xx - client error : not OK // 5xx - client error : not OK - if (response.status_code() >= 400) + if (localVarResponse.status_code() >= 400) { - throw ApiException(response.status_code() - , utility::conversions::to_string_t("error calling getInventory: ") + response.reason_phrase() - , std::make_shared(response.extract_utf8string(true).get())); + throw ApiException(localVarResponse.status_code() + , utility::conversions::to_string_t("error calling getInventory: ") + localVarResponse.reason_phrase() + , std::make_shared(localVarResponse.extract_utf8string(true).get())); } // check response content type - if(response.headers().has(utility::conversions::to_string_t("Content-Type"))) + if(localVarResponse.headers().has(utility::conversions::to_string_t("Content-Type"))) { - utility::string_t contentType = response.headers()[utility::conversions::to_string_t("Content-Type")]; - if( contentType.find(responseHttpContentType) == std::string::npos ) + utility::string_t localVarContentType = localVarResponse.headers()[utility::conversions::to_string_t("Content-Type")]; + if( localVarContentType.find(localVarResponseHttpContentType) == std::string::npos ) { throw ApiException(500 - , utility::conversions::to_string_t("error calling getInventory: unexpected response type: ") + contentType - , std::make_shared(response.extract_utf8string(true).get())); + , utility::conversions::to_string_t("error calling getInventory: unexpected response type: ") + localVarContentType + , std::make_shared(localVarResponse.extract_utf8string(true).get())); } } - return response.extract_string(); + return localVarResponse.extract_string(); }) - .then([=](utility::string_t response) + .then([=](utility::string_t localVarResponse) { - std::map result; + std::map localVarResult; - if(responseHttpContentType == utility::conversions::to_string_t("application/json")) + if(localVarResponseHttpContentType == utility::conversions::to_string_t("application/json")) { - web::json::value json = web::json::value::parse(response); + web::json::value localVarJson = web::json::value::parse(localVarResponse); - for( auto& item : json.as_object() ) + for( auto& localVarItem : localVarJson.as_object() ) { - result[item.first] = ModelBase::int32_tFromJson(item.second); + localVarResult[localVarItem.first] = ModelBase::int32_tFromJson(localVarItem.second); } } - // else if(responseHttpContentType == utility::conversions::to_string_t("multipart/form-data")) + // else if(localVarResponseHttpContentType == utility::conversions::to_string_t("multipart/form-data")) // { // TODO multipart response parsing // } @@ -253,65 +253,65 @@ pplx::task> StoreApi::getInventory() , utility::conversions::to_string_t("error calling getInventory: unsupported response type")); } - return result; + return localVarResult; }); } pplx::task> StoreApi::getOrderById(int64_t orderId) { - std::shared_ptr apiConfiguration( m_ApiClient->getConfiguration() ); - utility::string_t path = utility::conversions::to_string_t("/store/order/{orderId}"); - boost::replace_all(path, utility::conversions::to_string_t("{") + utility::conversions::to_string_t("orderId") + utility::conversions::to_string_t("}"), ApiClient::parameterToString(orderId)); + std::shared_ptr localVarApiConfiguration( m_ApiClient->getConfiguration() ); + utility::string_t localVarPath = utility::conversions::to_string_t("/store/order/{orderId}"); + boost::replace_all(localVarPath, utility::conversions::to_string_t("{") + utility::conversions::to_string_t("orderId") + utility::conversions::to_string_t("}"), ApiClient::parameterToString(orderId)); - std::map queryParams; - std::map headerParams( apiConfiguration->getDefaultHeaders() ); - std::map formParams; - std::map> fileParams; + std::map localVarQueryParams; + std::map localVarHeaderParams( localVarApiConfiguration->getDefaultHeaders() ); + std::map localVarFormParams; + std::map> localVarFileParams; - std::unordered_set responseHttpContentTypes; - responseHttpContentTypes.insert( utility::conversions::to_string_t("application/xml") ); - responseHttpContentTypes.insert( utility::conversions::to_string_t("application/json") ); + std::unordered_set localVarResponseHttpContentTypes; + localVarResponseHttpContentTypes.insert( utility::conversions::to_string_t("application/xml") ); + localVarResponseHttpContentTypes.insert( utility::conversions::to_string_t("application/json") ); - utility::string_t responseHttpContentType; + utility::string_t localVarResponseHttpContentType; // use JSON if possible - if ( responseHttpContentTypes.size() == 0 ) + if ( localVarResponseHttpContentTypes.size() == 0 ) { - responseHttpContentType = utility::conversions::to_string_t("application/json"); + localVarResponseHttpContentType = utility::conversions::to_string_t("application/json"); } // JSON - else if ( responseHttpContentTypes.find(utility::conversions::to_string_t("application/json")) != responseHttpContentTypes.end() ) + else if ( localVarResponseHttpContentTypes.find(utility::conversions::to_string_t("application/json")) != localVarResponseHttpContentTypes.end() ) { - responseHttpContentType = utility::conversions::to_string_t("application/json"); + localVarResponseHttpContentType = utility::conversions::to_string_t("application/json"); } // multipart formdata - else if( responseHttpContentTypes.find(utility::conversions::to_string_t("multipart/form-data")) != responseHttpContentTypes.end() ) + else if( localVarResponseHttpContentTypes.find(utility::conversions::to_string_t("multipart/form-data")) != localVarResponseHttpContentTypes.end() ) { - responseHttpContentType = utility::conversions::to_string_t("multipart/form-data"); + localVarResponseHttpContentType = utility::conversions::to_string_t("multipart/form-data"); } else { throw ApiException(400, utility::conversions::to_string_t("StoreApi->getOrderById does not produce any supported media type")); } - headerParams[utility::conversions::to_string_t("Accept")] = responseHttpContentType; + localVarHeaderParams[utility::conversions::to_string_t("Accept")] = localVarResponseHttpContentType; - std::unordered_set consumeHttpContentTypes; + std::unordered_set localVarConsumeHttpContentTypes; - std::shared_ptr httpBody; - utility::string_t requestHttpContentType; + std::shared_ptr localVarHttpBody; + utility::string_t localVarRequestHttpContentType; // use JSON if possible - if ( consumeHttpContentTypes.size() == 0 || consumeHttpContentTypes.find(utility::conversions::to_string_t("application/json")) != consumeHttpContentTypes.end() ) + if ( localVarConsumeHttpContentTypes.size() == 0 || localVarConsumeHttpContentTypes.find(utility::conversions::to_string_t("application/json")) != localVarConsumeHttpContentTypes.end() ) { - requestHttpContentType = utility::conversions::to_string_t("application/json"); + localVarRequestHttpContentType = utility::conversions::to_string_t("application/json"); } // multipart formdata - else if( consumeHttpContentTypes.find(utility::conversions::to_string_t("multipart/form-data")) != consumeHttpContentTypes.end() ) + else if( localVarConsumeHttpContentTypes.find(utility::conversions::to_string_t("multipart/form-data")) != localVarConsumeHttpContentTypes.end() ) { - requestHttpContentType = utility::conversions::to_string_t("multipart/form-data"); + localVarRequestHttpContentType = utility::conversions::to_string_t("multipart/form-data"); } else { @@ -319,46 +319,46 @@ pplx::task> StoreApi::getOrderById(int64_t orderId) } - return m_ApiClient->callApi(path, utility::conversions::to_string_t("GET"), queryParams, httpBody, headerParams, formParams, fileParams, requestHttpContentType) - .then([=](web::http::http_response response) + return m_ApiClient->callApi(localVarPath, utility::conversions::to_string_t("GET"), localVarQueryParams, localVarHttpBody, localVarHeaderParams, localVarFormParams, localVarFileParams, localVarRequestHttpContentType) + .then([=](web::http::http_response localVarResponse) { // 1xx - informational : OK // 2xx - successful : OK // 3xx - redirection : OK // 4xx - client error : not OK // 5xx - client error : not OK - if (response.status_code() >= 400) + if (localVarResponse.status_code() >= 400) { - throw ApiException(response.status_code() - , utility::conversions::to_string_t("error calling getOrderById: ") + response.reason_phrase() - , std::make_shared(response.extract_utf8string(true).get())); + throw ApiException(localVarResponse.status_code() + , utility::conversions::to_string_t("error calling getOrderById: ") + localVarResponse.reason_phrase() + , std::make_shared(localVarResponse.extract_utf8string(true).get())); } // check response content type - if(response.headers().has(utility::conversions::to_string_t("Content-Type"))) + if(localVarResponse.headers().has(utility::conversions::to_string_t("Content-Type"))) { - utility::string_t contentType = response.headers()[utility::conversions::to_string_t("Content-Type")]; - if( contentType.find(responseHttpContentType) == std::string::npos ) + utility::string_t localVarContentType = localVarResponse.headers()[utility::conversions::to_string_t("Content-Type")]; + if( localVarContentType.find(localVarResponseHttpContentType) == std::string::npos ) { throw ApiException(500 - , utility::conversions::to_string_t("error calling getOrderById: unexpected response type: ") + contentType - , std::make_shared(response.extract_utf8string(true).get())); + , utility::conversions::to_string_t("error calling getOrderById: unexpected response type: ") + localVarContentType + , std::make_shared(localVarResponse.extract_utf8string(true).get())); } } - return response.extract_string(); + return localVarResponse.extract_string(); }) - .then([=](utility::string_t response) + .then([=](utility::string_t localVarResponse) { - std::shared_ptr result(new Order()); + std::shared_ptr localVarResult(new Order()); - if(responseHttpContentType == utility::conversions::to_string_t("application/json")) + if(localVarResponseHttpContentType == utility::conversions::to_string_t("application/json")) { - web::json::value json = web::json::value::parse(response); + web::json::value localVarJson = web::json::value::parse(localVarResponse); - result->fromJson(json); + localVarResult->fromJson(localVarJson); } - // else if(responseHttpContentType == utility::conversions::to_string_t("multipart/form-data")) + // else if(localVarResponseHttpContentType == utility::conversions::to_string_t("multipart/form-data")) // { // TODO multipart response parsing // } @@ -368,7 +368,7 @@ pplx::task> StoreApi::getOrderById(int64_t orderId) , utility::conversions::to_string_t("error calling getOrderById: unsupported response type")); } - return result; + return localVarResult; }); } pplx::task> StoreApi::placeOrder(std::shared_ptr order) @@ -381,72 +381,72 @@ pplx::task> StoreApi::placeOrder(std::shared_ptr o } - std::shared_ptr apiConfiguration( m_ApiClient->getConfiguration() ); - utility::string_t path = utility::conversions::to_string_t("/store/order"); + std::shared_ptr localVarApiConfiguration( m_ApiClient->getConfiguration() ); + utility::string_t localVarPath = utility::conversions::to_string_t("/store/order"); - std::map queryParams; - std::map headerParams( apiConfiguration->getDefaultHeaders() ); - std::map formParams; - std::map> fileParams; + std::map localVarQueryParams; + std::map localVarHeaderParams( localVarApiConfiguration->getDefaultHeaders() ); + std::map localVarFormParams; + std::map> localVarFileParams; - std::unordered_set responseHttpContentTypes; - responseHttpContentTypes.insert( utility::conversions::to_string_t("application/xml") ); - responseHttpContentTypes.insert( utility::conversions::to_string_t("application/json") ); + std::unordered_set localVarResponseHttpContentTypes; + localVarResponseHttpContentTypes.insert( utility::conversions::to_string_t("application/xml") ); + localVarResponseHttpContentTypes.insert( utility::conversions::to_string_t("application/json") ); - utility::string_t responseHttpContentType; + utility::string_t localVarResponseHttpContentType; // use JSON if possible - if ( responseHttpContentTypes.size() == 0 ) + if ( localVarResponseHttpContentTypes.size() == 0 ) { - responseHttpContentType = utility::conversions::to_string_t("application/json"); + localVarResponseHttpContentType = utility::conversions::to_string_t("application/json"); } // JSON - else if ( responseHttpContentTypes.find(utility::conversions::to_string_t("application/json")) != responseHttpContentTypes.end() ) + else if ( localVarResponseHttpContentTypes.find(utility::conversions::to_string_t("application/json")) != localVarResponseHttpContentTypes.end() ) { - responseHttpContentType = utility::conversions::to_string_t("application/json"); + localVarResponseHttpContentType = utility::conversions::to_string_t("application/json"); } // multipart formdata - else if( responseHttpContentTypes.find(utility::conversions::to_string_t("multipart/form-data")) != responseHttpContentTypes.end() ) + else if( localVarResponseHttpContentTypes.find(utility::conversions::to_string_t("multipart/form-data")) != localVarResponseHttpContentTypes.end() ) { - responseHttpContentType = utility::conversions::to_string_t("multipart/form-data"); + localVarResponseHttpContentType = utility::conversions::to_string_t("multipart/form-data"); } else { throw ApiException(400, utility::conversions::to_string_t("StoreApi->placeOrder does not produce any supported media type")); } - headerParams[utility::conversions::to_string_t("Accept")] = responseHttpContentType; + localVarHeaderParams[utility::conversions::to_string_t("Accept")] = localVarResponseHttpContentType; - std::unordered_set consumeHttpContentTypes; + std::unordered_set localVarConsumeHttpContentTypes; - std::shared_ptr httpBody; - utility::string_t requestHttpContentType; + std::shared_ptr localVarHttpBody; + utility::string_t localVarRequestHttpContentType; // use JSON if possible - if ( consumeHttpContentTypes.size() == 0 || consumeHttpContentTypes.find(utility::conversions::to_string_t("application/json")) != consumeHttpContentTypes.end() ) + if ( localVarConsumeHttpContentTypes.size() == 0 || localVarConsumeHttpContentTypes.find(utility::conversions::to_string_t("application/json")) != localVarConsumeHttpContentTypes.end() ) { - requestHttpContentType = utility::conversions::to_string_t("application/json"); - web::json::value json; + localVarRequestHttpContentType = utility::conversions::to_string_t("application/json"); + web::json::value localVarJson; - json = ModelBase::toJson(order); + localVarJson = ModelBase::toJson(order); - httpBody = std::shared_ptr( new JsonBody( json ) ); + localVarHttpBody = std::shared_ptr( new JsonBody( localVarJson ) ); } // multipart formdata - else if( consumeHttpContentTypes.find(utility::conversions::to_string_t("multipart/form-data")) != consumeHttpContentTypes.end() ) + else if( localVarConsumeHttpContentTypes.find(utility::conversions::to_string_t("multipart/form-data")) != localVarConsumeHttpContentTypes.end() ) { - requestHttpContentType = utility::conversions::to_string_t("multipart/form-data"); - std::shared_ptr multipart(new MultipartFormData); + localVarRequestHttpContentType = utility::conversions::to_string_t("multipart/form-data"); + std::shared_ptr localVarMultipart(new MultipartFormData); if(order.get()) { - order->toMultipart(multipart, utility::conversions::to_string_t("order")); + order->toMultipart(localVarMultipart, utility::conversions::to_string_t("order")); } - httpBody = multipart; - requestHttpContentType += utility::conversions::to_string_t("; boundary=") + multipart->getBoundary(); + localVarHttpBody = localVarMultipart; + localVarRequestHttpContentType += utility::conversions::to_string_t("; boundary=") + localVarMultipart->getBoundary(); } else { @@ -454,46 +454,46 @@ pplx::task> StoreApi::placeOrder(std::shared_ptr o } - return m_ApiClient->callApi(path, utility::conversions::to_string_t("POST"), queryParams, httpBody, headerParams, formParams, fileParams, requestHttpContentType) - .then([=](web::http::http_response response) + return m_ApiClient->callApi(localVarPath, utility::conversions::to_string_t("POST"), localVarQueryParams, localVarHttpBody, localVarHeaderParams, localVarFormParams, localVarFileParams, localVarRequestHttpContentType) + .then([=](web::http::http_response localVarResponse) { // 1xx - informational : OK // 2xx - successful : OK // 3xx - redirection : OK // 4xx - client error : not OK // 5xx - client error : not OK - if (response.status_code() >= 400) + if (localVarResponse.status_code() >= 400) { - throw ApiException(response.status_code() - , utility::conversions::to_string_t("error calling placeOrder: ") + response.reason_phrase() - , std::make_shared(response.extract_utf8string(true).get())); + throw ApiException(localVarResponse.status_code() + , utility::conversions::to_string_t("error calling placeOrder: ") + localVarResponse.reason_phrase() + , std::make_shared(localVarResponse.extract_utf8string(true).get())); } // check response content type - if(response.headers().has(utility::conversions::to_string_t("Content-Type"))) + if(localVarResponse.headers().has(utility::conversions::to_string_t("Content-Type"))) { - utility::string_t contentType = response.headers()[utility::conversions::to_string_t("Content-Type")]; - if( contentType.find(responseHttpContentType) == std::string::npos ) + utility::string_t localVarContentType = localVarResponse.headers()[utility::conversions::to_string_t("Content-Type")]; + if( localVarContentType.find(localVarResponseHttpContentType) == std::string::npos ) { throw ApiException(500 - , utility::conversions::to_string_t("error calling placeOrder: unexpected response type: ") + contentType - , std::make_shared(response.extract_utf8string(true).get())); + , utility::conversions::to_string_t("error calling placeOrder: unexpected response type: ") + localVarContentType + , std::make_shared(localVarResponse.extract_utf8string(true).get())); } } - return response.extract_string(); + return localVarResponse.extract_string(); }) - .then([=](utility::string_t response) + .then([=](utility::string_t localVarResponse) { - std::shared_ptr result(new Order()); + std::shared_ptr localVarResult(new Order()); - if(responseHttpContentType == utility::conversions::to_string_t("application/json")) + if(localVarResponseHttpContentType == utility::conversions::to_string_t("application/json")) { - web::json::value json = web::json::value::parse(response); + web::json::value localVarJson = web::json::value::parse(localVarResponse); - result->fromJson(json); + localVarResult->fromJson(localVarJson); } - // else if(responseHttpContentType == utility::conversions::to_string_t("multipart/form-data")) + // else if(localVarResponseHttpContentType == utility::conversions::to_string_t("multipart/form-data")) // { // TODO multipart response parsing // } @@ -503,7 +503,7 @@ pplx::task> StoreApi::placeOrder(std::shared_ptr o , utility::conversions::to_string_t("error calling placeOrder: unsupported response type")); } - return result; + return localVarResult; }); } diff --git a/samples/client/petstore/cpp-restsdk/api/UserApi.cpp b/samples/client/petstore/cpp-restsdk/api/UserApi.cpp index 9a466b26c153..af3fb210b684 100644 --- a/samples/client/petstore/cpp-restsdk/api/UserApi.cpp +++ b/samples/client/petstore/cpp-restsdk/api/UserApi.cpp @@ -45,70 +45,70 @@ pplx::task UserApi::createUser(std::shared_ptr user) } - std::shared_ptr apiConfiguration( m_ApiClient->getConfiguration() ); - utility::string_t path = utility::conversions::to_string_t("/user"); + std::shared_ptr localVarApiConfiguration( m_ApiClient->getConfiguration() ); + utility::string_t localVarPath = utility::conversions::to_string_t("/user"); - std::map queryParams; - std::map headerParams( apiConfiguration->getDefaultHeaders() ); - std::map formParams; - std::map> fileParams; + std::map localVarQueryParams; + std::map localVarHeaderParams( localVarApiConfiguration->getDefaultHeaders() ); + std::map localVarFormParams; + std::map> localVarFileParams; - std::unordered_set responseHttpContentTypes; + std::unordered_set localVarResponseHttpContentTypes; - utility::string_t responseHttpContentType; + utility::string_t localVarResponseHttpContentType; // use JSON if possible - if ( responseHttpContentTypes.size() == 0 ) + if ( localVarResponseHttpContentTypes.size() == 0 ) { - responseHttpContentType = utility::conversions::to_string_t("application/json"); + localVarResponseHttpContentType = utility::conversions::to_string_t("application/json"); } // JSON - else if ( responseHttpContentTypes.find(utility::conversions::to_string_t("application/json")) != responseHttpContentTypes.end() ) + else if ( localVarResponseHttpContentTypes.find(utility::conversions::to_string_t("application/json")) != localVarResponseHttpContentTypes.end() ) { - responseHttpContentType = utility::conversions::to_string_t("application/json"); + localVarResponseHttpContentType = utility::conversions::to_string_t("application/json"); } // multipart formdata - else if( responseHttpContentTypes.find(utility::conversions::to_string_t("multipart/form-data")) != responseHttpContentTypes.end() ) + else if( localVarResponseHttpContentTypes.find(utility::conversions::to_string_t("multipart/form-data")) != localVarResponseHttpContentTypes.end() ) { - responseHttpContentType = utility::conversions::to_string_t("multipart/form-data"); + localVarResponseHttpContentType = utility::conversions::to_string_t("multipart/form-data"); } else { throw ApiException(400, utility::conversions::to_string_t("UserApi->createUser does not produce any supported media type")); } - headerParams[utility::conversions::to_string_t("Accept")] = responseHttpContentType; + localVarHeaderParams[utility::conversions::to_string_t("Accept")] = localVarResponseHttpContentType; - std::unordered_set consumeHttpContentTypes; + std::unordered_set localVarConsumeHttpContentTypes; - std::shared_ptr httpBody; - utility::string_t requestHttpContentType; + std::shared_ptr localVarHttpBody; + utility::string_t localVarRequestHttpContentType; // use JSON if possible - if ( consumeHttpContentTypes.size() == 0 || consumeHttpContentTypes.find(utility::conversions::to_string_t("application/json")) != consumeHttpContentTypes.end() ) + if ( localVarConsumeHttpContentTypes.size() == 0 || localVarConsumeHttpContentTypes.find(utility::conversions::to_string_t("application/json")) != localVarConsumeHttpContentTypes.end() ) { - requestHttpContentType = utility::conversions::to_string_t("application/json"); - web::json::value json; + localVarRequestHttpContentType = utility::conversions::to_string_t("application/json"); + web::json::value localVarJson; - json = ModelBase::toJson(user); + localVarJson = ModelBase::toJson(user); - httpBody = std::shared_ptr( new JsonBody( json ) ); + localVarHttpBody = std::shared_ptr( new JsonBody( localVarJson ) ); } // multipart formdata - else if( consumeHttpContentTypes.find(utility::conversions::to_string_t("multipart/form-data")) != consumeHttpContentTypes.end() ) + else if( localVarConsumeHttpContentTypes.find(utility::conversions::to_string_t("multipart/form-data")) != localVarConsumeHttpContentTypes.end() ) { - requestHttpContentType = utility::conversions::to_string_t("multipart/form-data"); - std::shared_ptr multipart(new MultipartFormData); + localVarRequestHttpContentType = utility::conversions::to_string_t("multipart/form-data"); + std::shared_ptr localVarMultipart(new MultipartFormData); if(user.get()) { - user->toMultipart(multipart, utility::conversions::to_string_t("user")); + user->toMultipart(localVarMultipart, utility::conversions::to_string_t("user")); } - httpBody = multipart; - requestHttpContentType += utility::conversions::to_string_t("; boundary=") + multipart->getBoundary(); + localVarHttpBody = localVarMultipart; + localVarRequestHttpContentType += utility::conversions::to_string_t("; boundary=") + localVarMultipart->getBoundary(); } else { @@ -116,36 +116,36 @@ pplx::task UserApi::createUser(std::shared_ptr user) } - return m_ApiClient->callApi(path, utility::conversions::to_string_t("POST"), queryParams, httpBody, headerParams, formParams, fileParams, requestHttpContentType) - .then([=](web::http::http_response response) + return m_ApiClient->callApi(localVarPath, utility::conversions::to_string_t("POST"), localVarQueryParams, localVarHttpBody, localVarHeaderParams, localVarFormParams, localVarFileParams, localVarRequestHttpContentType) + .then([=](web::http::http_response localVarResponse) { // 1xx - informational : OK // 2xx - successful : OK // 3xx - redirection : OK // 4xx - client error : not OK // 5xx - client error : not OK - if (response.status_code() >= 400) + if (localVarResponse.status_code() >= 400) { - throw ApiException(response.status_code() - , utility::conversions::to_string_t("error calling createUser: ") + response.reason_phrase() - , std::make_shared(response.extract_utf8string(true).get())); + throw ApiException(localVarResponse.status_code() + , utility::conversions::to_string_t("error calling createUser: ") + localVarResponse.reason_phrase() + , std::make_shared(localVarResponse.extract_utf8string(true).get())); } // check response content type - if(response.headers().has(utility::conversions::to_string_t("Content-Type"))) + if(localVarResponse.headers().has(utility::conversions::to_string_t("Content-Type"))) { - utility::string_t contentType = response.headers()[utility::conversions::to_string_t("Content-Type")]; - if( contentType.find(responseHttpContentType) == std::string::npos ) + utility::string_t localVarContentType = localVarResponse.headers()[utility::conversions::to_string_t("Content-Type")]; + if( localVarContentType.find(localVarResponseHttpContentType) == std::string::npos ) { throw ApiException(500 - , utility::conversions::to_string_t("error calling createUser: unexpected response type: ") + contentType - , std::make_shared(response.extract_utf8string(true).get())); + , utility::conversions::to_string_t("error calling createUser: unexpected response type: ") + localVarContentType + , std::make_shared(localVarResponse.extract_utf8string(true).get())); } } - return response.extract_string(); + return localVarResponse.extract_string(); }) - .then([=](utility::string_t response) + .then([=](utility::string_t localVarResponse) { return void(); }); @@ -154,81 +154,81 @@ pplx::task UserApi::createUsersWithArrayInput(std::vector apiConfiguration( m_ApiClient->getConfiguration() ); - utility::string_t path = utility::conversions::to_string_t("/user/createWithArray"); + std::shared_ptr localVarApiConfiguration( m_ApiClient->getConfiguration() ); + utility::string_t localVarPath = utility::conversions::to_string_t("/user/createWithArray"); - std::map queryParams; - std::map headerParams( apiConfiguration->getDefaultHeaders() ); - std::map formParams; - std::map> fileParams; + std::map localVarQueryParams; + std::map localVarHeaderParams( localVarApiConfiguration->getDefaultHeaders() ); + std::map localVarFormParams; + std::map> localVarFileParams; - std::unordered_set responseHttpContentTypes; + std::unordered_set localVarResponseHttpContentTypes; - utility::string_t responseHttpContentType; + utility::string_t localVarResponseHttpContentType; // use JSON if possible - if ( responseHttpContentTypes.size() == 0 ) + if ( localVarResponseHttpContentTypes.size() == 0 ) { - responseHttpContentType = utility::conversions::to_string_t("application/json"); + localVarResponseHttpContentType = utility::conversions::to_string_t("application/json"); } // JSON - else if ( responseHttpContentTypes.find(utility::conversions::to_string_t("application/json")) != responseHttpContentTypes.end() ) + else if ( localVarResponseHttpContentTypes.find(utility::conversions::to_string_t("application/json")) != localVarResponseHttpContentTypes.end() ) { - responseHttpContentType = utility::conversions::to_string_t("application/json"); + localVarResponseHttpContentType = utility::conversions::to_string_t("application/json"); } // multipart formdata - else if( responseHttpContentTypes.find(utility::conversions::to_string_t("multipart/form-data")) != responseHttpContentTypes.end() ) + else if( localVarResponseHttpContentTypes.find(utility::conversions::to_string_t("multipart/form-data")) != localVarResponseHttpContentTypes.end() ) { - responseHttpContentType = utility::conversions::to_string_t("multipart/form-data"); + localVarResponseHttpContentType = utility::conversions::to_string_t("multipart/form-data"); } else { throw ApiException(400, utility::conversions::to_string_t("UserApi->createUsersWithArrayInput does not produce any supported media type")); } - headerParams[utility::conversions::to_string_t("Accept")] = responseHttpContentType; + localVarHeaderParams[utility::conversions::to_string_t("Accept")] = localVarResponseHttpContentType; - std::unordered_set consumeHttpContentTypes; + std::unordered_set localVarConsumeHttpContentTypes; - std::shared_ptr httpBody; - utility::string_t requestHttpContentType; + std::shared_ptr localVarHttpBody; + utility::string_t localVarRequestHttpContentType; // use JSON if possible - if ( consumeHttpContentTypes.size() == 0 || consumeHttpContentTypes.find(utility::conversions::to_string_t("application/json")) != consumeHttpContentTypes.end() ) + if ( localVarConsumeHttpContentTypes.size() == 0 || localVarConsumeHttpContentTypes.find(utility::conversions::to_string_t("application/json")) != localVarConsumeHttpContentTypes.end() ) { - requestHttpContentType = utility::conversions::to_string_t("application/json"); - web::json::value json; + localVarRequestHttpContentType = utility::conversions::to_string_t("application/json"); + web::json::value localVarJson; { - std::vector jsonArray; - for( auto& item : user ) + std::vector localVarJsonArray; + for( auto& localVarItem : user ) { - jsonArray.push_back( item.get() ? item->toJson() : web::json::value::null() ); + localVarJsonArray.push_back( localVarItem.get() ? localVarItem->toJson() : web::json::value::null() ); } - json = web::json::value::array(jsonArray); + localVarJson = web::json::value::array(localVarJsonArray); } - httpBody = std::shared_ptr( new JsonBody( json ) ); + localVarHttpBody = std::shared_ptr( new JsonBody( localVarJson ) ); } // multipart formdata - else if( consumeHttpContentTypes.find(utility::conversions::to_string_t("multipart/form-data")) != consumeHttpContentTypes.end() ) + else if( localVarConsumeHttpContentTypes.find(utility::conversions::to_string_t("multipart/form-data")) != localVarConsumeHttpContentTypes.end() ) { - requestHttpContentType = utility::conversions::to_string_t("multipart/form-data"); - std::shared_ptr multipart(new MultipartFormData); + localVarRequestHttpContentType = utility::conversions::to_string_t("multipart/form-data"); + std::shared_ptr localVarMultipart(new MultipartFormData); { - std::vector jsonArray; - for( auto& item : user ) + std::vector localVarJsonArray; + for( auto& localVarItem : user ) { - jsonArray.push_back( item.get() ? item->toJson() : web::json::value::null() ); + localVarJsonArray.push_back( localVarItem.get() ? localVarItem->toJson() : web::json::value::null() ); } - multipart->add(ModelBase::toHttpContent(utility::conversions::to_string_t("user"), web::json::value::array(jsonArray), utility::conversions::to_string_t("application/json"))); + localVarMultipart->add(ModelBase::toHttpContent(utility::conversions::to_string_t("user"), web::json::value::array(localVarJsonArray), utility::conversions::to_string_t("application/json"))); } - httpBody = multipart; - requestHttpContentType += utility::conversions::to_string_t("; boundary=") + multipart->getBoundary(); + localVarHttpBody = localVarMultipart; + localVarRequestHttpContentType += utility::conversions::to_string_t("; boundary=") + localVarMultipart->getBoundary(); } else { @@ -236,36 +236,36 @@ pplx::task UserApi::createUsersWithArrayInput(std::vectorcallApi(path, utility::conversions::to_string_t("POST"), queryParams, httpBody, headerParams, formParams, fileParams, requestHttpContentType) - .then([=](web::http::http_response response) + return m_ApiClient->callApi(localVarPath, utility::conversions::to_string_t("POST"), localVarQueryParams, localVarHttpBody, localVarHeaderParams, localVarFormParams, localVarFileParams, localVarRequestHttpContentType) + .then([=](web::http::http_response localVarResponse) { // 1xx - informational : OK // 2xx - successful : OK // 3xx - redirection : OK // 4xx - client error : not OK // 5xx - client error : not OK - if (response.status_code() >= 400) + if (localVarResponse.status_code() >= 400) { - throw ApiException(response.status_code() - , utility::conversions::to_string_t("error calling createUsersWithArrayInput: ") + response.reason_phrase() - , std::make_shared(response.extract_utf8string(true).get())); + throw ApiException(localVarResponse.status_code() + , utility::conversions::to_string_t("error calling createUsersWithArrayInput: ") + localVarResponse.reason_phrase() + , std::make_shared(localVarResponse.extract_utf8string(true).get())); } // check response content type - if(response.headers().has(utility::conversions::to_string_t("Content-Type"))) + if(localVarResponse.headers().has(utility::conversions::to_string_t("Content-Type"))) { - utility::string_t contentType = response.headers()[utility::conversions::to_string_t("Content-Type")]; - if( contentType.find(responseHttpContentType) == std::string::npos ) + utility::string_t localVarContentType = localVarResponse.headers()[utility::conversions::to_string_t("Content-Type")]; + if( localVarContentType.find(localVarResponseHttpContentType) == std::string::npos ) { throw ApiException(500 - , utility::conversions::to_string_t("error calling createUsersWithArrayInput: unexpected response type: ") + contentType - , std::make_shared(response.extract_utf8string(true).get())); + , utility::conversions::to_string_t("error calling createUsersWithArrayInput: unexpected response type: ") + localVarContentType + , std::make_shared(localVarResponse.extract_utf8string(true).get())); } } - return response.extract_string(); + return localVarResponse.extract_string(); }) - .then([=](utility::string_t response) + .then([=](utility::string_t localVarResponse) { return void(); }); @@ -274,81 +274,81 @@ pplx::task UserApi::createUsersWithListInput(std::vector apiConfiguration( m_ApiClient->getConfiguration() ); - utility::string_t path = utility::conversions::to_string_t("/user/createWithList"); + std::shared_ptr localVarApiConfiguration( m_ApiClient->getConfiguration() ); + utility::string_t localVarPath = utility::conversions::to_string_t("/user/createWithList"); - std::map queryParams; - std::map headerParams( apiConfiguration->getDefaultHeaders() ); - std::map formParams; - std::map> fileParams; + std::map localVarQueryParams; + std::map localVarHeaderParams( localVarApiConfiguration->getDefaultHeaders() ); + std::map localVarFormParams; + std::map> localVarFileParams; - std::unordered_set responseHttpContentTypes; + std::unordered_set localVarResponseHttpContentTypes; - utility::string_t responseHttpContentType; + utility::string_t localVarResponseHttpContentType; // use JSON if possible - if ( responseHttpContentTypes.size() == 0 ) + if ( localVarResponseHttpContentTypes.size() == 0 ) { - responseHttpContentType = utility::conversions::to_string_t("application/json"); + localVarResponseHttpContentType = utility::conversions::to_string_t("application/json"); } // JSON - else if ( responseHttpContentTypes.find(utility::conversions::to_string_t("application/json")) != responseHttpContentTypes.end() ) + else if ( localVarResponseHttpContentTypes.find(utility::conversions::to_string_t("application/json")) != localVarResponseHttpContentTypes.end() ) { - responseHttpContentType = utility::conversions::to_string_t("application/json"); + localVarResponseHttpContentType = utility::conversions::to_string_t("application/json"); } // multipart formdata - else if( responseHttpContentTypes.find(utility::conversions::to_string_t("multipart/form-data")) != responseHttpContentTypes.end() ) + else if( localVarResponseHttpContentTypes.find(utility::conversions::to_string_t("multipart/form-data")) != localVarResponseHttpContentTypes.end() ) { - responseHttpContentType = utility::conversions::to_string_t("multipart/form-data"); + localVarResponseHttpContentType = utility::conversions::to_string_t("multipart/form-data"); } else { throw ApiException(400, utility::conversions::to_string_t("UserApi->createUsersWithListInput does not produce any supported media type")); } - headerParams[utility::conversions::to_string_t("Accept")] = responseHttpContentType; + localVarHeaderParams[utility::conversions::to_string_t("Accept")] = localVarResponseHttpContentType; - std::unordered_set consumeHttpContentTypes; + std::unordered_set localVarConsumeHttpContentTypes; - std::shared_ptr httpBody; - utility::string_t requestHttpContentType; + std::shared_ptr localVarHttpBody; + utility::string_t localVarRequestHttpContentType; // use JSON if possible - if ( consumeHttpContentTypes.size() == 0 || consumeHttpContentTypes.find(utility::conversions::to_string_t("application/json")) != consumeHttpContentTypes.end() ) + if ( localVarConsumeHttpContentTypes.size() == 0 || localVarConsumeHttpContentTypes.find(utility::conversions::to_string_t("application/json")) != localVarConsumeHttpContentTypes.end() ) { - requestHttpContentType = utility::conversions::to_string_t("application/json"); - web::json::value json; + localVarRequestHttpContentType = utility::conversions::to_string_t("application/json"); + web::json::value localVarJson; { - std::vector jsonArray; - for( auto& item : user ) + std::vector localVarJsonArray; + for( auto& localVarItem : user ) { - jsonArray.push_back( item.get() ? item->toJson() : web::json::value::null() ); + localVarJsonArray.push_back( localVarItem.get() ? localVarItem->toJson() : web::json::value::null() ); } - json = web::json::value::array(jsonArray); + localVarJson = web::json::value::array(localVarJsonArray); } - httpBody = std::shared_ptr( new JsonBody( json ) ); + localVarHttpBody = std::shared_ptr( new JsonBody( localVarJson ) ); } // multipart formdata - else if( consumeHttpContentTypes.find(utility::conversions::to_string_t("multipart/form-data")) != consumeHttpContentTypes.end() ) + else if( localVarConsumeHttpContentTypes.find(utility::conversions::to_string_t("multipart/form-data")) != localVarConsumeHttpContentTypes.end() ) { - requestHttpContentType = utility::conversions::to_string_t("multipart/form-data"); - std::shared_ptr multipart(new MultipartFormData); + localVarRequestHttpContentType = utility::conversions::to_string_t("multipart/form-data"); + std::shared_ptr localVarMultipart(new MultipartFormData); { - std::vector jsonArray; - for( auto& item : user ) + std::vector localVarJsonArray; + for( auto& localVarItem : user ) { - jsonArray.push_back( item.get() ? item->toJson() : web::json::value::null() ); + localVarJsonArray.push_back( localVarItem.get() ? localVarItem->toJson() : web::json::value::null() ); } - multipart->add(ModelBase::toHttpContent(utility::conversions::to_string_t("user"), web::json::value::array(jsonArray), utility::conversions::to_string_t("application/json"))); + localVarMultipart->add(ModelBase::toHttpContent(utility::conversions::to_string_t("user"), web::json::value::array(localVarJsonArray), utility::conversions::to_string_t("application/json"))); } - httpBody = multipart; - requestHttpContentType += utility::conversions::to_string_t("; boundary=") + multipart->getBoundary(); + localVarHttpBody = localVarMultipart; + localVarRequestHttpContentType += utility::conversions::to_string_t("; boundary=") + localVarMultipart->getBoundary(); } else { @@ -356,36 +356,36 @@ pplx::task UserApi::createUsersWithListInput(std::vectorcallApi(path, utility::conversions::to_string_t("POST"), queryParams, httpBody, headerParams, formParams, fileParams, requestHttpContentType) - .then([=](web::http::http_response response) + return m_ApiClient->callApi(localVarPath, utility::conversions::to_string_t("POST"), localVarQueryParams, localVarHttpBody, localVarHeaderParams, localVarFormParams, localVarFileParams, localVarRequestHttpContentType) + .then([=](web::http::http_response localVarResponse) { // 1xx - informational : OK // 2xx - successful : OK // 3xx - redirection : OK // 4xx - client error : not OK // 5xx - client error : not OK - if (response.status_code() >= 400) + if (localVarResponse.status_code() >= 400) { - throw ApiException(response.status_code() - , utility::conversions::to_string_t("error calling createUsersWithListInput: ") + response.reason_phrase() - , std::make_shared(response.extract_utf8string(true).get())); + throw ApiException(localVarResponse.status_code() + , utility::conversions::to_string_t("error calling createUsersWithListInput: ") + localVarResponse.reason_phrase() + , std::make_shared(localVarResponse.extract_utf8string(true).get())); } // check response content type - if(response.headers().has(utility::conversions::to_string_t("Content-Type"))) + if(localVarResponse.headers().has(utility::conversions::to_string_t("Content-Type"))) { - utility::string_t contentType = response.headers()[utility::conversions::to_string_t("Content-Type")]; - if( contentType.find(responseHttpContentType) == std::string::npos ) + utility::string_t localVarContentType = localVarResponse.headers()[utility::conversions::to_string_t("Content-Type")]; + if( localVarContentType.find(localVarResponseHttpContentType) == std::string::npos ) { throw ApiException(500 - , utility::conversions::to_string_t("error calling createUsersWithListInput: unexpected response type: ") + contentType - , std::make_shared(response.extract_utf8string(true).get())); + , utility::conversions::to_string_t("error calling createUsersWithListInput: unexpected response type: ") + localVarContentType + , std::make_shared(localVarResponse.extract_utf8string(true).get())); } } - return response.extract_string(); + return localVarResponse.extract_string(); }) - .then([=](utility::string_t response) + .then([=](utility::string_t localVarResponse) { return void(); }); @@ -394,56 +394,56 @@ pplx::task UserApi::deleteUser(utility::string_t username) { - std::shared_ptr apiConfiguration( m_ApiClient->getConfiguration() ); - utility::string_t path = utility::conversions::to_string_t("/user/{username}"); - boost::replace_all(path, utility::conversions::to_string_t("{") + utility::conversions::to_string_t("username") + utility::conversions::to_string_t("}"), ApiClient::parameterToString(username)); + std::shared_ptr localVarApiConfiguration( m_ApiClient->getConfiguration() ); + utility::string_t localVarPath = utility::conversions::to_string_t("/user/{username}"); + boost::replace_all(localVarPath, utility::conversions::to_string_t("{") + utility::conversions::to_string_t("username") + utility::conversions::to_string_t("}"), ApiClient::parameterToString(username)); - std::map queryParams; - std::map headerParams( apiConfiguration->getDefaultHeaders() ); - std::map formParams; - std::map> fileParams; + std::map localVarQueryParams; + std::map localVarHeaderParams( localVarApiConfiguration->getDefaultHeaders() ); + std::map localVarFormParams; + std::map> localVarFileParams; - std::unordered_set responseHttpContentTypes; + std::unordered_set localVarResponseHttpContentTypes; - utility::string_t responseHttpContentType; + utility::string_t localVarResponseHttpContentType; // use JSON if possible - if ( responseHttpContentTypes.size() == 0 ) + if ( localVarResponseHttpContentTypes.size() == 0 ) { - responseHttpContentType = utility::conversions::to_string_t("application/json"); + localVarResponseHttpContentType = utility::conversions::to_string_t("application/json"); } // JSON - else if ( responseHttpContentTypes.find(utility::conversions::to_string_t("application/json")) != responseHttpContentTypes.end() ) + else if ( localVarResponseHttpContentTypes.find(utility::conversions::to_string_t("application/json")) != localVarResponseHttpContentTypes.end() ) { - responseHttpContentType = utility::conversions::to_string_t("application/json"); + localVarResponseHttpContentType = utility::conversions::to_string_t("application/json"); } // multipart formdata - else if( responseHttpContentTypes.find(utility::conversions::to_string_t("multipart/form-data")) != responseHttpContentTypes.end() ) + else if( localVarResponseHttpContentTypes.find(utility::conversions::to_string_t("multipart/form-data")) != localVarResponseHttpContentTypes.end() ) { - responseHttpContentType = utility::conversions::to_string_t("multipart/form-data"); + localVarResponseHttpContentType = utility::conversions::to_string_t("multipart/form-data"); } else { throw ApiException(400, utility::conversions::to_string_t("UserApi->deleteUser does not produce any supported media type")); } - headerParams[utility::conversions::to_string_t("Accept")] = responseHttpContentType; + localVarHeaderParams[utility::conversions::to_string_t("Accept")] = localVarResponseHttpContentType; - std::unordered_set consumeHttpContentTypes; + std::unordered_set localVarConsumeHttpContentTypes; - std::shared_ptr httpBody; - utility::string_t requestHttpContentType; + std::shared_ptr localVarHttpBody; + utility::string_t localVarRequestHttpContentType; // use JSON if possible - if ( consumeHttpContentTypes.size() == 0 || consumeHttpContentTypes.find(utility::conversions::to_string_t("application/json")) != consumeHttpContentTypes.end() ) + if ( localVarConsumeHttpContentTypes.size() == 0 || localVarConsumeHttpContentTypes.find(utility::conversions::to_string_t("application/json")) != localVarConsumeHttpContentTypes.end() ) { - requestHttpContentType = utility::conversions::to_string_t("application/json"); + localVarRequestHttpContentType = utility::conversions::to_string_t("application/json"); } // multipart formdata - else if( consumeHttpContentTypes.find(utility::conversions::to_string_t("multipart/form-data")) != consumeHttpContentTypes.end() ) + else if( localVarConsumeHttpContentTypes.find(utility::conversions::to_string_t("multipart/form-data")) != localVarConsumeHttpContentTypes.end() ) { - requestHttpContentType = utility::conversions::to_string_t("multipart/form-data"); + localVarRequestHttpContentType = utility::conversions::to_string_t("multipart/form-data"); } else { @@ -451,36 +451,36 @@ pplx::task UserApi::deleteUser(utility::string_t username) } - return m_ApiClient->callApi(path, utility::conversions::to_string_t("DELETE"), queryParams, httpBody, headerParams, formParams, fileParams, requestHttpContentType) - .then([=](web::http::http_response response) + return m_ApiClient->callApi(localVarPath, utility::conversions::to_string_t("DELETE"), localVarQueryParams, localVarHttpBody, localVarHeaderParams, localVarFormParams, localVarFileParams, localVarRequestHttpContentType) + .then([=](web::http::http_response localVarResponse) { // 1xx - informational : OK // 2xx - successful : OK // 3xx - redirection : OK // 4xx - client error : not OK // 5xx - client error : not OK - if (response.status_code() >= 400) + if (localVarResponse.status_code() >= 400) { - throw ApiException(response.status_code() - , utility::conversions::to_string_t("error calling deleteUser: ") + response.reason_phrase() - , std::make_shared(response.extract_utf8string(true).get())); + throw ApiException(localVarResponse.status_code() + , utility::conversions::to_string_t("error calling deleteUser: ") + localVarResponse.reason_phrase() + , std::make_shared(localVarResponse.extract_utf8string(true).get())); } // check response content type - if(response.headers().has(utility::conversions::to_string_t("Content-Type"))) + if(localVarResponse.headers().has(utility::conversions::to_string_t("Content-Type"))) { - utility::string_t contentType = response.headers()[utility::conversions::to_string_t("Content-Type")]; - if( contentType.find(responseHttpContentType) == std::string::npos ) + utility::string_t localVarContentType = localVarResponse.headers()[utility::conversions::to_string_t("Content-Type")]; + if( localVarContentType.find(localVarResponseHttpContentType) == std::string::npos ) { throw ApiException(500 - , utility::conversions::to_string_t("error calling deleteUser: unexpected response type: ") + contentType - , std::make_shared(response.extract_utf8string(true).get())); + , utility::conversions::to_string_t("error calling deleteUser: unexpected response type: ") + localVarContentType + , std::make_shared(localVarResponse.extract_utf8string(true).get())); } } - return response.extract_string(); + return localVarResponse.extract_string(); }) - .then([=](utility::string_t response) + .then([=](utility::string_t localVarResponse) { return void(); }); @@ -489,58 +489,58 @@ pplx::task> UserApi::getUserByName(utility::string_t usern { - std::shared_ptr apiConfiguration( m_ApiClient->getConfiguration() ); - utility::string_t path = utility::conversions::to_string_t("/user/{username}"); - boost::replace_all(path, utility::conversions::to_string_t("{") + utility::conversions::to_string_t("username") + utility::conversions::to_string_t("}"), ApiClient::parameterToString(username)); + std::shared_ptr localVarApiConfiguration( m_ApiClient->getConfiguration() ); + utility::string_t localVarPath = utility::conversions::to_string_t("/user/{username}"); + boost::replace_all(localVarPath, utility::conversions::to_string_t("{") + utility::conversions::to_string_t("username") + utility::conversions::to_string_t("}"), ApiClient::parameterToString(username)); - std::map queryParams; - std::map headerParams( apiConfiguration->getDefaultHeaders() ); - std::map formParams; - std::map> fileParams; + std::map localVarQueryParams; + std::map localVarHeaderParams( localVarApiConfiguration->getDefaultHeaders() ); + std::map localVarFormParams; + std::map> localVarFileParams; - std::unordered_set responseHttpContentTypes; - responseHttpContentTypes.insert( utility::conversions::to_string_t("application/xml") ); - responseHttpContentTypes.insert( utility::conversions::to_string_t("application/json") ); + std::unordered_set localVarResponseHttpContentTypes; + localVarResponseHttpContentTypes.insert( utility::conversions::to_string_t("application/xml") ); + localVarResponseHttpContentTypes.insert( utility::conversions::to_string_t("application/json") ); - utility::string_t responseHttpContentType; + utility::string_t localVarResponseHttpContentType; // use JSON if possible - if ( responseHttpContentTypes.size() == 0 ) + if ( localVarResponseHttpContentTypes.size() == 0 ) { - responseHttpContentType = utility::conversions::to_string_t("application/json"); + localVarResponseHttpContentType = utility::conversions::to_string_t("application/json"); } // JSON - else if ( responseHttpContentTypes.find(utility::conversions::to_string_t("application/json")) != responseHttpContentTypes.end() ) + else if ( localVarResponseHttpContentTypes.find(utility::conversions::to_string_t("application/json")) != localVarResponseHttpContentTypes.end() ) { - responseHttpContentType = utility::conversions::to_string_t("application/json"); + localVarResponseHttpContentType = utility::conversions::to_string_t("application/json"); } // multipart formdata - else if( responseHttpContentTypes.find(utility::conversions::to_string_t("multipart/form-data")) != responseHttpContentTypes.end() ) + else if( localVarResponseHttpContentTypes.find(utility::conversions::to_string_t("multipart/form-data")) != localVarResponseHttpContentTypes.end() ) { - responseHttpContentType = utility::conversions::to_string_t("multipart/form-data"); + localVarResponseHttpContentType = utility::conversions::to_string_t("multipart/form-data"); } else { throw ApiException(400, utility::conversions::to_string_t("UserApi->getUserByName does not produce any supported media type")); } - headerParams[utility::conversions::to_string_t("Accept")] = responseHttpContentType; + localVarHeaderParams[utility::conversions::to_string_t("Accept")] = localVarResponseHttpContentType; - std::unordered_set consumeHttpContentTypes; + std::unordered_set localVarConsumeHttpContentTypes; - std::shared_ptr httpBody; - utility::string_t requestHttpContentType; + std::shared_ptr localVarHttpBody; + utility::string_t localVarRequestHttpContentType; // use JSON if possible - if ( consumeHttpContentTypes.size() == 0 || consumeHttpContentTypes.find(utility::conversions::to_string_t("application/json")) != consumeHttpContentTypes.end() ) + if ( localVarConsumeHttpContentTypes.size() == 0 || localVarConsumeHttpContentTypes.find(utility::conversions::to_string_t("application/json")) != localVarConsumeHttpContentTypes.end() ) { - requestHttpContentType = utility::conversions::to_string_t("application/json"); + localVarRequestHttpContentType = utility::conversions::to_string_t("application/json"); } // multipart formdata - else if( consumeHttpContentTypes.find(utility::conversions::to_string_t("multipart/form-data")) != consumeHttpContentTypes.end() ) + else if( localVarConsumeHttpContentTypes.find(utility::conversions::to_string_t("multipart/form-data")) != localVarConsumeHttpContentTypes.end() ) { - requestHttpContentType = utility::conversions::to_string_t("multipart/form-data"); + localVarRequestHttpContentType = utility::conversions::to_string_t("multipart/form-data"); } else { @@ -548,46 +548,46 @@ pplx::task> UserApi::getUserByName(utility::string_t usern } - return m_ApiClient->callApi(path, utility::conversions::to_string_t("GET"), queryParams, httpBody, headerParams, formParams, fileParams, requestHttpContentType) - .then([=](web::http::http_response response) + return m_ApiClient->callApi(localVarPath, utility::conversions::to_string_t("GET"), localVarQueryParams, localVarHttpBody, localVarHeaderParams, localVarFormParams, localVarFileParams, localVarRequestHttpContentType) + .then([=](web::http::http_response localVarResponse) { // 1xx - informational : OK // 2xx - successful : OK // 3xx - redirection : OK // 4xx - client error : not OK // 5xx - client error : not OK - if (response.status_code() >= 400) + if (localVarResponse.status_code() >= 400) { - throw ApiException(response.status_code() - , utility::conversions::to_string_t("error calling getUserByName: ") + response.reason_phrase() - , std::make_shared(response.extract_utf8string(true).get())); + throw ApiException(localVarResponse.status_code() + , utility::conversions::to_string_t("error calling getUserByName: ") + localVarResponse.reason_phrase() + , std::make_shared(localVarResponse.extract_utf8string(true).get())); } // check response content type - if(response.headers().has(utility::conversions::to_string_t("Content-Type"))) + if(localVarResponse.headers().has(utility::conversions::to_string_t("Content-Type"))) { - utility::string_t contentType = response.headers()[utility::conversions::to_string_t("Content-Type")]; - if( contentType.find(responseHttpContentType) == std::string::npos ) + utility::string_t localVarContentType = localVarResponse.headers()[utility::conversions::to_string_t("Content-Type")]; + if( localVarContentType.find(localVarResponseHttpContentType) == std::string::npos ) { throw ApiException(500 - , utility::conversions::to_string_t("error calling getUserByName: unexpected response type: ") + contentType - , std::make_shared(response.extract_utf8string(true).get())); + , utility::conversions::to_string_t("error calling getUserByName: unexpected response type: ") + localVarContentType + , std::make_shared(localVarResponse.extract_utf8string(true).get())); } } - return response.extract_string(); + return localVarResponse.extract_string(); }) - .then([=](utility::string_t response) + .then([=](utility::string_t localVarResponse) { - std::shared_ptr result(new User()); + std::shared_ptr localVarResult(new User()); - if(responseHttpContentType == utility::conversions::to_string_t("application/json")) + if(localVarResponseHttpContentType == utility::conversions::to_string_t("application/json")) { - web::json::value json = web::json::value::parse(response); + web::json::value localVarJson = web::json::value::parse(localVarResponse); - result->fromJson(json); + localVarResult->fromJson(localVarJson); } - // else if(responseHttpContentType == utility::conversions::to_string_t("multipart/form-data")) + // else if(localVarResponseHttpContentType == utility::conversions::to_string_t("multipart/form-data")) // { // TODO multipart response parsing // } @@ -597,75 +597,75 @@ pplx::task> UserApi::getUserByName(utility::string_t usern , utility::conversions::to_string_t("error calling getUserByName: unsupported response type")); } - return result; + return localVarResult; }); } pplx::task UserApi::loginUser(utility::string_t username, utility::string_t password) { - std::shared_ptr apiConfiguration( m_ApiClient->getConfiguration() ); - utility::string_t path = utility::conversions::to_string_t("/user/login"); + std::shared_ptr localVarApiConfiguration( m_ApiClient->getConfiguration() ); + utility::string_t localVarPath = utility::conversions::to_string_t("/user/login"); - std::map queryParams; - std::map headerParams( apiConfiguration->getDefaultHeaders() ); - std::map formParams; - std::map> fileParams; + std::map localVarQueryParams; + std::map localVarHeaderParams( localVarApiConfiguration->getDefaultHeaders() ); + std::map localVarFormParams; + std::map> localVarFileParams; - std::unordered_set responseHttpContentTypes; - responseHttpContentTypes.insert( utility::conversions::to_string_t("application/xml") ); - responseHttpContentTypes.insert( utility::conversions::to_string_t("application/json") ); + std::unordered_set localVarResponseHttpContentTypes; + localVarResponseHttpContentTypes.insert( utility::conversions::to_string_t("application/xml") ); + localVarResponseHttpContentTypes.insert( utility::conversions::to_string_t("application/json") ); - utility::string_t responseHttpContentType; + utility::string_t localVarResponseHttpContentType; // use JSON if possible - if ( responseHttpContentTypes.size() == 0 ) + if ( localVarResponseHttpContentTypes.size() == 0 ) { - responseHttpContentType = utility::conversions::to_string_t("text/plain"); + localVarResponseHttpContentType = utility::conversions::to_string_t("text/plain"); } // JSON - else if ( responseHttpContentTypes.find(utility::conversions::to_string_t("application/json")) != responseHttpContentTypes.end() ) + else if ( localVarResponseHttpContentTypes.find(utility::conversions::to_string_t("application/json")) != localVarResponseHttpContentTypes.end() ) { - responseHttpContentType = utility::conversions::to_string_t("application/json"); + localVarResponseHttpContentType = utility::conversions::to_string_t("application/json"); } // multipart formdata - else if( responseHttpContentTypes.find(utility::conversions::to_string_t("multipart/form-data")) != responseHttpContentTypes.end() ) + else if( localVarResponseHttpContentTypes.find(utility::conversions::to_string_t("multipart/form-data")) != localVarResponseHttpContentTypes.end() ) { - responseHttpContentType = utility::conversions::to_string_t("multipart/form-data"); + localVarResponseHttpContentType = utility::conversions::to_string_t("multipart/form-data"); } // plain text - else if( responseHttpContentTypes.find(utility::conversions::to_string_t("text/plain")) != responseHttpContentTypes.end() ) + else if( localVarResponseHttpContentTypes.find(utility::conversions::to_string_t("text/plain")) != localVarResponseHttpContentTypes.end() ) { - responseHttpContentType = utility::conversions::to_string_t("text/plain"); + localVarResponseHttpContentType = utility::conversions::to_string_t("text/plain"); } else { throw ApiException(400, utility::conversions::to_string_t("UserApi->loginUser does not produce any supported media type")); } - headerParams[utility::conversions::to_string_t("Accept")] = responseHttpContentType; + localVarHeaderParams[utility::conversions::to_string_t("Accept")] = localVarResponseHttpContentType; - std::unordered_set consumeHttpContentTypes; + std::unordered_set localVarConsumeHttpContentTypes; { - queryParams[utility::conversions::to_string_t("username")] = ApiClient::parameterToString(username); + localVarQueryParams[utility::conversions::to_string_t("username")] = ApiClient::parameterToString(username); } { - queryParams[utility::conversions::to_string_t("password")] = ApiClient::parameterToString(password); + localVarQueryParams[utility::conversions::to_string_t("password")] = ApiClient::parameterToString(password); } - std::shared_ptr httpBody; - utility::string_t requestHttpContentType; + std::shared_ptr localVarHttpBody; + utility::string_t localVarRequestHttpContentType; // use JSON if possible - if ( consumeHttpContentTypes.size() == 0 || consumeHttpContentTypes.find(utility::conversions::to_string_t("application/json")) != consumeHttpContentTypes.end() ) + if ( localVarConsumeHttpContentTypes.size() == 0 || localVarConsumeHttpContentTypes.find(utility::conversions::to_string_t("application/json")) != localVarConsumeHttpContentTypes.end() ) { - requestHttpContentType = utility::conversions::to_string_t("application/json"); + localVarRequestHttpContentType = utility::conversions::to_string_t("application/json"); } // multipart formdata - else if( consumeHttpContentTypes.find(utility::conversions::to_string_t("multipart/form-data")) != consumeHttpContentTypes.end() ) + else if( localVarConsumeHttpContentTypes.find(utility::conversions::to_string_t("multipart/form-data")) != localVarConsumeHttpContentTypes.end() ) { - requestHttpContentType = utility::conversions::to_string_t("multipart/form-data"); + localVarRequestHttpContentType = utility::conversions::to_string_t("multipart/form-data"); } else { @@ -673,51 +673,51 @@ pplx::task UserApi::loginUser(utility::string_t username, uti } - return m_ApiClient->callApi(path, utility::conversions::to_string_t("GET"), queryParams, httpBody, headerParams, formParams, fileParams, requestHttpContentType) - .then([=](web::http::http_response response) + return m_ApiClient->callApi(localVarPath, utility::conversions::to_string_t("GET"), localVarQueryParams, localVarHttpBody, localVarHeaderParams, localVarFormParams, localVarFileParams, localVarRequestHttpContentType) + .then([=](web::http::http_response localVarResponse) { // 1xx - informational : OK // 2xx - successful : OK // 3xx - redirection : OK // 4xx - client error : not OK // 5xx - client error : not OK - if (response.status_code() >= 400) + if (localVarResponse.status_code() >= 400) { - throw ApiException(response.status_code() - , utility::conversions::to_string_t("error calling loginUser: ") + response.reason_phrase() - , std::make_shared(response.extract_utf8string(true).get())); + throw ApiException(localVarResponse.status_code() + , utility::conversions::to_string_t("error calling loginUser: ") + localVarResponse.reason_phrase() + , std::make_shared(localVarResponse.extract_utf8string(true).get())); } // check response content type - if(response.headers().has(utility::conversions::to_string_t("Content-Type"))) + if(localVarResponse.headers().has(utility::conversions::to_string_t("Content-Type"))) { - utility::string_t contentType = response.headers()[utility::conversions::to_string_t("Content-Type")]; - if( contentType.find(responseHttpContentType) == std::string::npos ) + utility::string_t localVarContentType = localVarResponse.headers()[utility::conversions::to_string_t("Content-Type")]; + if( localVarContentType.find(localVarResponseHttpContentType) == std::string::npos ) { throw ApiException(500 - , utility::conversions::to_string_t("error calling loginUser: unexpected response type: ") + contentType - , std::make_shared(response.extract_utf8string(true).get())); + , utility::conversions::to_string_t("error calling loginUser: unexpected response type: ") + localVarContentType + , std::make_shared(localVarResponse.extract_utf8string(true).get())); } } - return response.extract_string(); + return localVarResponse.extract_string(); }) - .then([=](utility::string_t response) + .then([=](utility::string_t localVarResponse) { - utility::string_t result(utility::conversions::to_string_t("")); + utility::string_t localVarResult(utility::conversions::to_string_t("")); - if(responseHttpContentType == utility::conversions::to_string_t("application/json")) + if(localVarResponseHttpContentType == utility::conversions::to_string_t("application/json")) { - web::json::value json = web::json::value::parse(response); + web::json::value localVarJson = web::json::value::parse(localVarResponse); - result = ModelBase::stringFromJson(json); + localVarResult = ModelBase::stringFromJson(localVarJson); } - else if(responseHttpContentType == utility::conversions::to_string_t("text/plain")) + else if(localVarResponseHttpContentType == utility::conversions::to_string_t("text/plain")) { - result = response; + localVarResult = localVarResponse; } - // else if(responseHttpContentType == utility::conversions::to_string_t("multipart/form-data")) + // else if(localVarResponseHttpContentType == utility::conversions::to_string_t("multipart/form-data")) // { // TODO multipart response parsing // } @@ -727,62 +727,62 @@ pplx::task UserApi::loginUser(utility::string_t username, uti , utility::conversions::to_string_t("error calling loginUser: unsupported response type")); } - return result; + return localVarResult; }); } pplx::task UserApi::logoutUser() { - std::shared_ptr apiConfiguration( m_ApiClient->getConfiguration() ); - utility::string_t path = utility::conversions::to_string_t("/user/logout"); + std::shared_ptr localVarApiConfiguration( m_ApiClient->getConfiguration() ); + utility::string_t localVarPath = utility::conversions::to_string_t("/user/logout"); - std::map queryParams; - std::map headerParams( apiConfiguration->getDefaultHeaders() ); - std::map formParams; - std::map> fileParams; + std::map localVarQueryParams; + std::map localVarHeaderParams( localVarApiConfiguration->getDefaultHeaders() ); + std::map localVarFormParams; + std::map> localVarFileParams; - std::unordered_set responseHttpContentTypes; + std::unordered_set localVarResponseHttpContentTypes; - utility::string_t responseHttpContentType; + utility::string_t localVarResponseHttpContentType; // use JSON if possible - if ( responseHttpContentTypes.size() == 0 ) + if ( localVarResponseHttpContentTypes.size() == 0 ) { - responseHttpContentType = utility::conversions::to_string_t("application/json"); + localVarResponseHttpContentType = utility::conversions::to_string_t("application/json"); } // JSON - else if ( responseHttpContentTypes.find(utility::conversions::to_string_t("application/json")) != responseHttpContentTypes.end() ) + else if ( localVarResponseHttpContentTypes.find(utility::conversions::to_string_t("application/json")) != localVarResponseHttpContentTypes.end() ) { - responseHttpContentType = utility::conversions::to_string_t("application/json"); + localVarResponseHttpContentType = utility::conversions::to_string_t("application/json"); } // multipart formdata - else if( responseHttpContentTypes.find(utility::conversions::to_string_t("multipart/form-data")) != responseHttpContentTypes.end() ) + else if( localVarResponseHttpContentTypes.find(utility::conversions::to_string_t("multipart/form-data")) != localVarResponseHttpContentTypes.end() ) { - responseHttpContentType = utility::conversions::to_string_t("multipart/form-data"); + localVarResponseHttpContentType = utility::conversions::to_string_t("multipart/form-data"); } else { throw ApiException(400, utility::conversions::to_string_t("UserApi->logoutUser does not produce any supported media type")); } - headerParams[utility::conversions::to_string_t("Accept")] = responseHttpContentType; + localVarHeaderParams[utility::conversions::to_string_t("Accept")] = localVarResponseHttpContentType; - std::unordered_set consumeHttpContentTypes; + std::unordered_set localVarConsumeHttpContentTypes; - std::shared_ptr httpBody; - utility::string_t requestHttpContentType; + std::shared_ptr localVarHttpBody; + utility::string_t localVarRequestHttpContentType; // use JSON if possible - if ( consumeHttpContentTypes.size() == 0 || consumeHttpContentTypes.find(utility::conversions::to_string_t("application/json")) != consumeHttpContentTypes.end() ) + if ( localVarConsumeHttpContentTypes.size() == 0 || localVarConsumeHttpContentTypes.find(utility::conversions::to_string_t("application/json")) != localVarConsumeHttpContentTypes.end() ) { - requestHttpContentType = utility::conversions::to_string_t("application/json"); + localVarRequestHttpContentType = utility::conversions::to_string_t("application/json"); } // multipart formdata - else if( consumeHttpContentTypes.find(utility::conversions::to_string_t("multipart/form-data")) != consumeHttpContentTypes.end() ) + else if( localVarConsumeHttpContentTypes.find(utility::conversions::to_string_t("multipart/form-data")) != localVarConsumeHttpContentTypes.end() ) { - requestHttpContentType = utility::conversions::to_string_t("multipart/form-data"); + localVarRequestHttpContentType = utility::conversions::to_string_t("multipart/form-data"); } else { @@ -790,36 +790,36 @@ pplx::task UserApi::logoutUser() } - return m_ApiClient->callApi(path, utility::conversions::to_string_t("GET"), queryParams, httpBody, headerParams, formParams, fileParams, requestHttpContentType) - .then([=](web::http::http_response response) + return m_ApiClient->callApi(localVarPath, utility::conversions::to_string_t("GET"), localVarQueryParams, localVarHttpBody, localVarHeaderParams, localVarFormParams, localVarFileParams, localVarRequestHttpContentType) + .then([=](web::http::http_response localVarResponse) { // 1xx - informational : OK // 2xx - successful : OK // 3xx - redirection : OK // 4xx - client error : not OK // 5xx - client error : not OK - if (response.status_code() >= 400) + if (localVarResponse.status_code() >= 400) { - throw ApiException(response.status_code() - , utility::conversions::to_string_t("error calling logoutUser: ") + response.reason_phrase() - , std::make_shared(response.extract_utf8string(true).get())); + throw ApiException(localVarResponse.status_code() + , utility::conversions::to_string_t("error calling logoutUser: ") + localVarResponse.reason_phrase() + , std::make_shared(localVarResponse.extract_utf8string(true).get())); } // check response content type - if(response.headers().has(utility::conversions::to_string_t("Content-Type"))) + if(localVarResponse.headers().has(utility::conversions::to_string_t("Content-Type"))) { - utility::string_t contentType = response.headers()[utility::conversions::to_string_t("Content-Type")]; - if( contentType.find(responseHttpContentType) == std::string::npos ) + utility::string_t localVarContentType = localVarResponse.headers()[utility::conversions::to_string_t("Content-Type")]; + if( localVarContentType.find(localVarResponseHttpContentType) == std::string::npos ) { throw ApiException(500 - , utility::conversions::to_string_t("error calling logoutUser: unexpected response type: ") + contentType - , std::make_shared(response.extract_utf8string(true).get())); + , utility::conversions::to_string_t("error calling logoutUser: unexpected response type: ") + localVarContentType + , std::make_shared(localVarResponse.extract_utf8string(true).get())); } } - return response.extract_string(); + return localVarResponse.extract_string(); }) - .then([=](utility::string_t response) + .then([=](utility::string_t localVarResponse) { return void(); }); @@ -834,71 +834,71 @@ pplx::task UserApi::updateUser(utility::string_t username, std::shared_ptr } - std::shared_ptr apiConfiguration( m_ApiClient->getConfiguration() ); - utility::string_t path = utility::conversions::to_string_t("/user/{username}"); - boost::replace_all(path, utility::conversions::to_string_t("{") + utility::conversions::to_string_t("username") + utility::conversions::to_string_t("}"), ApiClient::parameterToString(username)); + std::shared_ptr localVarApiConfiguration( m_ApiClient->getConfiguration() ); + utility::string_t localVarPath = utility::conversions::to_string_t("/user/{username}"); + boost::replace_all(localVarPath, utility::conversions::to_string_t("{") + utility::conversions::to_string_t("username") + utility::conversions::to_string_t("}"), ApiClient::parameterToString(username)); - std::map queryParams; - std::map headerParams( apiConfiguration->getDefaultHeaders() ); - std::map formParams; - std::map> fileParams; + std::map localVarQueryParams; + std::map localVarHeaderParams( localVarApiConfiguration->getDefaultHeaders() ); + std::map localVarFormParams; + std::map> localVarFileParams; - std::unordered_set responseHttpContentTypes; + std::unordered_set localVarResponseHttpContentTypes; - utility::string_t responseHttpContentType; + utility::string_t localVarResponseHttpContentType; // use JSON if possible - if ( responseHttpContentTypes.size() == 0 ) + if ( localVarResponseHttpContentTypes.size() == 0 ) { - responseHttpContentType = utility::conversions::to_string_t("application/json"); + localVarResponseHttpContentType = utility::conversions::to_string_t("application/json"); } // JSON - else if ( responseHttpContentTypes.find(utility::conversions::to_string_t("application/json")) != responseHttpContentTypes.end() ) + else if ( localVarResponseHttpContentTypes.find(utility::conversions::to_string_t("application/json")) != localVarResponseHttpContentTypes.end() ) { - responseHttpContentType = utility::conversions::to_string_t("application/json"); + localVarResponseHttpContentType = utility::conversions::to_string_t("application/json"); } // multipart formdata - else if( responseHttpContentTypes.find(utility::conversions::to_string_t("multipart/form-data")) != responseHttpContentTypes.end() ) + else if( localVarResponseHttpContentTypes.find(utility::conversions::to_string_t("multipart/form-data")) != localVarResponseHttpContentTypes.end() ) { - responseHttpContentType = utility::conversions::to_string_t("multipart/form-data"); + localVarResponseHttpContentType = utility::conversions::to_string_t("multipart/form-data"); } else { throw ApiException(400, utility::conversions::to_string_t("UserApi->updateUser does not produce any supported media type")); } - headerParams[utility::conversions::to_string_t("Accept")] = responseHttpContentType; + localVarHeaderParams[utility::conversions::to_string_t("Accept")] = localVarResponseHttpContentType; - std::unordered_set consumeHttpContentTypes; + std::unordered_set localVarConsumeHttpContentTypes; - std::shared_ptr httpBody; - utility::string_t requestHttpContentType; + std::shared_ptr localVarHttpBody; + utility::string_t localVarRequestHttpContentType; // use JSON if possible - if ( consumeHttpContentTypes.size() == 0 || consumeHttpContentTypes.find(utility::conversions::to_string_t("application/json")) != consumeHttpContentTypes.end() ) + if ( localVarConsumeHttpContentTypes.size() == 0 || localVarConsumeHttpContentTypes.find(utility::conversions::to_string_t("application/json")) != localVarConsumeHttpContentTypes.end() ) { - requestHttpContentType = utility::conversions::to_string_t("application/json"); - web::json::value json; + localVarRequestHttpContentType = utility::conversions::to_string_t("application/json"); + web::json::value localVarJson; - json = ModelBase::toJson(user); + localVarJson = ModelBase::toJson(user); - httpBody = std::shared_ptr( new JsonBody( json ) ); + localVarHttpBody = std::shared_ptr( new JsonBody( localVarJson ) ); } // multipart formdata - else if( consumeHttpContentTypes.find(utility::conversions::to_string_t("multipart/form-data")) != consumeHttpContentTypes.end() ) + else if( localVarConsumeHttpContentTypes.find(utility::conversions::to_string_t("multipart/form-data")) != localVarConsumeHttpContentTypes.end() ) { - requestHttpContentType = utility::conversions::to_string_t("multipart/form-data"); - std::shared_ptr multipart(new MultipartFormData); + localVarRequestHttpContentType = utility::conversions::to_string_t("multipart/form-data"); + std::shared_ptr localVarMultipart(new MultipartFormData); if(user.get()) { - user->toMultipart(multipart, utility::conversions::to_string_t("user")); + user->toMultipart(localVarMultipart, utility::conversions::to_string_t("user")); } - httpBody = multipart; - requestHttpContentType += utility::conversions::to_string_t("; boundary=") + multipart->getBoundary(); + localVarHttpBody = localVarMultipart; + localVarRequestHttpContentType += utility::conversions::to_string_t("; boundary=") + localVarMultipart->getBoundary(); } else { @@ -906,36 +906,36 @@ pplx::task UserApi::updateUser(utility::string_t username, std::shared_ptr } - return m_ApiClient->callApi(path, utility::conversions::to_string_t("PUT"), queryParams, httpBody, headerParams, formParams, fileParams, requestHttpContentType) - .then([=](web::http::http_response response) + return m_ApiClient->callApi(localVarPath, utility::conversions::to_string_t("PUT"), localVarQueryParams, localVarHttpBody, localVarHeaderParams, localVarFormParams, localVarFileParams, localVarRequestHttpContentType) + .then([=](web::http::http_response localVarResponse) { // 1xx - informational : OK // 2xx - successful : OK // 3xx - redirection : OK // 4xx - client error : not OK // 5xx - client error : not OK - if (response.status_code() >= 400) + if (localVarResponse.status_code() >= 400) { - throw ApiException(response.status_code() - , utility::conversions::to_string_t("error calling updateUser: ") + response.reason_phrase() - , std::make_shared(response.extract_utf8string(true).get())); + throw ApiException(localVarResponse.status_code() + , utility::conversions::to_string_t("error calling updateUser: ") + localVarResponse.reason_phrase() + , std::make_shared(localVarResponse.extract_utf8string(true).get())); } // check response content type - if(response.headers().has(utility::conversions::to_string_t("Content-Type"))) + if(localVarResponse.headers().has(utility::conversions::to_string_t("Content-Type"))) { - utility::string_t contentType = response.headers()[utility::conversions::to_string_t("Content-Type")]; - if( contentType.find(responseHttpContentType) == std::string::npos ) + utility::string_t localVarContentType = localVarResponse.headers()[utility::conversions::to_string_t("Content-Type")]; + if( localVarContentType.find(localVarResponseHttpContentType) == std::string::npos ) { throw ApiException(500 - , utility::conversions::to_string_t("error calling updateUser: unexpected response type: ") + contentType - , std::make_shared(response.extract_utf8string(true).get())); + , utility::conversions::to_string_t("error calling updateUser: unexpected response type: ") + localVarContentType + , std::make_shared(localVarResponse.extract_utf8string(true).get())); } } - return response.extract_string(); + return localVarResponse.extract_string(); }) - .then([=](utility::string_t response) + .then([=](utility::string_t localVarResponse) { return void(); }); From 0f30a052b2b90a254820f4c2453ffba381cf4a72 Mon Sep 17 00:00:00 2001 From: William Cheng Date: Fri, 17 Aug 2018 17:22:30 +0800 Subject: [PATCH 04/15] Add an option to skip "form" model generation (#700) * add option to generate all models * update doc * rename option to skipFormModel * update petstore samples * Update doc * Update samples --- docs/customization.md | 8 + .../codegen/CodegenConstants.java | 1 + .../codegen/DefaultGenerator.java | 15 +- .../lib/OpenAPIPetstore/API/Fake.hs | 6 +- .../lib/OpenAPIPetstore/Model.hs | 259 +++++- .../lib/OpenAPIPetstore/ModelLens.hs | 144 ++++ .../haskell-http-client/tests/Instances.hs | 48 ++ .../haskell-http-client/tests/Test.hs | 6 + .../petstore/php/OpenAPIClient-php/README.md | 6 + .../php/OpenAPIClient-php/docs/Model/Body.md | 11 + .../php/OpenAPIClient-php/docs/Model/Body1.md | 11 + .../php/OpenAPIClient-php/docs/Model/Body2.md | 11 + .../php/OpenAPIClient-php/docs/Model/Body3.md | 23 + .../php/OpenAPIClient-php/docs/Model/Body4.md | 11 + .../php/OpenAPIClient-php/docs/Model/Body5.md | 11 + .../php/OpenAPIClient-php/lib/Model/Body.php | 327 +++++++ .../php/OpenAPIClient-php/lib/Model/Body1.php | 327 +++++++ .../php/OpenAPIClient-php/lib/Model/Body2.php | 385 +++++++++ .../php/OpenAPIClient-php/lib/Model/Body3.php | 805 ++++++++++++++++++ .../php/OpenAPIClient-php/lib/Model/Body4.php | 333 ++++++++ .../php/OpenAPIClient-php/lib/Model/Body5.php | 330 +++++++ .../test/Model/Body1Test.php | 92 ++ .../test/Model/Body2Test.php | 92 ++ .../test/Model/Body3Test.php | 176 ++++ .../test/Model/Body4Test.php | 92 ++ .../test/Model/Body5Test.php | 92 ++ .../OpenAPIClient-php/test/Model/BodyTest.php | 92 ++ 27 files changed, 3702 insertions(+), 12 deletions(-) create mode 100644 samples/openapi3/client/petstore/php/OpenAPIClient-php/docs/Model/Body.md create mode 100644 samples/openapi3/client/petstore/php/OpenAPIClient-php/docs/Model/Body1.md create mode 100644 samples/openapi3/client/petstore/php/OpenAPIClient-php/docs/Model/Body2.md create mode 100644 samples/openapi3/client/petstore/php/OpenAPIClient-php/docs/Model/Body3.md create mode 100644 samples/openapi3/client/petstore/php/OpenAPIClient-php/docs/Model/Body4.md create mode 100644 samples/openapi3/client/petstore/php/OpenAPIClient-php/docs/Model/Body5.md create mode 100644 samples/openapi3/client/petstore/php/OpenAPIClient-php/lib/Model/Body.php create mode 100644 samples/openapi3/client/petstore/php/OpenAPIClient-php/lib/Model/Body1.php create mode 100644 samples/openapi3/client/petstore/php/OpenAPIClient-php/lib/Model/Body2.php create mode 100644 samples/openapi3/client/petstore/php/OpenAPIClient-php/lib/Model/Body3.php create mode 100644 samples/openapi3/client/petstore/php/OpenAPIClient-php/lib/Model/Body4.php create mode 100644 samples/openapi3/client/petstore/php/OpenAPIClient-php/lib/Model/Body5.php create mode 100644 samples/openapi3/client/petstore/php/OpenAPIClient-php/test/Model/Body1Test.php create mode 100644 samples/openapi3/client/petstore/php/OpenAPIClient-php/test/Model/Body2Test.php create mode 100644 samples/openapi3/client/petstore/php/OpenAPIClient-php/test/Model/Body3Test.php create mode 100644 samples/openapi3/client/petstore/php/OpenAPIClient-php/test/Model/Body4Test.php create mode 100644 samples/openapi3/client/petstore/php/OpenAPIClient-php/test/Model/Body5Test.php create mode 100644 samples/openapi3/client/petstore/php/OpenAPIClient-php/test/Model/BodyTest.php diff --git a/docs/customization.md b/docs/customization.md index ec1a534c98da..b9254eab691a 100644 --- a/docs/customization.md +++ b/docs/customization.md @@ -106,6 +106,14 @@ java -Dapis -DmodelTests=false {opts} When using selective generation, _only_ the templates needed for the specific generation will be used. +To skip models defined as the form parameters in "requestBody", please use `skipFormModel` (default to false) (this option is introduced at v3.2.2) + +```sh +java -DskipFormModel=true +``` + +This option will be helpful to skip model generation due to the form parameter, which is defined differently in OAS3 as there's no form parameter in OAS3 + ### Ignore file format OpenAPI Generator supports a `.openapi-generator-ignore` file, similar to `.gitignore` or `.dockerignore` you're probably already familiar with. diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/CodegenConstants.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/CodegenConstants.java index 9aa86e736451..d96fda52687b 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/CodegenConstants.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/CodegenConstants.java @@ -31,6 +31,7 @@ public class CodegenConstants { public static final String API_TESTS = "apiTests"; public static final String API_DOCS = "apiDocs"; public static final String WITH_XML = "withXml"; + public static final String SKIP_FORM_MODEL = "skipFormModel"; /* /end System Properties */ public static final String API_PACKAGE = "apiPackage"; diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/DefaultGenerator.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/DefaultGenerator.java index 1ba9611cfd36..b583079e0ff5 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/DefaultGenerator.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/DefaultGenerator.java @@ -286,7 +286,7 @@ private void generateModelTests(List files, Map models, St private void generateModelDocumentation(List files, Map models, String modelName) throws IOException { for (String templateName : config.modelDocTemplateFiles().keySet()) { String docExtension = config.getDocExtension(); - String suffix = docExtension!=null ? docExtension : config.modelDocTemplateFiles().get(templateName); + String suffix = docExtension != null ? docExtension : config.modelDocTemplateFiles().get(templateName); String filename = config.modelDocFileFolder() + File.separator + config.toModelDocFilename(modelName) + suffix; if (!config.shouldOverwrite(filename)) { LOGGER.info("Skipped overwriting " + filename); @@ -382,6 +382,10 @@ private Model getParent(Model model) { } */ }); + Boolean skipFormModel = System.getProperty(CodegenConstants.SKIP_FORM_MODEL) != null ? + Boolean.valueOf(System.getProperty(CodegenConstants.SKIP_FORM_MODEL)) : + getGeneratorPropertyDefaultSwitch(CodegenConstants.SKIP_FORM_MODEL, false); + // process models only for (String name : modelKeys) { try { @@ -393,8 +397,13 @@ private Model getParent(Model model) { // don't generate models that are not used as object (e.g. form parameters) if (unusedModels.contains(name)) { - LOGGER.debug("Model " + name + " not generated since it's marked as unused (due to form parameters)"); - continue; + if (Boolean.FALSE.equals(skipFormModel)) { + // if skipFormModel sets to true, still generate the model and log the result + LOGGER.info("Model " + name + " (marked as unused due to form parameters) is generated due to skipFormModel=false (default)"); + } else { + LOGGER.info("Model " + name + " not generated since it's marked as unused (due to form parameters) and skipFormModel set to true"); + continue; + } } Schema schema = schemas.get(name); diff --git a/samples/client/petstore/haskell-http-client/lib/OpenAPIPetstore/API/Fake.hs b/samples/client/petstore/haskell-http-client/lib/OpenAPIPetstore/API/Fake.hs index 98881805310e..51f5f5e51c7c 100644 --- a/samples/client/petstore/haskell-http-client/lib/OpenAPIPetstore/API/Fake.hs +++ b/samples/client/petstore/haskell-http-client/lib/OpenAPIPetstore/API/Fake.hs @@ -73,7 +73,7 @@ fakeOuterBooleanSerialize _ = data FakeOuterBooleanSerialize -- | /Body Param/ "body" - Input boolean as post body -instance HasBodyParam FakeOuterBooleanSerialize BodyBool +instance HasBodyParam FakeOuterBooleanSerialize Body8 -- | @application/json@ instance Consumes FakeOuterBooleanSerialize MimeJSON @@ -123,7 +123,7 @@ fakeOuterNumberSerialize _ = data FakeOuterNumberSerialize -- | /Body Param/ "body" - Input number as post body -instance HasBodyParam FakeOuterNumberSerialize Body +instance HasBodyParam FakeOuterNumberSerialize Body6 -- | @application/json@ instance Consumes FakeOuterNumberSerialize MimeJSON @@ -148,7 +148,7 @@ fakeOuterStringSerialize _ = data FakeOuterStringSerialize -- | /Body Param/ "body" - Input string as post body -instance HasBodyParam FakeOuterStringSerialize BodyText +instance HasBodyParam FakeOuterStringSerialize Body7 -- | @application/json@ instance Consumes FakeOuterStringSerialize MimeJSON diff --git a/samples/client/petstore/haskell-http-client/lib/OpenAPIPetstore/Model.hs b/samples/client/petstore/haskell-http-client/lib/OpenAPIPetstore/Model.hs index cb46c7b8b2c5..f4a0f43dbada 100644 --- a/samples/client/petstore/haskell-http-client/lib/OpenAPIPetstore/Model.hs +++ b/samples/client/petstore/haskell-http-client/lib/OpenAPIPetstore/Model.hs @@ -72,14 +72,14 @@ newtype AdditionalMetadata = AdditionalMetadata { unAdditionalMetadata :: Text } -- ** ApiKey newtype ApiKey = ApiKey { unApiKey :: Text } deriving (P.Eq, P.Show) --- ** Body -newtype Body = Body { unBody :: Double } deriving (P.Eq, P.Show, A.ToJSON) +-- ** Body6 +newtype Body6 = Body6 { unBody6 :: Double } deriving (P.Eq, P.Show, A.ToJSON) --- ** BodyBool -newtype BodyBool = BodyBool { unBodyBool :: Bool } deriving (P.Eq, P.Show, A.ToJSON) +-- ** Body7 +newtype Body7 = Body7 { unBody7 :: Text } deriving (P.Eq, P.Show, A.ToJSON) --- ** BodyText -newtype BodyText = BodyText { unBodyText :: Text } deriving (P.Eq, P.Show, A.ToJSON) +-- ** Body8 +newtype Body8 = Body8 { unBody8 :: Bool } deriving (P.Eq, P.Show, A.ToJSON) -- ** Byte newtype Byte = Byte { unByte :: ByteArray } deriving (P.Eq, P.Show) @@ -416,6 +416,253 @@ mkArrayTest = , arrayTestArrayArrayOfModel = Nothing } +-- ** Body +-- | Body +data Body = Body + { bodyName :: !(Maybe Text) -- ^ "name" - Updated name of the pet + , bodyStatus :: !(Maybe Text) -- ^ "status" - Updated status of the pet + } deriving (P.Show, P.Eq, P.Typeable) + +-- | FromJSON Body +instance A.FromJSON Body where + parseJSON = A.withObject "Body" $ \o -> + Body + <$> (o .:? "name") + <*> (o .:? "status") + +-- | ToJSON Body +instance A.ToJSON Body where + toJSON Body {..} = + _omitNulls + [ "name" .= bodyName + , "status" .= bodyStatus + ] + + +-- | Construct a value of type 'Body' (by applying it's required fields, if any) +mkBody + :: Body +mkBody = + Body + { bodyName = Nothing + , bodyStatus = Nothing + } + +-- ** Body1 +-- | Body1 +data Body1 = Body1 + { body1AdditionalMetadata :: !(Maybe Text) -- ^ "additionalMetadata" - Additional data to pass to server + , body1File :: !(Maybe FilePath) -- ^ "file" - file to upload + } deriving (P.Show, P.Eq, P.Typeable) + +-- | FromJSON Body1 +instance A.FromJSON Body1 where + parseJSON = A.withObject "Body1" $ \o -> + Body1 + <$> (o .:? "additionalMetadata") + <*> (o .:? "file") + +-- | ToJSON Body1 +instance A.ToJSON Body1 where + toJSON Body1 {..} = + _omitNulls + [ "additionalMetadata" .= body1AdditionalMetadata + , "file" .= body1File + ] + + +-- | Construct a value of type 'Body1' (by applying it's required fields, if any) +mkBody1 + :: Body1 +mkBody1 = + Body1 + { body1AdditionalMetadata = Nothing + , body1File = Nothing + } + +-- ** Body2 +-- | Body2 +data Body2 = Body2 + { body2EnumFormStringArray :: !(Maybe [E'EnumFormStringArray]) -- ^ "enum_form_string_array" - Form parameter enum test (string array) + , body2EnumFormString :: !(Maybe E'EnumFormString) -- ^ "enum_form_string" - Form parameter enum test (string) + } deriving (P.Show, P.Eq, P.Typeable) + +-- | FromJSON Body2 +instance A.FromJSON Body2 where + parseJSON = A.withObject "Body2" $ \o -> + Body2 + <$> (o .:? "enum_form_string_array") + <*> (o .:? "enum_form_string") + +-- | ToJSON Body2 +instance A.ToJSON Body2 where + toJSON Body2 {..} = + _omitNulls + [ "enum_form_string_array" .= body2EnumFormStringArray + , "enum_form_string" .= body2EnumFormString + ] + + +-- | Construct a value of type 'Body2' (by applying it's required fields, if any) +mkBody2 + :: Body2 +mkBody2 = + Body2 + { body2EnumFormStringArray = Nothing + , body2EnumFormString = Nothing + } + +-- ** Body3 +-- | Body3 +data Body3 = Body3 + { body3Integer :: !(Maybe Int) -- ^ "integer" - None + , body3Int32 :: !(Maybe Int) -- ^ "int32" - None + , body3Int64 :: !(Maybe Integer) -- ^ "int64" - None + , body3Number :: !(Double) -- ^ /Required/ "number" - None + , body3Float :: !(Maybe Float) -- ^ "float" - None + , body3Double :: !(Double) -- ^ /Required/ "double" - None + , body3String :: !(Maybe Text) -- ^ "string" - None + , body3PatternWithoutDelimiter :: !(Text) -- ^ /Required/ "pattern_without_delimiter" - None + , body3Byte :: !(ByteArray) -- ^ /Required/ "byte" - None + , body3Binary :: !(Maybe FilePath) -- ^ "binary" - None + , body3Date :: !(Maybe Date) -- ^ "date" - None + , body3DateTime :: !(Maybe DateTime) -- ^ "dateTime" - None + , body3Password :: !(Maybe Text) -- ^ "password" - None + , body3Callback :: !(Maybe Text) -- ^ "callback" - None + } deriving (P.Show, P.Eq, P.Typeable) + +-- | FromJSON Body3 +instance A.FromJSON Body3 where + parseJSON = A.withObject "Body3" $ \o -> + Body3 + <$> (o .:? "integer") + <*> (o .:? "int32") + <*> (o .:? "int64") + <*> (o .: "number") + <*> (o .:? "float") + <*> (o .: "double") + <*> (o .:? "string") + <*> (o .: "pattern_without_delimiter") + <*> (o .: "byte") + <*> (o .:? "binary") + <*> (o .:? "date") + <*> (o .:? "dateTime") + <*> (o .:? "password") + <*> (o .:? "callback") + +-- | ToJSON Body3 +instance A.ToJSON Body3 where + toJSON Body3 {..} = + _omitNulls + [ "integer" .= body3Integer + , "int32" .= body3Int32 + , "int64" .= body3Int64 + , "number" .= body3Number + , "float" .= body3Float + , "double" .= body3Double + , "string" .= body3String + , "pattern_without_delimiter" .= body3PatternWithoutDelimiter + , "byte" .= body3Byte + , "binary" .= body3Binary + , "date" .= body3Date + , "dateTime" .= body3DateTime + , "password" .= body3Password + , "callback" .= body3Callback + ] + + +-- | Construct a value of type 'Body3' (by applying it's required fields, if any) +mkBody3 + :: Double -- ^ 'body3Number': None + -> Double -- ^ 'body3Double': None + -> Text -- ^ 'body3PatternWithoutDelimiter': None + -> ByteArray -- ^ 'body3Byte': None + -> Body3 +mkBody3 body3Number body3Double body3PatternWithoutDelimiter body3Byte = + Body3 + { body3Integer = Nothing + , body3Int32 = Nothing + , body3Int64 = Nothing + , body3Number + , body3Float = Nothing + , body3Double + , body3String = Nothing + , body3PatternWithoutDelimiter + , body3Byte + , body3Binary = Nothing + , body3Date = Nothing + , body3DateTime = Nothing + , body3Password = Nothing + , body3Callback = Nothing + } + +-- ** Body4 +-- | Body4 +data Body4 = Body4 + { body4Param :: !(Text) -- ^ /Required/ "param" - field1 + , body4Param2 :: !(Text) -- ^ /Required/ "param2" - field2 + } deriving (P.Show, P.Eq, P.Typeable) + +-- | FromJSON Body4 +instance A.FromJSON Body4 where + parseJSON = A.withObject "Body4" $ \o -> + Body4 + <$> (o .: "param") + <*> (o .: "param2") + +-- | ToJSON Body4 +instance A.ToJSON Body4 where + toJSON Body4 {..} = + _omitNulls + [ "param" .= body4Param + , "param2" .= body4Param2 + ] + + +-- | Construct a value of type 'Body4' (by applying it's required fields, if any) +mkBody4 + :: Text -- ^ 'body4Param': field1 + -> Text -- ^ 'body4Param2': field2 + -> Body4 +mkBody4 body4Param body4Param2 = + Body4 + { body4Param + , body4Param2 + } + +-- ** Body5 +-- | Body5 +data Body5 = Body5 + { body5AdditionalMetadata :: !(Maybe Text) -- ^ "additionalMetadata" - Additional data to pass to server + , body5RequiredFile :: !(FilePath) -- ^ /Required/ "requiredFile" - file to upload + } deriving (P.Show, P.Eq, P.Typeable) + +-- | FromJSON Body5 +instance A.FromJSON Body5 where + parseJSON = A.withObject "Body5" $ \o -> + Body5 + <$> (o .:? "additionalMetadata") + <*> (o .: "requiredFile") + +-- | ToJSON Body5 +instance A.ToJSON Body5 where + toJSON Body5 {..} = + _omitNulls + [ "additionalMetadata" .= body5AdditionalMetadata + , "requiredFile" .= body5RequiredFile + ] + + +-- | Construct a value of type 'Body5' (by applying it's required fields, if any) +mkBody5 + :: FilePath -- ^ 'body5RequiredFile': file to upload + -> Body5 +mkBody5 body5RequiredFile = + Body5 + { body5AdditionalMetadata = Nothing + , body5RequiredFile + } + -- ** Capitalization -- | Capitalization data Capitalization = Capitalization diff --git a/samples/client/petstore/haskell-http-client/lib/OpenAPIPetstore/ModelLens.hs b/samples/client/petstore/haskell-http-client/lib/OpenAPIPetstore/ModelLens.hs index f30ff167e37f..317dbe109c88 100644 --- a/samples/client/petstore/haskell-http-client/lib/OpenAPIPetstore/ModelLens.hs +++ b/samples/client/petstore/haskell-http-client/lib/OpenAPIPetstore/ModelLens.hs @@ -124,6 +124,150 @@ arrayTestArrayArrayOfModelL f ArrayTest{..} = (\arrayTestArrayArrayOfModel -> Ar +-- * Body + +-- | 'bodyName' Lens +bodyNameL :: Lens_' Body (Maybe Text) +bodyNameL f Body{..} = (\bodyName -> Body { bodyName, ..} ) <$> f bodyName +{-# INLINE bodyNameL #-} + +-- | 'bodyStatus' Lens +bodyStatusL :: Lens_' Body (Maybe Text) +bodyStatusL f Body{..} = (\bodyStatus -> Body { bodyStatus, ..} ) <$> f bodyStatus +{-# INLINE bodyStatusL #-} + + + +-- * Body1 + +-- | 'body1AdditionalMetadata' Lens +body1AdditionalMetadataL :: Lens_' Body1 (Maybe Text) +body1AdditionalMetadataL f Body1{..} = (\body1AdditionalMetadata -> Body1 { body1AdditionalMetadata, ..} ) <$> f body1AdditionalMetadata +{-# INLINE body1AdditionalMetadataL #-} + +-- | 'body1File' Lens +body1FileL :: Lens_' Body1 (Maybe FilePath) +body1FileL f Body1{..} = (\body1File -> Body1 { body1File, ..} ) <$> f body1File +{-# INLINE body1FileL #-} + + + +-- * Body2 + +-- | 'body2EnumFormStringArray' Lens +body2EnumFormStringArrayL :: Lens_' Body2 (Maybe [E'EnumFormStringArray]) +body2EnumFormStringArrayL f Body2{..} = (\body2EnumFormStringArray -> Body2 { body2EnumFormStringArray, ..} ) <$> f body2EnumFormStringArray +{-# INLINE body2EnumFormStringArrayL #-} + +-- | 'body2EnumFormString' Lens +body2EnumFormStringL :: Lens_' Body2 (Maybe E'EnumFormString) +body2EnumFormStringL f Body2{..} = (\body2EnumFormString -> Body2 { body2EnumFormString, ..} ) <$> f body2EnumFormString +{-# INLINE body2EnumFormStringL #-} + + + +-- * Body3 + +-- | 'body3Integer' Lens +body3IntegerL :: Lens_' Body3 (Maybe Int) +body3IntegerL f Body3{..} = (\body3Integer -> Body3 { body3Integer, ..} ) <$> f body3Integer +{-# INLINE body3IntegerL #-} + +-- | 'body3Int32' Lens +body3Int32L :: Lens_' Body3 (Maybe Int) +body3Int32L f Body3{..} = (\body3Int32 -> Body3 { body3Int32, ..} ) <$> f body3Int32 +{-# INLINE body3Int32L #-} + +-- | 'body3Int64' Lens +body3Int64L :: Lens_' Body3 (Maybe Integer) +body3Int64L f Body3{..} = (\body3Int64 -> Body3 { body3Int64, ..} ) <$> f body3Int64 +{-# INLINE body3Int64L #-} + +-- | 'body3Number' Lens +body3NumberL :: Lens_' Body3 (Double) +body3NumberL f Body3{..} = (\body3Number -> Body3 { body3Number, ..} ) <$> f body3Number +{-# INLINE body3NumberL #-} + +-- | 'body3Float' Lens +body3FloatL :: Lens_' Body3 (Maybe Float) +body3FloatL f Body3{..} = (\body3Float -> Body3 { body3Float, ..} ) <$> f body3Float +{-# INLINE body3FloatL #-} + +-- | 'body3Double' Lens +body3DoubleL :: Lens_' Body3 (Double) +body3DoubleL f Body3{..} = (\body3Double -> Body3 { body3Double, ..} ) <$> f body3Double +{-# INLINE body3DoubleL #-} + +-- | 'body3String' Lens +body3StringL :: Lens_' Body3 (Maybe Text) +body3StringL f Body3{..} = (\body3String -> Body3 { body3String, ..} ) <$> f body3String +{-# INLINE body3StringL #-} + +-- | 'body3PatternWithoutDelimiter' Lens +body3PatternWithoutDelimiterL :: Lens_' Body3 (Text) +body3PatternWithoutDelimiterL f Body3{..} = (\body3PatternWithoutDelimiter -> Body3 { body3PatternWithoutDelimiter, ..} ) <$> f body3PatternWithoutDelimiter +{-# INLINE body3PatternWithoutDelimiterL #-} + +-- | 'body3Byte' Lens +body3ByteL :: Lens_' Body3 (ByteArray) +body3ByteL f Body3{..} = (\body3Byte -> Body3 { body3Byte, ..} ) <$> f body3Byte +{-# INLINE body3ByteL #-} + +-- | 'body3Binary' Lens +body3BinaryL :: Lens_' Body3 (Maybe FilePath) +body3BinaryL f Body3{..} = (\body3Binary -> Body3 { body3Binary, ..} ) <$> f body3Binary +{-# INLINE body3BinaryL #-} + +-- | 'body3Date' Lens +body3DateL :: Lens_' Body3 (Maybe Date) +body3DateL f Body3{..} = (\body3Date -> Body3 { body3Date, ..} ) <$> f body3Date +{-# INLINE body3DateL #-} + +-- | 'body3DateTime' Lens +body3DateTimeL :: Lens_' Body3 (Maybe DateTime) +body3DateTimeL f Body3{..} = (\body3DateTime -> Body3 { body3DateTime, ..} ) <$> f body3DateTime +{-# INLINE body3DateTimeL #-} + +-- | 'body3Password' Lens +body3PasswordL :: Lens_' Body3 (Maybe Text) +body3PasswordL f Body3{..} = (\body3Password -> Body3 { body3Password, ..} ) <$> f body3Password +{-# INLINE body3PasswordL #-} + +-- | 'body3Callback' Lens +body3CallbackL :: Lens_' Body3 (Maybe Text) +body3CallbackL f Body3{..} = (\body3Callback -> Body3 { body3Callback, ..} ) <$> f body3Callback +{-# INLINE body3CallbackL #-} + + + +-- * Body4 + +-- | 'body4Param' Lens +body4ParamL :: Lens_' Body4 (Text) +body4ParamL f Body4{..} = (\body4Param -> Body4 { body4Param, ..} ) <$> f body4Param +{-# INLINE body4ParamL #-} + +-- | 'body4Param2' Lens +body4Param2L :: Lens_' Body4 (Text) +body4Param2L f Body4{..} = (\body4Param2 -> Body4 { body4Param2, ..} ) <$> f body4Param2 +{-# INLINE body4Param2L #-} + + + +-- * Body5 + +-- | 'body5AdditionalMetadata' Lens +body5AdditionalMetadataL :: Lens_' Body5 (Maybe Text) +body5AdditionalMetadataL f Body5{..} = (\body5AdditionalMetadata -> Body5 { body5AdditionalMetadata, ..} ) <$> f body5AdditionalMetadata +{-# INLINE body5AdditionalMetadataL #-} + +-- | 'body5RequiredFile' Lens +body5RequiredFileL :: Lens_' Body5 (FilePath) +body5RequiredFileL f Body5{..} = (\body5RequiredFile -> Body5 { body5RequiredFile, ..} ) <$> f body5RequiredFile +{-# INLINE body5RequiredFileL #-} + + + -- * Capitalization -- | 'capitalizationSmallCamel' Lens diff --git a/samples/client/petstore/haskell-http-client/tests/Instances.hs b/samples/client/petstore/haskell-http-client/tests/Instances.hs index 14cef8e188cb..6e54830ccfa3 100644 --- a/samples/client/petstore/haskell-http-client/tests/Instances.hs +++ b/samples/client/petstore/haskell-http-client/tests/Instances.hs @@ -130,6 +130,54 @@ instance Arbitrary ArrayTest where <*> arbitrary -- arrayTestArrayArrayOfInteger :: Maybe [[Integer]] <*> arbitrary -- arrayTestArrayArrayOfModel :: Maybe [[ReadOnlyFirst]] +instance Arbitrary Body where + arbitrary = + Body + <$> arbitrary -- bodyName :: Maybe Text + <*> arbitrary -- bodyStatus :: Maybe Text + +instance Arbitrary Body1 where + arbitrary = + Body1 + <$> arbitrary -- body1AdditionalMetadata :: Maybe Text + <*> arbitrary -- body1File :: Maybe FilePath + +instance Arbitrary Body2 where + arbitrary = + Body2 + <$> arbitrary -- body2EnumFormStringArray :: Maybe [Text] + <*> arbitrary -- body2EnumFormString :: Maybe Text + +instance Arbitrary Body3 where + arbitrary = + Body3 + <$> arbitrary -- body3Integer :: Maybe Int + <*> arbitrary -- body3Int32 :: Maybe Int + <*> arbitrary -- body3Int64 :: Maybe Integer + <*> arbitrary -- body3Number :: Double + <*> arbitrary -- body3Float :: Maybe Float + <*> arbitrary -- body3Double :: Double + <*> arbitrary -- body3String :: Maybe Text + <*> arbitrary -- body3PatternWithoutDelimiter :: Text + <*> arbitrary -- body3Byte :: ByteArray + <*> arbitrary -- body3Binary :: Maybe FilePath + <*> arbitrary -- body3Date :: Maybe Date + <*> arbitrary -- body3DateTime :: Maybe DateTime + <*> arbitrary -- body3Password :: Maybe Text + <*> arbitrary -- body3Callback :: Maybe Text + +instance Arbitrary Body4 where + arbitrary = + Body4 + <$> arbitrary -- body4Param :: Text + <*> arbitrary -- body4Param2 :: Text + +instance Arbitrary Body5 where + arbitrary = + Body5 + <$> arbitrary -- body5AdditionalMetadata :: Maybe Text + <*> arbitrary -- body5RequiredFile :: FilePath + instance Arbitrary Capitalization where arbitrary = Capitalization diff --git a/samples/client/petstore/haskell-http-client/tests/Test.hs b/samples/client/petstore/haskell-http-client/tests/Test.hs index ea6fff251e36..ee6483020f44 100644 --- a/samples/client/petstore/haskell-http-client/tests/Test.hs +++ b/samples/client/petstore/haskell-http-client/tests/Test.hs @@ -27,6 +27,12 @@ main = propMimeEq MimeJSON (Proxy :: Proxy ArrayOfArrayOfNumberOnly) propMimeEq MimeJSON (Proxy :: Proxy ArrayOfNumberOnly) propMimeEq MimeJSON (Proxy :: Proxy ArrayTest) + propMimeEq MimeJSON (Proxy :: Proxy Body) + propMimeEq MimeJSON (Proxy :: Proxy Body1) + propMimeEq MimeJSON (Proxy :: Proxy Body2) + propMimeEq MimeJSON (Proxy :: Proxy Body3) + propMimeEq MimeJSON (Proxy :: Proxy Body4) + propMimeEq MimeJSON (Proxy :: Proxy Body5) propMimeEq MimeJSON (Proxy :: Proxy Capitalization) propMimeEq MimeJSON (Proxy :: Proxy Cat) propMimeEq MimeJSON (Proxy :: Proxy Category) diff --git a/samples/openapi3/client/petstore/php/OpenAPIClient-php/README.md b/samples/openapi3/client/petstore/php/OpenAPIClient-php/README.md index 4ae16d9d8649..b42462087c72 100644 --- a/samples/openapi3/client/petstore/php/OpenAPIClient-php/README.md +++ b/samples/openapi3/client/petstore/php/OpenAPIClient-php/README.md @@ -124,6 +124,12 @@ Class | Method | HTTP request | Description - [ArrayOfArrayOfNumberOnly](docs/Model/ArrayOfArrayOfNumberOnly.md) - [ArrayOfNumberOnly](docs/Model/ArrayOfNumberOnly.md) - [ArrayTest](docs/Model/ArrayTest.md) + - [Body](docs/Model/Body.md) + - [Body1](docs/Model/Body1.md) + - [Body2](docs/Model/Body2.md) + - [Body3](docs/Model/Body3.md) + - [Body4](docs/Model/Body4.md) + - [Body5](docs/Model/Body5.md) - [Capitalization](docs/Model/Capitalization.md) - [Cat](docs/Model/Cat.md) - [Category](docs/Model/Category.md) diff --git a/samples/openapi3/client/petstore/php/OpenAPIClient-php/docs/Model/Body.md b/samples/openapi3/client/petstore/php/OpenAPIClient-php/docs/Model/Body.md new file mode 100644 index 000000000000..c3cbc85ee899 --- /dev/null +++ b/samples/openapi3/client/petstore/php/OpenAPIClient-php/docs/Model/Body.md @@ -0,0 +1,11 @@ +# Body + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**name** | **string** | Updated name of the pet | [optional] +**status** | **string** | Updated status of the pet | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/samples/openapi3/client/petstore/php/OpenAPIClient-php/docs/Model/Body1.md b/samples/openapi3/client/petstore/php/OpenAPIClient-php/docs/Model/Body1.md new file mode 100644 index 000000000000..8f063c22f08b --- /dev/null +++ b/samples/openapi3/client/petstore/php/OpenAPIClient-php/docs/Model/Body1.md @@ -0,0 +1,11 @@ +# Body1 + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**additional_metadata** | **string** | Additional data to pass to server | [optional] +**file** | [**\SplFileObject**](\SplFileObject.md) | file to upload | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/samples/openapi3/client/petstore/php/OpenAPIClient-php/docs/Model/Body2.md b/samples/openapi3/client/petstore/php/OpenAPIClient-php/docs/Model/Body2.md new file mode 100644 index 000000000000..5afe5ce7313c --- /dev/null +++ b/samples/openapi3/client/petstore/php/OpenAPIClient-php/docs/Model/Body2.md @@ -0,0 +1,11 @@ +# Body2 + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**enum_form_string_array** | **string[]** | Form parameter enum test (string array) | [optional] +**enum_form_string** | **string** | Form parameter enum test (string) | [optional] [default to '-efg'] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/samples/openapi3/client/petstore/php/OpenAPIClient-php/docs/Model/Body3.md b/samples/openapi3/client/petstore/php/OpenAPIClient-php/docs/Model/Body3.md new file mode 100644 index 000000000000..fe21931b97de --- /dev/null +++ b/samples/openapi3/client/petstore/php/OpenAPIClient-php/docs/Model/Body3.md @@ -0,0 +1,23 @@ +# Body3 + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**integer** | **int** | None | [optional] +**int32** | **int** | None | [optional] +**int64** | **int** | None | [optional] +**number** | **float** | None | +**float** | **float** | None | [optional] +**double** | **double** | None | +**string** | **string** | None | [optional] +**pattern_without_delimiter** | **string** | None | +**byte** | **string** | None | +**binary** | [**\SplFileObject**](\SplFileObject.md) | None | [optional] +**date** | [**\DateTime**](\DateTime.md) | None | [optional] +**date_time** | [**\DateTime**](\DateTime.md) | None | [optional] +**password** | **string** | None | [optional] +**callback** | **string** | None | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/samples/openapi3/client/petstore/php/OpenAPIClient-php/docs/Model/Body4.md b/samples/openapi3/client/petstore/php/OpenAPIClient-php/docs/Model/Body4.md new file mode 100644 index 000000000000..f583ce67bec3 --- /dev/null +++ b/samples/openapi3/client/petstore/php/OpenAPIClient-php/docs/Model/Body4.md @@ -0,0 +1,11 @@ +# Body4 + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**param** | **string** | field1 | +**param2** | **string** | field2 | + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/samples/openapi3/client/petstore/php/OpenAPIClient-php/docs/Model/Body5.md b/samples/openapi3/client/petstore/php/OpenAPIClient-php/docs/Model/Body5.md new file mode 100644 index 000000000000..bb39fd91717f --- /dev/null +++ b/samples/openapi3/client/petstore/php/OpenAPIClient-php/docs/Model/Body5.md @@ -0,0 +1,11 @@ +# Body5 + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**additional_metadata** | **string** | Additional data to pass to server | [optional] +**required_file** | [**\SplFileObject**](\SplFileObject.md) | file to upload | + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/samples/openapi3/client/petstore/php/OpenAPIClient-php/lib/Model/Body.php b/samples/openapi3/client/petstore/php/OpenAPIClient-php/lib/Model/Body.php new file mode 100644 index 000000000000..b37b54099ebd --- /dev/null +++ b/samples/openapi3/client/petstore/php/OpenAPIClient-php/lib/Model/Body.php @@ -0,0 +1,327 @@ + 'string', + 'status' => 'string' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPIFormats = [ + 'name' => null, + 'status' => null + ]; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'name' => 'name', + 'status' => 'status' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'name' => 'setName', + 'status' => 'setStatus' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'name' => 'getName', + 'status' => 'getStatus' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->container['name'] = isset($data['name']) ? $data['name'] : null; + $this->container['status'] = isset($data['status']) ? $data['status'] : null; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets name + * + * @return string|null + */ + public function getName() + { + return $this->container['name']; + } + + /** + * Sets name + * + * @param string|null $name Updated name of the pet + * + * @return $this + */ + public function setName($name) + { + $this->container['name'] = $name; + + return $this; + } + + /** + * Gets status + * + * @return string|null + */ + public function getStatus() + { + return $this->container['status']; + } + + /** + * Sets status + * + * @param string|null $status Updated status of the pet + * + * @return $this + */ + public function setStatus($status) + { + $this->container['status'] = $status; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset) + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed + */ + public function offsetGet($offset) + { + return isset($this->container[$offset]) ? $this->container[$offset] : null; + } + + /** + * Sets value based on offset. + * + * @param integer $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value) + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset) + { + unset($this->container[$offset]); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } +} + + diff --git a/samples/openapi3/client/petstore/php/OpenAPIClient-php/lib/Model/Body1.php b/samples/openapi3/client/petstore/php/OpenAPIClient-php/lib/Model/Body1.php new file mode 100644 index 000000000000..f7b43d84adfb --- /dev/null +++ b/samples/openapi3/client/petstore/php/OpenAPIClient-php/lib/Model/Body1.php @@ -0,0 +1,327 @@ + 'string', + 'file' => '\SplFileObject' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPIFormats = [ + 'additional_metadata' => null, + 'file' => 'binary' + ]; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'additional_metadata' => 'additionalMetadata', + 'file' => 'file' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'additional_metadata' => 'setAdditionalMetadata', + 'file' => 'setFile' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'additional_metadata' => 'getAdditionalMetadata', + 'file' => 'getFile' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->container['additional_metadata'] = isset($data['additional_metadata']) ? $data['additional_metadata'] : null; + $this->container['file'] = isset($data['file']) ? $data['file'] : null; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets additional_metadata + * + * @return string|null + */ + public function getAdditionalMetadata() + { + return $this->container['additional_metadata']; + } + + /** + * Sets additional_metadata + * + * @param string|null $additional_metadata Additional data to pass to server + * + * @return $this + */ + public function setAdditionalMetadata($additional_metadata) + { + $this->container['additional_metadata'] = $additional_metadata; + + return $this; + } + + /** + * Gets file + * + * @return \SplFileObject|null + */ + public function getFile() + { + return $this->container['file']; + } + + /** + * Sets file + * + * @param \SplFileObject|null $file file to upload + * + * @return $this + */ + public function setFile($file) + { + $this->container['file'] = $file; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset) + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed + */ + public function offsetGet($offset) + { + return isset($this->container[$offset]) ? $this->container[$offset] : null; + } + + /** + * Sets value based on offset. + * + * @param integer $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value) + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset) + { + unset($this->container[$offset]); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } +} + + diff --git a/samples/openapi3/client/petstore/php/OpenAPIClient-php/lib/Model/Body2.php b/samples/openapi3/client/petstore/php/OpenAPIClient-php/lib/Model/Body2.php new file mode 100644 index 000000000000..38a56c52dc00 --- /dev/null +++ b/samples/openapi3/client/petstore/php/OpenAPIClient-php/lib/Model/Body2.php @@ -0,0 +1,385 @@ + 'string[]', + 'enum_form_string' => 'string' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPIFormats = [ + 'enum_form_string_array' => null, + 'enum_form_string' => null + ]; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'enum_form_string_array' => 'enum_form_string_array', + 'enum_form_string' => 'enum_form_string' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'enum_form_string_array' => 'setEnumFormStringArray', + 'enum_form_string' => 'setEnumFormString' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'enum_form_string_array' => 'getEnumFormStringArray', + 'enum_form_string' => 'getEnumFormString' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + const ENUM_FORM_STRING_ARRAY_GREATER_THAN = '>'; + const ENUM_FORM_STRING_ARRAY_DOLLAR = '$'; + const ENUM_FORM_STRING_ABC = '_abc'; + const ENUM_FORM_STRING_EFG = '-efg'; + const ENUM_FORM_STRING_XYZ = '(xyz)'; + + + + /** + * Gets allowable values of the enum + * + * @return string[] + */ + public function getEnumFormStringArrayAllowableValues() + { + return [ + self::ENUM_FORM_STRING_ARRAY_GREATER_THAN, + self::ENUM_FORM_STRING_ARRAY_DOLLAR, + ]; + } + + /** + * Gets allowable values of the enum + * + * @return string[] + */ + public function getEnumFormStringAllowableValues() + { + return [ + self::ENUM_FORM_STRING_ABC, + self::ENUM_FORM_STRING_EFG, + self::ENUM_FORM_STRING_XYZ, + ]; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->container['enum_form_string_array'] = isset($data['enum_form_string_array']) ? $data['enum_form_string_array'] : null; + $this->container['enum_form_string'] = isset($data['enum_form_string']) ? $data['enum_form_string'] : '-efg'; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + $allowedValues = $this->getEnumFormStringAllowableValues(); + if (!is_null($this->container['enum_form_string']) && !in_array($this->container['enum_form_string'], $allowedValues, true)) { + $invalidProperties[] = sprintf( + "invalid value for 'enum_form_string', must be one of '%s'", + implode("', '", $allowedValues) + ); + } + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets enum_form_string_array + * + * @return string[]|null + */ + public function getEnumFormStringArray() + { + return $this->container['enum_form_string_array']; + } + + /** + * Sets enum_form_string_array + * + * @param string[]|null $enum_form_string_array Form parameter enum test (string array) + * + * @return $this + */ + public function setEnumFormStringArray($enum_form_string_array) + { + $allowedValues = $this->getEnumFormStringArrayAllowableValues(); + if (!is_null($enum_form_string_array) && array_diff($enum_form_string_array, $allowedValues)) { + throw new \InvalidArgumentException( + sprintf( + "Invalid value for 'enum_form_string_array', must be one of '%s'", + implode("', '", $allowedValues) + ) + ); + } + $this->container['enum_form_string_array'] = $enum_form_string_array; + + return $this; + } + + /** + * Gets enum_form_string + * + * @return string|null + */ + public function getEnumFormString() + { + return $this->container['enum_form_string']; + } + + /** + * Sets enum_form_string + * + * @param string|null $enum_form_string Form parameter enum test (string) + * + * @return $this + */ + public function setEnumFormString($enum_form_string) + { + $allowedValues = $this->getEnumFormStringAllowableValues(); + if (!is_null($enum_form_string) && !in_array($enum_form_string, $allowedValues, true)) { + throw new \InvalidArgumentException( + sprintf( + "Invalid value for 'enum_form_string', must be one of '%s'", + implode("', '", $allowedValues) + ) + ); + } + $this->container['enum_form_string'] = $enum_form_string; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset) + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed + */ + public function offsetGet($offset) + { + return isset($this->container[$offset]) ? $this->container[$offset] : null; + } + + /** + * Sets value based on offset. + * + * @param integer $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value) + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset) + { + unset($this->container[$offset]); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } +} + + diff --git a/samples/openapi3/client/petstore/php/OpenAPIClient-php/lib/Model/Body3.php b/samples/openapi3/client/petstore/php/OpenAPIClient-php/lib/Model/Body3.php new file mode 100644 index 000000000000..e5ef4ec88813 --- /dev/null +++ b/samples/openapi3/client/petstore/php/OpenAPIClient-php/lib/Model/Body3.php @@ -0,0 +1,805 @@ + 'int', + 'int32' => 'int', + 'int64' => 'int', + 'number' => 'float', + 'float' => 'float', + 'double' => 'double', + 'string' => 'string', + 'pattern_without_delimiter' => 'string', + 'byte' => 'string', + 'binary' => '\SplFileObject', + 'date' => '\DateTime', + 'date_time' => '\DateTime', + 'password' => 'string', + 'callback' => 'string' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPIFormats = [ + 'integer' => 'int32', + 'int32' => 'int32', + 'int64' => 'int64', + 'number' => null, + 'float' => 'float', + 'double' => 'double', + 'string' => null, + 'pattern_without_delimiter' => null, + 'byte' => 'byte', + 'binary' => 'binary', + 'date' => 'date', + 'date_time' => 'date-time', + 'password' => 'password', + 'callback' => null + ]; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'integer' => 'integer', + 'int32' => 'int32', + 'int64' => 'int64', + 'number' => 'number', + 'float' => 'float', + 'double' => 'double', + 'string' => 'string', + 'pattern_without_delimiter' => 'pattern_without_delimiter', + 'byte' => 'byte', + 'binary' => 'binary', + 'date' => 'date', + 'date_time' => 'dateTime', + 'password' => 'password', + 'callback' => 'callback' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'integer' => 'setInteger', + 'int32' => 'setInt32', + 'int64' => 'setInt64', + 'number' => 'setNumber', + 'float' => 'setFloat', + 'double' => 'setDouble', + 'string' => 'setString', + 'pattern_without_delimiter' => 'setPatternWithoutDelimiter', + 'byte' => 'setByte', + 'binary' => 'setBinary', + 'date' => 'setDate', + 'date_time' => 'setDateTime', + 'password' => 'setPassword', + 'callback' => 'setCallback' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'integer' => 'getInteger', + 'int32' => 'getInt32', + 'int64' => 'getInt64', + 'number' => 'getNumber', + 'float' => 'getFloat', + 'double' => 'getDouble', + 'string' => 'getString', + 'pattern_without_delimiter' => 'getPatternWithoutDelimiter', + 'byte' => 'getByte', + 'binary' => 'getBinary', + 'date' => 'getDate', + 'date_time' => 'getDateTime', + 'password' => 'getPassword', + 'callback' => 'getCallback' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->container['integer'] = isset($data['integer']) ? $data['integer'] : null; + $this->container['int32'] = isset($data['int32']) ? $data['int32'] : null; + $this->container['int64'] = isset($data['int64']) ? $data['int64'] : null; + $this->container['number'] = isset($data['number']) ? $data['number'] : null; + $this->container['float'] = isset($data['float']) ? $data['float'] : null; + $this->container['double'] = isset($data['double']) ? $data['double'] : null; + $this->container['string'] = isset($data['string']) ? $data['string'] : null; + $this->container['pattern_without_delimiter'] = isset($data['pattern_without_delimiter']) ? $data['pattern_without_delimiter'] : null; + $this->container['byte'] = isset($data['byte']) ? $data['byte'] : null; + $this->container['binary'] = isset($data['binary']) ? $data['binary'] : null; + $this->container['date'] = isset($data['date']) ? $data['date'] : null; + $this->container['date_time'] = isset($data['date_time']) ? $data['date_time'] : null; + $this->container['password'] = isset($data['password']) ? $data['password'] : null; + $this->container['callback'] = isset($data['callback']) ? $data['callback'] : null; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + if (!is_null($this->container['integer']) && ($this->container['integer'] > 100)) { + $invalidProperties[] = "invalid value for 'integer', must be smaller than or equal to 100."; + } + + if (!is_null($this->container['integer']) && ($this->container['integer'] < 10)) { + $invalidProperties[] = "invalid value for 'integer', must be bigger than or equal to 10."; + } + + if (!is_null($this->container['int32']) && ($this->container['int32'] > 200)) { + $invalidProperties[] = "invalid value for 'int32', must be smaller than or equal to 200."; + } + + if (!is_null($this->container['int32']) && ($this->container['int32'] < 20)) { + $invalidProperties[] = "invalid value for 'int32', must be bigger than or equal to 20."; + } + + if ($this->container['number'] === null) { + $invalidProperties[] = "'number' can't be null"; + } + if (($this->container['number'] > 543.2)) { + $invalidProperties[] = "invalid value for 'number', must be smaller than or equal to 543.2."; + } + + if (($this->container['number'] < 32.1)) { + $invalidProperties[] = "invalid value for 'number', must be bigger than or equal to 32.1."; + } + + if (!is_null($this->container['float']) && ($this->container['float'] > 987.6)) { + $invalidProperties[] = "invalid value for 'float', must be smaller than or equal to 987.6."; + } + + if ($this->container['double'] === null) { + $invalidProperties[] = "'double' can't be null"; + } + if (($this->container['double'] > 123.4)) { + $invalidProperties[] = "invalid value for 'double', must be smaller than or equal to 123.4."; + } + + if (($this->container['double'] < 67.8)) { + $invalidProperties[] = "invalid value for 'double', must be bigger than or equal to 67.8."; + } + + if (!is_null($this->container['string']) && !preg_match("/[a-z]/i", $this->container['string'])) { + $invalidProperties[] = "invalid value for 'string', must be conform to the pattern /[a-z]/i."; + } + + if ($this->container['pattern_without_delimiter'] === null) { + $invalidProperties[] = "'pattern_without_delimiter' can't be null"; + } + if (!preg_match("/^[A-Z].*/", $this->container['pattern_without_delimiter'])) { + $invalidProperties[] = "invalid value for 'pattern_without_delimiter', must be conform to the pattern /^[A-Z].*/."; + } + + if ($this->container['byte'] === null) { + $invalidProperties[] = "'byte' can't be null"; + } + if (!is_null($this->container['password']) && (mb_strlen($this->container['password']) > 64)) { + $invalidProperties[] = "invalid value for 'password', the character length must be smaller than or equal to 64."; + } + + if (!is_null($this->container['password']) && (mb_strlen($this->container['password']) < 10)) { + $invalidProperties[] = "invalid value for 'password', the character length must be bigger than or equal to 10."; + } + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets integer + * + * @return int|null + */ + public function getInteger() + { + return $this->container['integer']; + } + + /** + * Sets integer + * + * @param int|null $integer None + * + * @return $this + */ + public function setInteger($integer) + { + + if (!is_null($integer) && ($integer > 100)) { + throw new \InvalidArgumentException('invalid value for $integer when calling Body3., must be smaller than or equal to 100.'); + } + if (!is_null($integer) && ($integer < 10)) { + throw new \InvalidArgumentException('invalid value for $integer when calling Body3., must be bigger than or equal to 10.'); + } + + $this->container['integer'] = $integer; + + return $this; + } + + /** + * Gets int32 + * + * @return int|null + */ + public function getInt32() + { + return $this->container['int32']; + } + + /** + * Sets int32 + * + * @param int|null $int32 None + * + * @return $this + */ + public function setInt32($int32) + { + + if (!is_null($int32) && ($int32 > 200)) { + throw new \InvalidArgumentException('invalid value for $int32 when calling Body3., must be smaller than or equal to 200.'); + } + if (!is_null($int32) && ($int32 < 20)) { + throw new \InvalidArgumentException('invalid value for $int32 when calling Body3., must be bigger than or equal to 20.'); + } + + $this->container['int32'] = $int32; + + return $this; + } + + /** + * Gets int64 + * + * @return int|null + */ + public function getInt64() + { + return $this->container['int64']; + } + + /** + * Sets int64 + * + * @param int|null $int64 None + * + * @return $this + */ + public function setInt64($int64) + { + $this->container['int64'] = $int64; + + return $this; + } + + /** + * Gets number + * + * @return float + */ + public function getNumber() + { + return $this->container['number']; + } + + /** + * Sets number + * + * @param float $number None + * + * @return $this + */ + public function setNumber($number) + { + + if (($number > 543.2)) { + throw new \InvalidArgumentException('invalid value for $number when calling Body3., must be smaller than or equal to 543.2.'); + } + if (($number < 32.1)) { + throw new \InvalidArgumentException('invalid value for $number when calling Body3., must be bigger than or equal to 32.1.'); + } + + $this->container['number'] = $number; + + return $this; + } + + /** + * Gets float + * + * @return float|null + */ + public function getFloat() + { + return $this->container['float']; + } + + /** + * Sets float + * + * @param float|null $float None + * + * @return $this + */ + public function setFloat($float) + { + + if (!is_null($float) && ($float > 987.6)) { + throw new \InvalidArgumentException('invalid value for $float when calling Body3., must be smaller than or equal to 987.6.'); + } + + $this->container['float'] = $float; + + return $this; + } + + /** + * Gets double + * + * @return double + */ + public function getDouble() + { + return $this->container['double']; + } + + /** + * Sets double + * + * @param double $double None + * + * @return $this + */ + public function setDouble($double) + { + + if (($double > 123.4)) { + throw new \InvalidArgumentException('invalid value for $double when calling Body3., must be smaller than or equal to 123.4.'); + } + if (($double < 67.8)) { + throw new \InvalidArgumentException('invalid value for $double when calling Body3., must be bigger than or equal to 67.8.'); + } + + $this->container['double'] = $double; + + return $this; + } + + /** + * Gets string + * + * @return string|null + */ + public function getString() + { + return $this->container['string']; + } + + /** + * Sets string + * + * @param string|null $string None + * + * @return $this + */ + public function setString($string) + { + + if (!is_null($string) && (!preg_match("/[a-z]/i", $string))) { + throw new \InvalidArgumentException("invalid value for $string when calling Body3., must conform to the pattern /[a-z]/i."); + } + + $this->container['string'] = $string; + + return $this; + } + + /** + * Gets pattern_without_delimiter + * + * @return string + */ + public function getPatternWithoutDelimiter() + { + return $this->container['pattern_without_delimiter']; + } + + /** + * Sets pattern_without_delimiter + * + * @param string $pattern_without_delimiter None + * + * @return $this + */ + public function setPatternWithoutDelimiter($pattern_without_delimiter) + { + + if ((!preg_match("/^[A-Z].*/", $pattern_without_delimiter))) { + throw new \InvalidArgumentException("invalid value for $pattern_without_delimiter when calling Body3., must conform to the pattern /^[A-Z].*/."); + } + + $this->container['pattern_without_delimiter'] = $pattern_without_delimiter; + + return $this; + } + + /** + * Gets byte + * + * @return string + */ + public function getByte() + { + return $this->container['byte']; + } + + /** + * Sets byte + * + * @param string $byte None + * + * @return $this + */ + public function setByte($byte) + { + $this->container['byte'] = $byte; + + return $this; + } + + /** + * Gets binary + * + * @return \SplFileObject|null + */ + public function getBinary() + { + return $this->container['binary']; + } + + /** + * Sets binary + * + * @param \SplFileObject|null $binary None + * + * @return $this + */ + public function setBinary($binary) + { + $this->container['binary'] = $binary; + + return $this; + } + + /** + * Gets date + * + * @return \DateTime|null + */ + public function getDate() + { + return $this->container['date']; + } + + /** + * Sets date + * + * @param \DateTime|null $date None + * + * @return $this + */ + public function setDate($date) + { + $this->container['date'] = $date; + + return $this; + } + + /** + * Gets date_time + * + * @return \DateTime|null + */ + public function getDateTime() + { + return $this->container['date_time']; + } + + /** + * Sets date_time + * + * @param \DateTime|null $date_time None + * + * @return $this + */ + public function setDateTime($date_time) + { + $this->container['date_time'] = $date_time; + + return $this; + } + + /** + * Gets password + * + * @return string|null + */ + public function getPassword() + { + return $this->container['password']; + } + + /** + * Sets password + * + * @param string|null $password None + * + * @return $this + */ + public function setPassword($password) + { + if (!is_null($password) && (mb_strlen($password) > 64)) { + throw new \InvalidArgumentException('invalid length for $password when calling Body3., must be smaller than or equal to 64.'); + } + if (!is_null($password) && (mb_strlen($password) < 10)) { + throw new \InvalidArgumentException('invalid length for $password when calling Body3., must be bigger than or equal to 10.'); + } + + $this->container['password'] = $password; + + return $this; + } + + /** + * Gets callback + * + * @return string|null + */ + public function getCallback() + { + return $this->container['callback']; + } + + /** + * Sets callback + * + * @param string|null $callback None + * + * @return $this + */ + public function setCallback($callback) + { + $this->container['callback'] = $callback; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset) + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed + */ + public function offsetGet($offset) + { + return isset($this->container[$offset]) ? $this->container[$offset] : null; + } + + /** + * Sets value based on offset. + * + * @param integer $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value) + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset) + { + unset($this->container[$offset]); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } +} + + diff --git a/samples/openapi3/client/petstore/php/OpenAPIClient-php/lib/Model/Body4.php b/samples/openapi3/client/petstore/php/OpenAPIClient-php/lib/Model/Body4.php new file mode 100644 index 000000000000..fdbe3fba12ef --- /dev/null +++ b/samples/openapi3/client/petstore/php/OpenAPIClient-php/lib/Model/Body4.php @@ -0,0 +1,333 @@ + 'string', + 'param2' => 'string' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPIFormats = [ + 'param' => null, + 'param2' => null + ]; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'param' => 'param', + 'param2' => 'param2' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'param' => 'setParam', + 'param2' => 'setParam2' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'param' => 'getParam', + 'param2' => 'getParam2' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->container['param'] = isset($data['param']) ? $data['param'] : null; + $this->container['param2'] = isset($data['param2']) ? $data['param2'] : null; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + if ($this->container['param'] === null) { + $invalidProperties[] = "'param' can't be null"; + } + if ($this->container['param2'] === null) { + $invalidProperties[] = "'param2' can't be null"; + } + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets param + * + * @return string + */ + public function getParam() + { + return $this->container['param']; + } + + /** + * Sets param + * + * @param string $param field1 + * + * @return $this + */ + public function setParam($param) + { + $this->container['param'] = $param; + + return $this; + } + + /** + * Gets param2 + * + * @return string + */ + public function getParam2() + { + return $this->container['param2']; + } + + /** + * Sets param2 + * + * @param string $param2 field2 + * + * @return $this + */ + public function setParam2($param2) + { + $this->container['param2'] = $param2; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset) + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed + */ + public function offsetGet($offset) + { + return isset($this->container[$offset]) ? $this->container[$offset] : null; + } + + /** + * Sets value based on offset. + * + * @param integer $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value) + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset) + { + unset($this->container[$offset]); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } +} + + diff --git a/samples/openapi3/client/petstore/php/OpenAPIClient-php/lib/Model/Body5.php b/samples/openapi3/client/petstore/php/OpenAPIClient-php/lib/Model/Body5.php new file mode 100644 index 000000000000..6e81d36b2666 --- /dev/null +++ b/samples/openapi3/client/petstore/php/OpenAPIClient-php/lib/Model/Body5.php @@ -0,0 +1,330 @@ + 'string', + 'required_file' => '\SplFileObject' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPIFormats = [ + 'additional_metadata' => null, + 'required_file' => 'binary' + ]; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'additional_metadata' => 'additionalMetadata', + 'required_file' => 'requiredFile' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'additional_metadata' => 'setAdditionalMetadata', + 'required_file' => 'setRequiredFile' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'additional_metadata' => 'getAdditionalMetadata', + 'required_file' => 'getRequiredFile' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->container['additional_metadata'] = isset($data['additional_metadata']) ? $data['additional_metadata'] : null; + $this->container['required_file'] = isset($data['required_file']) ? $data['required_file'] : null; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + if ($this->container['required_file'] === null) { + $invalidProperties[] = "'required_file' can't be null"; + } + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets additional_metadata + * + * @return string|null + */ + public function getAdditionalMetadata() + { + return $this->container['additional_metadata']; + } + + /** + * Sets additional_metadata + * + * @param string|null $additional_metadata Additional data to pass to server + * + * @return $this + */ + public function setAdditionalMetadata($additional_metadata) + { + $this->container['additional_metadata'] = $additional_metadata; + + return $this; + } + + /** + * Gets required_file + * + * @return \SplFileObject + */ + public function getRequiredFile() + { + return $this->container['required_file']; + } + + /** + * Sets required_file + * + * @param \SplFileObject $required_file file to upload + * + * @return $this + */ + public function setRequiredFile($required_file) + { + $this->container['required_file'] = $required_file; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + public function offsetExists($offset) + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed + */ + public function offsetGet($offset) + { + return isset($this->container[$offset]) ? $this->container[$offset] : null; + } + + /** + * Sets value based on offset. + * + * @param integer $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value) + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + public function offsetUnset($offset) + { + unset($this->container[$offset]); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } +} + + diff --git a/samples/openapi3/client/petstore/php/OpenAPIClient-php/test/Model/Body1Test.php b/samples/openapi3/client/petstore/php/OpenAPIClient-php/test/Model/Body1Test.php new file mode 100644 index 000000000000..710ebc4d0d08 --- /dev/null +++ b/samples/openapi3/client/petstore/php/OpenAPIClient-php/test/Model/Body1Test.php @@ -0,0 +1,92 @@ + Date: Fri, 17 Aug 2018 19:15:02 +0300 Subject: [PATCH 05/15] [Java][Rest-assured] Fix generated javadoc and "swagger-annotations" improvement (#831) Added "@Api" swagger annotation, "nickname" for ApiOperation. Fixed javadock for rest-assured client. --- .../Java/libraries/rest-assured/api.mustache | 20 +++-- .../client/api/AnotherFakeApi.java | 8 +- .../org/openapitools/client/api/FakeApi.java | 90 +++++++++++-------- .../client/api/FakeClassnameTags123Api.java | 8 +- .../org/openapitools/client/api/PetApi.java | 80 +++++++++-------- .../org/openapitools/client/api/StoreApi.java | 37 ++++---- .../org/openapitools/client/api/UserApi.java | 71 ++++++++------- 7 files changed, 178 insertions(+), 136 deletions(-) diff --git a/modules/openapi-generator/src/main/resources/Java/libraries/rest-assured/api.mustache b/modules/openapi-generator/src/main/resources/Java/libraries/rest-assured/api.mustache index f536ddf9b493..75c3a373ae3e 100644 --- a/modules/openapi-generator/src/main/resources/Java/libraries/rest-assured/api.mustache +++ b/modules/openapi-generator/src/main/resources/Java/libraries/rest-assured/api.mustache @@ -28,6 +28,7 @@ import {{invokerPackage}}.JSON; import static io.restassured.http.Method.*; +@Api(value = "{{{baseName}}}") public class {{classname}} { private RequestSpecBuilder reqSpec; @@ -44,10 +45,11 @@ public class {{classname}} { {{#operation}} @ApiOperation(value = "{{{summary}}}", - notes = "{{{notes}}}", - tags={ {{#tags}}{{#name}}"{{{name}}}"{{/name}}{{^-last}}, {{/-last}}{{/tags}} }) + notes = "{{{notes}}}", + nickname = "{{{operationId}}}", + tags = { {{#tags}}{{#name}}"{{{name}}}"{{/name}}{{^-last}}, {{/-last}}{{/tags}} }) @ApiResponses(value = { {{#responses}} - @ApiResponse(code = {{{code}}}, message = "{{{message}}}") {{#hasMore}},{{/hasMore}}{{/responses}} }) + @ApiResponse(code = {{{code}}}, message = "{{{message}}}") {{#hasMore}},{{/hasMore}}{{/responses}} }) {{#isDeprecated}} @Deprecated {{/isDeprecated}} @@ -135,7 +137,7 @@ public class {{classname}} { {{#bodyParams}} /** - * @param {{paramName}} ({{{dataType}}}) {{description}}{{#required}} (required){{/required}}{{^required}} (optional{{#defaultValue}}, default to {{.}}{{/defaultValue}}){{/required}} + * @param {{paramName}} ({{dataType}}) {{description}}{{#required}} (required){{/required}}{{^required}} (optional{{#defaultValue}}, default to {{.}}{{/defaultValue}}){{/required}} * @return operation */ public {{operationIdCamelCase}}Oper body({{{dataType}}} {{paramName}}) { @@ -148,7 +150,7 @@ public class {{classname}} { public static final String {{#convert}}{{paramName}}{{/convert}}_HEADER = "{{baseName}}"; /** - * @param {{paramName}} ({{{dataType}}}) {{description}}{{#required}} (required){{/required}}{{^required}} (optional{{#defaultValue}}, default to {{.}}{{/defaultValue}}){{/required}} + * @param {{paramName}} ({{dataType}}) {{description}}{{#required}} (required){{/required}}{{^required}} (optional{{#defaultValue}}, default to {{.}}{{/defaultValue}}){{/required}} * @return operation */ public {{operationIdCamelCase}}Oper {{paramName}}Header(String {{paramName}}) { @@ -161,7 +163,7 @@ public class {{classname}} { public static final String {{#convert}}{{paramName}}{{/convert}}_PATH = "{{baseName}}"; /** - * @param {{paramName}} ({{{dataType}}}) {{description}}{{#required}} (required){{/required}}{{^required}} (optional{{#defaultValue}}, default to {{.}}{{/defaultValue}}){{/required}} + * @param {{paramName}} ({{dataType}}) {{description}}{{#required}} (required){{/required}}{{^required}} (optional{{#defaultValue}}, default to {{.}}{{/defaultValue}}){{/required}} * @return operation */ public {{operationIdCamelCase}}Oper {{paramName}}Path(Object {{paramName}}) { @@ -174,7 +176,7 @@ public class {{classname}} { public static final String {{#convert}}{{paramName}}{{/convert}}_QUERY = "{{baseName}}"; /** - * @param {{paramName}} ({{{dataType}}}) {{description}}{{#required}} (required){{/required}}{{^required}} (optional{{#defaultValue}}, default to {{.}}{{/defaultValue}}){{/required}} + * @param {{paramName}} ({{dataType}}) {{description}}{{#required}} (required){{/required}}{{^required}} (optional{{#defaultValue}}, default to {{.}}{{/defaultValue}}){{/required}} * @return operation */ public {{operationIdCamelCase}}Oper {{paramName}}Query(Object... {{paramName}}) { @@ -188,7 +190,7 @@ public class {{classname}} { public static final String {{#convert}}{{paramName}}{{/convert}}_FORM = "{{baseName}}"; /** - * @param {{paramName}} ({{{dataType}}}) {{description}}{{#required}} (required){{/required}}{{^required}} (optional{{#defaultValue}}, default to {{.}}{{/defaultValue}}){{/required}} + * @param {{paramName}} ({{dataType}}) {{description}}{{#required}} (required){{/required}}{{^required}} (optional{{#defaultValue}}, default to {{.}}{{/defaultValue}}){{/required}} * @return operation */ public {{operationIdCamelCase}}Oper {{paramName}}Form(Object... {{paramName}}) { @@ -203,7 +205,7 @@ public class {{classname}} { /** * It will assume that the control name is file and the <content-type> is <application/octet-stream> * @see #reqSpec for customise - * @param {{paramName}} ({{{dataType}}}) {{description}}{{#required}} (required){{/required}}{{^required}} (optional{{#defaultValue}}, default to {{.}}{{/defaultValue}}){{/required}} + * @param {{paramName}} ({{dataType}}) {{description}}{{#required}} (required){{/required}}{{^required}} (optional{{#defaultValue}}, default to {{.}}{{/defaultValue}}){{/required}} * @return operation */ public {{operationIdCamelCase}}Oper {{paramName}}MultiPart({{{dataType}}} {{paramName}}) { diff --git a/samples/client/petstore/java/rest-assured/src/main/java/org/openapitools/client/api/AnotherFakeApi.java b/samples/client/petstore/java/rest-assured/src/main/java/org/openapitools/client/api/AnotherFakeApi.java index 9baed9be21d3..0128eed22b56 100644 --- a/samples/client/petstore/java/rest-assured/src/main/java/org/openapitools/client/api/AnotherFakeApi.java +++ b/samples/client/petstore/java/rest-assured/src/main/java/org/openapitools/client/api/AnotherFakeApi.java @@ -36,6 +36,7 @@ import static io.restassured.http.Method.*; +@Api(value = "AnotherFake") public class AnotherFakeApi { private RequestSpecBuilder reqSpec; @@ -50,10 +51,11 @@ public static AnotherFakeApi anotherFake(RequestSpecBuilder reqSpec) { @ApiOperation(value = "To test special tags", - notes = "To test special tags and operation ID starting with number", - tags={ "$another-fake?" }) + notes = "To test special tags and operation ID starting with number", + nickname = "call123testSpecialTags", + tags = { "$another-fake?" }) @ApiResponses(value = { - @ApiResponse(code = 200, message = "successful operation") }) + @ApiResponse(code = 200, message = "successful operation") }) public Call123testSpecialTagsOper call123testSpecialTags() { return new Call123testSpecialTagsOper(reqSpec); } diff --git a/samples/client/petstore/java/rest-assured/src/main/java/org/openapitools/client/api/FakeApi.java b/samples/client/petstore/java/rest-assured/src/main/java/org/openapitools/client/api/FakeApi.java index c5a3414f460f..250ef18113a7 100644 --- a/samples/client/petstore/java/rest-assured/src/main/java/org/openapitools/client/api/FakeApi.java +++ b/samples/client/petstore/java/rest-assured/src/main/java/org/openapitools/client/api/FakeApi.java @@ -43,6 +43,7 @@ import static io.restassured.http.Method.*; +@Api(value = "Fake") public class FakeApi { private RequestSpecBuilder reqSpec; @@ -57,102 +58,113 @@ public static FakeApi fake(RequestSpecBuilder reqSpec) { @ApiOperation(value = "", - notes = "Test serialization of outer boolean types", - tags={ "fake" }) + notes = "Test serialization of outer boolean types", + nickname = "fakeOuterBooleanSerialize", + tags = { "fake" }) @ApiResponses(value = { - @ApiResponse(code = 200, message = "Output boolean") }) + @ApiResponse(code = 200, message = "Output boolean") }) public FakeOuterBooleanSerializeOper fakeOuterBooleanSerialize() { return new FakeOuterBooleanSerializeOper(reqSpec); } @ApiOperation(value = "", - notes = "Test serialization of object with outer number type", - tags={ "fake" }) + notes = "Test serialization of object with outer number type", + nickname = "fakeOuterCompositeSerialize", + tags = { "fake" }) @ApiResponses(value = { - @ApiResponse(code = 200, message = "Output composite") }) + @ApiResponse(code = 200, message = "Output composite") }) public FakeOuterCompositeSerializeOper fakeOuterCompositeSerialize() { return new FakeOuterCompositeSerializeOper(reqSpec); } @ApiOperation(value = "", - notes = "Test serialization of outer number types", - tags={ "fake" }) + notes = "Test serialization of outer number types", + nickname = "fakeOuterNumberSerialize", + tags = { "fake" }) @ApiResponses(value = { - @ApiResponse(code = 200, message = "Output number") }) + @ApiResponse(code = 200, message = "Output number") }) public FakeOuterNumberSerializeOper fakeOuterNumberSerialize() { return new FakeOuterNumberSerializeOper(reqSpec); } @ApiOperation(value = "", - notes = "Test serialization of outer string types", - tags={ "fake" }) + notes = "Test serialization of outer string types", + nickname = "fakeOuterStringSerialize", + tags = { "fake" }) @ApiResponses(value = { - @ApiResponse(code = 200, message = "Output string") }) + @ApiResponse(code = 200, message = "Output string") }) public FakeOuterStringSerializeOper fakeOuterStringSerialize() { return new FakeOuterStringSerializeOper(reqSpec); } @ApiOperation(value = "", - notes = "For this test, the body for this request much reference a schema named `File`.", - tags={ "fake" }) + notes = "For this test, the body for this request much reference a schema named `File`.", + nickname = "testBodyWithFileSchema", + tags = { "fake" }) @ApiResponses(value = { - @ApiResponse(code = 200, message = "Success") }) + @ApiResponse(code = 200, message = "Success") }) public TestBodyWithFileSchemaOper testBodyWithFileSchema() { return new TestBodyWithFileSchemaOper(reqSpec); } @ApiOperation(value = "", - notes = "", - tags={ "fake" }) + notes = "", + nickname = "testBodyWithQueryParams", + tags = { "fake" }) @ApiResponses(value = { - @ApiResponse(code = 200, message = "Success") }) + @ApiResponse(code = 200, message = "Success") }) public TestBodyWithQueryParamsOper testBodyWithQueryParams() { return new TestBodyWithQueryParamsOper(reqSpec); } @ApiOperation(value = "To test \"client\" model", - notes = "To test \"client\" model", - tags={ "fake" }) + notes = "To test \"client\" model", + nickname = "testClientModel", + tags = { "fake" }) @ApiResponses(value = { - @ApiResponse(code = 200, message = "successful operation") }) + @ApiResponse(code = 200, message = "successful operation") }) public TestClientModelOper testClientModel() { return new TestClientModelOper(reqSpec); } @ApiOperation(value = "Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 ", - notes = "Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 ", - tags={ "fake" }) + notes = "Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 ", + nickname = "testEndpointParameters", + tags = { "fake" }) @ApiResponses(value = { - @ApiResponse(code = 400, message = "Invalid username supplied") , - @ApiResponse(code = 404, message = "User not found") }) + @ApiResponse(code = 400, message = "Invalid username supplied") , + @ApiResponse(code = 404, message = "User not found") }) public TestEndpointParametersOper testEndpointParameters() { return new TestEndpointParametersOper(reqSpec); } @ApiOperation(value = "To test enum parameters", - notes = "To test enum parameters", - tags={ "fake" }) + notes = "To test enum parameters", + nickname = "testEnumParameters", + tags = { "fake" }) @ApiResponses(value = { - @ApiResponse(code = 400, message = "Invalid request") , - @ApiResponse(code = 404, message = "Not found") }) + @ApiResponse(code = 400, message = "Invalid request") , + @ApiResponse(code = 404, message = "Not found") }) public TestEnumParametersOper testEnumParameters() { return new TestEnumParametersOper(reqSpec); } @ApiOperation(value = "test inline additionalProperties", - notes = "", - tags={ "fake" }) + notes = "", + nickname = "testInlineAdditionalProperties", + tags = { "fake" }) @ApiResponses(value = { - @ApiResponse(code = 200, message = "successful operation") }) + @ApiResponse(code = 200, message = "successful operation") }) public TestInlineAdditionalPropertiesOper testInlineAdditionalProperties() { return new TestInlineAdditionalPropertiesOper(reqSpec); } @ApiOperation(value = "test json serialization of form data", - notes = "", - tags={ "fake" }) + notes = "", + nickname = "testJsonFormData", + tags = { "fake" }) @ApiResponses(value = { - @ApiResponse(code = 200, message = "successful operation") }) + @ApiResponse(code = 200, message = "successful operation") }) public TestJsonFormDataOper testJsonFormData() { return new TestJsonFormDataOper(reqSpec); } @@ -913,7 +925,7 @@ public T execute(Function handler) { public static final String ENUM_HEADER_STRING_ARRAY_HEADER = "enum_header_string_array"; /** - * @param enumHeaderStringArray (List) Header parameter enum test (string array) (optional) + * @param enumHeaderStringArray (List<String>) Header parameter enum test (string array) (optional) * @return operation */ public TestEnumParametersOper enumHeaderStringArrayHeader(String enumHeaderStringArray) { @@ -935,7 +947,7 @@ public TestEnumParametersOper enumHeaderStringHeader(String enumHeaderString) { public static final String ENUM_QUERY_STRING_ARRAY_QUERY = "enum_query_string_array"; /** - * @param enumQueryStringArray (List) Query parameter enum test (string array) (optional) + * @param enumQueryStringArray (List<String>) Query parameter enum test (string array) (optional) * @return operation */ public TestEnumParametersOper enumQueryStringArrayQuery(Object... enumQueryStringArray) { @@ -979,7 +991,7 @@ public TestEnumParametersOper enumQueryDoubleQuery(Object... enumQueryDouble) { public static final String ENUM_FORM_STRING_ARRAY_FORM = "enum_form_string_array"; /** - * @param enumFormStringArray (List) Form parameter enum test (string array) (optional, default to $) + * @param enumFormStringArray (List<String>) Form parameter enum test (string array) (optional, default to $) * @return operation */ public TestEnumParametersOper enumFormStringArrayForm(Object... enumFormStringArray) { @@ -1050,7 +1062,7 @@ public T execute(Function handler) { } /** - * @param requestBody (Map) request body (required) + * @param requestBody (Map<String, String>) request body (required) * @return operation */ public TestInlineAdditionalPropertiesOper body(Map requestBody) { diff --git a/samples/client/petstore/java/rest-assured/src/main/java/org/openapitools/client/api/FakeClassnameTags123Api.java b/samples/client/petstore/java/rest-assured/src/main/java/org/openapitools/client/api/FakeClassnameTags123Api.java index 459e77f08ed0..beb30b39339d 100644 --- a/samples/client/petstore/java/rest-assured/src/main/java/org/openapitools/client/api/FakeClassnameTags123Api.java +++ b/samples/client/petstore/java/rest-assured/src/main/java/org/openapitools/client/api/FakeClassnameTags123Api.java @@ -36,6 +36,7 @@ import static io.restassured.http.Method.*; +@Api(value = "FakeClassnameTags123") public class FakeClassnameTags123Api { private RequestSpecBuilder reqSpec; @@ -50,10 +51,11 @@ public static FakeClassnameTags123Api fakeClassnameTags123(RequestSpecBuilder re @ApiOperation(value = "To test class name in snake case", - notes = "To test class name in snake case", - tags={ "fake_classname_tags 123#$%^" }) + notes = "To test class name in snake case", + nickname = "testClassname", + tags = { "fake_classname_tags 123#$%^" }) @ApiResponses(value = { - @ApiResponse(code = 200, message = "successful operation") }) + @ApiResponse(code = 200, message = "successful operation") }) public TestClassnameOper testClassname() { return new TestClassnameOper(reqSpec); } diff --git a/samples/client/petstore/java/rest-assured/src/main/java/org/openapitools/client/api/PetApi.java b/samples/client/petstore/java/rest-assured/src/main/java/org/openapitools/client/api/PetApi.java index f0ed89d9c3f3..43e9f0704844 100644 --- a/samples/client/petstore/java/rest-assured/src/main/java/org/openapitools/client/api/PetApi.java +++ b/samples/client/petstore/java/rest-assured/src/main/java/org/openapitools/client/api/PetApi.java @@ -38,6 +38,7 @@ import static io.restassured.http.Method.*; +@Api(value = "Pet") public class PetApi { private RequestSpecBuilder reqSpec; @@ -52,89 +53,98 @@ public static PetApi pet(RequestSpecBuilder reqSpec) { @ApiOperation(value = "Add a new pet to the store", - notes = "", - tags={ "pet" }) + notes = "", + nickname = "addPet", + tags = { "pet" }) @ApiResponses(value = { - @ApiResponse(code = 405, message = "Invalid input") }) + @ApiResponse(code = 405, message = "Invalid input") }) public AddPetOper addPet() { return new AddPetOper(reqSpec); } @ApiOperation(value = "Deletes a pet", - notes = "", - tags={ "pet" }) + notes = "", + nickname = "deletePet", + tags = { "pet" }) @ApiResponses(value = { - @ApiResponse(code = 400, message = "Invalid pet value") }) + @ApiResponse(code = 400, message = "Invalid pet value") }) public DeletePetOper deletePet() { return new DeletePetOper(reqSpec); } @ApiOperation(value = "Finds Pets by status", - notes = "Multiple status values can be provided with comma separated strings", - tags={ "pet" }) + notes = "Multiple status values can be provided with comma separated strings", + nickname = "findPetsByStatus", + tags = { "pet" }) @ApiResponses(value = { - @ApiResponse(code = 200, message = "successful operation") , - @ApiResponse(code = 400, message = "Invalid status value") }) + @ApiResponse(code = 200, message = "successful operation") , + @ApiResponse(code = 400, message = "Invalid status value") }) public FindPetsByStatusOper findPetsByStatus() { return new FindPetsByStatusOper(reqSpec); } @ApiOperation(value = "Finds Pets by tags", - notes = "Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.", - tags={ "pet" }) + notes = "Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.", + nickname = "findPetsByTags", + tags = { "pet" }) @ApiResponses(value = { - @ApiResponse(code = 200, message = "successful operation") , - @ApiResponse(code = 400, message = "Invalid tag value") }) + @ApiResponse(code = 200, message = "successful operation") , + @ApiResponse(code = 400, message = "Invalid tag value") }) @Deprecated public FindPetsByTagsOper findPetsByTags() { return new FindPetsByTagsOper(reqSpec); } @ApiOperation(value = "Find pet by ID", - notes = "Returns a single pet", - tags={ "pet" }) + notes = "Returns a single pet", + nickname = "getPetById", + tags = { "pet" }) @ApiResponses(value = { - @ApiResponse(code = 200, message = "successful operation") , - @ApiResponse(code = 400, message = "Invalid ID supplied") , - @ApiResponse(code = 404, message = "Pet not found") }) + @ApiResponse(code = 200, message = "successful operation") , + @ApiResponse(code = 400, message = "Invalid ID supplied") , + @ApiResponse(code = 404, message = "Pet not found") }) public GetPetByIdOper getPetById() { return new GetPetByIdOper(reqSpec); } @ApiOperation(value = "Update an existing pet", - notes = "", - tags={ "pet" }) + notes = "", + nickname = "updatePet", + tags = { "pet" }) @ApiResponses(value = { - @ApiResponse(code = 400, message = "Invalid ID supplied") , - @ApiResponse(code = 404, message = "Pet not found") , - @ApiResponse(code = 405, message = "Validation exception") }) + @ApiResponse(code = 400, message = "Invalid ID supplied") , + @ApiResponse(code = 404, message = "Pet not found") , + @ApiResponse(code = 405, message = "Validation exception") }) public UpdatePetOper updatePet() { return new UpdatePetOper(reqSpec); } @ApiOperation(value = "Updates a pet in the store with form data", - notes = "", - tags={ "pet" }) + notes = "", + nickname = "updatePetWithForm", + tags = { "pet" }) @ApiResponses(value = { - @ApiResponse(code = 405, message = "Invalid input") }) + @ApiResponse(code = 405, message = "Invalid input") }) public UpdatePetWithFormOper updatePetWithForm() { return new UpdatePetWithFormOper(reqSpec); } @ApiOperation(value = "uploads an image", - notes = "", - tags={ "pet" }) + notes = "", + nickname = "uploadFile", + tags = { "pet" }) @ApiResponses(value = { - @ApiResponse(code = 200, message = "successful operation") }) + @ApiResponse(code = 200, message = "successful operation") }) public UploadFileOper uploadFile() { return new UploadFileOper(reqSpec); } @ApiOperation(value = "uploads an image (required)", - notes = "", - tags={ "pet" }) + notes = "", + nickname = "uploadFileWithRequiredFile", + tags = { "pet" }) @ApiResponses(value = { - @ApiResponse(code = 200, message = "successful operation") }) + @ApiResponse(code = 200, message = "successful operation") }) public UploadFileWithRequiredFileOper uploadFileWithRequiredFile() { return new UploadFileWithRequiredFileOper(reqSpec); } @@ -326,7 +336,7 @@ public List executeAs(Function handler) { public static final String STATUS_QUERY = "status"; /** - * @param status (List) Status values that need to be considered for filter (required) + * @param status (List<String>) Status values that need to be considered for filter (required) * @return operation */ public FindPetsByStatusOper statusQuery(Object... status) { @@ -400,7 +410,7 @@ public List executeAs(Function handler) { public static final String TAGS_QUERY = "tags"; /** - * @param tags (List) Tags to filter by (required) + * @param tags (List<String>) Tags to filter by (required) * @return operation */ public FindPetsByTagsOper tagsQuery(Object... tags) { diff --git a/samples/client/petstore/java/rest-assured/src/main/java/org/openapitools/client/api/StoreApi.java b/samples/client/petstore/java/rest-assured/src/main/java/org/openapitools/client/api/StoreApi.java index 03a4d5587f97..3db2be24e474 100644 --- a/samples/client/petstore/java/rest-assured/src/main/java/org/openapitools/client/api/StoreApi.java +++ b/samples/client/petstore/java/rest-assured/src/main/java/org/openapitools/client/api/StoreApi.java @@ -36,6 +36,7 @@ import static io.restassured.http.Method.*; +@Api(value = "Store") public class StoreApi { private RequestSpecBuilder reqSpec; @@ -50,41 +51,45 @@ public static StoreApi store(RequestSpecBuilder reqSpec) { @ApiOperation(value = "Delete purchase order by ID", - notes = "For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors", - tags={ "store" }) + notes = "For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors", + nickname = "deleteOrder", + tags = { "store" }) @ApiResponses(value = { - @ApiResponse(code = 400, message = "Invalid ID supplied") , - @ApiResponse(code = 404, message = "Order not found") }) + @ApiResponse(code = 400, message = "Invalid ID supplied") , + @ApiResponse(code = 404, message = "Order not found") }) public DeleteOrderOper deleteOrder() { return new DeleteOrderOper(reqSpec); } @ApiOperation(value = "Returns pet inventories by status", - notes = "Returns a map of status codes to quantities", - tags={ "store" }) + notes = "Returns a map of status codes to quantities", + nickname = "getInventory", + tags = { "store" }) @ApiResponses(value = { - @ApiResponse(code = 200, message = "successful operation") }) + @ApiResponse(code = 200, message = "successful operation") }) public GetInventoryOper getInventory() { return new GetInventoryOper(reqSpec); } @ApiOperation(value = "Find purchase order by ID", - notes = "For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions", - tags={ "store" }) + notes = "For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions", + nickname = "getOrderById", + tags = { "store" }) @ApiResponses(value = { - @ApiResponse(code = 200, message = "successful operation") , - @ApiResponse(code = 400, message = "Invalid ID supplied") , - @ApiResponse(code = 404, message = "Order not found") }) + @ApiResponse(code = 200, message = "successful operation") , + @ApiResponse(code = 400, message = "Invalid ID supplied") , + @ApiResponse(code = 404, message = "Order not found") }) public GetOrderByIdOper getOrderById() { return new GetOrderByIdOper(reqSpec); } @ApiOperation(value = "Place an order for a pet", - notes = "", - tags={ "store" }) + notes = "", + nickname = "placeOrder", + tags = { "store" }) @ApiResponses(value = { - @ApiResponse(code = 200, message = "successful operation") , - @ApiResponse(code = 400, message = "Invalid Order") }) + @ApiResponse(code = 200, message = "successful operation") , + @ApiResponse(code = 400, message = "Invalid Order") }) public PlaceOrderOper placeOrder() { return new PlaceOrderOper(reqSpec); } diff --git a/samples/client/petstore/java/rest-assured/src/main/java/org/openapitools/client/api/UserApi.java b/samples/client/petstore/java/rest-assured/src/main/java/org/openapitools/client/api/UserApi.java index de5aa794f07f..ccbc21769a47 100644 --- a/samples/client/petstore/java/rest-assured/src/main/java/org/openapitools/client/api/UserApi.java +++ b/samples/client/petstore/java/rest-assured/src/main/java/org/openapitools/client/api/UserApi.java @@ -36,6 +36,7 @@ import static io.restassured.http.Method.*; +@Api(value = "User") public class UserApi { private RequestSpecBuilder reqSpec; @@ -50,78 +51,86 @@ public static UserApi user(RequestSpecBuilder reqSpec) { @ApiOperation(value = "Create user", - notes = "This can only be done by the logged in user.", - tags={ "user" }) + notes = "This can only be done by the logged in user.", + nickname = "createUser", + tags = { "user" }) @ApiResponses(value = { - @ApiResponse(code = 0, message = "successful operation") }) + @ApiResponse(code = 0, message = "successful operation") }) public CreateUserOper createUser() { return new CreateUserOper(reqSpec); } @ApiOperation(value = "Creates list of users with given input array", - notes = "", - tags={ "user" }) + notes = "", + nickname = "createUsersWithArrayInput", + tags = { "user" }) @ApiResponses(value = { - @ApiResponse(code = 0, message = "successful operation") }) + @ApiResponse(code = 0, message = "successful operation") }) public CreateUsersWithArrayInputOper createUsersWithArrayInput() { return new CreateUsersWithArrayInputOper(reqSpec); } @ApiOperation(value = "Creates list of users with given input array", - notes = "", - tags={ "user" }) + notes = "", + nickname = "createUsersWithListInput", + tags = { "user" }) @ApiResponses(value = { - @ApiResponse(code = 0, message = "successful operation") }) + @ApiResponse(code = 0, message = "successful operation") }) public CreateUsersWithListInputOper createUsersWithListInput() { return new CreateUsersWithListInputOper(reqSpec); } @ApiOperation(value = "Delete user", - notes = "This can only be done by the logged in user.", - tags={ "user" }) + notes = "This can only be done by the logged in user.", + nickname = "deleteUser", + tags = { "user" }) @ApiResponses(value = { - @ApiResponse(code = 400, message = "Invalid username supplied") , - @ApiResponse(code = 404, message = "User not found") }) + @ApiResponse(code = 400, message = "Invalid username supplied") , + @ApiResponse(code = 404, message = "User not found") }) public DeleteUserOper deleteUser() { return new DeleteUserOper(reqSpec); } @ApiOperation(value = "Get user by user name", - notes = "", - tags={ "user" }) + notes = "", + nickname = "getUserByName", + tags = { "user" }) @ApiResponses(value = { - @ApiResponse(code = 200, message = "successful operation") , - @ApiResponse(code = 400, message = "Invalid username supplied") , - @ApiResponse(code = 404, message = "User not found") }) + @ApiResponse(code = 200, message = "successful operation") , + @ApiResponse(code = 400, message = "Invalid username supplied") , + @ApiResponse(code = 404, message = "User not found") }) public GetUserByNameOper getUserByName() { return new GetUserByNameOper(reqSpec); } @ApiOperation(value = "Logs user into the system", - notes = "", - tags={ "user" }) + notes = "", + nickname = "loginUser", + tags = { "user" }) @ApiResponses(value = { - @ApiResponse(code = 200, message = "successful operation") , - @ApiResponse(code = 400, message = "Invalid username/password supplied") }) + @ApiResponse(code = 200, message = "successful operation") , + @ApiResponse(code = 400, message = "Invalid username/password supplied") }) public LoginUserOper loginUser() { return new LoginUserOper(reqSpec); } @ApiOperation(value = "Logs out current logged in user session", - notes = "", - tags={ "user" }) + notes = "", + nickname = "logoutUser", + tags = { "user" }) @ApiResponses(value = { - @ApiResponse(code = 0, message = "successful operation") }) + @ApiResponse(code = 0, message = "successful operation") }) public LogoutUserOper logoutUser() { return new LogoutUserOper(reqSpec); } @ApiOperation(value = "Updated user", - notes = "This can only be done by the logged in user.", - tags={ "user" }) + notes = "This can only be done by the logged in user.", + nickname = "updateUser", + tags = { "user" }) @ApiResponses(value = { - @ApiResponse(code = 400, message = "Invalid user supplied") , - @ApiResponse(code = 404, message = "User not found") }) + @ApiResponse(code = 400, message = "Invalid user supplied") , + @ApiResponse(code = 404, message = "User not found") }) public UpdateUserOper updateUser() { return new UpdateUserOper(reqSpec); } @@ -228,7 +237,7 @@ public T execute(Function handler) { } /** - * @param user (List) List of user object (required) + * @param user (List<User>) List of user object (required) * @return operation */ public CreateUsersWithArrayInputOper body(List user) { @@ -288,7 +297,7 @@ public T execute(Function handler) { } /** - * @param user (List) List of user object (required) + * @param user (List<User>) List of user object (required) * @return operation */ public CreateUsersWithListInputOper body(List user) { From d593988e5dfc101527ccde6aee314aab5bba17b8 Mon Sep 17 00:00:00 2001 From: William Cheng Date: Sun, 19 Aug 2018 14:52:21 +0800 Subject: [PATCH 06/15] fix erlang optiona/required parameters (#829) --- .../languages/ErlangClientCodegen.java | 3 + .../codegen/mustache/JoinWithCommaLambda.java | 59 +++++++++++++++++++ .../main/resources/erlang-client/api.mustache | 6 +- .../erlang-client/.openapi-generator/VERSION | 2 +- 4 files changed, 66 insertions(+), 4 deletions(-) create mode 100644 modules/openapi-generator/src/main/java/org/openapitools/codegen/mustache/JoinWithCommaLambda.java diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/ErlangClientCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/ErlangClientCodegen.java index 631c93e2b6e0..5ba57db31e1b 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/ErlangClientCodegen.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/ErlangClientCodegen.java @@ -21,6 +21,7 @@ import com.samskivert.mustache.Template; import org.openapitools.codegen.*; +import org.openapitools.codegen.mustache.JoinWithCommaLambda; import io.swagger.v3.oas.models.media.*; import java.io.File; @@ -133,6 +134,8 @@ public String getSchemaType(Schema p) { public void processOpts() { super.processOpts(); + additionalProperties.put("joinWithComma", new JoinWithCommaLambda()); + if (additionalProperties.containsKey(CodegenConstants.PACKAGE_NAME)) { setPackageName((String) additionalProperties.get(CodegenConstants.PACKAGE_NAME)); } else { diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/mustache/JoinWithCommaLambda.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/mustache/JoinWithCommaLambda.java new file mode 100644 index 000000000000..809445549404 --- /dev/null +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/mustache/JoinWithCommaLambda.java @@ -0,0 +1,59 @@ +/* + * Copyright 2018 OpenAPI-Generator Contributors (https://openapi-generator.tech) + * Copyright 2018 SmartBear Software + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.openapitools.codegen.mustache; + +import com.samskivert.mustache.Mustache; +import com.samskivert.mustache.Template; +import org.openapitools.codegen.CodegenConfig; +import org.openapitools.codegen.DefaultCodegen; + +import java.io.IOException; +import java.io.Writer; + +/** + * Split text by 2 spaces and then join the strings with ", " + * + * Register: + *
+ * additionalProperties.put("joinWithComma", new JoinWithCommaLambda());
+ * 
+ * + * Use: + *
+ * {{#joinWithComma}}{{name}}{{/joinWithComma}}
+ * 
+ */ +public class JoinWithCommaLambda implements Mustache.Lambda { + private CodegenConfig generator = null; + + public JoinWithCommaLambda() { + + } + + public JoinWithCommaLambda generator(final CodegenConfig generator) { + this.generator = generator; + return this; + } + + @Override + public void execute(Template.Fragment fragment, Writer writer) throws IOException { + String[] substr = fragment.execute().trim().split(" "); + + writer.write(String.join(", ", substr)); + } +} diff --git a/modules/openapi-generator/src/main/resources/erlang-client/api.mustache b/modules/openapi-generator/src/main/resources/erlang-client/api.mustache index c292cf28aa3f..a2335745bbba 100644 --- a/modules/openapi-generator/src/main/resources/erlang-client/api.mustache +++ b/modules/openapi-generator/src/main/resources/erlang-client/api.mustache @@ -22,9 +22,9 @@ Method = {{httpMethod}}, Path = ["{{{replacedPathName}}}"], - QS = {{#queryParams.isEmpty}}[]{{/queryParams.isEmpty}}{{^queryParams.isEmpty}}lists:flatten([{{#queryParams}}{{#required}}{{^-first}}, {{/-first}}{{#qsEncode}}{{this}}{{/qsEncode}}{{/required}}{{/queryParams}}])++{{packageName}}_utils:optional_params([{{#queryParams}}{{^required}}{{^-first}}, {{/-first}}'{{baseName}}'{{/required}}{{/queryParams}}], _OptionalParams){{/queryParams.isEmpty}}, - Headers = {{#headerParams.isEmpty}}[]{{/headerParams.isEmpty}}{{^headerParams.isEmpty}}[{{#headerParams}}{{#required}}{{^-first}}, {{/-first}}{<<"{{baseName}}">>, {{paramName}}}{{/required}}{{/headerParams}}]++{{packageName}}_utils:optional_params([{{#headerParams}}{{^required}}{{^-first}}, {{/-first}}'{{baseName}}'{{/required}}{{/headerParams}}], _OptionalParams){{/headerParams.isEmpty}}, - Body1 = {{^formParams.isEmpty}}{form, [{{#formParams}}{{#required}}{{^-first}}, {{/-first}}{<<"{{baseName}}">>, {{paramName}}}{{/required}}{{/formParams}}]++{{packageName}}_utils:optional_params([{{#formParams}}{{^required}}{{^-first}}, {{/-first}}'{{baseName}}'{{/required}}{{/formParams}}], _OptionalParams)}{{/formParams.isEmpty}}{{#formParams.isEmpty}}{{#bodyParams.isEmpty}}[]{{/bodyParams.isEmpty}}{{^bodyParams.isEmpty}}{{#bodyParams}}{{paramName}}{{/bodyParams}}{{/bodyParams.isEmpty}}{{/formParams.isEmpty}}, + QS = {{#queryParams.isEmpty}}[]{{/queryParams.isEmpty}}{{^queryParams.isEmpty}}lists:flatten([{{#joinWithComma}}{{#queryParams}}{{#required}}{{#qsEncode}}{{this}}{{/qsEncode}} {{/required}}{{/queryParams}}{{/joinWithComma}}])++{{packageName}}_utils:optional_params([{{#joinWithComma}}{{#queryParams}}{{^required}} '{{baseName}}'{{/required}}{{/queryParams}}{{/joinWithComma}}], _OptionalParams){{/queryParams.isEmpty}}, + Headers = {{#headerParams.isEmpty}}[]{{/headerParams.isEmpty}}{{^headerParams.isEmpty}}[{{#headerParams}}{{#required}} {<<"{{baseName}}">>, {{paramName}}}{{/required}}{{/headerParams}}]++{{packageName}}_utils:optional_params([{{#joinWithComma}}{{#headerParams}}{{^required}} '{{baseName}}'{{/required}}{{/headerParams}}{{/joinWithComma}}], _OptionalParams){{/headerParams.isEmpty}}, + Body1 = {{^formParams.isEmpty}}{form, [{{#joinWithComma}}{{#formParams}}{{#required}} {<<"{{baseName}}">>, {{paramName}}}{{/required}}{{/formParams}}{{/joinWithComma}}]++{{packageName}}_utils:optional_params([{{#joinWithComma}}{{#formParams}}{{^required}} '{{baseName}}'{{/required}}{{/formParams}}{{/joinWithComma}}], _OptionalParams)}{{/formParams.isEmpty}}{{#formParams.isEmpty}}{{#bodyParams.isEmpty}}[]{{/bodyParams.isEmpty}}{{^bodyParams.isEmpty}}{{#bodyParams}}{{paramName}}{{/bodyParams}}{{/bodyParams.isEmpty}}{{/formParams.isEmpty}}, ContentTypeHeader = {{packageName}}_utils:select_header_content_type([{{#consumes}}{{^-first}}, {{/-first}}<<"{{mediaType}}">>{{/consumes}}]), Opts = maps:get(hackney_opts, Optional, []), diff --git a/samples/client/petstore/erlang-client/.openapi-generator/VERSION b/samples/client/petstore/erlang-client/.openapi-generator/VERSION index 096bf47efe31..105bb87d77b3 100644 --- a/samples/client/petstore/erlang-client/.openapi-generator/VERSION +++ b/samples/client/petstore/erlang-client/.openapi-generator/VERSION @@ -1 +1 @@ -3.0.0-SNAPSHOT \ No newline at end of file +3.2.2-SNAPSHOT \ No newline at end of file From 3b9de3baa3d6da136039cc0249451c33631e647c Mon Sep 17 00:00:00 2001 From: Tino Fuhrmann Date: Sun, 19 Aug 2018 11:45:55 +0200 Subject: [PATCH 07/15] Added server variable support (#816) * Added server variable support * Replaced tabs with 4 spaces --- .../openapitools/codegen/CodegenConfig.java | 6 +++ .../openapitools/codegen/CodegenServer.java | 9 +++++ .../codegen/CodegenServerVariable.java | 10 +++++ .../openapitools/codegen/DefaultCodegen.java | 37 +++++++++++++++++++ .../codegen/DefaultGenerator.java | 6 +++ .../codegen/utils/URLPathUtils.java | 2 +- 6 files changed, 69 insertions(+), 1 deletion(-) create mode 100644 modules/openapi-generator/src/main/java/org/openapitools/codegen/CodegenServer.java create mode 100644 modules/openapi-generator/src/main/java/org/openapitools/codegen/CodegenServerVariable.java diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/CodegenConfig.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/CodegenConfig.java index e91d00d4ce33..61b98db1bef6 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/CodegenConfig.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/CodegenConfig.java @@ -23,6 +23,8 @@ import io.swagger.v3.oas.models.Operation; import io.swagger.v3.oas.models.media.Schema; import io.swagger.v3.oas.models.security.SecurityScheme; +import io.swagger.v3.oas.models.servers.Server; +import io.swagger.v3.oas.models.servers.ServerVariable; import java.util.List; import java.util.Map; @@ -113,6 +115,10 @@ public interface CodegenConfig { List fromSecurity(Map schemas); + List fromServers(List servers); + + List fromServerVariables(Map variables); + Set defaultIncludes(); Map typeMapping(); diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/CodegenServer.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/CodegenServer.java new file mode 100644 index 000000000000..0708d4407fc2 --- /dev/null +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/CodegenServer.java @@ -0,0 +1,9 @@ +package org.openapitools.codegen; + +import java.util.List; + +public class CodegenServer { + public String url; + public String description; + public List variables; +} diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/CodegenServerVariable.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/CodegenServerVariable.java new file mode 100644 index 000000000000..15e9db55b67a --- /dev/null +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/CodegenServerVariable.java @@ -0,0 +1,10 @@ +package org.openapitools.codegen; + +import java.util.List; + +public class CodegenServerVariable { + public String name; + public String defaultValue; + public String description; + public List enumValues; +} diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/DefaultCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/DefaultCodegen.java index 46790890a855..8e1b5ea349b9 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/DefaultCodegen.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/DefaultCodegen.java @@ -43,6 +43,8 @@ import io.swagger.v3.oas.models.security.OAuthFlow; import io.swagger.v3.oas.models.security.OAuthFlows; import io.swagger.v3.oas.models.security.SecurityScheme; +import io.swagger.v3.oas.models.servers.Server; +import io.swagger.v3.oas.models.servers.ServerVariable; import io.swagger.v3.parser.util.SchemaTypeUtil; import org.apache.commons.lang3.ObjectUtils; @@ -64,6 +66,7 @@ import java.util.HashSet; import java.util.Iterator; import java.util.LinkedHashMap; +import java.util.LinkedList; import java.util.List; import java.util.Map; import java.util.Map.Entry; @@ -4588,4 +4591,38 @@ public void generateYAMLSpecFile(Map objs) { public boolean isDataTypeString(String dataType) { return "String".equals(dataType); } + + @Override + public List fromServers(List servers) { + if (servers == null) { + return Collections.emptyList(); + } + List codegenServers = new LinkedList<>(); + for (Server server: servers) { + CodegenServer cs = new CodegenServer(); + cs.description = server.getDescription(); + cs.url = server.getUrl(); + cs.variables = this.fromServerVariables(server.getVariables()); + codegenServers.add(cs); + } + return codegenServers; + } + + @Override + public List fromServerVariables(Map variables) { + if (variables == null) { + return Collections.emptyList(); + } + List codegenServerVariables = new LinkedList<>(); + for (Entry variableEntry: variables.entrySet()) { + CodegenServerVariable codegenServerVariable = new CodegenServerVariable(); + ServerVariable variable = variableEntry.getValue(); + codegenServerVariable.defaultValue = variable.getDefault(); + codegenServerVariable.description = variable.getDescription(); + codegenServerVariable.enumValues = variable.getEnum(); + codegenServerVariable.name = variableEntry.getKey(); + codegenServerVariables.add(codegenServerVariable); + } + return codegenServerVariables; + } } diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/DefaultGenerator.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/DefaultGenerator.java index b583079e0ff5..71e901054226 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/DefaultGenerator.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/DefaultGenerator.java @@ -762,6 +762,12 @@ private Map buildSupportFileBundle(List allOperations, L bundle.put("authMethods", authMethods); bundle.put("hasAuthMethods", true); } + + List servers = config.fromServers(openAPI.getServers()); + if (servers != null && !servers.isEmpty()) { + bundle.put("servers", servers); + bundle.put("hasServers", true); + } if (openAPI.getExternalDocs() != null) { bundle.put("externalDocs", openAPI.getExternalDocs()); diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/utils/URLPathUtils.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/utils/URLPathUtils.java index 91aba80d82c9..fdfa6fdfd6bc 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/utils/URLPathUtils.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/utils/URLPathUtils.java @@ -50,7 +50,7 @@ public static URL getServerURL(OpenAPI openAPI) { return getServerURL(servers.get(0)); } - static URL getServerURL(final Server server) { + public static URL getServerURL(final Server server) { String url = server.getUrl(); ServerVariables variables = server.getVariables(); if(variables == null) { From 62dfb749f1530a09327cb70a7eddd01f94e7d284 Mon Sep 17 00:00:00 2001 From: Jim Schubert Date: Sun, 19 Aug 2018 16:17:26 -0400 Subject: [PATCH 08/15] [gradle-plugin] README notes on multiple specs (#847) A user asked about how one would approach generating code from multiple specifications. Adding this information to the README, as it seems others would find the information helpful. Also explaining how to use tasks from this plugin as this may not be commonly known or intuitive beahvior. --- .../README.adoc | 76 +++++++++++++++++++ 1 file changed, 76 insertions(+) diff --git a/modules/openapi-generator-gradle-plugin/README.adoc b/modules/openapi-generator-gradle-plugin/README.adoc index ba0eb6dab25e..4090a03e88af 100644 --- a/modules/openapi-generator-gradle-plugin/README.adoc +++ b/modules/openapi-generator-gradle-plugin/README.adoc @@ -2,6 +2,9 @@ This document describes the gradle plugin for OpenAPI Generator. +This gradle plugin offers a declarative DSL via _extensions_ (these are Gradle project extensions). +These map almost fully 1:1 with the options you'd pass to the CLI or Maven plugin. The plugin maps the extensions to a task of the same name to provide a clean API. If you're interested in the extension/task mapping concept from a high-level, you can https://docs.gradle.org/current/userguide/custom_plugins.html#sec:mapping_extension_properties_to_task_properties[check out Gradle's docs]. + == Tasks Tasks are listed under the "OpenAPI Tools" tasks heading. @@ -24,6 +27,17 @@ Tasks are listed under the "OpenAPI Tools" tasks heading. |Validates an Open API 2.0 or 3.x specification document. |=== + +[NOTE] +==== +The plugin implements the above tasks as project extensions of the same name. If you'd like to declare +these tasks as dependencies to other tasks (using `dependsOn`), you'll need a task reference. e.g.: + +``` +compileJava.dependsOn tasks.openApiGenerate +``` +==== + == Plugin Setup [source,groovy] @@ -455,3 +469,65 @@ Run with --stacktrace option to get the stack trace. Run with --info or --debug ---- $ ./gradlew openApiValidate --input=/Users/jim/projects/openapi-generator/modules/openapi-generator/src/test/resources/3_0/petstore.yaml ---- + +=== Generate multiple sources + +If you want to perform multiple generation tasks, you'd want to create a task that inherits from the `GenerateTask`. +Examples can be found in https://github.com/OpenAPITools/openapi-generator/blob/master/modules/openapi-generator-gradle-plugin/samples/local-spec/build.gradle[samples/local-spec/build.gradle]. + +To match the example you are using for that old swagger based plugin: + +```gradle +task buildGoClient(type: org.openapitools.generator.gradle.plugin.tasks.GenerateTask){ + generatorName = "go" + inputSpec = "$rootDir/petstore-v3.0.yaml".toString() + additionalProperties = [ + packageName: "petstore" + ] + outputDir = "$buildDir/go".toString() + configOptions = [ + dateLibrary: "threetenp" + ] +} +task buildKotlinClient(type: org.openapitools.generator.gradle.plugin.tasks.GenerateTask){ + generatorName = "kotlin" + inputSpec = "$rootDir/petstore-v3.0.yaml".toString() + outputDir = "$buildDir/kotlin".toString() + apiPackage = "org.openapitools.example.api" + invokerPackage = "org.openapitools.example.invoker" + modelPackage = "org.openapitools.example.model" + configOptions = [ + dateLibrary: "java8" + ] + systemProperties = [ + modelDocs: "false" + ] +} +``` + +To execute your specs, you'd then do: + +``` +./gradlew buildGoClient buildKotlinClient +``` + +If you want to simplify the execution, you could create a new task with `dependsOn`. + +```gradle +task codegen(dependsOn: ['buildGoClient', 'buildKotlinClient']) +``` + +Or, if you're generating the code on compile, you can add these as a dependency to `compileJava` or any other existing task: + + +```gradle +compileJava.dependsOn buildKotlinClient, tasks.openApiGenerate +``` + +[NOTE] +==== +`openApiGenerate` is a project extension _and_ a task. If you want to use this in `dependsOn`, +you need a task reference or instance. One way to do this is to access it as `tasks.openApiGenerate`. + +You can run `gradle tasks --debug` to see this registration. +==== From bd7c9e30d323a6b7c78c2e64de917f39f9fbca39 Mon Sep 17 00:00:00 2001 From: Jack O'Sullivan Date: Mon, 20 Aug 2018 02:33:49 +0100 Subject: [PATCH 09/15] [cli] Don't log to STDOUT if debug flags are set (#474) It makes sense that error messages should be written to STDERR and all others should be written to STDOUT (as shown in #207). However, it would be convenient to parse the debugging output when the relevant flags are set. This change will disable logging to STDOUT and redirect all log messages to STDERR when any of the debug flags are set. (Resolves #473) --- .../org/openapitools/codegen/cmd/Generate.java | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/modules/openapi-generator-cli/src/main/java/org/openapitools/codegen/cmd/Generate.java b/modules/openapi-generator-cli/src/main/java/org/openapitools/codegen/cmd/Generate.java index 8c4db2af9e48..ae3613c41a99 100644 --- a/modules/openapi-generator-cli/src/main/java/org/openapitools/codegen/cmd/Generate.java +++ b/modules/openapi-generator-cli/src/main/java/org/openapitools/codegen/cmd/Generate.java @@ -17,6 +17,8 @@ package org.openapitools.codegen.cmd; +import ch.qos.logback.classic.LoggerContext; +import ch.qos.logback.core.spi.FilterAttachable; import io.airlift.airline.Command; import io.airlift.airline.Option; import org.openapitools.codegen.ClientOptInput; @@ -32,6 +34,7 @@ import java.util.ArrayList; import java.util.List; +import java.util.stream.Stream; /** * User: lanwen Date: 24.03.15 Time: 20:22 @@ -199,8 +202,23 @@ public class Generate implements Runnable { description = "Skips the default behavior of validating an input specification.") private Boolean skipValidateSpec; + @Option(name = {"--log-to-stderr"}, + title = "Log to STDERR", + description = "write all log messages (not just errors) to STDOUT." + + " Useful for piping the JSON output of debug options (e.g. `-DdebugOperations`) to an external parser directly while testing a generator.") + private Boolean logToStderr; + @Override public void run() { + if (logToStderr != null) { + LoggerContext lc = (LoggerContext) LoggerFactory.getILoggerFactory(); + Stream.of(Logger.ROOT_LOGGER_NAME, "io.swagger", "org.openapitools") + .map(lc::getLogger) + .peek(logger -> logger.detachAppender("STDOUT")) + .reduce((logger, next) -> logger.getName().equals(Logger.ROOT_LOGGER_NAME) ? logger : next) + .map(root -> root.getAppender("STDERR")) + .ifPresent(FilterAttachable::clearAllFilters); + } // attempt to read from config file CodegenConfigurator configurator = CodegenConfigurator.fromFile(configFile); From a3e5edc367946111f224af83378f4e91627ea973 Mon Sep 17 00:00:00 2001 From: Jim Schubert Date: Sun, 19 Aug 2018 21:37:20 -0400 Subject: [PATCH 10/15] :memo: Updating 'help generate' switches in README Adds new --log-to-stderr as well as a missed option for --skip-validate-spec. --- README.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 45f98af85527..dfbb92f28578 100644 --- a/README.md +++ b/README.md @@ -406,13 +406,14 @@ SYNOPSIS [--invoker-package ] [(-l | --lang )] [--language-specific-primitives ...] - [--library ] [--model-name-prefix ] + [--library ] [--log-to-stderr] + [--model-name-prefix ] [--model-name-suffix ] [--model-package ] [(-o | --output )] [--release-note ] [--remove-operation-id-prefix] [--reserved-words-mappings ...] - [(-s | --skip-overwrite)] + [(-s | --skip-overwrite)] [--skip-validate-spec] [(-t