[JAVA][Server] Fixed issue #1525: Fix model class field initializations (Regression since 3.3.1) (#1549)

* Fixed issue #1525. Adjust class field declarations with proper initializations.

* Adjusted templates to add default only when it is exists.
This commit is contained in:
ccozzolino 2018-12-12 11:11:47 -06:00 committed by William Cheng
parent 0b029088f4
commit 95c744381b
18 changed files with 55 additions and 53 deletions

View File

@ -5,7 +5,7 @@ public class {{classname}} {{#parent}}extends {{{parent}}}{{/parent}} {{#seriali
{{>enumClass}}{{/isContainer}}{{#isContainer}}{{#mostInnerItems}}
{{>enumClass}}{{/mostInnerItems}}{{/isContainer}}{{/isEnum}}
private {{{datatypeWithEnum}}} {{name}} = {{{defaultValue}}};{{/vars}}
private {{{datatypeWithEnum}}} {{name}}{{#defaultValue}} = {{{.}}}{{/defaultValue}};{{/vars}}
public {{classname}} () {

View File

@ -6,7 +6,7 @@ public class {{classname}} {{#parent}}extends {{{parent}}}{{/parent}} {{#seriali
{{>enumClass}}{{/isContainer}}{{#isContainer}}{{#mostInnerItems}}
{{>enumClass}}{{/mostInnerItems}}{{/isContainer}}{{/isEnum}}
private {{{datatypeWithEnum}}} {{name}} = {{{defaultValue}}};{{/vars}}
private {{{datatypeWithEnum}}} {{name}}{{#defaultValue}} = {{{.}}}{{/defaultValue}};{{/vars}}
{{#vars}}
/**{{#description}}

View File

@ -1 +1 @@
3.2.0-SNAPSHOT
3.3.4-SNAPSHOT

View File

@ -10,8 +10,8 @@ import com.fasterxml.jackson.annotation.JsonProperty;
@JsonInclude(JsonInclude.Include.NON_NULL)
public class Category {
private Long id = null;
private String name = null;
private Long id;
private String name;
public Category () {

View File

@ -10,9 +10,9 @@ import com.fasterxml.jackson.annotation.JsonProperty;
@JsonInclude(JsonInclude.Include.NON_NULL)
public class ModelApiResponse {
private Integer code = null;
private String type = null;
private String message = null;
private Integer code;
private String type;
private String message;
public ModelApiResponse () {

View File

@ -12,10 +12,10 @@ import java.time.OffsetDateTime;
@JsonInclude(JsonInclude.Include.NON_NULL)
public class Order {
private Long id = null;
private Long petId = null;
private Integer quantity = null;
private OffsetDateTime shipDate = null;
private Long id;
private Long petId;
private Integer quantity;
private OffsetDateTime shipDate;
public enum StatusEnum {
@ -36,7 +36,7 @@ public class Order {
}
}
private StatusEnum status = null;
private StatusEnum status;
private Boolean complete = false;
public Order () {

View File

@ -15,9 +15,9 @@ import org.openapitools.server.api.model.Tag;
@JsonInclude(JsonInclude.Include.NON_NULL)
public class Pet {
private Long id = null;
private Long id;
private Category category = null;
private String name = null;
private String name;
private List<String> photoUrls = new ArrayList<>();
private List<Tag> tags = new ArrayList<>();
@ -40,7 +40,7 @@ public class Pet {
}
}
private StatusEnum status = null;
private StatusEnum status;
public Pet () {

View File

@ -10,8 +10,8 @@ import com.fasterxml.jackson.annotation.JsonProperty;
@JsonInclude(JsonInclude.Include.NON_NULL)
public class Tag {
private Long id = null;
private String name = null;
private Long id;
private String name;
public Tag () {

View File

@ -10,14 +10,14 @@ import com.fasterxml.jackson.annotation.JsonProperty;
@JsonInclude(JsonInclude.Include.NON_NULL)
public class User {
private Long id = null;
private String username = null;
private String firstName = null;
private String lastName = null;
private String email = null;
private String password = null;
private String phone = null;
private Integer userStatus = null;
private Long id;
private String username;
private String firstName;
private String lastName;
private String email;
private String password;
private String phone;
private Integer userStatus;
public User () {

View File

@ -118,8 +118,8 @@
"type" : "array",
"items" : {
"type" : "string",
"enum" : [ "available", "pending", "sold" ],
"default" : "available"
"default" : "available",
"enum" : [ "available", "pending", "sold" ]
}
}
} ],

View File

@ -1 +1 @@
3.0.0-SNAPSHOT
3.3.4-SNAPSHOT

View File

@ -16,8 +16,8 @@ import io.swagger.annotations.ApiModelProperty;
@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaUndertowServerCodegen")
public class Category {
private Long id = null;
private String name = null;
private Long id;
private String name;
/**
**/

View File

@ -16,9 +16,9 @@ import io.swagger.annotations.ApiModelProperty;
@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaUndertowServerCodegen")
public class ModelApiResponse {
private Integer code = null;
private String type = null;
private String message = null;
private Integer code;
private String type;
private String message;
/**
**/

View File

@ -18,10 +18,10 @@ import java.util.Date;
@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaUndertowServerCodegen")
public class Order {
private Long id = null;
private Long petId = null;
private Integer quantity = null;
private Date shipDate = null;
private Long id;
private Long petId;
private Integer quantity;
private Date shipDate;
public enum StatusEnum {
@ -42,7 +42,7 @@ public class Order {
}
}
private StatusEnum status = null;
private StatusEnum status;
private Boolean complete = false;
/**
@ -141,7 +141,7 @@ public class Order {
@ApiModelProperty(value = "")
@JsonProperty("complete")
public Boolean isComplete() {
public Boolean getComplete() {
return complete;
}
public void setComplete(Boolean complete) {

View File

@ -21,9 +21,9 @@ import org.openapitools.model.Tag;
@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaUndertowServerCodegen")
public class Pet {
private Long id = null;
private Long id;
private Category category = null;
private String name = null;
private String name;
private List<String> photoUrls = new ArrayList<String>();
private List<Tag> tags = new ArrayList<Tag>();
@ -46,7 +46,7 @@ public class Pet {
}
}
private StatusEnum status = null;
private StatusEnum status;
/**
**/

View File

@ -16,8 +16,8 @@ import io.swagger.annotations.ApiModelProperty;
@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaUndertowServerCodegen")
public class Tag {
private Long id = null;
private String name = null;
private Long id;
private String name;
/**
**/

View File

@ -16,14 +16,14 @@ import io.swagger.annotations.ApiModelProperty;
@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaUndertowServerCodegen")
public class User {
private Long id = null;
private String username = null;
private String firstName = null;
private String lastName = null;
private String email = null;
private String password = null;
private String phone = null;
private Integer userStatus = null;
private Long id;
private String username;
private String firstName;
private String lastName;
private String email;
private String password;
private String phone;
private Integer userStatus;
/**
**/

View File

@ -108,6 +108,7 @@
"in" : "query",
"description" : "Status values that need to be considered for filter",
"required" : true,
"style" : "form",
"explode" : false,
"schema" : {
"type" : "array",
@ -162,6 +163,7 @@
"in" : "query",
"description" : "Tags to filter by",
"required" : true,
"style" : "form",
"explode" : false,
"schema" : {
"type" : "array",