Java: do not generate setter for readonly properties

This commit is contained in:
xhh 2016-02-22 15:44:32 +08:00
parent 0ba123d60f
commit b8beca7f24
18 changed files with 22 additions and 127 deletions

View File

@ -33,10 +33,10 @@ public class {{classname}} {{#parent}}extends {{{parent}}}{{/parent}} {{#seriali
@ApiModelProperty({{#required}}required = {{required}}, {{/required}}value = "{{{description}}}")
public {{{datatypeWithEnum}}} {{getter}}() {
return {{name}};
}
}{{^isReadOnly}}
public void {{setter}}({{{datatypeWithEnum}}} {{name}}) {
this.{{name}} = {{name}};
}
}{{/isReadOnly}}
{{/vars}}

View File

@ -8,7 +8,7 @@ public class {{classname}} {{#parent}}extends {{{parent}}}{{/parent}} {{#seriali
{{>enumClass}}{{/items}}{{/items.isEnum}}
private {{{datatypeWithEnum}}} {{name}} = {{{defaultValue}}};{{/vars}}
{{#vars}}
{{#vars}}{{^isReadOnly}}
/**{{#description}}
* {{{description}}}{{/description}}{{#minimum}}
* minimum: {{minimum}}{{/minimum}}{{#maximum}}
@ -18,16 +18,16 @@ public class {{classname}} {{#parent}}extends {{{parent}}}{{/parent}} {{#seriali
this.{{name}} = {{name}};
return this;
}
{{#vendorExtensions.extraAnnotation}}{{vendorExtensions.extraAnnotation}}{{/vendorExtensions.extraAnnotation}}
{{/isReadOnly}}{{#vendorExtensions.extraAnnotation}}
{{vendorExtensions.extraAnnotation}}{{/vendorExtensions.extraAnnotation}}
@ApiModelProperty({{#example}}example = "{{example}}", {{/example}}{{#required}}required = {{required}}, {{/required}}value = "{{{description}}}")
@JsonProperty("{{baseName}}")
public {{{datatypeWithEnum}}} {{getter}}() {
return {{name}};
}
}{{^isReadOnly}}
public void {{setter}}({{{datatypeWithEnum}}} {{name}}) {
this.{{name}} = {{name}};
}
}{{/isReadOnly}}
{{/vars}}

View File

@ -9,7 +9,7 @@ import io.swagger.annotations.ApiModelProperty;
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-02-17T17:16:20.498+08:00")
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-02-22T14:59:49.052+08:00")
public class Category {
private Long id = null;
@ -23,7 +23,6 @@ public class Category {
return this;
}
@ApiModelProperty(example = "null", value = "")
@JsonProperty("id")
public Long getId() {
@ -41,7 +40,6 @@ public class Category {
return this;
}
@ApiModelProperty(example = "null", value = "")
@JsonProperty("name")
public String getName() {

View File

@ -11,7 +11,7 @@ import java.util.Date;
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-02-17T17:16:20.498+08:00")
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-02-22T14:59:49.052+08:00")
public class Order {
private Long id = null;
@ -42,22 +42,11 @@ public class Order {
private Boolean complete = null;
/**
**/
public Order 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;
}
/**
@ -67,7 +56,6 @@ public class Order {
return this;
}
@ApiModelProperty(example = "null", value = "")
@JsonProperty("petId")
public Long getPetId() {
@ -85,7 +73,6 @@ public class Order {
return this;
}
@ApiModelProperty(example = "null", value = "")
@JsonProperty("quantity")
public Integer getQuantity() {
@ -103,7 +90,6 @@ public class Order {
return this;
}
@ApiModelProperty(example = "null", value = "")
@JsonProperty("shipDate")
public Date getShipDate() {
@ -122,7 +108,6 @@ public class Order {
return this;
}
@ApiModelProperty(example = "null", value = "Order Status")
@JsonProperty("status")
public StatusEnum getStatus() {
@ -140,7 +125,6 @@ public class Order {
return this;
}
@ApiModelProperty(example = "null", value = "")
@JsonProperty("complete")
public Boolean getComplete() {

View File

@ -14,7 +14,7 @@ import java.util.List;
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-02-17T17:16:20.498+08:00")
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-02-22T14:59:49.052+08:00")
public class Pet {
private Long id = null;
@ -52,7 +52,6 @@ public class Pet {
return this;
}
@ApiModelProperty(example = "null", value = "")
@JsonProperty("id")
public Long getId() {
@ -70,7 +69,6 @@ public class Pet {
return this;
}
@ApiModelProperty(example = "null", value = "")
@JsonProperty("category")
public Category getCategory() {
@ -88,7 +86,6 @@ public class Pet {
return this;
}
@ApiModelProperty(example = "doggie", required = true, value = "")
@JsonProperty("name")
public String getName() {
@ -106,7 +103,6 @@ public class Pet {
return this;
}
@ApiModelProperty(example = "null", required = true, value = "")
@JsonProperty("photoUrls")
public List<String> getPhotoUrls() {
@ -124,7 +120,6 @@ public class Pet {
return this;
}
@ApiModelProperty(example = "null", value = "")
@JsonProperty("tags")
public List<Tag> getTags() {
@ -143,7 +138,6 @@ public class Pet {
return this;
}
@ApiModelProperty(example = "null", value = "pet status in the store")
@JsonProperty("status")
public StatusEnum getStatus() {

View File

@ -9,7 +9,7 @@ import io.swagger.annotations.ApiModelProperty;
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-02-17T17:16:20.498+08:00")
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-02-22T14:59:49.052+08:00")
public class Tag {
private Long id = null;
@ -23,7 +23,6 @@ public class Tag {
return this;
}
@ApiModelProperty(example = "null", value = "")
@JsonProperty("id")
public Long getId() {
@ -41,7 +40,6 @@ public class Tag {
return this;
}
@ApiModelProperty(example = "null", value = "")
@JsonProperty("name")
public String getName() {

View File

@ -9,7 +9,7 @@ import io.swagger.annotations.ApiModelProperty;
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-02-17T17:16:20.498+08:00")
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-02-22T14:59:49.052+08:00")
public class User {
private Long id = null;
@ -29,7 +29,6 @@ public class User {
return this;
}
@ApiModelProperty(example = "null", value = "")
@JsonProperty("id")
public Long getId() {
@ -47,7 +46,6 @@ public class User {
return this;
}
@ApiModelProperty(example = "null", value = "")
@JsonProperty("username")
public String getUsername() {
@ -65,7 +63,6 @@ public class User {
return this;
}
@ApiModelProperty(example = "null", value = "")
@JsonProperty("firstName")
public String getFirstName() {
@ -83,7 +80,6 @@ public class User {
return this;
}
@ApiModelProperty(example = "null", value = "")
@JsonProperty("lastName")
public String getLastName() {
@ -101,7 +97,6 @@ public class User {
return this;
}
@ApiModelProperty(example = "null", value = "")
@JsonProperty("email")
public String getEmail() {
@ -119,7 +114,6 @@ public class User {
return this;
}
@ApiModelProperty(example = "null", value = "")
@JsonProperty("password")
public String getPassword() {
@ -137,7 +131,6 @@ public class User {
return this;
}
@ApiModelProperty(example = "null", value = "")
@JsonProperty("phone")
public String getPhone() {
@ -156,7 +149,6 @@ public class User {
return this;
}
@ApiModelProperty(example = "null", value = "User Status")
@JsonProperty("userStatus")
public Integer getUserStatus() {

View File

@ -9,7 +9,7 @@ import io.swagger.annotations.ApiModelProperty;
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-02-17T17:16:23.375+08:00")
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-02-22T15:32:23.465+08:00")
public class Category {
private Long id = null;
@ -23,7 +23,6 @@ public class Category {
return this;
}
@ApiModelProperty(example = "null", value = "")
@JsonProperty("id")
public Long getId() {
@ -41,7 +40,6 @@ public class Category {
return this;
}
@ApiModelProperty(example = "null", value = "")
@JsonProperty("name")
public String getName() {

View File

@ -11,7 +11,7 @@ import java.util.Date;
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-02-17T17:16:23.375+08:00")
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-02-22T15:32:23.465+08:00")
public class Order {
private Long id = null;
@ -42,22 +42,11 @@ public class Order {
private Boolean complete = null;
/**
**/
public Order 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;
}
/**
@ -67,7 +56,6 @@ public class Order {
return this;
}
@ApiModelProperty(example = "null", value = "")
@JsonProperty("petId")
public Long getPetId() {
@ -85,7 +73,6 @@ public class Order {
return this;
}
@ApiModelProperty(example = "null", value = "")
@JsonProperty("quantity")
public Integer getQuantity() {
@ -103,7 +90,6 @@ public class Order {
return this;
}
@ApiModelProperty(example = "null", value = "")
@JsonProperty("shipDate")
public Date getShipDate() {
@ -122,7 +108,6 @@ public class Order {
return this;
}
@ApiModelProperty(example = "null", value = "Order Status")
@JsonProperty("status")
public StatusEnum getStatus() {
@ -140,7 +125,6 @@ public class Order {
return this;
}
@ApiModelProperty(example = "null", value = "")
@JsonProperty("complete")
public Boolean getComplete() {

View File

@ -14,7 +14,7 @@ import java.util.List;
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-02-17T17:16:23.375+08:00")
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-02-22T15:32:23.465+08:00")
public class Pet {
private Long id = null;
@ -52,7 +52,6 @@ public class Pet {
return this;
}
@ApiModelProperty(example = "null", value = "")
@JsonProperty("id")
public Long getId() {
@ -70,7 +69,6 @@ public class Pet {
return this;
}
@ApiModelProperty(example = "null", value = "")
@JsonProperty("category")
public Category getCategory() {
@ -88,7 +86,6 @@ public class Pet {
return this;
}
@ApiModelProperty(example = "doggie", required = true, value = "")
@JsonProperty("name")
public String getName() {
@ -106,7 +103,6 @@ public class Pet {
return this;
}
@ApiModelProperty(example = "null", required = true, value = "")
@JsonProperty("photoUrls")
public List<String> getPhotoUrls() {
@ -124,7 +120,6 @@ public class Pet {
return this;
}
@ApiModelProperty(example = "null", value = "")
@JsonProperty("tags")
public List<Tag> getTags() {
@ -143,7 +138,6 @@ public class Pet {
return this;
}
@ApiModelProperty(example = "null", value = "pet status in the store")
@JsonProperty("status")
public StatusEnum getStatus() {

View File

@ -9,7 +9,7 @@ import io.swagger.annotations.ApiModelProperty;
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-02-17T17:16:23.375+08:00")
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-02-22T15:32:23.465+08:00")
public class Tag {
private Long id = null;
@ -23,7 +23,6 @@ public class Tag {
return this;
}
@ApiModelProperty(example = "null", value = "")
@JsonProperty("id")
public Long getId() {
@ -41,7 +40,6 @@ public class Tag {
return this;
}
@ApiModelProperty(example = "null", value = "")
@JsonProperty("name")
public String getName() {

View File

@ -9,7 +9,7 @@ import io.swagger.annotations.ApiModelProperty;
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-02-17T17:16:23.375+08:00")
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-02-22T15:32:23.465+08:00")
public class User {
private Long id = null;
@ -29,7 +29,6 @@ public class User {
return this;
}
@ApiModelProperty(example = "null", value = "")
@JsonProperty("id")
public Long getId() {
@ -47,7 +46,6 @@ public class User {
return this;
}
@ApiModelProperty(example = "null", value = "")
@JsonProperty("username")
public String getUsername() {
@ -65,7 +63,6 @@ public class User {
return this;
}
@ApiModelProperty(example = "null", value = "")
@JsonProperty("firstName")
public String getFirstName() {
@ -83,7 +80,6 @@ public class User {
return this;
}
@ApiModelProperty(example = "null", value = "")
@JsonProperty("lastName")
public String getLastName() {
@ -101,7 +97,6 @@ public class User {
return this;
}
@ApiModelProperty(example = "null", value = "")
@JsonProperty("email")
public String getEmail() {
@ -119,7 +114,6 @@ public class User {
return this;
}
@ApiModelProperty(example = "null", value = "")
@JsonProperty("password")
public String getPassword() {
@ -137,7 +131,6 @@ public class User {
return this;
}
@ApiModelProperty(example = "null", value = "")
@JsonProperty("phone")
public String getPhone() {
@ -156,7 +149,6 @@ public class User {
return this;
}
@ApiModelProperty(example = "null", value = "User Status")
@JsonProperty("userStatus")
public Integer getUserStatus() {

View File

@ -9,7 +9,7 @@ import io.swagger.annotations.ApiModelProperty;
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-02-17T17:16:21.885+08:00")
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-02-22T15:34:25.436+08:00")
public class Category {
private Long id = null;
@ -23,7 +23,6 @@ public class Category {
return this;
}
@ApiModelProperty(example = "null", value = "")
@JsonProperty("id")
public Long getId() {
@ -41,7 +40,6 @@ public class Category {
return this;
}
@ApiModelProperty(example = "null", value = "")
@JsonProperty("name")
public String getName() {

View File

@ -11,7 +11,7 @@ import java.util.Date;
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-02-17T17:16:21.885+08:00")
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-02-22T15:34:25.436+08:00")
public class Order {
private Long id = null;
@ -42,22 +42,11 @@ public class Order {
private Boolean complete = null;
/**
**/
public Order 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;
}
/**
@ -67,7 +56,6 @@ public class Order {
return this;
}
@ApiModelProperty(example = "null", value = "")
@JsonProperty("petId")
public Long getPetId() {
@ -85,7 +73,6 @@ public class Order {
return this;
}
@ApiModelProperty(example = "null", value = "")
@JsonProperty("quantity")
public Integer getQuantity() {
@ -103,7 +90,6 @@ public class Order {
return this;
}
@ApiModelProperty(example = "null", value = "")
@JsonProperty("shipDate")
public Date getShipDate() {
@ -122,7 +108,6 @@ public class Order {
return this;
}
@ApiModelProperty(example = "null", value = "Order Status")
@JsonProperty("status")
public StatusEnum getStatus() {
@ -140,7 +125,6 @@ public class Order {
return this;
}
@ApiModelProperty(example = "null", value = "")
@JsonProperty("complete")
public Boolean getComplete() {

View File

@ -14,7 +14,7 @@ import java.util.List;
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-02-17T17:16:21.885+08:00")
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-02-22T15:34:25.436+08:00")
public class Pet {
private Long id = null;
@ -52,7 +52,6 @@ public class Pet {
return this;
}
@ApiModelProperty(example = "null", value = "")
@JsonProperty("id")
public Long getId() {
@ -70,7 +69,6 @@ public class Pet {
return this;
}
@ApiModelProperty(example = "null", value = "")
@JsonProperty("category")
public Category getCategory() {
@ -88,7 +86,6 @@ public class Pet {
return this;
}
@ApiModelProperty(example = "doggie", required = true, value = "")
@JsonProperty("name")
public String getName() {
@ -106,7 +103,6 @@ public class Pet {
return this;
}
@ApiModelProperty(example = "null", required = true, value = "")
@JsonProperty("photoUrls")
public List<String> getPhotoUrls() {
@ -124,7 +120,6 @@ public class Pet {
return this;
}
@ApiModelProperty(example = "null", value = "")
@JsonProperty("tags")
public List<Tag> getTags() {
@ -143,7 +138,6 @@ public class Pet {
return this;
}
@ApiModelProperty(example = "null", value = "pet status in the store")
@JsonProperty("status")
public StatusEnum getStatus() {

View File

@ -9,7 +9,7 @@ import io.swagger.annotations.ApiModelProperty;
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-02-17T17:16:21.885+08:00")
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-02-22T15:34:25.436+08:00")
public class Tag {
private Long id = null;
@ -23,7 +23,6 @@ public class Tag {
return this;
}
@ApiModelProperty(example = "null", value = "")
@JsonProperty("id")
public Long getId() {
@ -41,7 +40,6 @@ public class Tag {
return this;
}
@ApiModelProperty(example = "null", value = "")
@JsonProperty("name")
public String getName() {

View File

@ -9,7 +9,7 @@ import io.swagger.annotations.ApiModelProperty;
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-02-17T17:16:21.885+08:00")
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-02-22T15:34:25.436+08:00")
public class User {
private Long id = null;
@ -29,7 +29,6 @@ public class User {
return this;
}
@ApiModelProperty(example = "null", value = "")
@JsonProperty("id")
public Long getId() {
@ -47,7 +46,6 @@ public class User {
return this;
}
@ApiModelProperty(example = "null", value = "")
@JsonProperty("username")
public String getUsername() {
@ -65,7 +63,6 @@ public class User {
return this;
}
@ApiModelProperty(example = "null", value = "")
@JsonProperty("firstName")
public String getFirstName() {
@ -83,7 +80,6 @@ public class User {
return this;
}
@ApiModelProperty(example = "null", value = "")
@JsonProperty("lastName")
public String getLastName() {
@ -101,7 +97,6 @@ public class User {
return this;
}
@ApiModelProperty(example = "null", value = "")
@JsonProperty("email")
public String getEmail() {
@ -119,7 +114,6 @@ public class User {
return this;
}
@ApiModelProperty(example = "null", value = "")
@JsonProperty("password")
public String getPassword() {
@ -137,7 +131,6 @@ public class User {
return this;
}
@ApiModelProperty(example = "null", value = "")
@JsonProperty("phone")
public String getPhone() {
@ -156,7 +149,6 @@ public class User {
return this;
}
@ApiModelProperty(example = "null", value = "User Status")
@JsonProperty("userStatus")
public Integer getUserStatus() {

View File

@ -62,9 +62,6 @@ public enum StatusEnum {
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
/**