From 426cc6b6b490d7bc5017de6b43416bff81a37531 Mon Sep 17 00:00:00 2001 From: cbornet Date: Tue, 21 Jun 2016 16:19:37 +0200 Subject: [PATCH] better enums and dependency update --- .../codegen/languages/SpringCodegen.java | 27 +---- .../resources/JavaSpring/enumClass.mustache | 17 +++ .../JavaSpring/enumOuterClass.mustache | 3 + .../libraries/spring-boot/pom.mustache | 11 +- .../main/resources/JavaSpring/model.mustache | 69 +----------- .../main/resources/JavaSpring/pojo.mustache | 73 +++++++++++++ samples/client/petstore/spring-stubs/pom.xml | 7 +- .../main/java/io/swagger/model/Category.java | 43 ++++++-- .../io/swagger/model/ModelApiResponse.java | 51 +++++++-- .../src/main/java/io/swagger/model/Order.java | 98 ++++++++++++++--- .../src/main/java/io/swagger/model/Pet.java | 100 ++++++++++++++---- .../src/main/java/io/swagger/model/Tag.java | 43 ++++++-- .../src/main/java/io/swagger/model/User.java | 91 +++++++++++++--- .../main/java/io/swagger/model/Category.java | 43 ++++++-- .../io/swagger/model/ModelApiResponse.java | 51 +++++++-- .../src/main/java/io/swagger/model/Order.java | 98 ++++++++++++++--- .../src/main/java/io/swagger/model/Pet.java | 100 ++++++++++++++---- .../src/main/java/io/swagger/model/Tag.java | 43 ++++++-- .../src/main/java/io/swagger/model/User.java | 91 +++++++++++++--- .../main/java/io/swagger/model/Category.java | 43 ++++++-- .../io/swagger/model/ModelApiResponse.java | 51 +++++++-- .../src/main/java/io/swagger/model/Order.java | 98 ++++++++++++++--- .../src/main/java/io/swagger/model/Pet.java | 100 ++++++++++++++---- .../src/main/java/io/swagger/model/Tag.java | 43 ++++++-- .../src/main/java/io/swagger/model/User.java | 91 +++++++++++++--- .../springboot/.swagger-codegen-ignore | 2 +- samples/server/petstore/springboot/pom.xml | 7 +- .../main/java/io/swagger/model/Category.java | 43 ++++++-- .../io/swagger/model/ModelApiResponse.java | 51 +++++++-- .../src/main/java/io/swagger/model/Order.java | 98 ++++++++++++++--- .../src/main/java/io/swagger/model/Pet.java | 100 ++++++++++++++---- .../src/main/java/io/swagger/model/Tag.java | 43 ++++++-- .../src/main/java/io/swagger/model/User.java | 91 +++++++++++++--- 33 files changed, 1493 insertions(+), 427 deletions(-) create mode 100644 modules/swagger-codegen/src/main/resources/JavaSpring/enumClass.mustache create mode 100644 modules/swagger-codegen/src/main/resources/JavaSpring/enumOuterClass.mustache create mode 100644 modules/swagger-codegen/src/main/resources/JavaSpring/pojo.mustache diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/SpringCodegen.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/SpringCodegen.java index 713c01b626..9a4ee3256e 100644 --- a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/SpringCodegen.java +++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/SpringCodegen.java @@ -291,34 +291,15 @@ public class SpringCodegen extends AbstractJavaCodegen { public void setJava8(boolean java8) { this.java8 = java8; } public void setAsync(boolean async) { this.async = async; } - - @Override - public Map postProcessModels(Map objs) { - // remove the import of "Object" to avoid compilation error - List> imports = (List>) objs.get("imports"); - Iterator> iterator = imports.iterator(); - while (iterator.hasNext()) { - String _import = iterator.next().get("import"); - if (_import.endsWith(".Object")) iterator.remove(); - } - List models = (List) objs.get("models"); - for (Object _mo : models) { - Map mo = (Map) _mo; - CodegenModel cm = (CodegenModel) mo.get("model"); - for (CodegenProperty var : cm.vars) { - // handle default value for enum, e.g. available => StatusEnum.available - if (var.isEnum && var.defaultValue != null && !"null".equals(var.defaultValue)) { - var.defaultValue = var.datatypeWithEnum + "." + var.defaultValue; - } - } - } - return objs; - } @Override public void postProcessModelProperty(CodegenModel model, CodegenProperty property) { super.postProcessModelProperty(model, property); + if("null".equals(property.example)) { + property.example = null; + } + //Add imports for Jackson if(!BooleanUtils.toBoolean(model.isEnum)) { model.imports.add("JsonProperty"); diff --git a/modules/swagger-codegen/src/main/resources/JavaSpring/enumClass.mustache b/modules/swagger-codegen/src/main/resources/JavaSpring/enumClass.mustache new file mode 100644 index 0000000000..0867107d99 --- /dev/null +++ b/modules/swagger-codegen/src/main/resources/JavaSpring/enumClass.mustache @@ -0,0 +1,17 @@ + + public enum {{{datatypeWithEnum}}} { + {{#allowableValues}}{{#enumVars}}{{{name}}}({{{value}}}){{^-last}}, + {{/-last}}{{#-last}};{{/-last}}{{/enumVars}}{{/allowableValues}} + + private String value; + + {{{datatypeWithEnum}}}(String value) { + this.value = value; + } + + @Override + @JsonValue + public String toString() { + return value; + } + } diff --git a/modules/swagger-codegen/src/main/resources/JavaSpring/enumOuterClass.mustache b/modules/swagger-codegen/src/main/resources/JavaSpring/enumOuterClass.mustache new file mode 100644 index 0000000000..7aea7b92f2 --- /dev/null +++ b/modules/swagger-codegen/src/main/resources/JavaSpring/enumOuterClass.mustache @@ -0,0 +1,3 @@ +public enum {{classname}} { + {{#allowableValues}}{{.}}{{^-last}}, {{/-last}}{{/allowableValues}} +} \ No newline at end of file diff --git a/modules/swagger-codegen/src/main/resources/JavaSpring/libraries/spring-boot/pom.mustache b/modules/swagger-codegen/src/main/resources/JavaSpring/libraries/spring-boot/pom.mustache index d3b0cbfd46..3ee88cff43 100644 --- a/modules/swagger-codegen/src/main/resources/JavaSpring/libraries/spring-boot/pom.mustache +++ b/modules/swagger-codegen/src/main/resources/JavaSpring/libraries/spring-boot/pom.mustache @@ -6,16 +6,15 @@ {{artifactId}} {{artifactVersion}} - 2.4.0 - {{#java8}} - 1.8 - 1.8 - {{/java8}} + {{#java8}}1.8{{/java8}}{{^java8}}1.7{{/java8}} + ${java.version} + ${java.version} + 2.5.0 org.springframework.boot spring-boot-starter-parent - 1.3.3.RELEASE + 1.3.5.RELEASE src/main/java diff --git a/modules/swagger-codegen/src/main/resources/JavaSpring/model.mustache b/modules/swagger-codegen/src/main/resources/JavaSpring/model.mustache index d69af3892b..b9512d2b83 100644 --- a/modules/swagger-codegen/src/main/resources/JavaSpring/model.mustache +++ b/modules/swagger-codegen/src/main/resources/JavaSpring/model.mustache @@ -1,77 +1,16 @@ package {{package}}; +import java.util.Objects; {{#imports}}import {{import}}; {{/imports}} -import io.swagger.annotations.*; -import com.fasterxml.jackson.annotation.JsonProperty; - -import java.util.Objects; +{{#serializableModel}}import java.io.Serializable;{{/serializableModel}} {{#models}} - {{#model}}{{#description}} /** * {{description}} **/{{/description}} -{{>generatedAnnotation}} -@ApiModel(description = "{{{description}}}") -public class {{classname}} {{#parent}}extends {{{parent}}}{{/parent}} { - {{#vars}}{{#isEnum}} - public enum {{datatypeWithEnum}} { - {{#allowableValues}}{{#values}} {{.}}, {{/values}}{{/allowableValues}} - }; - {{/isEnum}}{{#items}}{{#isEnum}} - public enum {{datatypeWithEnum}} { - {{#allowableValues}}{{#values}} {{.}}, {{/values}}{{/allowableValues}} - }; - {{/isEnum}}{{/items}} - private {{{datatypeWithEnum}}} {{name}} = {{{defaultValue}}};{{/vars}} - - {{#vars}} - /**{{#description}} - * {{{description}}}{{/description}}{{#minimum}} - * minimum: {{minimum}}{{/minimum}}{{#maximum}} - * maximum: {{maximum}}{{/maximum}} - **/ - @ApiModelProperty({{#required}}required = {{required}}, {{/required}}value = "{{{description}}}") - @JsonProperty("{{baseName}}") - public {{{datatypeWithEnum}}} {{getter}}() { - return {{name}}; - } - public void {{setter}}({{{datatypeWithEnum}}} {{name}}) { - this.{{name}} = {{name}}; - } - - {{/vars}} - - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - {{classname}} {{classVarName}} = ({{classname}}) o;{{#hasVars}} - return {{#vars}}Objects.equals({{name}}, {{classVarName}}.{{name}}){{#hasMore}} && - {{/hasMore}}{{^hasMore}};{{/hasMore}}{{/vars}}{{/hasVars}}{{^hasVars}} - return true;{{/hasVars}} - } - - @Override - public int hashCode() { - return Objects.hash({{#vars}}{{name}}{{#hasMore}}, {{/hasMore}}{{/vars}}); - } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("class {{classname}} {\n"); - {{#parent}}sb.append(" " + super.toString()).append("\n");{{/parent}} - {{#vars}}sb.append(" {{name}}: ").append({{name}}).append("\n"); - {{/vars}}sb.append("}\n"); - return sb.toString(); - } -} +{{#isEnum}}{{>enumOuterClass}}{{/isEnum}} +{{^isEnum}}{{>pojo}}{{/isEnum}} {{/model}} {{/models}} diff --git a/modules/swagger-codegen/src/main/resources/JavaSpring/pojo.mustache b/modules/swagger-codegen/src/main/resources/JavaSpring/pojo.mustache new file mode 100644 index 0000000000..58bfed1638 --- /dev/null +++ b/modules/swagger-codegen/src/main/resources/JavaSpring/pojo.mustache @@ -0,0 +1,73 @@ +{{#description}}@ApiModel(description = "{{{description}}}"){{/description}} +{{>generatedAnnotation}} +public class {{classname}} {{#parent}}extends {{{parent}}}{{/parent}} {{#serializableModel}}implements Serializable{{/serializableModel}} { + {{#vars}}{{#isEnum}} + +{{>enumClass}}{{/isEnum}}{{#items.isEnum}}{{#items}} + +{{>enumClass}}{{/items}}{{/items.isEnum}} + private {{{datatypeWithEnum}}} {{name}} = {{{defaultValue}}};{{/vars}} + + {{#vars}} + /**{{#description}} + * {{{description}}}{{/description}}{{#minimum}} + * minimum: {{minimum}}{{/minimum}}{{#maximum}} + * maximum: {{maximum}}{{/maximum}} + **/ + public {{classname}} {{name}}({{{datatypeWithEnum}}} {{name}}) { + this.{{name}} = {{name}}; + return this; + } + + {{#vendorExtensions.extraAnnotation}}{{vendorExtensions.extraAnnotation}}{{/vendorExtensions.extraAnnotation}} + @ApiModelProperty({{#example}}example = "{{example}}", {{/example}}{{#required}}required = {{required}}, {{/required}}value = "{{{description}}}") + @JsonProperty("{{baseName}}") + public {{{datatypeWithEnum}}} {{getter}}() { + return {{name}}; + } + public void {{setter}}({{{datatypeWithEnum}}} {{name}}) { + this.{{name}} = {{name}}; + } + + {{/vars}} + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + {{classname}} {{classVarName}} = ({{classname}}) o;{{#hasVars}} + return {{#vars}}Objects.equals({{name}}, {{classVarName}}.{{name}}){{#hasMore}} && + {{/hasMore}}{{^hasMore}};{{/hasMore}}{{/vars}}{{/hasVars}}{{^hasVars}} + return true;{{/hasVars}} + } + + @Override + public int hashCode() { + return Objects.hash({{#vars}}{{name}}{{#hasMore}}, {{/hasMore}}{{/vars}}); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class {{classname}} {\n"); + {{#parent}}sb.append(" ").append(toIndentedString(super.toString())).append("\n");{{/parent}} + {{#vars}}sb.append(" {{name}}: ").append(toIndentedString({{name}})).append("\n"); + {{/vars}}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/spring-stubs/pom.xml b/samples/client/petstore/spring-stubs/pom.xml index 48dc8da3f8..d6e6b09a2e 100644 --- a/samples/client/petstore/spring-stubs/pom.xml +++ b/samples/client/petstore/spring-stubs/pom.xml @@ -6,12 +6,15 @@ swagger-spring-server 1.0.0 - 2.4.0 + 1.7 + ${java.version} + ${java.version} + 2.5.0 org.springframework.boot spring-boot-starter-parent - 1.3.3.RELEASE + 1.3.5.RELEASE src/main/java diff --git a/samples/client/petstore/spring-stubs/src/main/java/io/swagger/model/Category.java b/samples/client/petstore/spring-stubs/src/main/java/io/swagger/model/Category.java index 74686904c6..67bc75b3b1 100644 --- a/samples/client/petstore/spring-stubs/src/main/java/io/swagger/model/Category.java +++ b/samples/client/petstore/spring-stubs/src/main/java/io/swagger/model/Category.java @@ -1,23 +1,28 @@ package io.swagger.model; +import java.util.Objects; +import com.fasterxml.jackson.annotation.JsonProperty; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; -import io.swagger.annotations.*; -import com.fasterxml.jackson.annotation.JsonProperty; - -import java.util.Objects; -@ApiModel(description = "") -public class Category { + + +public class Category { private Long id = null; private String name = null; /** **/ + public Category id(Long id) { + this.id = id; + return this; + } + + @ApiModelProperty(value = "") @JsonProperty("id") public Long getId() { @@ -29,6 +34,12 @@ public class Category { /** **/ + public Category name(String name) { + this.name = name; + return this; + } + + @ApiModelProperty(value = "") @JsonProperty("name") public String getName() { @@ -58,13 +69,25 @@ public class Category { } @Override - public String toString() { + public String toString() { StringBuilder sb = new StringBuilder(); sb.append("class Category {\n"); - sb.append(" id: ").append(id).append("\n"); - sb.append(" name: ").append(name).append("\n"); - sb.append("}\n"); + sb.append(" id: ").append(toIndentedString(id)).append("\n"); + sb.append(" name: ").append(toIndentedString(name)).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/spring-stubs/src/main/java/io/swagger/model/ModelApiResponse.java b/samples/client/petstore/spring-stubs/src/main/java/io/swagger/model/ModelApiResponse.java index 124d25f1b1..5e3aa82bbe 100644 --- a/samples/client/petstore/spring-stubs/src/main/java/io/swagger/model/ModelApiResponse.java +++ b/samples/client/petstore/spring-stubs/src/main/java/io/swagger/model/ModelApiResponse.java @@ -1,17 +1,16 @@ package io.swagger.model; +import java.util.Objects; +import com.fasterxml.jackson.annotation.JsonProperty; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; -import io.swagger.annotations.*; -import com.fasterxml.jackson.annotation.JsonProperty; - -import java.util.Objects; -@ApiModel(description = "") -public class ModelApiResponse { + + +public class ModelApiResponse { private Integer code = null; private String type = null; @@ -19,6 +18,12 @@ public class ModelApiResponse { /** **/ + public ModelApiResponse code(Integer code) { + this.code = code; + return this; + } + + @ApiModelProperty(value = "") @JsonProperty("code") public Integer getCode() { @@ -30,6 +35,12 @@ public class ModelApiResponse { /** **/ + public ModelApiResponse type(String type) { + this.type = type; + return this; + } + + @ApiModelProperty(value = "") @JsonProperty("type") public String getType() { @@ -41,6 +52,12 @@ public class ModelApiResponse { /** **/ + public ModelApiResponse message(String message) { + this.message = message; + return this; + } + + @ApiModelProperty(value = "") @JsonProperty("message") public String getMessage() { @@ -71,14 +88,26 @@ public class ModelApiResponse { } @Override - public String toString() { + public String toString() { StringBuilder sb = new StringBuilder(); sb.append("class ModelApiResponse {\n"); - sb.append(" code: ").append(code).append("\n"); - sb.append(" type: ").append(type).append("\n"); - sb.append(" message: ").append(message).append("\n"); - sb.append("}\n"); + sb.append(" code: ").append(toIndentedString(code)).append("\n"); + sb.append(" type: ").append(toIndentedString(type)).append("\n"); + sb.append(" message: ").append(toIndentedString(message)).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/spring-stubs/src/main/java/io/swagger/model/Order.java b/samples/client/petstore/spring-stubs/src/main/java/io/swagger/model/Order.java index 7a2448f064..55859fc408 100644 --- a/samples/client/petstore/spring-stubs/src/main/java/io/swagger/model/Order.java +++ b/samples/client/petstore/spring-stubs/src/main/java/io/swagger/model/Order.java @@ -1,32 +1,54 @@ package io.swagger.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 org.joda.time.DateTime; -import io.swagger.annotations.*; -import com.fasterxml.jackson.annotation.JsonProperty; - -import java.util.Objects; -@ApiModel(description = "") -public class Order { + + +public class Order { private Long id = null; private Long petId = null; private Integer quantity = null; private DateTime shipDate = null; + + public enum StatusEnum { - placed, approved, delivered, - }; - + PLACED("placed"), + APPROVED("approved"), + DELIVERED("delivered"); + + private String value; + + StatusEnum(String value) { + this.value = value; + } + + @Override + @JsonValue + public String toString() { + return value; + } + } + private StatusEnum status = null; private Boolean complete = false; /** **/ + public Order id(Long id) { + this.id = id; + return this; + } + + @ApiModelProperty(value = "") @JsonProperty("id") public Long getId() { @@ -38,6 +60,12 @@ public class Order { /** **/ + public Order petId(Long petId) { + this.petId = petId; + return this; + } + + @ApiModelProperty(value = "") @JsonProperty("petId") public Long getPetId() { @@ -49,6 +77,12 @@ public class Order { /** **/ + public Order quantity(Integer quantity) { + this.quantity = quantity; + return this; + } + + @ApiModelProperty(value = "") @JsonProperty("quantity") public Integer getQuantity() { @@ -60,6 +94,12 @@ public class Order { /** **/ + public Order shipDate(DateTime shipDate) { + this.shipDate = shipDate; + return this; + } + + @ApiModelProperty(value = "") @JsonProperty("shipDate") public DateTime getShipDate() { @@ -72,6 +112,12 @@ public class Order { /** * Order Status **/ + public Order status(StatusEnum status) { + this.status = status; + return this; + } + + @ApiModelProperty(value = "Order Status") @JsonProperty("status") public StatusEnum getStatus() { @@ -83,6 +129,12 @@ public class Order { /** **/ + public Order complete(Boolean complete) { + this.complete = complete; + return this; + } + + @ApiModelProperty(value = "") @JsonProperty("complete") public Boolean getComplete() { @@ -116,17 +168,29 @@ public class Order { } @Override - public String toString() { + public String toString() { StringBuilder sb = new StringBuilder(); sb.append("class Order {\n"); - sb.append(" id: ").append(id).append("\n"); - sb.append(" petId: ").append(petId).append("\n"); - sb.append(" quantity: ").append(quantity).append("\n"); - sb.append(" shipDate: ").append(shipDate).append("\n"); - sb.append(" status: ").append(status).append("\n"); - sb.append(" complete: ").append(complete).append("\n"); - sb.append("}\n"); + sb.append(" id: ").append(toIndentedString(id)).append("\n"); + sb.append(" petId: ").append(toIndentedString(petId)).append("\n"); + sb.append(" quantity: ").append(toIndentedString(quantity)).append("\n"); + sb.append(" shipDate: ").append(toIndentedString(shipDate)).append("\n"); + sb.append(" status: ").append(toIndentedString(status)).append("\n"); + sb.append(" complete: ").append(toIndentedString(complete)).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/spring-stubs/src/main/java/io/swagger/model/Pet.java b/samples/client/petstore/spring-stubs/src/main/java/io/swagger/model/Pet.java index 8984bfcc17..24092cbee2 100644 --- a/samples/client/petstore/spring-stubs/src/main/java/io/swagger/model/Pet.java +++ b/samples/client/petstore/spring-stubs/src/main/java/io/swagger/model/Pet.java @@ -1,5 +1,8 @@ package io.swagger.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.model.Category; @@ -7,29 +10,48 @@ import io.swagger.model.Tag; import java.util.ArrayList; import java.util.List; -import io.swagger.annotations.*; -import com.fasterxml.jackson.annotation.JsonProperty; - -import java.util.Objects; -@ApiModel(description = "") -public class Pet { + + +public class Pet { private Long id = null; private Category category = null; private String name = null; private List photoUrls = new ArrayList(); private List tags = new ArrayList(); + + public enum StatusEnum { - available, pending, sold, - }; - + 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 Pet id(Long id) { + this.id = id; + return this; + } + + @ApiModelProperty(value = "") @JsonProperty("id") public Long getId() { @@ -41,6 +63,12 @@ public class Pet { /** **/ + public Pet category(Category category) { + this.category = category; + return this; + } + + @ApiModelProperty(value = "") @JsonProperty("category") public Category getCategory() { @@ -52,7 +80,13 @@ public class Pet { /** **/ - @ApiModelProperty(required = true, value = "") + public Pet name(String name) { + this.name = name; + return this; + } + + + @ApiModelProperty(example = "doggie", required = true, value = "") @JsonProperty("name") public String getName() { return name; @@ -63,6 +97,12 @@ public class Pet { /** **/ + public Pet photoUrls(List photoUrls) { + this.photoUrls = photoUrls; + return this; + } + + @ApiModelProperty(required = true, value = "") @JsonProperty("photoUrls") public List getPhotoUrls() { @@ -74,6 +114,12 @@ public class Pet { /** **/ + public Pet tags(List tags) { + this.tags = tags; + return this; + } + + @ApiModelProperty(value = "") @JsonProperty("tags") public List getTags() { @@ -86,6 +132,12 @@ public class Pet { /** * pet status in the store **/ + public Pet status(StatusEnum status) { + this.status = status; + return this; + } + + @ApiModelProperty(value = "pet status in the store") @JsonProperty("status") public StatusEnum getStatus() { @@ -119,17 +171,29 @@ public class Pet { } @Override - public String toString() { + public String toString() { StringBuilder sb = new StringBuilder(); sb.append("class Pet {\n"); - sb.append(" id: ").append(id).append("\n"); - sb.append(" category: ").append(category).append("\n"); - sb.append(" name: ").append(name).append("\n"); - sb.append(" photoUrls: ").append(photoUrls).append("\n"); - sb.append(" tags: ").append(tags).append("\n"); - sb.append(" status: ").append(status).append("\n"); - sb.append("}\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/spring-stubs/src/main/java/io/swagger/model/Tag.java b/samples/client/petstore/spring-stubs/src/main/java/io/swagger/model/Tag.java index 92fb3c6904..f26d84e74b 100644 --- a/samples/client/petstore/spring-stubs/src/main/java/io/swagger/model/Tag.java +++ b/samples/client/petstore/spring-stubs/src/main/java/io/swagger/model/Tag.java @@ -1,23 +1,28 @@ package io.swagger.model; +import java.util.Objects; +import com.fasterxml.jackson.annotation.JsonProperty; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; -import io.swagger.annotations.*; -import com.fasterxml.jackson.annotation.JsonProperty; - -import java.util.Objects; -@ApiModel(description = "") -public class Tag { + + +public class Tag { private Long id = null; private String name = null; /** **/ + public Tag id(Long id) { + this.id = id; + return this; + } + + @ApiModelProperty(value = "") @JsonProperty("id") public Long getId() { @@ -29,6 +34,12 @@ public class Tag { /** **/ + public Tag name(String name) { + this.name = name; + return this; + } + + @ApiModelProperty(value = "") @JsonProperty("name") public String getName() { @@ -58,13 +69,25 @@ public class Tag { } @Override - public String toString() { + public String toString() { StringBuilder sb = new StringBuilder(); sb.append("class Tag {\n"); - sb.append(" id: ").append(id).append("\n"); - sb.append(" name: ").append(name).append("\n"); - sb.append("}\n"); + sb.append(" id: ").append(toIndentedString(id)).append("\n"); + sb.append(" name: ").append(toIndentedString(name)).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/spring-stubs/src/main/java/io/swagger/model/User.java b/samples/client/petstore/spring-stubs/src/main/java/io/swagger/model/User.java index 2b0e82db79..5dc291a788 100644 --- a/samples/client/petstore/spring-stubs/src/main/java/io/swagger/model/User.java +++ b/samples/client/petstore/spring-stubs/src/main/java/io/swagger/model/User.java @@ -1,17 +1,16 @@ package io.swagger.model; +import java.util.Objects; +import com.fasterxml.jackson.annotation.JsonProperty; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; -import io.swagger.annotations.*; -import com.fasterxml.jackson.annotation.JsonProperty; - -import java.util.Objects; -@ApiModel(description = "") -public class User { + + +public class User { private Long id = null; private String username = null; @@ -24,6 +23,12 @@ public class User { /** **/ + public User id(Long id) { + this.id = id; + return this; + } + + @ApiModelProperty(value = "") @JsonProperty("id") public Long getId() { @@ -35,6 +40,12 @@ public class User { /** **/ + public User username(String username) { + this.username = username; + return this; + } + + @ApiModelProperty(value = "") @JsonProperty("username") public String getUsername() { @@ -46,6 +57,12 @@ public class User { /** **/ + public User firstName(String firstName) { + this.firstName = firstName; + return this; + } + + @ApiModelProperty(value = "") @JsonProperty("firstName") public String getFirstName() { @@ -57,6 +74,12 @@ public class User { /** **/ + public User lastName(String lastName) { + this.lastName = lastName; + return this; + } + + @ApiModelProperty(value = "") @JsonProperty("lastName") public String getLastName() { @@ -68,6 +91,12 @@ public class User { /** **/ + public User email(String email) { + this.email = email; + return this; + } + + @ApiModelProperty(value = "") @JsonProperty("email") public String getEmail() { @@ -79,6 +108,12 @@ public class User { /** **/ + public User password(String password) { + this.password = password; + return this; + } + + @ApiModelProperty(value = "") @JsonProperty("password") public String getPassword() { @@ -90,6 +125,12 @@ public class User { /** **/ + public User phone(String phone) { + this.phone = phone; + return this; + } + + @ApiModelProperty(value = "") @JsonProperty("phone") public String getPhone() { @@ -102,6 +143,12 @@ public class User { /** * User Status **/ + public User userStatus(Integer userStatus) { + this.userStatus = userStatus; + return this; + } + + @ApiModelProperty(value = "User Status") @JsonProperty("userStatus") public Integer getUserStatus() { @@ -137,19 +184,31 @@ public class User { } @Override - public String toString() { + public String toString() { StringBuilder sb = new StringBuilder(); sb.append("class User {\n"); - sb.append(" id: ").append(id).append("\n"); - sb.append(" username: ").append(username).append("\n"); - sb.append(" firstName: ").append(firstName).append("\n"); - sb.append(" lastName: ").append(lastName).append("\n"); - sb.append(" email: ").append(email).append("\n"); - sb.append(" password: ").append(password).append("\n"); - sb.append(" phone: ").append(phone).append("\n"); - sb.append(" userStatus: ").append(userStatus).append("\n"); - sb.append("}\n"); + sb.append(" id: ").append(toIndentedString(id)).append("\n"); + sb.append(" username: ").append(toIndentedString(username)).append("\n"); + sb.append(" firstName: ").append(toIndentedString(firstName)).append("\n"); + sb.append(" lastName: ").append(toIndentedString(lastName)).append("\n"); + sb.append(" email: ").append(toIndentedString(email)).append("\n"); + sb.append(" password: ").append(toIndentedString(password)).append("\n"); + sb.append(" phone: ").append(toIndentedString(phone)).append("\n"); + sb.append(" userStatus: ").append(toIndentedString(userStatus)).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/server/petstore/spring-mvc-j8-async/src/main/java/io/swagger/model/Category.java b/samples/server/petstore/spring-mvc-j8-async/src/main/java/io/swagger/model/Category.java index 74686904c6..67bc75b3b1 100644 --- a/samples/server/petstore/spring-mvc-j8-async/src/main/java/io/swagger/model/Category.java +++ b/samples/server/petstore/spring-mvc-j8-async/src/main/java/io/swagger/model/Category.java @@ -1,23 +1,28 @@ package io.swagger.model; +import java.util.Objects; +import com.fasterxml.jackson.annotation.JsonProperty; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; -import io.swagger.annotations.*; -import com.fasterxml.jackson.annotation.JsonProperty; - -import java.util.Objects; -@ApiModel(description = "") -public class Category { + + +public class Category { private Long id = null; private String name = null; /** **/ + public Category id(Long id) { + this.id = id; + return this; + } + + @ApiModelProperty(value = "") @JsonProperty("id") public Long getId() { @@ -29,6 +34,12 @@ public class Category { /** **/ + public Category name(String name) { + this.name = name; + return this; + } + + @ApiModelProperty(value = "") @JsonProperty("name") public String getName() { @@ -58,13 +69,25 @@ public class Category { } @Override - public String toString() { + public String toString() { StringBuilder sb = new StringBuilder(); sb.append("class Category {\n"); - sb.append(" id: ").append(id).append("\n"); - sb.append(" name: ").append(name).append("\n"); - sb.append("}\n"); + sb.append(" id: ").append(toIndentedString(id)).append("\n"); + sb.append(" name: ").append(toIndentedString(name)).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/server/petstore/spring-mvc-j8-async/src/main/java/io/swagger/model/ModelApiResponse.java b/samples/server/petstore/spring-mvc-j8-async/src/main/java/io/swagger/model/ModelApiResponse.java index 124d25f1b1..5e3aa82bbe 100644 --- a/samples/server/petstore/spring-mvc-j8-async/src/main/java/io/swagger/model/ModelApiResponse.java +++ b/samples/server/petstore/spring-mvc-j8-async/src/main/java/io/swagger/model/ModelApiResponse.java @@ -1,17 +1,16 @@ package io.swagger.model; +import java.util.Objects; +import com.fasterxml.jackson.annotation.JsonProperty; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; -import io.swagger.annotations.*; -import com.fasterxml.jackson.annotation.JsonProperty; - -import java.util.Objects; -@ApiModel(description = "") -public class ModelApiResponse { + + +public class ModelApiResponse { private Integer code = null; private String type = null; @@ -19,6 +18,12 @@ public class ModelApiResponse { /** **/ + public ModelApiResponse code(Integer code) { + this.code = code; + return this; + } + + @ApiModelProperty(value = "") @JsonProperty("code") public Integer getCode() { @@ -30,6 +35,12 @@ public class ModelApiResponse { /** **/ + public ModelApiResponse type(String type) { + this.type = type; + return this; + } + + @ApiModelProperty(value = "") @JsonProperty("type") public String getType() { @@ -41,6 +52,12 @@ public class ModelApiResponse { /** **/ + public ModelApiResponse message(String message) { + this.message = message; + return this; + } + + @ApiModelProperty(value = "") @JsonProperty("message") public String getMessage() { @@ -71,14 +88,26 @@ public class ModelApiResponse { } @Override - public String toString() { + public String toString() { StringBuilder sb = new StringBuilder(); sb.append("class ModelApiResponse {\n"); - sb.append(" code: ").append(code).append("\n"); - sb.append(" type: ").append(type).append("\n"); - sb.append(" message: ").append(message).append("\n"); - sb.append("}\n"); + sb.append(" code: ").append(toIndentedString(code)).append("\n"); + sb.append(" type: ").append(toIndentedString(type)).append("\n"); + sb.append(" message: ").append(toIndentedString(message)).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/server/petstore/spring-mvc-j8-async/src/main/java/io/swagger/model/Order.java b/samples/server/petstore/spring-mvc-j8-async/src/main/java/io/swagger/model/Order.java index f1afe97e95..28b6d40e79 100644 --- a/samples/server/petstore/spring-mvc-j8-async/src/main/java/io/swagger/model/Order.java +++ b/samples/server/petstore/spring-mvc-j8-async/src/main/java/io/swagger/model/Order.java @@ -1,32 +1,54 @@ package io.swagger.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 java.time.OffsetDateTime; -import io.swagger.annotations.*; -import com.fasterxml.jackson.annotation.JsonProperty; - -import java.util.Objects; -@ApiModel(description = "") -public class Order { + + +public class Order { private Long id = null; private Long petId = null; private Integer quantity = null; private OffsetDateTime shipDate = null; + + public enum StatusEnum { - placed, approved, delivered, - }; - + PLACED("placed"), + APPROVED("approved"), + DELIVERED("delivered"); + + private String value; + + StatusEnum(String value) { + this.value = value; + } + + @Override + @JsonValue + public String toString() { + return value; + } + } + private StatusEnum status = null; private Boolean complete = false; /** **/ + public Order id(Long id) { + this.id = id; + return this; + } + + @ApiModelProperty(value = "") @JsonProperty("id") public Long getId() { @@ -38,6 +60,12 @@ public class Order { /** **/ + public Order petId(Long petId) { + this.petId = petId; + return this; + } + + @ApiModelProperty(value = "") @JsonProperty("petId") public Long getPetId() { @@ -49,6 +77,12 @@ public class Order { /** **/ + public Order quantity(Integer quantity) { + this.quantity = quantity; + return this; + } + + @ApiModelProperty(value = "") @JsonProperty("quantity") public Integer getQuantity() { @@ -60,6 +94,12 @@ public class Order { /** **/ + public Order shipDate(OffsetDateTime shipDate) { + this.shipDate = shipDate; + return this; + } + + @ApiModelProperty(value = "") @JsonProperty("shipDate") public OffsetDateTime getShipDate() { @@ -72,6 +112,12 @@ public class Order { /** * Order Status **/ + public Order status(StatusEnum status) { + this.status = status; + return this; + } + + @ApiModelProperty(value = "Order Status") @JsonProperty("status") public StatusEnum getStatus() { @@ -83,6 +129,12 @@ public class Order { /** **/ + public Order complete(Boolean complete) { + this.complete = complete; + return this; + } + + @ApiModelProperty(value = "") @JsonProperty("complete") public Boolean getComplete() { @@ -116,17 +168,29 @@ public class Order { } @Override - public String toString() { + public String toString() { StringBuilder sb = new StringBuilder(); sb.append("class Order {\n"); - sb.append(" id: ").append(id).append("\n"); - sb.append(" petId: ").append(petId).append("\n"); - sb.append(" quantity: ").append(quantity).append("\n"); - sb.append(" shipDate: ").append(shipDate).append("\n"); - sb.append(" status: ").append(status).append("\n"); - sb.append(" complete: ").append(complete).append("\n"); - sb.append("}\n"); + sb.append(" id: ").append(toIndentedString(id)).append("\n"); + sb.append(" petId: ").append(toIndentedString(petId)).append("\n"); + sb.append(" quantity: ").append(toIndentedString(quantity)).append("\n"); + sb.append(" shipDate: ").append(toIndentedString(shipDate)).append("\n"); + sb.append(" status: ").append(toIndentedString(status)).append("\n"); + sb.append(" complete: ").append(toIndentedString(complete)).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/server/petstore/spring-mvc-j8-async/src/main/java/io/swagger/model/Pet.java b/samples/server/petstore/spring-mvc-j8-async/src/main/java/io/swagger/model/Pet.java index 8984bfcc17..24092cbee2 100644 --- a/samples/server/petstore/spring-mvc-j8-async/src/main/java/io/swagger/model/Pet.java +++ b/samples/server/petstore/spring-mvc-j8-async/src/main/java/io/swagger/model/Pet.java @@ -1,5 +1,8 @@ package io.swagger.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.model.Category; @@ -7,29 +10,48 @@ import io.swagger.model.Tag; import java.util.ArrayList; import java.util.List; -import io.swagger.annotations.*; -import com.fasterxml.jackson.annotation.JsonProperty; - -import java.util.Objects; -@ApiModel(description = "") -public class Pet { + + +public class Pet { private Long id = null; private Category category = null; private String name = null; private List photoUrls = new ArrayList(); private List tags = new ArrayList(); + + public enum StatusEnum { - available, pending, sold, - }; - + 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 Pet id(Long id) { + this.id = id; + return this; + } + + @ApiModelProperty(value = "") @JsonProperty("id") public Long getId() { @@ -41,6 +63,12 @@ public class Pet { /** **/ + public Pet category(Category category) { + this.category = category; + return this; + } + + @ApiModelProperty(value = "") @JsonProperty("category") public Category getCategory() { @@ -52,7 +80,13 @@ public class Pet { /** **/ - @ApiModelProperty(required = true, value = "") + public Pet name(String name) { + this.name = name; + return this; + } + + + @ApiModelProperty(example = "doggie", required = true, value = "") @JsonProperty("name") public String getName() { return name; @@ -63,6 +97,12 @@ public class Pet { /** **/ + public Pet photoUrls(List photoUrls) { + this.photoUrls = photoUrls; + return this; + } + + @ApiModelProperty(required = true, value = "") @JsonProperty("photoUrls") public List getPhotoUrls() { @@ -74,6 +114,12 @@ public class Pet { /** **/ + public Pet tags(List tags) { + this.tags = tags; + return this; + } + + @ApiModelProperty(value = "") @JsonProperty("tags") public List getTags() { @@ -86,6 +132,12 @@ public class Pet { /** * pet status in the store **/ + public Pet status(StatusEnum status) { + this.status = status; + return this; + } + + @ApiModelProperty(value = "pet status in the store") @JsonProperty("status") public StatusEnum getStatus() { @@ -119,17 +171,29 @@ public class Pet { } @Override - public String toString() { + public String toString() { StringBuilder sb = new StringBuilder(); sb.append("class Pet {\n"); - sb.append(" id: ").append(id).append("\n"); - sb.append(" category: ").append(category).append("\n"); - sb.append(" name: ").append(name).append("\n"); - sb.append(" photoUrls: ").append(photoUrls).append("\n"); - sb.append(" tags: ").append(tags).append("\n"); - sb.append(" status: ").append(status).append("\n"); - sb.append("}\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/server/petstore/spring-mvc-j8-async/src/main/java/io/swagger/model/Tag.java b/samples/server/petstore/spring-mvc-j8-async/src/main/java/io/swagger/model/Tag.java index 92fb3c6904..f26d84e74b 100644 --- a/samples/server/petstore/spring-mvc-j8-async/src/main/java/io/swagger/model/Tag.java +++ b/samples/server/petstore/spring-mvc-j8-async/src/main/java/io/swagger/model/Tag.java @@ -1,23 +1,28 @@ package io.swagger.model; +import java.util.Objects; +import com.fasterxml.jackson.annotation.JsonProperty; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; -import io.swagger.annotations.*; -import com.fasterxml.jackson.annotation.JsonProperty; - -import java.util.Objects; -@ApiModel(description = "") -public class Tag { + + +public class Tag { private Long id = null; private String name = null; /** **/ + public Tag id(Long id) { + this.id = id; + return this; + } + + @ApiModelProperty(value = "") @JsonProperty("id") public Long getId() { @@ -29,6 +34,12 @@ public class Tag { /** **/ + public Tag name(String name) { + this.name = name; + return this; + } + + @ApiModelProperty(value = "") @JsonProperty("name") public String getName() { @@ -58,13 +69,25 @@ public class Tag { } @Override - public String toString() { + public String toString() { StringBuilder sb = new StringBuilder(); sb.append("class Tag {\n"); - sb.append(" id: ").append(id).append("\n"); - sb.append(" name: ").append(name).append("\n"); - sb.append("}\n"); + sb.append(" id: ").append(toIndentedString(id)).append("\n"); + sb.append(" name: ").append(toIndentedString(name)).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/server/petstore/spring-mvc-j8-async/src/main/java/io/swagger/model/User.java b/samples/server/petstore/spring-mvc-j8-async/src/main/java/io/swagger/model/User.java index 2b0e82db79..5dc291a788 100644 --- a/samples/server/petstore/spring-mvc-j8-async/src/main/java/io/swagger/model/User.java +++ b/samples/server/petstore/spring-mvc-j8-async/src/main/java/io/swagger/model/User.java @@ -1,17 +1,16 @@ package io.swagger.model; +import java.util.Objects; +import com.fasterxml.jackson.annotation.JsonProperty; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; -import io.swagger.annotations.*; -import com.fasterxml.jackson.annotation.JsonProperty; - -import java.util.Objects; -@ApiModel(description = "") -public class User { + + +public class User { private Long id = null; private String username = null; @@ -24,6 +23,12 @@ public class User { /** **/ + public User id(Long id) { + this.id = id; + return this; + } + + @ApiModelProperty(value = "") @JsonProperty("id") public Long getId() { @@ -35,6 +40,12 @@ public class User { /** **/ + public User username(String username) { + this.username = username; + return this; + } + + @ApiModelProperty(value = "") @JsonProperty("username") public String getUsername() { @@ -46,6 +57,12 @@ public class User { /** **/ + public User firstName(String firstName) { + this.firstName = firstName; + return this; + } + + @ApiModelProperty(value = "") @JsonProperty("firstName") public String getFirstName() { @@ -57,6 +74,12 @@ public class User { /** **/ + public User lastName(String lastName) { + this.lastName = lastName; + return this; + } + + @ApiModelProperty(value = "") @JsonProperty("lastName") public String getLastName() { @@ -68,6 +91,12 @@ public class User { /** **/ + public User email(String email) { + this.email = email; + return this; + } + + @ApiModelProperty(value = "") @JsonProperty("email") public String getEmail() { @@ -79,6 +108,12 @@ public class User { /** **/ + public User password(String password) { + this.password = password; + return this; + } + + @ApiModelProperty(value = "") @JsonProperty("password") public String getPassword() { @@ -90,6 +125,12 @@ public class User { /** **/ + public User phone(String phone) { + this.phone = phone; + return this; + } + + @ApiModelProperty(value = "") @JsonProperty("phone") public String getPhone() { @@ -102,6 +143,12 @@ public class User { /** * User Status **/ + public User userStatus(Integer userStatus) { + this.userStatus = userStatus; + return this; + } + + @ApiModelProperty(value = "User Status") @JsonProperty("userStatus") public Integer getUserStatus() { @@ -137,19 +184,31 @@ public class User { } @Override - public String toString() { + public String toString() { StringBuilder sb = new StringBuilder(); sb.append("class User {\n"); - sb.append(" id: ").append(id).append("\n"); - sb.append(" username: ").append(username).append("\n"); - sb.append(" firstName: ").append(firstName).append("\n"); - sb.append(" lastName: ").append(lastName).append("\n"); - sb.append(" email: ").append(email).append("\n"); - sb.append(" password: ").append(password).append("\n"); - sb.append(" phone: ").append(phone).append("\n"); - sb.append(" userStatus: ").append(userStatus).append("\n"); - sb.append("}\n"); + sb.append(" id: ").append(toIndentedString(id)).append("\n"); + sb.append(" username: ").append(toIndentedString(username)).append("\n"); + sb.append(" firstName: ").append(toIndentedString(firstName)).append("\n"); + sb.append(" lastName: ").append(toIndentedString(lastName)).append("\n"); + sb.append(" email: ").append(toIndentedString(email)).append("\n"); + sb.append(" password: ").append(toIndentedString(password)).append("\n"); + sb.append(" phone: ").append(toIndentedString(phone)).append("\n"); + sb.append(" userStatus: ").append(toIndentedString(userStatus)).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/server/petstore/spring-mvc/src/main/java/io/swagger/model/Category.java b/samples/server/petstore/spring-mvc/src/main/java/io/swagger/model/Category.java index 74686904c6..67bc75b3b1 100644 --- a/samples/server/petstore/spring-mvc/src/main/java/io/swagger/model/Category.java +++ b/samples/server/petstore/spring-mvc/src/main/java/io/swagger/model/Category.java @@ -1,23 +1,28 @@ package io.swagger.model; +import java.util.Objects; +import com.fasterxml.jackson.annotation.JsonProperty; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; -import io.swagger.annotations.*; -import com.fasterxml.jackson.annotation.JsonProperty; - -import java.util.Objects; -@ApiModel(description = "") -public class Category { + + +public class Category { private Long id = null; private String name = null; /** **/ + public Category id(Long id) { + this.id = id; + return this; + } + + @ApiModelProperty(value = "") @JsonProperty("id") public Long getId() { @@ -29,6 +34,12 @@ public class Category { /** **/ + public Category name(String name) { + this.name = name; + return this; + } + + @ApiModelProperty(value = "") @JsonProperty("name") public String getName() { @@ -58,13 +69,25 @@ public class Category { } @Override - public String toString() { + public String toString() { StringBuilder sb = new StringBuilder(); sb.append("class Category {\n"); - sb.append(" id: ").append(id).append("\n"); - sb.append(" name: ").append(name).append("\n"); - sb.append("}\n"); + sb.append(" id: ").append(toIndentedString(id)).append("\n"); + sb.append(" name: ").append(toIndentedString(name)).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/server/petstore/spring-mvc/src/main/java/io/swagger/model/ModelApiResponse.java b/samples/server/petstore/spring-mvc/src/main/java/io/swagger/model/ModelApiResponse.java index 124d25f1b1..5e3aa82bbe 100644 --- a/samples/server/petstore/spring-mvc/src/main/java/io/swagger/model/ModelApiResponse.java +++ b/samples/server/petstore/spring-mvc/src/main/java/io/swagger/model/ModelApiResponse.java @@ -1,17 +1,16 @@ package io.swagger.model; +import java.util.Objects; +import com.fasterxml.jackson.annotation.JsonProperty; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; -import io.swagger.annotations.*; -import com.fasterxml.jackson.annotation.JsonProperty; - -import java.util.Objects; -@ApiModel(description = "") -public class ModelApiResponse { + + +public class ModelApiResponse { private Integer code = null; private String type = null; @@ -19,6 +18,12 @@ public class ModelApiResponse { /** **/ + public ModelApiResponse code(Integer code) { + this.code = code; + return this; + } + + @ApiModelProperty(value = "") @JsonProperty("code") public Integer getCode() { @@ -30,6 +35,12 @@ public class ModelApiResponse { /** **/ + public ModelApiResponse type(String type) { + this.type = type; + return this; + } + + @ApiModelProperty(value = "") @JsonProperty("type") public String getType() { @@ -41,6 +52,12 @@ public class ModelApiResponse { /** **/ + public ModelApiResponse message(String message) { + this.message = message; + return this; + } + + @ApiModelProperty(value = "") @JsonProperty("message") public String getMessage() { @@ -71,14 +88,26 @@ public class ModelApiResponse { } @Override - public String toString() { + public String toString() { StringBuilder sb = new StringBuilder(); sb.append("class ModelApiResponse {\n"); - sb.append(" code: ").append(code).append("\n"); - sb.append(" type: ").append(type).append("\n"); - sb.append(" message: ").append(message).append("\n"); - sb.append("}\n"); + sb.append(" code: ").append(toIndentedString(code)).append("\n"); + sb.append(" type: ").append(toIndentedString(type)).append("\n"); + sb.append(" message: ").append(toIndentedString(message)).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/server/petstore/spring-mvc/src/main/java/io/swagger/model/Order.java b/samples/server/petstore/spring-mvc/src/main/java/io/swagger/model/Order.java index 7a2448f064..55859fc408 100644 --- a/samples/server/petstore/spring-mvc/src/main/java/io/swagger/model/Order.java +++ b/samples/server/petstore/spring-mvc/src/main/java/io/swagger/model/Order.java @@ -1,32 +1,54 @@ package io.swagger.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 org.joda.time.DateTime; -import io.swagger.annotations.*; -import com.fasterxml.jackson.annotation.JsonProperty; - -import java.util.Objects; -@ApiModel(description = "") -public class Order { + + +public class Order { private Long id = null; private Long petId = null; private Integer quantity = null; private DateTime shipDate = null; + + public enum StatusEnum { - placed, approved, delivered, - }; - + PLACED("placed"), + APPROVED("approved"), + DELIVERED("delivered"); + + private String value; + + StatusEnum(String value) { + this.value = value; + } + + @Override + @JsonValue + public String toString() { + return value; + } + } + private StatusEnum status = null; private Boolean complete = false; /** **/ + public Order id(Long id) { + this.id = id; + return this; + } + + @ApiModelProperty(value = "") @JsonProperty("id") public Long getId() { @@ -38,6 +60,12 @@ public class Order { /** **/ + public Order petId(Long petId) { + this.petId = petId; + return this; + } + + @ApiModelProperty(value = "") @JsonProperty("petId") public Long getPetId() { @@ -49,6 +77,12 @@ public class Order { /** **/ + public Order quantity(Integer quantity) { + this.quantity = quantity; + return this; + } + + @ApiModelProperty(value = "") @JsonProperty("quantity") public Integer getQuantity() { @@ -60,6 +94,12 @@ public class Order { /** **/ + public Order shipDate(DateTime shipDate) { + this.shipDate = shipDate; + return this; + } + + @ApiModelProperty(value = "") @JsonProperty("shipDate") public DateTime getShipDate() { @@ -72,6 +112,12 @@ public class Order { /** * Order Status **/ + public Order status(StatusEnum status) { + this.status = status; + return this; + } + + @ApiModelProperty(value = "Order Status") @JsonProperty("status") public StatusEnum getStatus() { @@ -83,6 +129,12 @@ public class Order { /** **/ + public Order complete(Boolean complete) { + this.complete = complete; + return this; + } + + @ApiModelProperty(value = "") @JsonProperty("complete") public Boolean getComplete() { @@ -116,17 +168,29 @@ public class Order { } @Override - public String toString() { + public String toString() { StringBuilder sb = new StringBuilder(); sb.append("class Order {\n"); - sb.append(" id: ").append(id).append("\n"); - sb.append(" petId: ").append(petId).append("\n"); - sb.append(" quantity: ").append(quantity).append("\n"); - sb.append(" shipDate: ").append(shipDate).append("\n"); - sb.append(" status: ").append(status).append("\n"); - sb.append(" complete: ").append(complete).append("\n"); - sb.append("}\n"); + sb.append(" id: ").append(toIndentedString(id)).append("\n"); + sb.append(" petId: ").append(toIndentedString(petId)).append("\n"); + sb.append(" quantity: ").append(toIndentedString(quantity)).append("\n"); + sb.append(" shipDate: ").append(toIndentedString(shipDate)).append("\n"); + sb.append(" status: ").append(toIndentedString(status)).append("\n"); + sb.append(" complete: ").append(toIndentedString(complete)).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/server/petstore/spring-mvc/src/main/java/io/swagger/model/Pet.java b/samples/server/petstore/spring-mvc/src/main/java/io/swagger/model/Pet.java index 8984bfcc17..24092cbee2 100644 --- a/samples/server/petstore/spring-mvc/src/main/java/io/swagger/model/Pet.java +++ b/samples/server/petstore/spring-mvc/src/main/java/io/swagger/model/Pet.java @@ -1,5 +1,8 @@ package io.swagger.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.model.Category; @@ -7,29 +10,48 @@ import io.swagger.model.Tag; import java.util.ArrayList; import java.util.List; -import io.swagger.annotations.*; -import com.fasterxml.jackson.annotation.JsonProperty; - -import java.util.Objects; -@ApiModel(description = "") -public class Pet { + + +public class Pet { private Long id = null; private Category category = null; private String name = null; private List photoUrls = new ArrayList(); private List tags = new ArrayList(); + + public enum StatusEnum { - available, pending, sold, - }; - + 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 Pet id(Long id) { + this.id = id; + return this; + } + + @ApiModelProperty(value = "") @JsonProperty("id") public Long getId() { @@ -41,6 +63,12 @@ public class Pet { /** **/ + public Pet category(Category category) { + this.category = category; + return this; + } + + @ApiModelProperty(value = "") @JsonProperty("category") public Category getCategory() { @@ -52,7 +80,13 @@ public class Pet { /** **/ - @ApiModelProperty(required = true, value = "") + public Pet name(String name) { + this.name = name; + return this; + } + + + @ApiModelProperty(example = "doggie", required = true, value = "") @JsonProperty("name") public String getName() { return name; @@ -63,6 +97,12 @@ public class Pet { /** **/ + public Pet photoUrls(List photoUrls) { + this.photoUrls = photoUrls; + return this; + } + + @ApiModelProperty(required = true, value = "") @JsonProperty("photoUrls") public List getPhotoUrls() { @@ -74,6 +114,12 @@ public class Pet { /** **/ + public Pet tags(List tags) { + this.tags = tags; + return this; + } + + @ApiModelProperty(value = "") @JsonProperty("tags") public List getTags() { @@ -86,6 +132,12 @@ public class Pet { /** * pet status in the store **/ + public Pet status(StatusEnum status) { + this.status = status; + return this; + } + + @ApiModelProperty(value = "pet status in the store") @JsonProperty("status") public StatusEnum getStatus() { @@ -119,17 +171,29 @@ public class Pet { } @Override - public String toString() { + public String toString() { StringBuilder sb = new StringBuilder(); sb.append("class Pet {\n"); - sb.append(" id: ").append(id).append("\n"); - sb.append(" category: ").append(category).append("\n"); - sb.append(" name: ").append(name).append("\n"); - sb.append(" photoUrls: ").append(photoUrls).append("\n"); - sb.append(" tags: ").append(tags).append("\n"); - sb.append(" status: ").append(status).append("\n"); - sb.append("}\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/server/petstore/spring-mvc/src/main/java/io/swagger/model/Tag.java b/samples/server/petstore/spring-mvc/src/main/java/io/swagger/model/Tag.java index 92fb3c6904..f26d84e74b 100644 --- a/samples/server/petstore/spring-mvc/src/main/java/io/swagger/model/Tag.java +++ b/samples/server/petstore/spring-mvc/src/main/java/io/swagger/model/Tag.java @@ -1,23 +1,28 @@ package io.swagger.model; +import java.util.Objects; +import com.fasterxml.jackson.annotation.JsonProperty; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; -import io.swagger.annotations.*; -import com.fasterxml.jackson.annotation.JsonProperty; - -import java.util.Objects; -@ApiModel(description = "") -public class Tag { + + +public class Tag { private Long id = null; private String name = null; /** **/ + public Tag id(Long id) { + this.id = id; + return this; + } + + @ApiModelProperty(value = "") @JsonProperty("id") public Long getId() { @@ -29,6 +34,12 @@ public class Tag { /** **/ + public Tag name(String name) { + this.name = name; + return this; + } + + @ApiModelProperty(value = "") @JsonProperty("name") public String getName() { @@ -58,13 +69,25 @@ public class Tag { } @Override - public String toString() { + public String toString() { StringBuilder sb = new StringBuilder(); sb.append("class Tag {\n"); - sb.append(" id: ").append(id).append("\n"); - sb.append(" name: ").append(name).append("\n"); - sb.append("}\n"); + sb.append(" id: ").append(toIndentedString(id)).append("\n"); + sb.append(" name: ").append(toIndentedString(name)).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/server/petstore/spring-mvc/src/main/java/io/swagger/model/User.java b/samples/server/petstore/spring-mvc/src/main/java/io/swagger/model/User.java index 2b0e82db79..5dc291a788 100644 --- a/samples/server/petstore/spring-mvc/src/main/java/io/swagger/model/User.java +++ b/samples/server/petstore/spring-mvc/src/main/java/io/swagger/model/User.java @@ -1,17 +1,16 @@ package io.swagger.model; +import java.util.Objects; +import com.fasterxml.jackson.annotation.JsonProperty; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; -import io.swagger.annotations.*; -import com.fasterxml.jackson.annotation.JsonProperty; - -import java.util.Objects; -@ApiModel(description = "") -public class User { + + +public class User { private Long id = null; private String username = null; @@ -24,6 +23,12 @@ public class User { /** **/ + public User id(Long id) { + this.id = id; + return this; + } + + @ApiModelProperty(value = "") @JsonProperty("id") public Long getId() { @@ -35,6 +40,12 @@ public class User { /** **/ + public User username(String username) { + this.username = username; + return this; + } + + @ApiModelProperty(value = "") @JsonProperty("username") public String getUsername() { @@ -46,6 +57,12 @@ public class User { /** **/ + public User firstName(String firstName) { + this.firstName = firstName; + return this; + } + + @ApiModelProperty(value = "") @JsonProperty("firstName") public String getFirstName() { @@ -57,6 +74,12 @@ public class User { /** **/ + public User lastName(String lastName) { + this.lastName = lastName; + return this; + } + + @ApiModelProperty(value = "") @JsonProperty("lastName") public String getLastName() { @@ -68,6 +91,12 @@ public class User { /** **/ + public User email(String email) { + this.email = email; + return this; + } + + @ApiModelProperty(value = "") @JsonProperty("email") public String getEmail() { @@ -79,6 +108,12 @@ public class User { /** **/ + public User password(String password) { + this.password = password; + return this; + } + + @ApiModelProperty(value = "") @JsonProperty("password") public String getPassword() { @@ -90,6 +125,12 @@ public class User { /** **/ + public User phone(String phone) { + this.phone = phone; + return this; + } + + @ApiModelProperty(value = "") @JsonProperty("phone") public String getPhone() { @@ -102,6 +143,12 @@ public class User { /** * User Status **/ + public User userStatus(Integer userStatus) { + this.userStatus = userStatus; + return this; + } + + @ApiModelProperty(value = "User Status") @JsonProperty("userStatus") public Integer getUserStatus() { @@ -137,19 +184,31 @@ public class User { } @Override - public String toString() { + public String toString() { StringBuilder sb = new StringBuilder(); sb.append("class User {\n"); - sb.append(" id: ").append(id).append("\n"); - sb.append(" username: ").append(username).append("\n"); - sb.append(" firstName: ").append(firstName).append("\n"); - sb.append(" lastName: ").append(lastName).append("\n"); - sb.append(" email: ").append(email).append("\n"); - sb.append(" password: ").append(password).append("\n"); - sb.append(" phone: ").append(phone).append("\n"); - sb.append(" userStatus: ").append(userStatus).append("\n"); - sb.append("}\n"); + sb.append(" id: ").append(toIndentedString(id)).append("\n"); + sb.append(" username: ").append(toIndentedString(username)).append("\n"); + sb.append(" firstName: ").append(toIndentedString(firstName)).append("\n"); + sb.append(" lastName: ").append(toIndentedString(lastName)).append("\n"); + sb.append(" email: ").append(toIndentedString(email)).append("\n"); + sb.append(" password: ").append(toIndentedString(password)).append("\n"); + sb.append(" phone: ").append(toIndentedString(phone)).append("\n"); + sb.append(" userStatus: ").append(toIndentedString(userStatus)).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/server/petstore/springboot/.swagger-codegen-ignore b/samples/server/petstore/springboot/.swagger-codegen-ignore index 19d3377182..c5fa491b4c 100644 --- a/samples/server/petstore/springboot/.swagger-codegen-ignore +++ b/samples/server/petstore/springboot/.swagger-codegen-ignore @@ -14,7 +14,7 @@ # You can recursively match patterns against a directory, file or extension with a double asterisk (**): #foo/**/qux -# Thsi matches foo/bar/qux, foo/baz/qux, and foo/bar/baz/qux +# This matches foo/bar/qux, foo/baz/qux, and foo/bar/baz/qux # You can also negate patterns with an exclamation (!). # For example, you can ignore all files in a docs folder with the file extension .md: diff --git a/samples/server/petstore/springboot/pom.xml b/samples/server/petstore/springboot/pom.xml index c22baba41b..4cf50070b8 100644 --- a/samples/server/petstore/springboot/pom.xml +++ b/samples/server/petstore/springboot/pom.xml @@ -6,12 +6,15 @@ swagger-spring-server 1.0.0 - 2.4.0 + 1.7 + ${java.version} + ${java.version} + 2.5.0 org.springframework.boot spring-boot-starter-parent - 1.3.3.RELEASE + 1.3.5.RELEASE src/main/java diff --git a/samples/server/petstore/springboot/src/main/java/io/swagger/model/Category.java b/samples/server/petstore/springboot/src/main/java/io/swagger/model/Category.java index 74686904c6..67bc75b3b1 100644 --- a/samples/server/petstore/springboot/src/main/java/io/swagger/model/Category.java +++ b/samples/server/petstore/springboot/src/main/java/io/swagger/model/Category.java @@ -1,23 +1,28 @@ package io.swagger.model; +import java.util.Objects; +import com.fasterxml.jackson.annotation.JsonProperty; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; -import io.swagger.annotations.*; -import com.fasterxml.jackson.annotation.JsonProperty; - -import java.util.Objects; -@ApiModel(description = "") -public class Category { + + +public class Category { private Long id = null; private String name = null; /** **/ + public Category id(Long id) { + this.id = id; + return this; + } + + @ApiModelProperty(value = "") @JsonProperty("id") public Long getId() { @@ -29,6 +34,12 @@ public class Category { /** **/ + public Category name(String name) { + this.name = name; + return this; + } + + @ApiModelProperty(value = "") @JsonProperty("name") public String getName() { @@ -58,13 +69,25 @@ public class Category { } @Override - public String toString() { + public String toString() { StringBuilder sb = new StringBuilder(); sb.append("class Category {\n"); - sb.append(" id: ").append(id).append("\n"); - sb.append(" name: ").append(name).append("\n"); - sb.append("}\n"); + sb.append(" id: ").append(toIndentedString(id)).append("\n"); + sb.append(" name: ").append(toIndentedString(name)).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/server/petstore/springboot/src/main/java/io/swagger/model/ModelApiResponse.java b/samples/server/petstore/springboot/src/main/java/io/swagger/model/ModelApiResponse.java index 124d25f1b1..5e3aa82bbe 100644 --- a/samples/server/petstore/springboot/src/main/java/io/swagger/model/ModelApiResponse.java +++ b/samples/server/petstore/springboot/src/main/java/io/swagger/model/ModelApiResponse.java @@ -1,17 +1,16 @@ package io.swagger.model; +import java.util.Objects; +import com.fasterxml.jackson.annotation.JsonProperty; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; -import io.swagger.annotations.*; -import com.fasterxml.jackson.annotation.JsonProperty; - -import java.util.Objects; -@ApiModel(description = "") -public class ModelApiResponse { + + +public class ModelApiResponse { private Integer code = null; private String type = null; @@ -19,6 +18,12 @@ public class ModelApiResponse { /** **/ + public ModelApiResponse code(Integer code) { + this.code = code; + return this; + } + + @ApiModelProperty(value = "") @JsonProperty("code") public Integer getCode() { @@ -30,6 +35,12 @@ public class ModelApiResponse { /** **/ + public ModelApiResponse type(String type) { + this.type = type; + return this; + } + + @ApiModelProperty(value = "") @JsonProperty("type") public String getType() { @@ -41,6 +52,12 @@ public class ModelApiResponse { /** **/ + public ModelApiResponse message(String message) { + this.message = message; + return this; + } + + @ApiModelProperty(value = "") @JsonProperty("message") public String getMessage() { @@ -71,14 +88,26 @@ public class ModelApiResponse { } @Override - public String toString() { + public String toString() { StringBuilder sb = new StringBuilder(); sb.append("class ModelApiResponse {\n"); - sb.append(" code: ").append(code).append("\n"); - sb.append(" type: ").append(type).append("\n"); - sb.append(" message: ").append(message).append("\n"); - sb.append("}\n"); + sb.append(" code: ").append(toIndentedString(code)).append("\n"); + sb.append(" type: ").append(toIndentedString(type)).append("\n"); + sb.append(" message: ").append(toIndentedString(message)).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/server/petstore/springboot/src/main/java/io/swagger/model/Order.java b/samples/server/petstore/springboot/src/main/java/io/swagger/model/Order.java index 7a2448f064..55859fc408 100644 --- a/samples/server/petstore/springboot/src/main/java/io/swagger/model/Order.java +++ b/samples/server/petstore/springboot/src/main/java/io/swagger/model/Order.java @@ -1,32 +1,54 @@ package io.swagger.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 org.joda.time.DateTime; -import io.swagger.annotations.*; -import com.fasterxml.jackson.annotation.JsonProperty; - -import java.util.Objects; -@ApiModel(description = "") -public class Order { + + +public class Order { private Long id = null; private Long petId = null; private Integer quantity = null; private DateTime shipDate = null; + + public enum StatusEnum { - placed, approved, delivered, - }; - + PLACED("placed"), + APPROVED("approved"), + DELIVERED("delivered"); + + private String value; + + StatusEnum(String value) { + this.value = value; + } + + @Override + @JsonValue + public String toString() { + return value; + } + } + private StatusEnum status = null; private Boolean complete = false; /** **/ + public Order id(Long id) { + this.id = id; + return this; + } + + @ApiModelProperty(value = "") @JsonProperty("id") public Long getId() { @@ -38,6 +60,12 @@ public class Order { /** **/ + public Order petId(Long petId) { + this.petId = petId; + return this; + } + + @ApiModelProperty(value = "") @JsonProperty("petId") public Long getPetId() { @@ -49,6 +77,12 @@ public class Order { /** **/ + public Order quantity(Integer quantity) { + this.quantity = quantity; + return this; + } + + @ApiModelProperty(value = "") @JsonProperty("quantity") public Integer getQuantity() { @@ -60,6 +94,12 @@ public class Order { /** **/ + public Order shipDate(DateTime shipDate) { + this.shipDate = shipDate; + return this; + } + + @ApiModelProperty(value = "") @JsonProperty("shipDate") public DateTime getShipDate() { @@ -72,6 +112,12 @@ public class Order { /** * Order Status **/ + public Order status(StatusEnum status) { + this.status = status; + return this; + } + + @ApiModelProperty(value = "Order Status") @JsonProperty("status") public StatusEnum getStatus() { @@ -83,6 +129,12 @@ public class Order { /** **/ + public Order complete(Boolean complete) { + this.complete = complete; + return this; + } + + @ApiModelProperty(value = "") @JsonProperty("complete") public Boolean getComplete() { @@ -116,17 +168,29 @@ public class Order { } @Override - public String toString() { + public String toString() { StringBuilder sb = new StringBuilder(); sb.append("class Order {\n"); - sb.append(" id: ").append(id).append("\n"); - sb.append(" petId: ").append(petId).append("\n"); - sb.append(" quantity: ").append(quantity).append("\n"); - sb.append(" shipDate: ").append(shipDate).append("\n"); - sb.append(" status: ").append(status).append("\n"); - sb.append(" complete: ").append(complete).append("\n"); - sb.append("}\n"); + sb.append(" id: ").append(toIndentedString(id)).append("\n"); + sb.append(" petId: ").append(toIndentedString(petId)).append("\n"); + sb.append(" quantity: ").append(toIndentedString(quantity)).append("\n"); + sb.append(" shipDate: ").append(toIndentedString(shipDate)).append("\n"); + sb.append(" status: ").append(toIndentedString(status)).append("\n"); + sb.append(" complete: ").append(toIndentedString(complete)).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/server/petstore/springboot/src/main/java/io/swagger/model/Pet.java b/samples/server/petstore/springboot/src/main/java/io/swagger/model/Pet.java index 8984bfcc17..24092cbee2 100644 --- a/samples/server/petstore/springboot/src/main/java/io/swagger/model/Pet.java +++ b/samples/server/petstore/springboot/src/main/java/io/swagger/model/Pet.java @@ -1,5 +1,8 @@ package io.swagger.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.model.Category; @@ -7,29 +10,48 @@ import io.swagger.model.Tag; import java.util.ArrayList; import java.util.List; -import io.swagger.annotations.*; -import com.fasterxml.jackson.annotation.JsonProperty; - -import java.util.Objects; -@ApiModel(description = "") -public class Pet { + + +public class Pet { private Long id = null; private Category category = null; private String name = null; private List photoUrls = new ArrayList(); private List tags = new ArrayList(); + + public enum StatusEnum { - available, pending, sold, - }; - + 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 Pet id(Long id) { + this.id = id; + return this; + } + + @ApiModelProperty(value = "") @JsonProperty("id") public Long getId() { @@ -41,6 +63,12 @@ public class Pet { /** **/ + public Pet category(Category category) { + this.category = category; + return this; + } + + @ApiModelProperty(value = "") @JsonProperty("category") public Category getCategory() { @@ -52,7 +80,13 @@ public class Pet { /** **/ - @ApiModelProperty(required = true, value = "") + public Pet name(String name) { + this.name = name; + return this; + } + + + @ApiModelProperty(example = "doggie", required = true, value = "") @JsonProperty("name") public String getName() { return name; @@ -63,6 +97,12 @@ public class Pet { /** **/ + public Pet photoUrls(List photoUrls) { + this.photoUrls = photoUrls; + return this; + } + + @ApiModelProperty(required = true, value = "") @JsonProperty("photoUrls") public List getPhotoUrls() { @@ -74,6 +114,12 @@ public class Pet { /** **/ + public Pet tags(List tags) { + this.tags = tags; + return this; + } + + @ApiModelProperty(value = "") @JsonProperty("tags") public List getTags() { @@ -86,6 +132,12 @@ public class Pet { /** * pet status in the store **/ + public Pet status(StatusEnum status) { + this.status = status; + return this; + } + + @ApiModelProperty(value = "pet status in the store") @JsonProperty("status") public StatusEnum getStatus() { @@ -119,17 +171,29 @@ public class Pet { } @Override - public String toString() { + public String toString() { StringBuilder sb = new StringBuilder(); sb.append("class Pet {\n"); - sb.append(" id: ").append(id).append("\n"); - sb.append(" category: ").append(category).append("\n"); - sb.append(" name: ").append(name).append("\n"); - sb.append(" photoUrls: ").append(photoUrls).append("\n"); - sb.append(" tags: ").append(tags).append("\n"); - sb.append(" status: ").append(status).append("\n"); - sb.append("}\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/server/petstore/springboot/src/main/java/io/swagger/model/Tag.java b/samples/server/petstore/springboot/src/main/java/io/swagger/model/Tag.java index 92fb3c6904..f26d84e74b 100644 --- a/samples/server/petstore/springboot/src/main/java/io/swagger/model/Tag.java +++ b/samples/server/petstore/springboot/src/main/java/io/swagger/model/Tag.java @@ -1,23 +1,28 @@ package io.swagger.model; +import java.util.Objects; +import com.fasterxml.jackson.annotation.JsonProperty; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; -import io.swagger.annotations.*; -import com.fasterxml.jackson.annotation.JsonProperty; - -import java.util.Objects; -@ApiModel(description = "") -public class Tag { + + +public class Tag { private Long id = null; private String name = null; /** **/ + public Tag id(Long id) { + this.id = id; + return this; + } + + @ApiModelProperty(value = "") @JsonProperty("id") public Long getId() { @@ -29,6 +34,12 @@ public class Tag { /** **/ + public Tag name(String name) { + this.name = name; + return this; + } + + @ApiModelProperty(value = "") @JsonProperty("name") public String getName() { @@ -58,13 +69,25 @@ public class Tag { } @Override - public String toString() { + public String toString() { StringBuilder sb = new StringBuilder(); sb.append("class Tag {\n"); - sb.append(" id: ").append(id).append("\n"); - sb.append(" name: ").append(name).append("\n"); - sb.append("}\n"); + sb.append(" id: ").append(toIndentedString(id)).append("\n"); + sb.append(" name: ").append(toIndentedString(name)).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/server/petstore/springboot/src/main/java/io/swagger/model/User.java b/samples/server/petstore/springboot/src/main/java/io/swagger/model/User.java index 2b0e82db79..5dc291a788 100644 --- a/samples/server/petstore/springboot/src/main/java/io/swagger/model/User.java +++ b/samples/server/petstore/springboot/src/main/java/io/swagger/model/User.java @@ -1,17 +1,16 @@ package io.swagger.model; +import java.util.Objects; +import com.fasterxml.jackson.annotation.JsonProperty; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; -import io.swagger.annotations.*; -import com.fasterxml.jackson.annotation.JsonProperty; - -import java.util.Objects; -@ApiModel(description = "") -public class User { + + +public class User { private Long id = null; private String username = null; @@ -24,6 +23,12 @@ public class User { /** **/ + public User id(Long id) { + this.id = id; + return this; + } + + @ApiModelProperty(value = "") @JsonProperty("id") public Long getId() { @@ -35,6 +40,12 @@ public class User { /** **/ + public User username(String username) { + this.username = username; + return this; + } + + @ApiModelProperty(value = "") @JsonProperty("username") public String getUsername() { @@ -46,6 +57,12 @@ public class User { /** **/ + public User firstName(String firstName) { + this.firstName = firstName; + return this; + } + + @ApiModelProperty(value = "") @JsonProperty("firstName") public String getFirstName() { @@ -57,6 +74,12 @@ public class User { /** **/ + public User lastName(String lastName) { + this.lastName = lastName; + return this; + } + + @ApiModelProperty(value = "") @JsonProperty("lastName") public String getLastName() { @@ -68,6 +91,12 @@ public class User { /** **/ + public User email(String email) { + this.email = email; + return this; + } + + @ApiModelProperty(value = "") @JsonProperty("email") public String getEmail() { @@ -79,6 +108,12 @@ public class User { /** **/ + public User password(String password) { + this.password = password; + return this; + } + + @ApiModelProperty(value = "") @JsonProperty("password") public String getPassword() { @@ -90,6 +125,12 @@ public class User { /** **/ + public User phone(String phone) { + this.phone = phone; + return this; + } + + @ApiModelProperty(value = "") @JsonProperty("phone") public String getPhone() { @@ -102,6 +143,12 @@ public class User { /** * User Status **/ + public User userStatus(Integer userStatus) { + this.userStatus = userStatus; + return this; + } + + @ApiModelProperty(value = "User Status") @JsonProperty("userStatus") public Integer getUserStatus() { @@ -137,19 +184,31 @@ public class User { } @Override - public String toString() { + public String toString() { StringBuilder sb = new StringBuilder(); sb.append("class User {\n"); - sb.append(" id: ").append(id).append("\n"); - sb.append(" username: ").append(username).append("\n"); - sb.append(" firstName: ").append(firstName).append("\n"); - sb.append(" lastName: ").append(lastName).append("\n"); - sb.append(" email: ").append(email).append("\n"); - sb.append(" password: ").append(password).append("\n"); - sb.append(" phone: ").append(phone).append("\n"); - sb.append(" userStatus: ").append(userStatus).append("\n"); - sb.append("}\n"); + sb.append(" id: ").append(toIndentedString(id)).append("\n"); + sb.append(" username: ").append(toIndentedString(username)).append("\n"); + sb.append(" firstName: ").append(toIndentedString(firstName)).append("\n"); + sb.append(" lastName: ").append(toIndentedString(lastName)).append("\n"); + sb.append(" email: ").append(toIndentedString(email)).append("\n"); + sb.append(" password: ").append(toIndentedString(password)).append("\n"); + sb.append(" phone: ").append(toIndentedString(phone)).append("\n"); + sb.append(" userStatus: ").append(toIndentedString(userStatus)).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 "); + } } +