Update petstore to use an inline model for testing

and add test cases to Java clients for "object" type with no properties.
This commit is contained in:
xhh
2016-03-03 12:48:44 +08:00
parent 7bea6da587
commit f9cc29fb74
31 changed files with 872 additions and 1243 deletions

View File

@@ -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": {

View File

@@ -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 &#39;Find pet by ID&#39;
* Fake endpoint to test inline arbitrary object return by &#39;Find pet by ID&#39;
* Returns a pet when ID &lt; 10. ID &gt; 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<PetWithArbitraryObject> localVarReturnType = new GenericType<PetWithArbitraryObject>() {};
GenericType<InlineResponse200> localVarReturnType = new GenericType<InlineResponse200>() {};
return apiClient.invokeAPI(localVarPath, "GET", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, localVarReturnType);
}

View File

@@ -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 &#39;Get inventory&#39;
* Returns an arbitrary object which is actually a map of status codes to quantities
* @return Object
* @throws ApiException if fails to make API call

View File

@@ -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 ");
}
}

View File

@@ -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<String> photoUrls = new ArrayList<String>();
private List<Tag> tags = new ArrayList<Tag>();
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<String> photoUrls) {
this.photoUrls = photoUrls;
return this;
}
@ApiModelProperty(example = "null", required = true, value = "")
@JsonProperty("photoUrls")
public List<String> getPhotoUrls() {
return photoUrls;
}
public void setPhotoUrls(List<String> photoUrls) {
this.photoUrls = photoUrls;
}
/**
**/
public PetWithArbitraryObject tags(List<Tag> tags) {
this.tags = tags;
return this;
}
@ApiModelProperty(example = "null", value = "")
@JsonProperty("tags")
public List<Tag> getTags() {
return tags;
}
public void setTags(List<Tag> 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 ");
}
}

View File

@@ -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<String> 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();

View File

@@ -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();

View File

@@ -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 &#39;Find pet by ID&#39;
* Fake endpoint to test inline arbitrary object return by &#39;Find pet by ID&#39;
* Returns a pet when ID &lt; 10. ID &gt; 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 &#39;Find pet by ID&#39;

View File

@@ -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<String, Integer> getInventory();
/**
* Returns pet inventories by status
* Fake endpoint to test arbitrary object return by &#39;Get inventory&#39;
* Returns an arbitrary object which is actually a map of status codes to quantities
* @return Object
*/

View File

@@ -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 ");
}
}

View File

@@ -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<String> photoUrls = new ArrayList<String>();
private List<Tag> tags = new ArrayList<Tag>();
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<String> photoUrls) {
this.photoUrls = photoUrls;
return this;
}
@ApiModelProperty(example = "null", required = true, value = "")
@JsonProperty("photoUrls")
public List<String> getPhotoUrls() {
return photoUrls;
}
public void setPhotoUrls(List<String> photoUrls) {
this.photoUrls = photoUrls;
}
/**
**/
public PetWithArbitraryObject tags(List<Tag> tags) {
this.tags = tags;
return this;
}
@ApiModelProperty(example = "null", value = "")
@JsonProperty("tags")
public List<Tag> getTags() {
return tags;
}
public void setTags(List<Tag> 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 ");
}
}

View File

@@ -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 &#39;Find pet by ID&#39;
* Fake endpoint to test inline arbitrary object return by &#39;Find pet by ID&#39;
* Returns a pet when ID &lt; 10. ID &gt; 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<PetWithArbitraryObject> localVarReturnType = new GenericType<PetWithArbitraryObject>() {};
GenericType<InlineResponse200> localVarReturnType = new GenericType<InlineResponse200>() {};
return apiClient.invokeAPI(localVarPath, "GET", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, localVarReturnType);
}

View File

@@ -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 &#39;Get inventory&#39;
* Returns an arbitrary object which is actually a map of status codes to quantities
* @return Object
* @throws ApiException if fails to make API call

View File

@@ -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 ");
}
}

View File

@@ -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<String> photoUrls = new ArrayList<String>();
private List<Tag> tags = new ArrayList<Tag>();
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<String> photoUrls) {
this.photoUrls = photoUrls;
return this;
}
@ApiModelProperty(example = "null", required = true, value = "")
@JsonProperty("photoUrls")
public List<String> getPhotoUrls() {
return photoUrls;
}
public void setPhotoUrls(List<String> photoUrls) {
this.photoUrls = photoUrls;
}
/**
**/
public PetWithArbitraryObject tags(List<Tag> tags) {
this.tags = tags;
return this;
}
@ApiModelProperty(example = "null", value = "")
@JsonProperty("tags")
public List<Tag> getTags() {
return tags;
}
public void setTags(List<Tag> 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 ");
}
}

View File

@@ -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<String> 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();

View File

@@ -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();

View File

@@ -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 &#39;Find pet by ID&#39;
* Fake endpoint to test inline arbitrary object return by &#39;Find pet by ID&#39;
* Returns a pet when ID &lt; 10. ID &gt; 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<PetWithArbitraryObject> resp = getPetByIdWithObjectWithHttpInfo(petId);
public InlineResponse200 getPetByIdInObject(Long petId) throws ApiException {
ApiResponse<InlineResponse200> resp = getPetByIdInObjectWithHttpInfo(petId);
return resp.getData();
}
/**
* Fake endpoint to test byte array return by &#39;Find pet by ID&#39;
* Fake endpoint to test inline arbitrary object return by &#39;Find pet by ID&#39;
* Returns a pet when ID &lt; 10. ID &gt; 10 or nonintegers will simulate API error conditions
* @param petId ID of pet that needs to be fetched
* @return ApiResponse<PetWithArbitraryObject>
* @return ApiResponse<InlineResponse200>
* @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
*/
public ApiResponse<PetWithArbitraryObject> getPetByIdWithObjectWithHttpInfo(Long petId) throws ApiException {
Call call = getPetByIdWithObjectCall(petId, null, null);
Type localVarReturnType = new TypeToken<PetWithArbitraryObject>(){}.getType();
public ApiResponse<InlineResponse200> getPetByIdInObjectWithHttpInfo(Long petId) throws ApiException {
Call call = getPetByIdInObjectCall(petId, null, null);
Type localVarReturnType = new TypeToken<InlineResponse200>(){}.getType();
return apiClient.execute(call, localVarReturnType);
}
/**
* Fake endpoint to test byte array return by &#39;Find pet by ID&#39; (asynchronously)
* Fake endpoint to test inline arbitrary object return by &#39;Find pet by ID&#39; (asynchronously)
* Returns a pet when ID &lt; 10. ID &gt; 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<PetWithArbitraryObject> callback) throws ApiException {
public Call getPetByIdInObjectAsync(Long petId, final ApiCallback<InlineResponse200> 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<PetWithArbitraryObject>(){}.getType();
Call call = getPetByIdInObjectCall(petId, progressListener, progressRequestListener);
Type localVarReturnType = new TypeToken<InlineResponse200>(){}.getType();
apiClient.executeAsync(call, localVarReturnType, callback);
return call;
}

View File

@@ -291,7 +291,7 @@ public class StoreApi {
}
/**
* Returns pet inventories by status
* Fake endpoint to test arbitrary object return by &#39;Get inventory&#39;
* 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 &#39;Get inventory&#39;
* Returns an arbitrary object which is actually a map of status codes to quantities
* @return ApiResponse<Object>
* @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 &#39;Get inventory&#39; (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

View File

@@ -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 ");
}
}

View File

@@ -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<String> photoUrls = new ArrayList<String>();
@SerializedName("tags")
private List<Tag> tags = new ArrayList<Tag>();
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<String> getPhotoUrls() {
return photoUrls;
}
public void setPhotoUrls(List<String> photoUrls) {
this.photoUrls = photoUrls;
}
/**
**/
@ApiModelProperty(value = "")
public List<Tag> getTags() {
return tags;
}
public void setTags(List<Tag> 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 ");
}
}

View File

@@ -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<Pet>(){}.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<String> 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<Pet> pets = api.findPetsByStatus(Arrays.asList(new String[]{"available"}));
List<Pet> 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

View File

@@ -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();

View File

@@ -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 &#39;Find pet by ID&#39;
* Fake endpoint to test inline arbitrary object return by &#39;Find pet by ID&#39;
* Sync method
* Returns a pet when ID &lt; 10. ID &gt; 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 &#39;Find pet by ID&#39;
* Fake endpoint to test inline arbitrary object return by &#39;Find pet by ID&#39;
* 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<PetWithArbitraryObject> cb
void getPetByIdInObject(
@Path("petId") Long petId, Callback<InlineResponse200> cb
);
/**

View File

@@ -65,7 +65,7 @@ public interface StoreApi {
);
/**
* Returns pet inventories by status
* Fake endpoint to test arbitrary object return by &#39;Get inventory&#39;
* 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 &#39;Get inventory&#39;
* Async method
* @param cb callback method
* @return void

View File

@@ -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 ");
}
}

View File

@@ -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<String> photoUrls = new ArrayList<String>();
@SerializedName("tags")
private List<Tag> tags = new ArrayList<Tag>();
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<String> getPhotoUrls() {
return photoUrls;
}
public void setPhotoUrls(List<String> photoUrls) {
this.photoUrls = photoUrls;
}
/**
**/
@ApiModelProperty(value = "")
public List<Tag> getTags() {
return tags;
}
public void setTags(List<Tag> 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 ");
}
}

View File

@@ -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 &#39;Find pet by ID&#39;
* Fake endpoint to test inline arbitrary object return by &#39;Find pet by ID&#39;
* Returns a pet when ID &lt; 10. ID &gt; 10 or nonintegers will simulate API error conditions
* @param petId ID of pet that needs to be fetched
* @return Call<PetWithArbitraryObject>
* @return Call<InlineResponse200>
*/
@GET("pet/{petId}?response=inline_arbitrary_object")
Call<PetWithArbitraryObject> getPetByIdWithObject(
Call<InlineResponse200> getPetByIdInObject(
@Path("petId") Long petId
);

View File

@@ -42,7 +42,7 @@ public interface StoreApi {
/**
* Returns pet inventories by status
* Fake endpoint to test arbitrary object return by &#39;Get inventory&#39;
* Returns an arbitrary object which is actually a map of status codes to quantities
* @return Call<Object>
*/

View File

@@ -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 ");
}
}

View File

@@ -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<String> photoUrls = new ArrayList<String>();
@SerializedName("tags")
private List<Tag> tags = new ArrayList<Tag>();
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<String> getPhotoUrls() {
return photoUrls;
}
public void setPhotoUrls(List<String> photoUrls) {
this.photoUrls = photoUrls;
}
/**
**/
@ApiModelProperty(value = "")
public List<Tag> getTags() {
return tags;
}
public void setTags(List<Tag> 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 ");
}
}