Do not generate models for "object" type with no properties

Also updated the petstore sample to include operations to cover the case
in model property and response, and updated Java clients to sync with
it.

Closes #2237
This commit is contained in:
xhh
2016-03-02 21:08:41 +08:00
parent 336d80cbf3
commit 7bea6da587
21 changed files with 2184 additions and 105 deletions

View File

@@ -4,6 +4,7 @@ import io.swagger.client.ApiClient;
import io.swagger.client.model.Pet;
import java.io.File;
import io.swagger.client.model.PetWithArbitraryObject;
import java.util.ArrayList;
import java.util.HashMap;
@@ -11,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-02-25T16:20:49.744+08:00")
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-03-02T21:04:56.888+08:00")
public interface PetApi extends ApiClient.Api {
@@ -43,8 +44,8 @@ public interface PetApi extends ApiClient.Api {
/**
* Finds Pets by status
* Multiple status values can be provided with comma seperated strings
* @param status Status values that need to be considered for filter
* Multiple status values can be provided with comma separated strings
* @param status Status values that need to be considered for query
* @return List<Pet>
*/
@RequestLine("GET /pet/findByStatus?status={status}")
@@ -125,6 +126,19 @@ 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;
* 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
*/
@RequestLine("GET /pet/{petId}?response=inline_arbitrary_object")
@Headers({
"Content-type: application/json",
"Accepts: application/json",
})
PetWithArbitraryObject getPetByIdWithObject(@Param("petId") Long petId);
/**
* Fake endpoint to test byte array 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

View File

@@ -10,10 +10,23 @@ import java.util.List;
import java.util.Map;
import feign.*;
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-01-11T21:48:33.457Z")
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-03-02T21:04:56.888+08:00")
public interface StoreApi extends ApiClient.Api {
/**
* Finds orders by status
* A single status value can be provided as a string
* @param status Status value that needs to be considered for query
* @return List<Order>
*/
@RequestLine("GET /store/findByStatus?status={status}")
@Headers({
"Content-type: application/json",
"Accepts: application/json",
})
List<Order> findOrdersByStatus(@Param("status") String status);
/**
* Returns pet inventories by status
* Returns a map of status codes to quantities
@@ -26,6 +39,18 @@ public interface StoreApi extends ApiClient.Api {
})
Map<String, Integer> getInventory();
/**
* Returns pet inventories by status
* Returns an arbitrary object which is actually a map of status codes to quantities
* @return Object
*/
@RequestLine("GET /store/inventory?response=arbitrary_object")
@Headers({
"Content-type: application/json",
"Accepts: application/json",
})
Object getInventoryInObject();
/**
* Place an order for a pet
*

View File

@@ -0,0 +1,199 @@
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 ");
}
}