forked from loafle/openapi-generator-original
Add nullability annotations to Java generated clients (#19617)
* issue-1960: Add nullability annotations to Java generated clients Motivations: Have generated clients properly annotated for nullability to be able to check code using them with tools like NullAway Modifications: * Add nullable_var_annotations template to handle nullability annotation on vars * Add pojo templates to use the nullability template * Adapt tests * issue-1960: Add nullability annotations to Java generated clients Modifications: * Run export_docs_generator.sh script to update samples
This commit is contained in:
@@ -52,16 +52,18 @@ import org.openapitools.client.JSON;
|
||||
public class Category {
|
||||
public static final String SERIALIZED_NAME_ID = "id";
|
||||
@SerializedName(SERIALIZED_NAME_ID)
|
||||
@javax.annotation.Nullable
|
||||
private Long id;
|
||||
|
||||
public static final String SERIALIZED_NAME_NAME = "name";
|
||||
@SerializedName(SERIALIZED_NAME_NAME)
|
||||
@javax.annotation.Nullable
|
||||
private String name;
|
||||
|
||||
public Category() {
|
||||
}
|
||||
|
||||
public Category id(Long id) {
|
||||
public Category id(@javax.annotation.Nullable Long id) {
|
||||
this.id = id;
|
||||
return this;
|
||||
}
|
||||
@@ -75,12 +77,12 @@ public class Category {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Long id) {
|
||||
public void setId(@javax.annotation.Nullable Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
|
||||
public Category name(String name) {
|
||||
public Category name(@javax.annotation.Nullable String name) {
|
||||
this.name = name;
|
||||
return this;
|
||||
}
|
||||
@@ -94,7 +96,7 @@ public class Category {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
public void setName(@javax.annotation.Nullable String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
|
||||
@@ -52,20 +52,23 @@ import org.openapitools.client.JSON;
|
||||
public class ModelApiResponse {
|
||||
public static final String SERIALIZED_NAME_CODE = "code";
|
||||
@SerializedName(SERIALIZED_NAME_CODE)
|
||||
@javax.annotation.Nullable
|
||||
private Integer code;
|
||||
|
||||
public static final String SERIALIZED_NAME_TYPE = "type";
|
||||
@SerializedName(SERIALIZED_NAME_TYPE)
|
||||
@javax.annotation.Nullable
|
||||
private String type;
|
||||
|
||||
public static final String SERIALIZED_NAME_MESSAGE = "message";
|
||||
@SerializedName(SERIALIZED_NAME_MESSAGE)
|
||||
@javax.annotation.Nullable
|
||||
private String message;
|
||||
|
||||
public ModelApiResponse() {
|
||||
}
|
||||
|
||||
public ModelApiResponse code(Integer code) {
|
||||
public ModelApiResponse code(@javax.annotation.Nullable Integer code) {
|
||||
this.code = code;
|
||||
return this;
|
||||
}
|
||||
@@ -79,12 +82,12 @@ public class ModelApiResponse {
|
||||
return code;
|
||||
}
|
||||
|
||||
public void setCode(Integer code) {
|
||||
public void setCode(@javax.annotation.Nullable Integer code) {
|
||||
this.code = code;
|
||||
}
|
||||
|
||||
|
||||
public ModelApiResponse type(String type) {
|
||||
public ModelApiResponse type(@javax.annotation.Nullable String type) {
|
||||
this.type = type;
|
||||
return this;
|
||||
}
|
||||
@@ -98,12 +101,12 @@ public class ModelApiResponse {
|
||||
return type;
|
||||
}
|
||||
|
||||
public void setType(String type) {
|
||||
public void setType(@javax.annotation.Nullable String type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
|
||||
public ModelApiResponse message(String message) {
|
||||
public ModelApiResponse message(@javax.annotation.Nullable String message) {
|
||||
this.message = message;
|
||||
return this;
|
||||
}
|
||||
@@ -117,7 +120,7 @@ public class ModelApiResponse {
|
||||
return message;
|
||||
}
|
||||
|
||||
public void setMessage(String message) {
|
||||
public void setMessage(@javax.annotation.Nullable String message) {
|
||||
this.message = message;
|
||||
}
|
||||
|
||||
|
||||
@@ -53,18 +53,22 @@ import org.openapitools.client.JSON;
|
||||
public class Order {
|
||||
public static final String SERIALIZED_NAME_ID = "id";
|
||||
@SerializedName(SERIALIZED_NAME_ID)
|
||||
@javax.annotation.Nullable
|
||||
private Long id;
|
||||
|
||||
public static final String SERIALIZED_NAME_PET_ID = "petId";
|
||||
@SerializedName(SERIALIZED_NAME_PET_ID)
|
||||
@javax.annotation.Nullable
|
||||
private Long petId;
|
||||
|
||||
public static final String SERIALIZED_NAME_QUANTITY = "quantity";
|
||||
@SerializedName(SERIALIZED_NAME_QUANTITY)
|
||||
@javax.annotation.Nullable
|
||||
private Integer quantity;
|
||||
|
||||
public static final String SERIALIZED_NAME_SHIP_DATE = "shipDate";
|
||||
@SerializedName(SERIALIZED_NAME_SHIP_DATE)
|
||||
@javax.annotation.Nullable
|
||||
private OffsetDateTime shipDate;
|
||||
|
||||
/**
|
||||
@@ -123,16 +127,18 @@ public class Order {
|
||||
|
||||
public static final String SERIALIZED_NAME_STATUS = "status";
|
||||
@SerializedName(SERIALIZED_NAME_STATUS)
|
||||
@javax.annotation.Nullable
|
||||
private StatusEnum status;
|
||||
|
||||
public static final String SERIALIZED_NAME_COMPLETE = "complete";
|
||||
@SerializedName(SERIALIZED_NAME_COMPLETE)
|
||||
@javax.annotation.Nullable
|
||||
private Boolean complete = false;
|
||||
|
||||
public Order() {
|
||||
}
|
||||
|
||||
public Order id(Long id) {
|
||||
public Order id(@javax.annotation.Nullable Long id) {
|
||||
this.id = id;
|
||||
return this;
|
||||
}
|
||||
@@ -146,12 +152,12 @@ public class Order {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Long id) {
|
||||
public void setId(@javax.annotation.Nullable Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
|
||||
public Order petId(Long petId) {
|
||||
public Order petId(@javax.annotation.Nullable Long petId) {
|
||||
this.petId = petId;
|
||||
return this;
|
||||
}
|
||||
@@ -165,12 +171,12 @@ public class Order {
|
||||
return petId;
|
||||
}
|
||||
|
||||
public void setPetId(Long petId) {
|
||||
public void setPetId(@javax.annotation.Nullable Long petId) {
|
||||
this.petId = petId;
|
||||
}
|
||||
|
||||
|
||||
public Order quantity(Integer quantity) {
|
||||
public Order quantity(@javax.annotation.Nullable Integer quantity) {
|
||||
this.quantity = quantity;
|
||||
return this;
|
||||
}
|
||||
@@ -184,12 +190,12 @@ public class Order {
|
||||
return quantity;
|
||||
}
|
||||
|
||||
public void setQuantity(Integer quantity) {
|
||||
public void setQuantity(@javax.annotation.Nullable Integer quantity) {
|
||||
this.quantity = quantity;
|
||||
}
|
||||
|
||||
|
||||
public Order shipDate(OffsetDateTime shipDate) {
|
||||
public Order shipDate(@javax.annotation.Nullable OffsetDateTime shipDate) {
|
||||
this.shipDate = shipDate;
|
||||
return this;
|
||||
}
|
||||
@@ -203,12 +209,12 @@ public class Order {
|
||||
return shipDate;
|
||||
}
|
||||
|
||||
public void setShipDate(OffsetDateTime shipDate) {
|
||||
public void setShipDate(@javax.annotation.Nullable OffsetDateTime shipDate) {
|
||||
this.shipDate = shipDate;
|
||||
}
|
||||
|
||||
|
||||
public Order status(StatusEnum status) {
|
||||
public Order status(@javax.annotation.Nullable StatusEnum status) {
|
||||
this.status = status;
|
||||
return this;
|
||||
}
|
||||
@@ -222,12 +228,12 @@ public class Order {
|
||||
return status;
|
||||
}
|
||||
|
||||
public void setStatus(StatusEnum status) {
|
||||
public void setStatus(@javax.annotation.Nullable StatusEnum status) {
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
|
||||
public Order complete(Boolean complete) {
|
||||
public Order complete(@javax.annotation.Nullable Boolean complete) {
|
||||
this.complete = complete;
|
||||
return this;
|
||||
}
|
||||
@@ -241,7 +247,7 @@ public class Order {
|
||||
return complete;
|
||||
}
|
||||
|
||||
public void setComplete(Boolean complete) {
|
||||
public void setComplete(@javax.annotation.Nullable Boolean complete) {
|
||||
this.complete = complete;
|
||||
}
|
||||
|
||||
|
||||
@@ -56,22 +56,27 @@ import org.openapitools.client.JSON;
|
||||
public class Pet {
|
||||
public static final String SERIALIZED_NAME_ID = "id";
|
||||
@SerializedName(SERIALIZED_NAME_ID)
|
||||
@javax.annotation.Nullable
|
||||
private Long id;
|
||||
|
||||
public static final String SERIALIZED_NAME_CATEGORY = "category";
|
||||
@SerializedName(SERIALIZED_NAME_CATEGORY)
|
||||
@javax.annotation.Nullable
|
||||
private Category category;
|
||||
|
||||
public static final String SERIALIZED_NAME_NAME = "name";
|
||||
@SerializedName(SERIALIZED_NAME_NAME)
|
||||
@javax.annotation.Nonnull
|
||||
private String name;
|
||||
|
||||
public static final String SERIALIZED_NAME_PHOTO_URLS = "photoUrls";
|
||||
@SerializedName(SERIALIZED_NAME_PHOTO_URLS)
|
||||
@javax.annotation.Nonnull
|
||||
private List<String> photoUrls = new ArrayList<>();
|
||||
|
||||
public static final String SERIALIZED_NAME_TAGS = "tags";
|
||||
@SerializedName(SERIALIZED_NAME_TAGS)
|
||||
@javax.annotation.Nullable
|
||||
private List<Tag> tags = new ArrayList<>();
|
||||
|
||||
/**
|
||||
@@ -131,12 +136,13 @@ public class Pet {
|
||||
public static final String SERIALIZED_NAME_STATUS = "status";
|
||||
@Deprecated
|
||||
@SerializedName(SERIALIZED_NAME_STATUS)
|
||||
@javax.annotation.Nullable
|
||||
private StatusEnum status;
|
||||
|
||||
public Pet() {
|
||||
}
|
||||
|
||||
public Pet id(Long id) {
|
||||
public Pet id(@javax.annotation.Nullable Long id) {
|
||||
this.id = id;
|
||||
return this;
|
||||
}
|
||||
@@ -150,12 +156,12 @@ public class Pet {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Long id) {
|
||||
public void setId(@javax.annotation.Nullable Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
|
||||
public Pet category(Category category) {
|
||||
public Pet category(@javax.annotation.Nullable Category category) {
|
||||
this.category = category;
|
||||
return this;
|
||||
}
|
||||
@@ -169,12 +175,12 @@ public class Pet {
|
||||
return category;
|
||||
}
|
||||
|
||||
public void setCategory(Category category) {
|
||||
public void setCategory(@javax.annotation.Nullable Category category) {
|
||||
this.category = category;
|
||||
}
|
||||
|
||||
|
||||
public Pet name(String name) {
|
||||
public Pet name(@javax.annotation.Nonnull String name) {
|
||||
this.name = name;
|
||||
return this;
|
||||
}
|
||||
@@ -188,12 +194,12 @@ public class Pet {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
public void setName(@javax.annotation.Nonnull String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
|
||||
public Pet photoUrls(List<String> photoUrls) {
|
||||
public Pet photoUrls(@javax.annotation.Nonnull List<String> photoUrls) {
|
||||
this.photoUrls = photoUrls;
|
||||
return this;
|
||||
}
|
||||
@@ -215,12 +221,12 @@ public class Pet {
|
||||
return photoUrls;
|
||||
}
|
||||
|
||||
public void setPhotoUrls(List<String> photoUrls) {
|
||||
public void setPhotoUrls(@javax.annotation.Nonnull List<String> photoUrls) {
|
||||
this.photoUrls = photoUrls;
|
||||
}
|
||||
|
||||
|
||||
public Pet tags(List<Tag> tags) {
|
||||
public Pet tags(@javax.annotation.Nullable List<Tag> tags) {
|
||||
this.tags = tags;
|
||||
return this;
|
||||
}
|
||||
@@ -242,13 +248,13 @@ public class Pet {
|
||||
return tags;
|
||||
}
|
||||
|
||||
public void setTags(List<Tag> tags) {
|
||||
public void setTags(@javax.annotation.Nullable List<Tag> tags) {
|
||||
this.tags = tags;
|
||||
}
|
||||
|
||||
|
||||
@Deprecated
|
||||
public Pet status(StatusEnum status) {
|
||||
public Pet status(@javax.annotation.Nullable StatusEnum status) {
|
||||
this.status = status;
|
||||
return this;
|
||||
}
|
||||
@@ -265,7 +271,7 @@ public class Pet {
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public void setStatus(StatusEnum status) {
|
||||
public void setStatus(@javax.annotation.Nullable StatusEnum status) {
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
|
||||
@@ -52,16 +52,18 @@ import org.openapitools.client.JSON;
|
||||
public class Tag {
|
||||
public static final String SERIALIZED_NAME_ID = "id";
|
||||
@SerializedName(SERIALIZED_NAME_ID)
|
||||
@javax.annotation.Nullable
|
||||
private Long id;
|
||||
|
||||
public static final String SERIALIZED_NAME_NAME = "name";
|
||||
@SerializedName(SERIALIZED_NAME_NAME)
|
||||
@javax.annotation.Nullable
|
||||
private String name;
|
||||
|
||||
public Tag() {
|
||||
}
|
||||
|
||||
public Tag id(Long id) {
|
||||
public Tag id(@javax.annotation.Nullable Long id) {
|
||||
this.id = id;
|
||||
return this;
|
||||
}
|
||||
@@ -75,12 +77,12 @@ public class Tag {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Long id) {
|
||||
public void setId(@javax.annotation.Nullable Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
|
||||
public Tag name(String name) {
|
||||
public Tag name(@javax.annotation.Nullable String name) {
|
||||
this.name = name;
|
||||
return this;
|
||||
}
|
||||
@@ -94,7 +96,7 @@ public class Tag {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
public void setName(@javax.annotation.Nullable String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
|
||||
@@ -52,40 +52,48 @@ import org.openapitools.client.JSON;
|
||||
public class User {
|
||||
public static final String SERIALIZED_NAME_ID = "id";
|
||||
@SerializedName(SERIALIZED_NAME_ID)
|
||||
@javax.annotation.Nullable
|
||||
private Long id;
|
||||
|
||||
public static final String SERIALIZED_NAME_USERNAME = "username";
|
||||
@SerializedName(SERIALIZED_NAME_USERNAME)
|
||||
@javax.annotation.Nullable
|
||||
private String username;
|
||||
|
||||
public static final String SERIALIZED_NAME_FIRST_NAME = "firstName";
|
||||
@SerializedName(SERIALIZED_NAME_FIRST_NAME)
|
||||
@javax.annotation.Nullable
|
||||
private String firstName;
|
||||
|
||||
public static final String SERIALIZED_NAME_LAST_NAME = "lastName";
|
||||
@SerializedName(SERIALIZED_NAME_LAST_NAME)
|
||||
@javax.annotation.Nullable
|
||||
private String lastName;
|
||||
|
||||
public static final String SERIALIZED_NAME_EMAIL = "email";
|
||||
@SerializedName(SERIALIZED_NAME_EMAIL)
|
||||
@javax.annotation.Nullable
|
||||
private String email;
|
||||
|
||||
public static final String SERIALIZED_NAME_PASSWORD = "password";
|
||||
@SerializedName(SERIALIZED_NAME_PASSWORD)
|
||||
@javax.annotation.Nullable
|
||||
private String password;
|
||||
|
||||
public static final String SERIALIZED_NAME_PHONE = "phone";
|
||||
@SerializedName(SERIALIZED_NAME_PHONE)
|
||||
@javax.annotation.Nullable
|
||||
private String phone;
|
||||
|
||||
public static final String SERIALIZED_NAME_USER_STATUS = "userStatus";
|
||||
@SerializedName(SERIALIZED_NAME_USER_STATUS)
|
||||
@javax.annotation.Nullable
|
||||
private Integer userStatus;
|
||||
|
||||
public User() {
|
||||
}
|
||||
|
||||
public User id(Long id) {
|
||||
public User id(@javax.annotation.Nullable Long id) {
|
||||
this.id = id;
|
||||
return this;
|
||||
}
|
||||
@@ -99,12 +107,12 @@ public class User {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Long id) {
|
||||
public void setId(@javax.annotation.Nullable Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
|
||||
public User username(String username) {
|
||||
public User username(@javax.annotation.Nullable String username) {
|
||||
this.username = username;
|
||||
return this;
|
||||
}
|
||||
@@ -118,12 +126,12 @@ public class User {
|
||||
return username;
|
||||
}
|
||||
|
||||
public void setUsername(String username) {
|
||||
public void setUsername(@javax.annotation.Nullable String username) {
|
||||
this.username = username;
|
||||
}
|
||||
|
||||
|
||||
public User firstName(String firstName) {
|
||||
public User firstName(@javax.annotation.Nullable String firstName) {
|
||||
this.firstName = firstName;
|
||||
return this;
|
||||
}
|
||||
@@ -137,12 +145,12 @@ public class User {
|
||||
return firstName;
|
||||
}
|
||||
|
||||
public void setFirstName(String firstName) {
|
||||
public void setFirstName(@javax.annotation.Nullable String firstName) {
|
||||
this.firstName = firstName;
|
||||
}
|
||||
|
||||
|
||||
public User lastName(String lastName) {
|
||||
public User lastName(@javax.annotation.Nullable String lastName) {
|
||||
this.lastName = lastName;
|
||||
return this;
|
||||
}
|
||||
@@ -156,12 +164,12 @@ public class User {
|
||||
return lastName;
|
||||
}
|
||||
|
||||
public void setLastName(String lastName) {
|
||||
public void setLastName(@javax.annotation.Nullable String lastName) {
|
||||
this.lastName = lastName;
|
||||
}
|
||||
|
||||
|
||||
public User email(String email) {
|
||||
public User email(@javax.annotation.Nullable String email) {
|
||||
this.email = email;
|
||||
return this;
|
||||
}
|
||||
@@ -175,12 +183,12 @@ public class User {
|
||||
return email;
|
||||
}
|
||||
|
||||
public void setEmail(String email) {
|
||||
public void setEmail(@javax.annotation.Nullable String email) {
|
||||
this.email = email;
|
||||
}
|
||||
|
||||
|
||||
public User password(String password) {
|
||||
public User password(@javax.annotation.Nullable String password) {
|
||||
this.password = password;
|
||||
return this;
|
||||
}
|
||||
@@ -194,12 +202,12 @@ public class User {
|
||||
return password;
|
||||
}
|
||||
|
||||
public void setPassword(String password) {
|
||||
public void setPassword(@javax.annotation.Nullable String password) {
|
||||
this.password = password;
|
||||
}
|
||||
|
||||
|
||||
public User phone(String phone) {
|
||||
public User phone(@javax.annotation.Nullable String phone) {
|
||||
this.phone = phone;
|
||||
return this;
|
||||
}
|
||||
@@ -213,12 +221,12 @@ public class User {
|
||||
return phone;
|
||||
}
|
||||
|
||||
public void setPhone(String phone) {
|
||||
public void setPhone(@javax.annotation.Nullable String phone) {
|
||||
this.phone = phone;
|
||||
}
|
||||
|
||||
|
||||
public User userStatus(Integer userStatus) {
|
||||
public User userStatus(@javax.annotation.Nullable Integer userStatus) {
|
||||
this.userStatus = userStatus;
|
||||
return this;
|
||||
}
|
||||
@@ -232,7 +240,7 @@ public class User {
|
||||
return userStatus;
|
||||
}
|
||||
|
||||
public void setUserStatus(Integer userStatus) {
|
||||
public void setUserStatus(@javax.annotation.Nullable Integer userStatus) {
|
||||
this.userStatus = userStatus;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user