diff --git a/modules/swagger-codegen/src/test/resources/2_0/petstore.json b/modules/swagger-codegen/src/test/resources/2_0/petstore.json index fc6f7a4e0a..3f5687ead8 100644 --- a/modules/swagger-codegen/src/test/resources/2_0/petstore.json +++ b/modules/swagger-codegen/src/test/resources/2_0/petstore.json @@ -314,9 +314,9 @@ "tags": [ "pet" ], - "summary": "Fake endpoint to test byte array return by 'Find pet by ID'", + "summary": "Fake endpoint to test inline arbitrary object return by 'Find pet by ID'", "description": "Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error conditions", - "operationId": "getPetByIdWithObject", + "operationId": "getPetByIdInObject", "produces": [ "application/json", "application/xml" @@ -338,7 +338,23 @@ "200": { "description": "successful operation", "schema": { - "$ref": "#/definitions/PetWithArbitraryObject" + "type": "object", + "required": [ + "id" + ], + "properties": { + "id": { + "type": "integer", + "format": "int64" + }, + "category": { + "type": "object" + }, + "name": { + "type": "string", + "example": "doggie" + } + } } }, "400": { @@ -590,7 +606,7 @@ "tags": [ "store" ], - "summary": "Returns pet inventories by status", + "summary": "Fake endpoint to test arbitrary object return by 'Get inventory'", "description": "Returns an arbitrary object which is actually a map of status codes to quantities", "operationId": "getInventoryInObject", "produces": [ @@ -1186,57 +1202,6 @@ "name": "Pet" } }, - "PetWithArbitraryObject": { - "required": [ - "name", - "photoUrls" - ], - "properties": { - "id": { - "type": "integer", - "format": "int64" - }, - "category": { - "type": "object" - }, - "name": { - "type": "string", - "example": "doggie" - }, - "photoUrls": { - "type": "array", - "xml": { - "name": "photoUrl", - "wrapped": true - }, - "items": { - "type": "string" - } - }, - "tags": { - "type": "array", - "xml": { - "name": "tag", - "wrapped": true - }, - "items": { - "$ref": "#/definitions/Tag" - } - }, - "status": { - "type": "string", - "description": "pet status in the store", - "enum": [ - "available", - "pending", - "sold" - ] - } - }, - "xml": { - "name": "PetWithArbitraryObject" - } - }, "Tag": { "properties": { "id": { diff --git a/samples/client/petstore/java/default/src/main/java/io/swagger/client/api/PetApi.java b/samples/client/petstore/java/default/src/main/java/io/swagger/client/api/PetApi.java index bddfd069a1..d9a6341354 100644 --- a/samples/client/petstore/java/default/src/main/java/io/swagger/client/api/PetApi.java +++ b/samples/client/petstore/java/default/src/main/java/io/swagger/client/api/PetApi.java @@ -9,14 +9,14 @@ import io.swagger.client.Pair; import io.swagger.client.model.Pet; import java.io.File; -import io.swagger.client.model.PetWithArbitraryObject; +import io.swagger.client.model.InlineResponse200; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-03-02T21:04:54.084+08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-03-03T10:59:23.243+08:00") public class PetApi { private ApiClient apiClient; @@ -407,18 +407,18 @@ public class PetApi { } /** - * Fake endpoint to test byte array return by 'Find pet by ID' + * Fake endpoint to test inline arbitrary object return by 'Find pet by ID' * Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error conditions * @param petId ID of pet that needs to be fetched - * @return PetWithArbitraryObject + * @return InlineResponse200 * @throws ApiException if fails to make API call */ - public PetWithArbitraryObject getPetByIdWithObject(Long petId) throws ApiException { + public InlineResponse200 getPetByIdInObject(Long petId) throws ApiException { Object localVarPostBody = null; // verify the required parameter 'petId' is set if (petId == null) { - throw new ApiException(400, "Missing the required parameter 'petId' when calling getPetByIdWithObject"); + throw new ApiException(400, "Missing the required parameter 'petId' when calling getPetByIdInObject"); } // create path and map variables @@ -449,7 +449,7 @@ public class PetApi { String[] localVarAuthNames = new String[] { "petstore_auth", "api_key" }; - GenericType localVarReturnType = new GenericType() {}; + GenericType localVarReturnType = new GenericType() {}; return apiClient.invokeAPI(localVarPath, "GET", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, localVarReturnType); } diff --git a/samples/client/petstore/java/default/src/main/java/io/swagger/client/api/StoreApi.java b/samples/client/petstore/java/default/src/main/java/io/swagger/client/api/StoreApi.java index 272c9fe4b1..5b900ac15d 100644 --- a/samples/client/petstore/java/default/src/main/java/io/swagger/client/api/StoreApi.java +++ b/samples/client/petstore/java/default/src/main/java/io/swagger/client/api/StoreApi.java @@ -14,7 +14,7 @@ import java.util.HashMap; import java.util.List; import java.util.Map; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-03-02T21:04:54.084+08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-03-03T11:57:06.886+08:00") public class StoreApi { private ApiClient apiClient; @@ -121,7 +121,7 @@ public class StoreApi { } /** - * Returns pet inventories by status + * Fake endpoint to test arbitrary object return by 'Get inventory' * Returns an arbitrary object which is actually a map of status codes to quantities * @return Object * @throws ApiException if fails to make API call diff --git a/samples/client/petstore/java/default/src/main/java/io/swagger/client/model/InlineResponse200.java b/samples/client/petstore/java/default/src/main/java/io/swagger/client/model/InlineResponse200.java new file mode 100644 index 0000000000..ae04afd1f1 --- /dev/null +++ b/samples/client/petstore/java/default/src/main/java/io/swagger/client/model/InlineResponse200.java @@ -0,0 +1,114 @@ +package io.swagger.client.model; + +import java.util.Objects; +import com.fasterxml.jackson.annotation.JsonProperty; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; + + + + + +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-03-03T10:48:49.300+08:00") +public class InlineResponse200 { + + private String name = null; + private Long id = null; + private Object category = null; + + + /** + **/ + public InlineResponse200 name(String name) { + this.name = name; + return this; + } + + @ApiModelProperty(example = "doggie", value = "") + @JsonProperty("name") + public String getName() { + return name; + } + public void setName(String name) { + this.name = name; + } + + + /** + **/ + public InlineResponse200 id(Long id) { + this.id = id; + return this; + } + + @ApiModelProperty(example = "null", required = true, value = "") + @JsonProperty("id") + public Long getId() { + return id; + } + public void setId(Long id) { + this.id = id; + } + + + /** + **/ + public InlineResponse200 category(Object category) { + this.category = category; + return this; + } + + @ApiModelProperty(example = "null", value = "") + @JsonProperty("category") + public Object getCategory() { + return category; + } + public void setCategory(Object category) { + this.category = category; + } + + + + @Override + public boolean equals(java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + InlineResponse200 inlineResponse200 = (InlineResponse200) o; + return Objects.equals(this.name, inlineResponse200.name) && + Objects.equals(this.id, inlineResponse200.id) && + Objects.equals(this.category, inlineResponse200.category); + } + + @Override + public int hashCode() { + return Objects.hash(name, id, category); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class InlineResponse200 {\n"); + + sb.append(" name: ").append(toIndentedString(name)).append("\n"); + sb.append(" id: ").append(toIndentedString(id)).append("\n"); + sb.append(" category: ").append(toIndentedString(category)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(java.lang.Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} + diff --git a/samples/client/petstore/java/default/src/main/java/io/swagger/client/model/PetWithArbitraryObject.java b/samples/client/petstore/java/default/src/main/java/io/swagger/client/model/PetWithArbitraryObject.java deleted file mode 100644 index d9fdcf1e91..0000000000 --- a/samples/client/petstore/java/default/src/main/java/io/swagger/client/model/PetWithArbitraryObject.java +++ /dev/null @@ -1,199 +0,0 @@ -package io.swagger.client.model; - -import java.util.Objects; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonValue; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; -import io.swagger.client.model.Tag; -import java.util.ArrayList; -import java.util.List; - - - - - -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-03-02T21:04:54.084+08:00") -public class PetWithArbitraryObject { - - private Long id = null; - private Object category = null; - private String name = null; - private List photoUrls = new ArrayList(); - private List tags = new ArrayList(); - - - public enum StatusEnum { - AVAILABLE("available"), - PENDING("pending"), - SOLD("sold"); - - private String value; - - StatusEnum(String value) { - this.value = value; - } - - @Override - @JsonValue - public String toString() { - return value; - } - } - - private StatusEnum status = null; - - - /** - **/ - public PetWithArbitraryObject id(Long id) { - this.id = id; - return this; - } - - @ApiModelProperty(example = "null", value = "") - @JsonProperty("id") - public Long getId() { - return id; - } - public void setId(Long id) { - this.id = id; - } - - - /** - **/ - public PetWithArbitraryObject category(Object category) { - this.category = category; - return this; - } - - @ApiModelProperty(example = "null", value = "") - @JsonProperty("category") - public Object getCategory() { - return category; - } - public void setCategory(Object category) { - this.category = category; - } - - - /** - **/ - public PetWithArbitraryObject name(String name) { - this.name = name; - return this; - } - - @ApiModelProperty(example = "doggie", required = true, value = "") - @JsonProperty("name") - public String getName() { - return name; - } - public void setName(String name) { - this.name = name; - } - - - /** - **/ - public PetWithArbitraryObject photoUrls(List photoUrls) { - this.photoUrls = photoUrls; - return this; - } - - @ApiModelProperty(example = "null", required = true, value = "") - @JsonProperty("photoUrls") - public List getPhotoUrls() { - return photoUrls; - } - public void setPhotoUrls(List photoUrls) { - this.photoUrls = photoUrls; - } - - - /** - **/ - public PetWithArbitraryObject tags(List tags) { - this.tags = tags; - return this; - } - - @ApiModelProperty(example = "null", value = "") - @JsonProperty("tags") - public List getTags() { - return tags; - } - public void setTags(List tags) { - this.tags = tags; - } - - - /** - * pet status in the store - **/ - public PetWithArbitraryObject status(StatusEnum status) { - this.status = status; - return this; - } - - @ApiModelProperty(example = "null", value = "pet status in the store") - @JsonProperty("status") - public StatusEnum getStatus() { - return status; - } - public void setStatus(StatusEnum status) { - this.status = status; - } - - - - @Override - public boolean equals(java.lang.Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - PetWithArbitraryObject petWithArbitraryObject = (PetWithArbitraryObject) o; - return Objects.equals(this.id, petWithArbitraryObject.id) && - Objects.equals(this.category, petWithArbitraryObject.category) && - Objects.equals(this.name, petWithArbitraryObject.name) && - Objects.equals(this.photoUrls, petWithArbitraryObject.photoUrls) && - Objects.equals(this.tags, petWithArbitraryObject.tags) && - Objects.equals(this.status, petWithArbitraryObject.status); - } - - @Override - public int hashCode() { - return Objects.hash(id, category, name, photoUrls, tags, status); - } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("class PetWithArbitraryObject {\n"); - - sb.append(" id: ").append(toIndentedString(id)).append("\n"); - sb.append(" category: ").append(toIndentedString(category)).append("\n"); - sb.append(" name: ").append(toIndentedString(name)).append("\n"); - sb.append(" photoUrls: ").append(toIndentedString(photoUrls)).append("\n"); - sb.append(" tags: ").append(toIndentedString(tags)).append("\n"); - sb.append(" status: ").append(toIndentedString(status)).append("\n"); - sb.append("}"); - return sb.toString(); - } - - /** - * Convert the given object to string with each line indented by 4 spaces - * (except the first line). - */ - private String toIndentedString(java.lang.Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); - } -} - diff --git a/samples/client/petstore/java/default/src/test/java/io/swagger/petstore/test/PetApiTest.java b/samples/client/petstore/java/default/src/test/java/io/swagger/petstore/test/PetApiTest.java index 52956a229d..ad971ea666 100644 --- a/samples/client/petstore/java/default/src/test/java/io/swagger/petstore/test/PetApiTest.java +++ b/samples/client/petstore/java/default/src/test/java/io/swagger/petstore/test/PetApiTest.java @@ -17,6 +17,7 @@ import java.io.FileWriter; import java.util.ArrayList; import java.util.Arrays; import java.util.List; +import java.util.Map; import org.junit.*; import static org.junit.Assert.*; @@ -86,6 +87,39 @@ public class PetApiTest { assertEquals(fetched.getCategory().getName(), pet.getCategory().getName()); } + @Test + public void testGetPetByIdInObject() throws Exception { + Pet pet = new Pet(); + pet.setId(TestUtils.nextId()); + pet.setName("pet " + pet.getId()); + + Category category = new Category(); + category.setId(TestUtils.nextId()); + category.setName("category " + category.getId()); + pet.setCategory(category); + + pet.setStatus(Pet.StatusEnum.PENDING); + List photos = Arrays.asList(new String[]{"http://foo.bar.com/1"}); + pet.setPhotoUrls(photos); + + api.addPet(pet); + + InlineResponse200 fetched = api.getPetByIdInObject(pet.getId()); + assertEquals(pet.getId(), fetched.getId()); + assertEquals(pet.getName(), fetched.getName()); + + Object categoryObj = fetched.getCategory(); + assertNotNull(categoryObj); + assertTrue(categoryObj instanceof Map); + + Map categoryMap = (Map) categoryObj; + Object categoryIdObj = categoryMap.get("id"); + assertTrue(categoryIdObj instanceof Integer); + Integer categoryIdInt = (Integer) categoryIdObj; + assertEquals(category.getId(), Long.valueOf(categoryIdInt)); + assertEquals(category.getName(), categoryMap.get("name")); + } + @Test public void testUpdatePet() throws Exception { Pet pet = createRandomPet(); diff --git a/samples/client/petstore/java/default/src/test/java/io/swagger/petstore/test/StoreApiTest.java b/samples/client/petstore/java/default/src/test/java/io/swagger/petstore/test/StoreApiTest.java index 0d3c00b8bf..403f9b64ec 100644 --- a/samples/client/petstore/java/default/src/test/java/io/swagger/petstore/test/StoreApiTest.java +++ b/samples/client/petstore/java/default/src/test/java/io/swagger/petstore/test/StoreApiTest.java @@ -35,6 +35,19 @@ public class StoreApiTest { assertTrue(inventory.keySet().size() > 0); } + @Test + public void testGetInventoryInObject() throws Exception { + Object inventoryObj = api.getInventoryInObject(); + assertTrue(inventoryObj instanceof Map); + + Map inventoryMap = (Map) inventoryObj; + assertTrue(inventoryMap.keySet().size() > 0); + + Map.Entry firstEntry = (Map.Entry) inventoryMap.entrySet().iterator().next(); + assertTrue(firstEntry.getKey() instanceof String); + assertTrue(firstEntry.getValue() instanceof Integer); + } + @Test public void testPlaceOrder() throws Exception { Order order = createOrder(); diff --git a/samples/client/petstore/java/feign/src/main/java/io/swagger/client/api/PetApi.java b/samples/client/petstore/java/feign/src/main/java/io/swagger/client/api/PetApi.java index 025db31017..1ef43cc376 100644 --- a/samples/client/petstore/java/feign/src/main/java/io/swagger/client/api/PetApi.java +++ b/samples/client/petstore/java/feign/src/main/java/io/swagger/client/api/PetApi.java @@ -4,7 +4,7 @@ import io.swagger.client.ApiClient; import io.swagger.client.model.Pet; import java.io.File; -import io.swagger.client.model.PetWithArbitraryObject; +import io.swagger.client.model.InlineResponse200; import java.util.ArrayList; import java.util.HashMap; @@ -12,7 +12,7 @@ import java.util.List; import java.util.Map; import feign.*; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-03-02T21:04:56.888+08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-03-03T12:04:41.120+08:00") public interface PetApi extends ApiClient.Api { @@ -127,17 +127,17 @@ public interface PetApi extends ApiClient.Api { void uploadFile(@Param("petId") Long petId, @Param("additionalMetadata") String additionalMetadata, @Param("file") File file); /** - * Fake endpoint to test byte array return by 'Find pet by ID' + * Fake endpoint to test inline arbitrary object return by 'Find pet by ID' * Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error conditions * @param petId ID of pet that needs to be fetched - * @return PetWithArbitraryObject + * @return InlineResponse200 */ @RequestLine("GET /pet/{petId}?response=inline_arbitrary_object") @Headers({ "Content-type: application/json", "Accepts: application/json", }) - PetWithArbitraryObject getPetByIdWithObject(@Param("petId") Long petId); + InlineResponse200 getPetByIdInObject(@Param("petId") Long petId); /** * Fake endpoint to test byte array return by 'Find pet by ID' diff --git a/samples/client/petstore/java/feign/src/main/java/io/swagger/client/api/StoreApi.java b/samples/client/petstore/java/feign/src/main/java/io/swagger/client/api/StoreApi.java index 39cad85572..cb70916ae6 100644 --- a/samples/client/petstore/java/feign/src/main/java/io/swagger/client/api/StoreApi.java +++ b/samples/client/petstore/java/feign/src/main/java/io/swagger/client/api/StoreApi.java @@ -10,7 +10,7 @@ import java.util.List; import java.util.Map; import feign.*; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-03-02T21:04:56.888+08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-03-03T12:04:41.120+08:00") public interface StoreApi extends ApiClient.Api { @@ -40,7 +40,7 @@ public interface StoreApi extends ApiClient.Api { Map getInventory(); /** - * Returns pet inventories by status + * Fake endpoint to test arbitrary object return by 'Get inventory' * Returns an arbitrary object which is actually a map of status codes to quantities * @return Object */ diff --git a/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/InlineResponse200.java b/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/InlineResponse200.java new file mode 100644 index 0000000000..3cdf734a80 --- /dev/null +++ b/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/InlineResponse200.java @@ -0,0 +1,114 @@ +package io.swagger.client.model; + +import java.util.Objects; +import com.fasterxml.jackson.annotation.JsonProperty; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; + + + + + +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-03-03T12:04:41.120+08:00") +public class InlineResponse200 { + + private String name = null; + private Long id = null; + private Object category = null; + + + /** + **/ + public InlineResponse200 name(String name) { + this.name = name; + return this; + } + + @ApiModelProperty(example = "doggie", value = "") + @JsonProperty("name") + public String getName() { + return name; + } + public void setName(String name) { + this.name = name; + } + + + /** + **/ + public InlineResponse200 id(Long id) { + this.id = id; + return this; + } + + @ApiModelProperty(example = "null", required = true, value = "") + @JsonProperty("id") + public Long getId() { + return id; + } + public void setId(Long id) { + this.id = id; + } + + + /** + **/ + public InlineResponse200 category(Object category) { + this.category = category; + return this; + } + + @ApiModelProperty(example = "null", value = "") + @JsonProperty("category") + public Object getCategory() { + return category; + } + public void setCategory(Object category) { + this.category = category; + } + + + + @Override + public boolean equals(java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + InlineResponse200 inlineResponse200 = (InlineResponse200) o; + return Objects.equals(this.name, inlineResponse200.name) && + Objects.equals(this.id, inlineResponse200.id) && + Objects.equals(this.category, inlineResponse200.category); + } + + @Override + public int hashCode() { + return Objects.hash(name, id, category); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class InlineResponse200 {\n"); + + sb.append(" name: ").append(toIndentedString(name)).append("\n"); + sb.append(" id: ").append(toIndentedString(id)).append("\n"); + sb.append(" category: ").append(toIndentedString(category)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(java.lang.Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} + diff --git a/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/PetWithArbitraryObject.java b/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/PetWithArbitraryObject.java deleted file mode 100644 index 1f36205c61..0000000000 --- a/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/PetWithArbitraryObject.java +++ /dev/null @@ -1,199 +0,0 @@ -package io.swagger.client.model; - -import java.util.Objects; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonValue; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; -import io.swagger.client.model.Tag; -import java.util.ArrayList; -import java.util.List; - - - - - -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-03-02T21:04:56.888+08:00") -public class PetWithArbitraryObject { - - private Long id = null; - private Object category = null; - private String name = null; - private List photoUrls = new ArrayList(); - private List tags = new ArrayList(); - - - public enum StatusEnum { - AVAILABLE("available"), - PENDING("pending"), - SOLD("sold"); - - private String value; - - StatusEnum(String value) { - this.value = value; - } - - @Override - @JsonValue - public String toString() { - return value; - } - } - - private StatusEnum status = null; - - - /** - **/ - public PetWithArbitraryObject id(Long id) { - this.id = id; - return this; - } - - @ApiModelProperty(example = "null", value = "") - @JsonProperty("id") - public Long getId() { - return id; - } - public void setId(Long id) { - this.id = id; - } - - - /** - **/ - public PetWithArbitraryObject category(Object category) { - this.category = category; - return this; - } - - @ApiModelProperty(example = "null", value = "") - @JsonProperty("category") - public Object getCategory() { - return category; - } - public void setCategory(Object category) { - this.category = category; - } - - - /** - **/ - public PetWithArbitraryObject name(String name) { - this.name = name; - return this; - } - - @ApiModelProperty(example = "doggie", required = true, value = "") - @JsonProperty("name") - public String getName() { - return name; - } - public void setName(String name) { - this.name = name; - } - - - /** - **/ - public PetWithArbitraryObject photoUrls(List photoUrls) { - this.photoUrls = photoUrls; - return this; - } - - @ApiModelProperty(example = "null", required = true, value = "") - @JsonProperty("photoUrls") - public List getPhotoUrls() { - return photoUrls; - } - public void setPhotoUrls(List photoUrls) { - this.photoUrls = photoUrls; - } - - - /** - **/ - public PetWithArbitraryObject tags(List tags) { - this.tags = tags; - return this; - } - - @ApiModelProperty(example = "null", value = "") - @JsonProperty("tags") - public List getTags() { - return tags; - } - public void setTags(List tags) { - this.tags = tags; - } - - - /** - * pet status in the store - **/ - public PetWithArbitraryObject status(StatusEnum status) { - this.status = status; - return this; - } - - @ApiModelProperty(example = "null", value = "pet status in the store") - @JsonProperty("status") - public StatusEnum getStatus() { - return status; - } - public void setStatus(StatusEnum status) { - this.status = status; - } - - - - @Override - public boolean equals(java.lang.Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - PetWithArbitraryObject petWithArbitraryObject = (PetWithArbitraryObject) o; - return Objects.equals(this.id, petWithArbitraryObject.id) && - Objects.equals(this.category, petWithArbitraryObject.category) && - Objects.equals(this.name, petWithArbitraryObject.name) && - Objects.equals(this.photoUrls, petWithArbitraryObject.photoUrls) && - Objects.equals(this.tags, petWithArbitraryObject.tags) && - Objects.equals(this.status, petWithArbitraryObject.status); - } - - @Override - public int hashCode() { - return Objects.hash(id, category, name, photoUrls, tags, status); - } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("class PetWithArbitraryObject {\n"); - - sb.append(" id: ").append(toIndentedString(id)).append("\n"); - sb.append(" category: ").append(toIndentedString(category)).append("\n"); - sb.append(" name: ").append(toIndentedString(name)).append("\n"); - sb.append(" photoUrls: ").append(toIndentedString(photoUrls)).append("\n"); - sb.append(" tags: ").append(toIndentedString(tags)).append("\n"); - sb.append(" status: ").append(toIndentedString(status)).append("\n"); - sb.append("}"); - return sb.toString(); - } - - /** - * Convert the given object to string with each line indented by 4 spaces - * (except the first line). - */ - private String toIndentedString(java.lang.Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); - } -} - diff --git a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/api/PetApi.java b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/api/PetApi.java index f78c24df3c..e661539eab 100644 --- a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/api/PetApi.java +++ b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/api/PetApi.java @@ -9,14 +9,14 @@ import javax.ws.rs.core.GenericType; import io.swagger.client.model.Pet; import java.io.File; -import io.swagger.client.model.PetWithArbitraryObject; +import io.swagger.client.model.InlineResponse200; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-03-02T21:04:55.453+08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-03-03T12:04:39.601+08:00") public class PetApi { private ApiClient apiClient; @@ -407,18 +407,18 @@ public class PetApi { } /** - * Fake endpoint to test byte array return by 'Find pet by ID' + * Fake endpoint to test inline arbitrary object return by 'Find pet by ID' * Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error conditions * @param petId ID of pet that needs to be fetched - * @return PetWithArbitraryObject + * @return InlineResponse200 * @throws ApiException if fails to make API call */ - public PetWithArbitraryObject getPetByIdWithObject(Long petId) throws ApiException { + public InlineResponse200 getPetByIdInObject(Long petId) throws ApiException { Object localVarPostBody = null; // verify the required parameter 'petId' is set if (petId == null) { - throw new ApiException(400, "Missing the required parameter 'petId' when calling getPetByIdWithObject"); + throw new ApiException(400, "Missing the required parameter 'petId' when calling getPetByIdInObject"); } // create path and map variables @@ -449,7 +449,7 @@ public class PetApi { String[] localVarAuthNames = new String[] { "petstore_auth", "api_key" }; - GenericType localVarReturnType = new GenericType() {}; + GenericType localVarReturnType = new GenericType() {}; return apiClient.invokeAPI(localVarPath, "GET", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, localVarReturnType); } diff --git a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/api/StoreApi.java b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/api/StoreApi.java index 56d6f8e6b6..73801be33d 100644 --- a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/api/StoreApi.java +++ b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/api/StoreApi.java @@ -14,7 +14,7 @@ import java.util.HashMap; import java.util.List; import java.util.Map; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-03-02T21:04:55.453+08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-03-03T12:04:39.601+08:00") public class StoreApi { private ApiClient apiClient; @@ -121,7 +121,7 @@ public class StoreApi { } /** - * Returns pet inventories by status + * Fake endpoint to test arbitrary object return by 'Get inventory' * Returns an arbitrary object which is actually a map of status codes to quantities * @return Object * @throws ApiException if fails to make API call diff --git a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/InlineResponse200.java b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/InlineResponse200.java new file mode 100644 index 0000000000..a966f51c80 --- /dev/null +++ b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/InlineResponse200.java @@ -0,0 +1,114 @@ +package io.swagger.client.model; + +import java.util.Objects; +import com.fasterxml.jackson.annotation.JsonProperty; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; + + + + + +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-03-03T12:04:39.601+08:00") +public class InlineResponse200 { + + private String name = null; + private Long id = null; + private Object category = null; + + + /** + **/ + public InlineResponse200 name(String name) { + this.name = name; + return this; + } + + @ApiModelProperty(example = "doggie", value = "") + @JsonProperty("name") + public String getName() { + return name; + } + public void setName(String name) { + this.name = name; + } + + + /** + **/ + public InlineResponse200 id(Long id) { + this.id = id; + return this; + } + + @ApiModelProperty(example = "null", required = true, value = "") + @JsonProperty("id") + public Long getId() { + return id; + } + public void setId(Long id) { + this.id = id; + } + + + /** + **/ + public InlineResponse200 category(Object category) { + this.category = category; + return this; + } + + @ApiModelProperty(example = "null", value = "") + @JsonProperty("category") + public Object getCategory() { + return category; + } + public void setCategory(Object category) { + this.category = category; + } + + + + @Override + public boolean equals(java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + InlineResponse200 inlineResponse200 = (InlineResponse200) o; + return Objects.equals(this.name, inlineResponse200.name) && + Objects.equals(this.id, inlineResponse200.id) && + Objects.equals(this.category, inlineResponse200.category); + } + + @Override + public int hashCode() { + return Objects.hash(name, id, category); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class InlineResponse200 {\n"); + + sb.append(" name: ").append(toIndentedString(name)).append("\n"); + sb.append(" id: ").append(toIndentedString(id)).append("\n"); + sb.append(" category: ").append(toIndentedString(category)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(java.lang.Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} + diff --git a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/PetWithArbitraryObject.java b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/PetWithArbitraryObject.java deleted file mode 100644 index 3a19cf49fa..0000000000 --- a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/PetWithArbitraryObject.java +++ /dev/null @@ -1,199 +0,0 @@ -package io.swagger.client.model; - -import java.util.Objects; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonValue; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; -import io.swagger.client.model.Tag; -import java.util.ArrayList; -import java.util.List; - - - - - -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-03-02T21:04:55.453+08:00") -public class PetWithArbitraryObject { - - private Long id = null; - private Object category = null; - private String name = null; - private List photoUrls = new ArrayList(); - private List tags = new ArrayList(); - - - public enum StatusEnum { - AVAILABLE("available"), - PENDING("pending"), - SOLD("sold"); - - private String value; - - StatusEnum(String value) { - this.value = value; - } - - @Override - @JsonValue - public String toString() { - return value; - } - } - - private StatusEnum status = null; - - - /** - **/ - public PetWithArbitraryObject id(Long id) { - this.id = id; - return this; - } - - @ApiModelProperty(example = "null", value = "") - @JsonProperty("id") - public Long getId() { - return id; - } - public void setId(Long id) { - this.id = id; - } - - - /** - **/ - public PetWithArbitraryObject category(Object category) { - this.category = category; - return this; - } - - @ApiModelProperty(example = "null", value = "") - @JsonProperty("category") - public Object getCategory() { - return category; - } - public void setCategory(Object category) { - this.category = category; - } - - - /** - **/ - public PetWithArbitraryObject name(String name) { - this.name = name; - return this; - } - - @ApiModelProperty(example = "doggie", required = true, value = "") - @JsonProperty("name") - public String getName() { - return name; - } - public void setName(String name) { - this.name = name; - } - - - /** - **/ - public PetWithArbitraryObject photoUrls(List photoUrls) { - this.photoUrls = photoUrls; - return this; - } - - @ApiModelProperty(example = "null", required = true, value = "") - @JsonProperty("photoUrls") - public List getPhotoUrls() { - return photoUrls; - } - public void setPhotoUrls(List photoUrls) { - this.photoUrls = photoUrls; - } - - - /** - **/ - public PetWithArbitraryObject tags(List tags) { - this.tags = tags; - return this; - } - - @ApiModelProperty(example = "null", value = "") - @JsonProperty("tags") - public List getTags() { - return tags; - } - public void setTags(List tags) { - this.tags = tags; - } - - - /** - * pet status in the store - **/ - public PetWithArbitraryObject status(StatusEnum status) { - this.status = status; - return this; - } - - @ApiModelProperty(example = "null", value = "pet status in the store") - @JsonProperty("status") - public StatusEnum getStatus() { - return status; - } - public void setStatus(StatusEnum status) { - this.status = status; - } - - - - @Override - public boolean equals(java.lang.Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - PetWithArbitraryObject petWithArbitraryObject = (PetWithArbitraryObject) o; - return Objects.equals(this.id, petWithArbitraryObject.id) && - Objects.equals(this.category, petWithArbitraryObject.category) && - Objects.equals(this.name, petWithArbitraryObject.name) && - Objects.equals(this.photoUrls, petWithArbitraryObject.photoUrls) && - Objects.equals(this.tags, petWithArbitraryObject.tags) && - Objects.equals(this.status, petWithArbitraryObject.status); - } - - @Override - public int hashCode() { - return Objects.hash(id, category, name, photoUrls, tags, status); - } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("class PetWithArbitraryObject {\n"); - - sb.append(" id: ").append(toIndentedString(id)).append("\n"); - sb.append(" category: ").append(toIndentedString(category)).append("\n"); - sb.append(" name: ").append(toIndentedString(name)).append("\n"); - sb.append(" photoUrls: ").append(toIndentedString(photoUrls)).append("\n"); - sb.append(" tags: ").append(toIndentedString(tags)).append("\n"); - sb.append(" status: ").append(toIndentedString(status)).append("\n"); - sb.append("}"); - return sb.toString(); - } - - /** - * Convert the given object to string with each line indented by 4 spaces - * (except the first line). - */ - private String toIndentedString(java.lang.Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); - } -} - diff --git a/samples/client/petstore/java/jersey2/src/test/java/io/swagger/petstore/test/PetApiTest.java b/samples/client/petstore/java/jersey2/src/test/java/io/swagger/petstore/test/PetApiTest.java index cf74f0dc5e..9af7c53787 100644 --- a/samples/client/petstore/java/jersey2/src/test/java/io/swagger/petstore/test/PetApiTest.java +++ b/samples/client/petstore/java/jersey2/src/test/java/io/swagger/petstore/test/PetApiTest.java @@ -15,6 +15,7 @@ import java.io.FileWriter; import java.util.ArrayList; import java.util.Arrays; import java.util.List; +import java.util.Map; import org.junit.*; import static org.junit.Assert.*; @@ -83,6 +84,39 @@ public class PetApiTest { assertEquals(fetched.getCategory().getName(), pet.getCategory().getName()); } + @Test + public void testGetPetByIdInObject() throws Exception { + Pet pet = new Pet(); + pet.setId(TestUtils.nextId()); + pet.setName("pet " + pet.getId()); + + Category category = new Category(); + category.setId(TestUtils.nextId()); + category.setName("category " + category.getId()); + pet.setCategory(category); + + pet.setStatus(Pet.StatusEnum.PENDING); + List photos = Arrays.asList(new String[]{"http://foo.bar.com/1"}); + pet.setPhotoUrls(photos); + + api.addPet(pet); + + InlineResponse200 fetched = api.getPetByIdInObject(pet.getId()); + assertEquals(pet.getId(), fetched.getId()); + assertEquals(pet.getName(), fetched.getName()); + + Object categoryObj = fetched.getCategory(); + assertNotNull(categoryObj); + assertTrue(categoryObj instanceof Map); + + Map categoryMap = (Map) categoryObj; + Object categoryIdObj = categoryMap.get("id"); + assertTrue(categoryIdObj instanceof Integer); + Integer categoryIdInt = (Integer) categoryIdObj; + assertEquals(category.getId(), Long.valueOf(categoryIdInt)); + assertEquals(category.getName(), categoryMap.get("name")); + } + @Test public void testUpdatePet() throws Exception { Pet pet = createRandomPet(); diff --git a/samples/client/petstore/java/jersey2/src/test/java/io/swagger/petstore/test/StoreApiTest.java b/samples/client/petstore/java/jersey2/src/test/java/io/swagger/petstore/test/StoreApiTest.java index 431cdd2d89..b0106d2f4c 100644 --- a/samples/client/petstore/java/jersey2/src/test/java/io/swagger/petstore/test/StoreApiTest.java +++ b/samples/client/petstore/java/jersey2/src/test/java/io/swagger/petstore/test/StoreApiTest.java @@ -33,6 +33,19 @@ public class StoreApiTest { assertTrue(inventory.keySet().size() > 0); } + @Test + public void testGetInventoryInObject() throws Exception { + Object inventoryObj = api.getInventoryInObject(); + assertTrue(inventoryObj instanceof Map); + + Map inventoryMap = (Map) inventoryObj; + assertTrue(inventoryMap.keySet().size() > 0); + + Map.Entry firstEntry = (Map.Entry) inventoryMap.entrySet().iterator().next(); + assertTrue(firstEntry.getKey() instanceof String); + assertTrue(firstEntry.getValue() instanceof Integer); + } + @Test public void testPlaceOrder() throws Exception { Order order = createOrder(); diff --git a/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/api/PetApi.java b/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/api/PetApi.java index 033fd69c63..df64a90309 100644 --- a/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/api/PetApi.java +++ b/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/api/PetApi.java @@ -19,7 +19,7 @@ import java.io.IOException; import io.swagger.client.model.Pet; import java.io.File; -import io.swagger.client.model.PetWithArbitraryObject; +import io.swagger.client.model.InlineResponse200; import java.lang.reflect.Type; import java.util.ArrayList; @@ -896,13 +896,13 @@ public class PetApi { return call; } - /* Build call for getPetByIdWithObject */ - private Call getPetByIdWithObjectCall(Long petId, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException { + /* Build call for getPetByIdInObject */ + private Call getPetByIdInObjectCall(Long petId, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException { Object localVarPostBody = null; // verify the required parameter 'petId' is set if (petId == null) { - throw new ApiException("Missing the required parameter 'petId' when calling getPetByIdWithObject(Async)"); + throw new ApiException("Missing the required parameter 'petId' when calling getPetByIdInObject(Async)"); } @@ -945,39 +945,39 @@ public class PetApi { } /** - * Fake endpoint to test byte array return by 'Find pet by ID' + * Fake endpoint to test inline arbitrary object return by 'Find pet by ID' * Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error conditions * @param petId ID of pet that needs to be fetched - * @return PetWithArbitraryObject + * @return InlineResponse200 * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body */ - public PetWithArbitraryObject getPetByIdWithObject(Long petId) throws ApiException { - ApiResponse resp = getPetByIdWithObjectWithHttpInfo(petId); + public InlineResponse200 getPetByIdInObject(Long petId) throws ApiException { + ApiResponse resp = getPetByIdInObjectWithHttpInfo(petId); return resp.getData(); } /** - * Fake endpoint to test byte array return by 'Find pet by ID' + * Fake endpoint to test inline arbitrary object return by 'Find pet by ID' * Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error conditions * @param petId ID of pet that needs to be fetched - * @return ApiResponse + * @return ApiResponse * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body */ - public ApiResponse getPetByIdWithObjectWithHttpInfo(Long petId) throws ApiException { - Call call = getPetByIdWithObjectCall(petId, null, null); - Type localVarReturnType = new TypeToken(){}.getType(); + public ApiResponse getPetByIdInObjectWithHttpInfo(Long petId) throws ApiException { + Call call = getPetByIdInObjectCall(petId, null, null); + Type localVarReturnType = new TypeToken(){}.getType(); return apiClient.execute(call, localVarReturnType); } /** - * Fake endpoint to test byte array return by 'Find pet by ID' (asynchronously) + * Fake endpoint to test inline arbitrary object return by 'Find pet by ID' (asynchronously) * Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error conditions * @param petId ID of pet that needs to be fetched * @param callback The callback to be executed when the API call finishes * @return The request call * @throws ApiException If fail to process the API call, e.g. serializing the request body object */ - public Call getPetByIdWithObjectAsync(Long petId, final ApiCallback callback) throws ApiException { + public Call getPetByIdInObjectAsync(Long petId, final ApiCallback callback) throws ApiException { ProgressResponseBody.ProgressListener progressListener = null; ProgressRequestBody.ProgressRequestListener progressRequestListener = null; @@ -998,8 +998,8 @@ public class PetApi { }; } - Call call = getPetByIdWithObjectCall(petId, progressListener, progressRequestListener); - Type localVarReturnType = new TypeToken(){}.getType(); + Call call = getPetByIdInObjectCall(petId, progressListener, progressRequestListener); + Type localVarReturnType = new TypeToken(){}.getType(); apiClient.executeAsync(call, localVarReturnType, callback); return call; } diff --git a/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/api/StoreApi.java b/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/api/StoreApi.java index d08d931c81..7625fae65b 100644 --- a/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/api/StoreApi.java +++ b/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/api/StoreApi.java @@ -291,7 +291,7 @@ public class StoreApi { } /** - * Returns pet inventories by status + * Fake endpoint to test arbitrary object return by 'Get inventory' * Returns an arbitrary object which is actually a map of status codes to quantities * @return Object * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body @@ -302,7 +302,7 @@ public class StoreApi { } /** - * Returns pet inventories by status + * Fake endpoint to test arbitrary object return by 'Get inventory' * Returns an arbitrary object which is actually a map of status codes to quantities * @return ApiResponse * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body @@ -314,7 +314,7 @@ public class StoreApi { } /** - * Returns pet inventories by status (asynchronously) + * Fake endpoint to test arbitrary object return by 'Get inventory' (asynchronously) * Returns an arbitrary object which is actually a map of status codes to quantities * @param callback The callback to be executed when the API call finishes * @return The request call diff --git a/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/model/InlineResponse200.java b/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/model/InlineResponse200.java new file mode 100644 index 0000000000..2093866e06 --- /dev/null +++ b/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/model/InlineResponse200.java @@ -0,0 +1,101 @@ +package io.swagger.client.model; + +import java.util.Objects; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; + +import com.google.gson.annotations.SerializedName; + + + + +@ApiModel(description = "") +public class InlineResponse200 { + + @SerializedName("name") + private String name = null; + + @SerializedName("id") + private Long id = null; + + @SerializedName("category") + private Object category = null; + + + + /** + **/ + @ApiModelProperty(value = "") + public String getName() { + return name; + } + public void setName(String name) { + this.name = name; + } + + + /** + **/ + @ApiModelProperty(required = true, value = "") + public Long getId() { + return id; + } + public void setId(Long id) { + this.id = id; + } + + + /** + **/ + @ApiModelProperty(value = "") + public Object getCategory() { + return category; + } + public void setCategory(Object category) { + this.category = category; + } + + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + InlineResponse200 inlineResponse200 = (InlineResponse200) o; + return Objects.equals(this.name, inlineResponse200.name) && + Objects.equals(this.id, inlineResponse200.id) && + Objects.equals(this.category, inlineResponse200.category); + } + + @Override + public int hashCode() { + return Objects.hash(name, id, category); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class InlineResponse200 {\n"); + + sb.append(" name: ").append(toIndentedString(name)).append("\n"); + sb.append(" id: ").append(toIndentedString(id)).append("\n"); + sb.append(" category: ").append(toIndentedString(category)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} diff --git a/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/model/PetWithArbitraryObject.java b/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/model/PetWithArbitraryObject.java deleted file mode 100644 index 60d4690933..0000000000 --- a/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/model/PetWithArbitraryObject.java +++ /dev/null @@ -1,176 +0,0 @@ -package io.swagger.client.model; - -import java.util.Objects; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; -import io.swagger.client.model.Tag; -import java.util.ArrayList; -import java.util.List; - -import com.google.gson.annotations.SerializedName; - - - - -@ApiModel(description = "") -public class PetWithArbitraryObject { - - @SerializedName("id") - private Long id = null; - - @SerializedName("category") - private Object category = null; - - @SerializedName("name") - private String name = null; - - @SerializedName("photoUrls") - private List photoUrls = new ArrayList(); - - @SerializedName("tags") - private List tags = new ArrayList(); - - -public enum StatusEnum { - @SerializedName("available") - AVAILABLE("available"), - - @SerializedName("pending") - PENDING("pending"), - - @SerializedName("sold") - SOLD("sold"); - - private String value; - - StatusEnum(String value) { - this.value = value; - } - - @Override - public String toString() { - return value; - } -} - - @SerializedName("status") - private StatusEnum status = null; - - - - /** - **/ - @ApiModelProperty(value = "") - public Long getId() { - return id; - } - public void setId(Long id) { - this.id = id; - } - - - /** - **/ - @ApiModelProperty(value = "") - public Object getCategory() { - return category; - } - public void setCategory(Object category) { - this.category = category; - } - - - /** - **/ - @ApiModelProperty(required = true, value = "") - public String getName() { - return name; - } - public void setName(String name) { - this.name = name; - } - - - /** - **/ - @ApiModelProperty(required = true, value = "") - public List getPhotoUrls() { - return photoUrls; - } - public void setPhotoUrls(List photoUrls) { - this.photoUrls = photoUrls; - } - - - /** - **/ - @ApiModelProperty(value = "") - public List getTags() { - return tags; - } - public void setTags(List tags) { - this.tags = tags; - } - - - /** - * pet status in the store - **/ - @ApiModelProperty(value = "pet status in the store") - public StatusEnum getStatus() { - return status; - } - public void setStatus(StatusEnum status) { - this.status = status; - } - - - - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - PetWithArbitraryObject petWithArbitraryObject = (PetWithArbitraryObject) o; - return Objects.equals(this.id, petWithArbitraryObject.id) && - Objects.equals(this.category, petWithArbitraryObject.category) && - Objects.equals(this.name, petWithArbitraryObject.name) && - Objects.equals(this.photoUrls, petWithArbitraryObject.photoUrls) && - Objects.equals(this.tags, petWithArbitraryObject.tags) && - Objects.equals(this.status, petWithArbitraryObject.status); - } - - @Override - public int hashCode() { - return Objects.hash(id, category, name, photoUrls, tags, status); - } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("class PetWithArbitraryObject {\n"); - - sb.append(" id: ").append(toIndentedString(id)).append("\n"); - sb.append(" category: ").append(toIndentedString(category)).append("\n"); - sb.append(" name: ").append(toIndentedString(name)).append("\n"); - sb.append(" photoUrls: ").append(toIndentedString(photoUrls)).append("\n"); - sb.append(" tags: ").append(toIndentedString(tags)).append("\n"); - sb.append(" status: ").append(toIndentedString(status)).append("\n"); - sb.append("}"); - return sb.toString(); - } - - /** - * Convert the given object to string with each line indented by 4 spaces - * (except the first line). - */ - private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); - } -} diff --git a/samples/client/petstore/java/okhttp-gson/src/test/java/io/swagger/petstore/test/PetApiTest.java b/samples/client/petstore/java/okhttp-gson/src/test/java/io/swagger/petstore/test/PetApiTest.java index a0b9a19792..97e708fb2e 100644 --- a/samples/client/petstore/java/okhttp-gson/src/test/java/io/swagger/petstore/test/PetApiTest.java +++ b/samples/client/petstore/java/okhttp-gson/src/test/java/io/swagger/petstore/test/PetApiTest.java @@ -75,12 +75,10 @@ public class PetApiTest { @Test public void testCreateAndGetPetWithByteArray() throws Exception { Pet pet = createRandomPet(); - System.out.println(serializeJson(pet, api.getApiClient())); byte[] bytes = serializeJson(pet, api.getApiClient()).getBytes(); api.addPetUsingByteArray(bytes); byte[] fetchedBytes = api.petPetIdtestingByteArraytrueGet(pet.getId()); - System.out.println(new String(fetchedBytes)); Type type = new TypeToken(){}.getType(); Pet fetched = deserializeJson(new String(fetchedBytes), type, api.getApiClient()); assertNotNull(fetched); @@ -199,6 +197,40 @@ public class PetApiTest { assertEquals("application/json", exception.getResponseHeaders().get("Content-Type").get(0)); } + @Test + public void testGetPetByIdInObject() throws Exception { + Pet pet = new Pet(); + pet.setId(TestUtils.nextId()); + pet.setName("pet " + pet.getId()); + + Category category = new Category(); + category.setId(TestUtils.nextId()); + category.setName("category " + category.getId()); + pet.setCategory(category); + + pet.setStatus(Pet.StatusEnum.PENDING); + List photos = Arrays.asList(new String[]{"http://foo.bar.com/1"}); + pet.setPhotoUrls(photos); + + api.addPet(pet); + + InlineResponse200 fetched = api.getPetByIdInObject(pet.getId()); + assertEquals(pet.getId(), fetched.getId()); + assertEquals(pet.getName(), fetched.getName()); + + Object categoryObj = fetched.getCategory(); + assertNotNull(categoryObj); + assertTrue(categoryObj instanceof Map); + + Map categoryMap = (Map) categoryObj; + Object categoryIdObj = categoryMap.get("id"); + // NOTE: Gson parses integer value to double. + assertTrue(categoryIdObj instanceof Double); + Long categoryIdLong = ((Double) categoryIdObj).longValue(); + assertEquals(category.getId(), categoryIdLong); + assertEquals(category.getName(), categoryMap.get("name")); + } + @Test public void testUpdatePet() throws Exception { Pet pet = createRandomPet(); @@ -217,11 +249,11 @@ public class PetApiTest { public void testFindPetsByStatus() throws Exception { Pet pet = createRandomPet(); pet.setName("programmer"); - pet.setStatus(Pet.StatusEnum.AVAILABLE); + pet.setStatus(Pet.StatusEnum.PENDING); api.updatePet(pet); - List pets = api.findPetsByStatus(Arrays.asList(new String[]{"available"})); + List pets = api.findPetsByStatus(Arrays.asList(new String[]{"pending"})); assertNotNull(pets); boolean found = false; @@ -233,6 +265,8 @@ public class PetApiTest { } assertTrue(found); + + api.deletePet(pet.getId(), null); } @Test @@ -260,6 +294,8 @@ public class PetApiTest { } } assertTrue(found); + + api.deletePet(pet.getId(), null); } @Test diff --git a/samples/client/petstore/java/okhttp-gson/src/test/java/io/swagger/petstore/test/StoreApiTest.java b/samples/client/petstore/java/okhttp-gson/src/test/java/io/swagger/petstore/test/StoreApiTest.java index 0ced94728a..2f4c429725 100644 --- a/samples/client/petstore/java/okhttp-gson/src/test/java/io/swagger/petstore/test/StoreApiTest.java +++ b/samples/client/petstore/java/okhttp-gson/src/test/java/io/swagger/petstore/test/StoreApiTest.java @@ -38,6 +38,20 @@ public class StoreApiTest { assertTrue(inventory.keySet().size() > 0); } + @Test + public void testGetInventoryInObject() throws Exception { + Object inventoryObj = api.getInventoryInObject(); + assertTrue(inventoryObj instanceof Map); + + Map inventoryMap = (Map) inventoryObj; + assertTrue(inventoryMap.keySet().size() > 0); + + Map.Entry firstEntry = (Map.Entry) inventoryMap.entrySet().iterator().next(); + assertTrue(firstEntry.getKey() instanceof String); + // NOTE: Gson parses integer value to double. + assertTrue(firstEntry.getValue() instanceof Double); + } + @Test public void testPlaceOrder() throws Exception { Order order = createOrder(); diff --git a/samples/client/petstore/java/retrofit/src/main/java/io/swagger/client/api/PetApi.java b/samples/client/petstore/java/retrofit/src/main/java/io/swagger/client/api/PetApi.java index 4b4fc5ab5c..af1172aa9d 100644 --- a/samples/client/petstore/java/retrofit/src/main/java/io/swagger/client/api/PetApi.java +++ b/samples/client/petstore/java/retrofit/src/main/java/io/swagger/client/api/PetApi.java @@ -8,7 +8,7 @@ import retrofit.mime.*; import io.swagger.client.model.Pet; import java.io.File; -import io.swagger.client.model.PetWithArbitraryObject; +import io.swagger.client.model.InlineResponse200; import java.util.ArrayList; import java.util.HashMap; @@ -240,20 +240,20 @@ public interface PetApi { ); /** - * Fake endpoint to test byte array return by 'Find pet by ID' + * Fake endpoint to test inline arbitrary object return by 'Find pet by ID' * Sync method * Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error conditions * @param petId ID of pet that needs to be fetched - * @return PetWithArbitraryObject + * @return InlineResponse200 */ @GET("/pet/{petId}?response=inline_arbitrary_object") - PetWithArbitraryObject getPetByIdWithObject( + InlineResponse200 getPetByIdInObject( @Path("petId") Long petId ); /** - * Fake endpoint to test byte array return by 'Find pet by ID' + * Fake endpoint to test inline arbitrary object return by 'Find pet by ID' * Async method * @param petId ID of pet that needs to be fetched * @param cb callback method @@ -261,8 +261,8 @@ public interface PetApi { */ @GET("/pet/{petId}?response=inline_arbitrary_object") - void getPetByIdWithObject( - @Path("petId") Long petId, Callback cb + void getPetByIdInObject( + @Path("petId") Long petId, Callback cb ); /** diff --git a/samples/client/petstore/java/retrofit/src/main/java/io/swagger/client/api/StoreApi.java b/samples/client/petstore/java/retrofit/src/main/java/io/swagger/client/api/StoreApi.java index 7ee9852a50..d68906ca95 100644 --- a/samples/client/petstore/java/retrofit/src/main/java/io/swagger/client/api/StoreApi.java +++ b/samples/client/petstore/java/retrofit/src/main/java/io/swagger/client/api/StoreApi.java @@ -65,7 +65,7 @@ public interface StoreApi { ); /** - * Returns pet inventories by status + * Fake endpoint to test arbitrary object return by 'Get inventory' * Sync method * Returns an arbitrary object which is actually a map of status codes to quantities * @return Object @@ -76,7 +76,7 @@ public interface StoreApi { /** - * Returns pet inventories by status + * Fake endpoint to test arbitrary object return by 'Get inventory' * Async method * @param cb callback method * @return void diff --git a/samples/client/petstore/java/retrofit/src/main/java/io/swagger/client/model/InlineResponse200.java b/samples/client/petstore/java/retrofit/src/main/java/io/swagger/client/model/InlineResponse200.java new file mode 100644 index 0000000000..41e49b9cd3 --- /dev/null +++ b/samples/client/petstore/java/retrofit/src/main/java/io/swagger/client/model/InlineResponse200.java @@ -0,0 +1,101 @@ +package io.swagger.client.model; + +import java.util.Objects; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; + +import com.google.gson.annotations.SerializedName; + + + + +@ApiModel(description = "") +public class InlineResponse200 { + + @SerializedName("name") + private String name = null; + + @SerializedName("id") + private Long id = null; + + @SerializedName("category") + private Object category = null; + + + + /** + **/ + @ApiModelProperty(value = "") + public String getName() { + return name; + } + public void setName(String name) { + this.name = name; + } + + + /** + **/ + @ApiModelProperty(required = true, value = "") + public Long getId() { + return id; + } + public void setId(Long id) { + this.id = id; + } + + + /** + **/ + @ApiModelProperty(value = "") + public Object getCategory() { + return category; + } + public void setCategory(Object category) { + this.category = category; + } + + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + InlineResponse200 inlineResponse200 = (InlineResponse200) o; + return Objects.equals(name, inlineResponse200.name) && + Objects.equals(id, inlineResponse200.id) && + Objects.equals(category, inlineResponse200.category); + } + + @Override + public int hashCode() { + return Objects.hash(name, id, category); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class InlineResponse200 {\n"); + + sb.append(" name: ").append(toIndentedString(name)).append("\n"); + sb.append(" id: ").append(toIndentedString(id)).append("\n"); + sb.append(" category: ").append(toIndentedString(category)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} diff --git a/samples/client/petstore/java/retrofit/src/main/java/io/swagger/client/model/PetWithArbitraryObject.java b/samples/client/petstore/java/retrofit/src/main/java/io/swagger/client/model/PetWithArbitraryObject.java deleted file mode 100644 index ce3ec9ede1..0000000000 --- a/samples/client/petstore/java/retrofit/src/main/java/io/swagger/client/model/PetWithArbitraryObject.java +++ /dev/null @@ -1,176 +0,0 @@ -package io.swagger.client.model; - -import java.util.Objects; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; -import io.swagger.client.model.Tag; -import java.util.ArrayList; -import java.util.List; - -import com.google.gson.annotations.SerializedName; - - - - -@ApiModel(description = "") -public class PetWithArbitraryObject { - - @SerializedName("id") - private Long id = null; - - @SerializedName("category") - private Object category = null; - - @SerializedName("name") - private String name = null; - - @SerializedName("photoUrls") - private List photoUrls = new ArrayList(); - - @SerializedName("tags") - private List tags = new ArrayList(); - - -public enum StatusEnum { - @SerializedName("available") - AVAILABLE("available"), - - @SerializedName("pending") - PENDING("pending"), - - @SerializedName("sold") - SOLD("sold"); - - private String value; - - StatusEnum(String value) { - this.value = value; - } - - @Override - public String toString() { - return value; - } -} - - @SerializedName("status") - private StatusEnum status = null; - - - - /** - **/ - @ApiModelProperty(value = "") - public Long getId() { - return id; - } - public void setId(Long id) { - this.id = id; - } - - - /** - **/ - @ApiModelProperty(value = "") - public Object getCategory() { - return category; - } - public void setCategory(Object category) { - this.category = category; - } - - - /** - **/ - @ApiModelProperty(required = true, value = "") - public String getName() { - return name; - } - public void setName(String name) { - this.name = name; - } - - - /** - **/ - @ApiModelProperty(required = true, value = "") - public List getPhotoUrls() { - return photoUrls; - } - public void setPhotoUrls(List photoUrls) { - this.photoUrls = photoUrls; - } - - - /** - **/ - @ApiModelProperty(value = "") - public List getTags() { - return tags; - } - public void setTags(List tags) { - this.tags = tags; - } - - - /** - * pet status in the store - **/ - @ApiModelProperty(value = "pet status in the store") - public StatusEnum getStatus() { - return status; - } - public void setStatus(StatusEnum status) { - this.status = status; - } - - - - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - PetWithArbitraryObject petWithArbitraryObject = (PetWithArbitraryObject) o; - return Objects.equals(id, petWithArbitraryObject.id) && - Objects.equals(category, petWithArbitraryObject.category) && - Objects.equals(name, petWithArbitraryObject.name) && - Objects.equals(photoUrls, petWithArbitraryObject.photoUrls) && - Objects.equals(tags, petWithArbitraryObject.tags) && - Objects.equals(status, petWithArbitraryObject.status); - } - - @Override - public int hashCode() { - return Objects.hash(id, category, name, photoUrls, tags, status); - } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("class PetWithArbitraryObject {\n"); - - sb.append(" id: ").append(toIndentedString(id)).append("\n"); - sb.append(" category: ").append(toIndentedString(category)).append("\n"); - sb.append(" name: ").append(toIndentedString(name)).append("\n"); - sb.append(" photoUrls: ").append(toIndentedString(photoUrls)).append("\n"); - sb.append(" tags: ").append(toIndentedString(tags)).append("\n"); - sb.append(" status: ").append(toIndentedString(status)).append("\n"); - sb.append("}"); - return sb.toString(); - } - - /** - * Convert the given object to string with each line indented by 4 spaces - * (except the first line). - */ - private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); - } -} diff --git a/samples/client/petstore/java/retrofit2/src/main/java/io/swagger/client/api/PetApi.java b/samples/client/petstore/java/retrofit2/src/main/java/io/swagger/client/api/PetApi.java index 9fb0c97939..f7e5f15a42 100644 --- a/samples/client/petstore/java/retrofit2/src/main/java/io/swagger/client/api/PetApi.java +++ b/samples/client/petstore/java/retrofit2/src/main/java/io/swagger/client/api/PetApi.java @@ -10,7 +10,7 @@ import okhttp3.RequestBody; import io.swagger.client.model.Pet; import java.io.File; -import io.swagger.client.model.PetWithArbitraryObject; +import io.swagger.client.model.InlineResponse200; import java.util.ArrayList; import java.util.HashMap; @@ -131,14 +131,14 @@ public interface PetApi { /** - * Fake endpoint to test byte array return by 'Find pet by ID' + * Fake endpoint to test inline arbitrary object return by 'Find pet by ID' * Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error conditions * @param petId ID of pet that needs to be fetched - * @return Call + * @return Call */ @GET("pet/{petId}?response=inline_arbitrary_object") - Call getPetByIdWithObject( + Call getPetByIdInObject( @Path("petId") Long petId ); diff --git a/samples/client/petstore/java/retrofit2/src/main/java/io/swagger/client/api/StoreApi.java b/samples/client/petstore/java/retrofit2/src/main/java/io/swagger/client/api/StoreApi.java index 9a0b29ecb8..f23b71a2e1 100644 --- a/samples/client/petstore/java/retrofit2/src/main/java/io/swagger/client/api/StoreApi.java +++ b/samples/client/petstore/java/retrofit2/src/main/java/io/swagger/client/api/StoreApi.java @@ -42,7 +42,7 @@ public interface StoreApi { /** - * Returns pet inventories by status + * Fake endpoint to test arbitrary object return by 'Get inventory' * Returns an arbitrary object which is actually a map of status codes to quantities * @return Call */ diff --git a/samples/client/petstore/java/retrofit2/src/main/java/io/swagger/client/model/InlineResponse200.java b/samples/client/petstore/java/retrofit2/src/main/java/io/swagger/client/model/InlineResponse200.java new file mode 100644 index 0000000000..41e49b9cd3 --- /dev/null +++ b/samples/client/petstore/java/retrofit2/src/main/java/io/swagger/client/model/InlineResponse200.java @@ -0,0 +1,101 @@ +package io.swagger.client.model; + +import java.util.Objects; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; + +import com.google.gson.annotations.SerializedName; + + + + +@ApiModel(description = "") +public class InlineResponse200 { + + @SerializedName("name") + private String name = null; + + @SerializedName("id") + private Long id = null; + + @SerializedName("category") + private Object category = null; + + + + /** + **/ + @ApiModelProperty(value = "") + public String getName() { + return name; + } + public void setName(String name) { + this.name = name; + } + + + /** + **/ + @ApiModelProperty(required = true, value = "") + public Long getId() { + return id; + } + public void setId(Long id) { + this.id = id; + } + + + /** + **/ + @ApiModelProperty(value = "") + public Object getCategory() { + return category; + } + public void setCategory(Object category) { + this.category = category; + } + + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + InlineResponse200 inlineResponse200 = (InlineResponse200) o; + return Objects.equals(name, inlineResponse200.name) && + Objects.equals(id, inlineResponse200.id) && + Objects.equals(category, inlineResponse200.category); + } + + @Override + public int hashCode() { + return Objects.hash(name, id, category); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class InlineResponse200 {\n"); + + sb.append(" name: ").append(toIndentedString(name)).append("\n"); + sb.append(" id: ").append(toIndentedString(id)).append("\n"); + sb.append(" category: ").append(toIndentedString(category)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} diff --git a/samples/client/petstore/java/retrofit2/src/main/java/io/swagger/client/model/PetWithArbitraryObject.java b/samples/client/petstore/java/retrofit2/src/main/java/io/swagger/client/model/PetWithArbitraryObject.java deleted file mode 100644 index ce3ec9ede1..0000000000 --- a/samples/client/petstore/java/retrofit2/src/main/java/io/swagger/client/model/PetWithArbitraryObject.java +++ /dev/null @@ -1,176 +0,0 @@ -package io.swagger.client.model; - -import java.util.Objects; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; -import io.swagger.client.model.Tag; -import java.util.ArrayList; -import java.util.List; - -import com.google.gson.annotations.SerializedName; - - - - -@ApiModel(description = "") -public class PetWithArbitraryObject { - - @SerializedName("id") - private Long id = null; - - @SerializedName("category") - private Object category = null; - - @SerializedName("name") - private String name = null; - - @SerializedName("photoUrls") - private List photoUrls = new ArrayList(); - - @SerializedName("tags") - private List tags = new ArrayList(); - - -public enum StatusEnum { - @SerializedName("available") - AVAILABLE("available"), - - @SerializedName("pending") - PENDING("pending"), - - @SerializedName("sold") - SOLD("sold"); - - private String value; - - StatusEnum(String value) { - this.value = value; - } - - @Override - public String toString() { - return value; - } -} - - @SerializedName("status") - private StatusEnum status = null; - - - - /** - **/ - @ApiModelProperty(value = "") - public Long getId() { - return id; - } - public void setId(Long id) { - this.id = id; - } - - - /** - **/ - @ApiModelProperty(value = "") - public Object getCategory() { - return category; - } - public void setCategory(Object category) { - this.category = category; - } - - - /** - **/ - @ApiModelProperty(required = true, value = "") - public String getName() { - return name; - } - public void setName(String name) { - this.name = name; - } - - - /** - **/ - @ApiModelProperty(required = true, value = "") - public List getPhotoUrls() { - return photoUrls; - } - public void setPhotoUrls(List photoUrls) { - this.photoUrls = photoUrls; - } - - - /** - **/ - @ApiModelProperty(value = "") - public List getTags() { - return tags; - } - public void setTags(List tags) { - this.tags = tags; - } - - - /** - * pet status in the store - **/ - @ApiModelProperty(value = "pet status in the store") - public StatusEnum getStatus() { - return status; - } - public void setStatus(StatusEnum status) { - this.status = status; - } - - - - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - PetWithArbitraryObject petWithArbitraryObject = (PetWithArbitraryObject) o; - return Objects.equals(id, petWithArbitraryObject.id) && - Objects.equals(category, petWithArbitraryObject.category) && - Objects.equals(name, petWithArbitraryObject.name) && - Objects.equals(photoUrls, petWithArbitraryObject.photoUrls) && - Objects.equals(tags, petWithArbitraryObject.tags) && - Objects.equals(status, petWithArbitraryObject.status); - } - - @Override - public int hashCode() { - return Objects.hash(id, category, name, photoUrls, tags, status); - } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("class PetWithArbitraryObject {\n"); - - sb.append(" id: ").append(toIndentedString(id)).append("\n"); - sb.append(" category: ").append(toIndentedString(category)).append("\n"); - sb.append(" name: ").append(toIndentedString(name)).append("\n"); - sb.append(" photoUrls: ").append(toIndentedString(photoUrls)).append("\n"); - sb.append(" tags: ").append(toIndentedString(tags)).append("\n"); - sb.append(" status: ").append(toIndentedString(status)).append("\n"); - sb.append("}"); - return sb.toString(); - } - - /** - * Convert the given object to string with each line indented by 4 spaces - * (except the first line). - */ - private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); - } -}