forked from loafle/openapi-generator-original
[Java Play Framework] Remove most warnings + bug fixes (#6275)
* Removals of most of the warnings found by lint * Removals of most of the warnings found by lint (PART 2) * Removals of most of the warnings found by lint (PART 3) * Removals of most of the warnings found by lint (PART 4) * Removals of most of the warnings found by lint (PART 5) * Fix conversion error * Removal of unnecessary import. Other will need more complex login in the generator itself (not in the mustache files) * Add missing imports + fix to the regex. Generation of the samples
This commit is contained in:
committed by
wing328
parent
b0333af8bd
commit
ab28c7c825
@@ -1,11 +1,14 @@
|
||||
package apimodels;
|
||||
|
||||
import java.util.Objects;
|
||||
import com.fasterxml.jackson.annotation.*;
|
||||
import java.util.Set;
|
||||
import javax.validation.*;
|
||||
import java.util.Objects;
|
||||
/**
|
||||
* A category for a pet
|
||||
*/
|
||||
|
||||
@SuppressWarnings({"UnusedReturnValue", "WeakerAccess"})
|
||||
public class Category {
|
||||
@JsonProperty("id")
|
||||
private Long id = null;
|
||||
@@ -57,8 +60,8 @@ public class Category {
|
||||
return false;
|
||||
}
|
||||
Category category = (Category) o;
|
||||
return Objects.equals(this.id, category.id) &&
|
||||
Objects.equals(this.name, category.name);
|
||||
return Objects.equals(id, category.id) &&
|
||||
Objects.equals(name, category.name);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -66,6 +69,7 @@ public class Category {
|
||||
return Objects.hash(id, name);
|
||||
}
|
||||
|
||||
@SuppressWarnings("StringBufferReplaceableByString")
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
|
||||
@@ -1,11 +1,14 @@
|
||||
package apimodels;
|
||||
|
||||
import java.util.Objects;
|
||||
import com.fasterxml.jackson.annotation.*;
|
||||
import java.util.Set;
|
||||
import javax.validation.*;
|
||||
import java.util.Objects;
|
||||
/**
|
||||
* Describes the result of uploading an image resource
|
||||
*/
|
||||
|
||||
@SuppressWarnings({"UnusedReturnValue", "WeakerAccess"})
|
||||
public class ModelApiResponse {
|
||||
@JsonProperty("code")
|
||||
private Integer code = null;
|
||||
@@ -77,9 +80,9 @@ public class ModelApiResponse {
|
||||
return false;
|
||||
}
|
||||
ModelApiResponse _apiResponse = (ModelApiResponse) o;
|
||||
return Objects.equals(this.code, _apiResponse.code) &&
|
||||
Objects.equals(this.type, _apiResponse.type) &&
|
||||
Objects.equals(this.message, _apiResponse.message);
|
||||
return Objects.equals(code, _apiResponse.code) &&
|
||||
Objects.equals(type, _apiResponse.type) &&
|
||||
Objects.equals(message, _apiResponse.message);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -87,6 +90,7 @@ public class ModelApiResponse {
|
||||
return Objects.hash(code, type, message);
|
||||
}
|
||||
|
||||
@SuppressWarnings("StringBufferReplaceableByString")
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
|
||||
@@ -1,12 +1,15 @@
|
||||
package apimodels;
|
||||
|
||||
import java.util.Objects;
|
||||
import java.time.OffsetDateTime;
|
||||
import com.fasterxml.jackson.annotation.*;
|
||||
import java.util.Set;
|
||||
import javax.validation.*;
|
||||
import java.util.Objects;
|
||||
/**
|
||||
* An order for a pets from the pet store
|
||||
*/
|
||||
|
||||
@SuppressWarnings({"UnusedReturnValue", "WeakerAccess"})
|
||||
public class Order {
|
||||
@JsonProperty("id")
|
||||
private Long id = null;
|
||||
@@ -30,7 +33,7 @@ public class Order {
|
||||
|
||||
DELIVERED("delivered");
|
||||
|
||||
private String value;
|
||||
private final String value;
|
||||
|
||||
StatusEnum(String value) {
|
||||
this.value = value;
|
||||
@@ -171,12 +174,12 @@ public class Order {
|
||||
return false;
|
||||
}
|
||||
Order order = (Order) o;
|
||||
return Objects.equals(this.id, order.id) &&
|
||||
Objects.equals(this.petId, order.petId) &&
|
||||
Objects.equals(this.quantity, order.quantity) &&
|
||||
Objects.equals(this.shipDate, order.shipDate) &&
|
||||
Objects.equals(this.status, order.status) &&
|
||||
Objects.equals(this.complete, order.complete);
|
||||
return Objects.equals(id, order.id) &&
|
||||
Objects.equals(petId, order.petId) &&
|
||||
Objects.equals(quantity, order.quantity) &&
|
||||
Objects.equals(shipDate, order.shipDate) &&
|
||||
Objects.equals(status, order.status) &&
|
||||
Objects.equals(complete, order.complete);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -184,6 +187,7 @@ public class Order {
|
||||
return Objects.hash(id, petId, quantity, shipDate, status, complete);
|
||||
}
|
||||
|
||||
@SuppressWarnings("StringBufferReplaceableByString")
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
|
||||
@@ -1,15 +1,18 @@
|
||||
package apimodels;
|
||||
|
||||
import java.util.Objects;
|
||||
import apimodels.Category;
|
||||
import apimodels.Tag;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import com.fasterxml.jackson.annotation.*;
|
||||
import java.util.Set;
|
||||
import javax.validation.*;
|
||||
import java.util.Objects;
|
||||
/**
|
||||
* A pet for sale in the pet store
|
||||
*/
|
||||
|
||||
@SuppressWarnings({"UnusedReturnValue", "WeakerAccess"})
|
||||
public class Pet {
|
||||
@JsonProperty("id")
|
||||
private Long id = null;
|
||||
@@ -21,7 +24,7 @@ public class Pet {
|
||||
private String name = null;
|
||||
|
||||
@JsonProperty("photoUrls")
|
||||
private List<String> photoUrls = new ArrayList<String>();
|
||||
private List<String> photoUrls = new ArrayList<>();
|
||||
|
||||
@JsonProperty("tags")
|
||||
private List<Tag> tags = null;
|
||||
@@ -36,7 +39,7 @@ public class Pet {
|
||||
|
||||
SOLD("sold");
|
||||
|
||||
private String value;
|
||||
private final String value;
|
||||
|
||||
StatusEnum(String value) {
|
||||
this.value = value;
|
||||
@@ -119,7 +122,7 @@ public class Pet {
|
||||
}
|
||||
|
||||
public Pet addPhotoUrlsItem(String photoUrlsItem) {
|
||||
this.photoUrls.add(photoUrlsItem);
|
||||
photoUrls.add(photoUrlsItem);
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -141,10 +144,10 @@ public class Pet {
|
||||
}
|
||||
|
||||
public Pet addTagsItem(Tag tagsItem) {
|
||||
if (this.tags == null) {
|
||||
this.tags = new ArrayList<Tag>();
|
||||
if (tags == null) {
|
||||
tags = new ArrayList<>();
|
||||
}
|
||||
this.tags.add(tagsItem);
|
||||
tags.add(tagsItem);
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -187,12 +190,12 @@ public class Pet {
|
||||
return false;
|
||||
}
|
||||
Pet pet = (Pet) o;
|
||||
return Objects.equals(this.id, pet.id) &&
|
||||
Objects.equals(this.category, pet.category) &&
|
||||
Objects.equals(this.name, pet.name) &&
|
||||
Objects.equals(this.photoUrls, pet.photoUrls) &&
|
||||
Objects.equals(this.tags, pet.tags) &&
|
||||
Objects.equals(this.status, pet.status);
|
||||
return Objects.equals(id, pet.id) &&
|
||||
Objects.equals(category, pet.category) &&
|
||||
Objects.equals(name, pet.name) &&
|
||||
Objects.equals(photoUrls, pet.photoUrls) &&
|
||||
Objects.equals(tags, pet.tags) &&
|
||||
Objects.equals(status, pet.status);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -200,6 +203,7 @@ public class Pet {
|
||||
return Objects.hash(id, category, name, photoUrls, tags, status);
|
||||
}
|
||||
|
||||
@SuppressWarnings("StringBufferReplaceableByString")
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
|
||||
@@ -1,11 +1,14 @@
|
||||
package apimodels;
|
||||
|
||||
import java.util.Objects;
|
||||
import com.fasterxml.jackson.annotation.*;
|
||||
import java.util.Set;
|
||||
import javax.validation.*;
|
||||
import java.util.Objects;
|
||||
/**
|
||||
* A tag for a pet
|
||||
*/
|
||||
|
||||
@SuppressWarnings({"UnusedReturnValue", "WeakerAccess"})
|
||||
public class Tag {
|
||||
@JsonProperty("id")
|
||||
private Long id = null;
|
||||
@@ -57,8 +60,8 @@ public class Tag {
|
||||
return false;
|
||||
}
|
||||
Tag tag = (Tag) o;
|
||||
return Objects.equals(this.id, tag.id) &&
|
||||
Objects.equals(this.name, tag.name);
|
||||
return Objects.equals(id, tag.id) &&
|
||||
Objects.equals(name, tag.name);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -66,6 +69,7 @@ public class Tag {
|
||||
return Objects.hash(id, name);
|
||||
}
|
||||
|
||||
@SuppressWarnings("StringBufferReplaceableByString")
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
|
||||
@@ -1,11 +1,14 @@
|
||||
package apimodels;
|
||||
|
||||
import java.util.Objects;
|
||||
import com.fasterxml.jackson.annotation.*;
|
||||
import java.util.Set;
|
||||
import javax.validation.*;
|
||||
import java.util.Objects;
|
||||
/**
|
||||
* A User who is purchasing from the pet store
|
||||
*/
|
||||
|
||||
@SuppressWarnings({"UnusedReturnValue", "WeakerAccess"})
|
||||
public class User {
|
||||
@JsonProperty("id")
|
||||
private Long id = null;
|
||||
@@ -177,14 +180,14 @@ public class User {
|
||||
return false;
|
||||
}
|
||||
User user = (User) o;
|
||||
return Objects.equals(this.id, user.id) &&
|
||||
Objects.equals(this.username, user.username) &&
|
||||
Objects.equals(this.firstName, user.firstName) &&
|
||||
Objects.equals(this.lastName, user.lastName) &&
|
||||
Objects.equals(this.email, user.email) &&
|
||||
Objects.equals(this.password, user.password) &&
|
||||
Objects.equals(this.phone, user.phone) &&
|
||||
Objects.equals(this.userStatus, user.userStatus);
|
||||
return Objects.equals(id, user.id) &&
|
||||
Objects.equals(username, user.username) &&
|
||||
Objects.equals(firstName, user.firstName) &&
|
||||
Objects.equals(lastName, user.lastName) &&
|
||||
Objects.equals(email, user.email) &&
|
||||
Objects.equals(password, user.password) &&
|
||||
Objects.equals(phone, user.phone) &&
|
||||
Objects.equals(userStatus, user.userStatus);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -192,6 +195,7 @@ public class User {
|
||||
return Objects.hash(id, username, firstName, lastName, email, password, phone, userStatus);
|
||||
}
|
||||
|
||||
@SuppressWarnings("StringBufferReplaceableByString")
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
|
||||
@@ -13,7 +13,7 @@ import java.util.ArrayList;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
import com.google.inject.Inject;
|
||||
import java.io.IOException;
|
||||
import java.io.File;
|
||||
import swagger.SwaggerUtils;
|
||||
import com.fasterxml.jackson.core.type.TypeReference;
|
||||
|
||||
@@ -41,9 +41,7 @@ public class PetApiController extends Controller {
|
||||
body = mapper.readValue(nodebody.toString(), Pet.class);
|
||||
|
||||
imp.addPet(body);
|
||||
|
||||
return ok();
|
||||
|
||||
}
|
||||
|
||||
@ApiAction
|
||||
@@ -51,15 +49,13 @@ public class PetApiController extends Controller {
|
||||
String valueapiKey = request().getHeader("api_key");
|
||||
String apiKey;
|
||||
if (valueapiKey != null) {
|
||||
apiKey = (String)valueapiKey;
|
||||
apiKey = valueapiKey;
|
||||
|
||||
} else {
|
||||
apiKey = null;
|
||||
}
|
||||
imp.deletePet(petId, apiKey);
|
||||
|
||||
return ok();
|
||||
|
||||
}
|
||||
|
||||
@ApiAction
|
||||
@@ -73,8 +69,6 @@ public class PetApiController extends Controller {
|
||||
List<Pet> obj = imp.findPetsByStatus(status);
|
||||
JsonNode result = mapper.valueToTree(obj);
|
||||
return ok(result);
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ApiAction
|
||||
@@ -88,8 +82,6 @@ public class PetApiController extends Controller {
|
||||
List<Pet> obj = imp.findPetsByTags(tags);
|
||||
JsonNode result = mapper.valueToTree(obj);
|
||||
return ok(result);
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ApiAction
|
||||
@@ -97,8 +89,6 @@ public class PetApiController extends Controller {
|
||||
Pet obj = imp.getPetById(petId);
|
||||
JsonNode result = mapper.valueToTree(obj);
|
||||
return ok(result);
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ApiAction
|
||||
@@ -109,9 +99,7 @@ public class PetApiController extends Controller {
|
||||
body = mapper.readValue(nodebody.toString(), Pet.class);
|
||||
|
||||
imp.updatePet(body);
|
||||
|
||||
return ok();
|
||||
|
||||
}
|
||||
|
||||
@ApiAction
|
||||
@@ -119,7 +107,7 @@ public class PetApiController extends Controller {
|
||||
String valuename = (request().body().asMultipartFormData().asFormUrlEncoded().get("name"))[0];
|
||||
String name;
|
||||
if (valuename != null) {
|
||||
name = (String)valuename;
|
||||
name = valuename;
|
||||
|
||||
} else {
|
||||
name = null;
|
||||
@@ -127,15 +115,13 @@ public class PetApiController extends Controller {
|
||||
String valuestatus = (request().body().asMultipartFormData().asFormUrlEncoded().get("status"))[0];
|
||||
String status;
|
||||
if (valuestatus != null) {
|
||||
status = (String)valuestatus;
|
||||
status = valuestatus;
|
||||
|
||||
} else {
|
||||
status = null;
|
||||
}
|
||||
imp.updatePetWithForm(petId, name, status);
|
||||
|
||||
return ok();
|
||||
|
||||
}
|
||||
|
||||
@ApiAction
|
||||
@@ -143,16 +129,14 @@ public class PetApiController extends Controller {
|
||||
String valueadditionalMetadata = (request().body().asMultipartFormData().asFormUrlEncoded().get("additionalMetadata"))[0];
|
||||
String additionalMetadata;
|
||||
if (valueadditionalMetadata != null) {
|
||||
additionalMetadata = (String)valueadditionalMetadata;
|
||||
additionalMetadata = valueadditionalMetadata;
|
||||
|
||||
} else {
|
||||
additionalMetadata = null;
|
||||
}
|
||||
Http.MultipartFormData.FilePart file = request().body().asMultipartFormData().getFile("file");
|
||||
ModelApiResponse obj = imp.uploadFile(petId, additionalMetadata, file);
|
||||
ModelApiResponse obj = imp.uploadFile(petId, additionalMetadata, file);
|
||||
JsonNode result = mapper.valueToTree(obj);
|
||||
return ok(result);
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,6 +10,7 @@ import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
|
||||
|
||||
@SuppressWarnings("RedundantThrows")
|
||||
public interface PetApiControllerImpInterface {
|
||||
void addPet(Pet body) throws Exception;
|
||||
|
||||
|
||||
@@ -12,7 +12,7 @@ import java.util.ArrayList;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
import com.google.inject.Inject;
|
||||
import java.io.IOException;
|
||||
import java.io.File;
|
||||
import swagger.SwaggerUtils;
|
||||
import com.fasterxml.jackson.core.type.TypeReference;
|
||||
|
||||
@@ -35,9 +35,7 @@ public class StoreApiController extends Controller {
|
||||
@ApiAction
|
||||
public Result deleteOrder(String orderId) throws Exception {
|
||||
imp.deleteOrder(orderId);
|
||||
|
||||
return ok();
|
||||
|
||||
}
|
||||
|
||||
@ApiAction
|
||||
@@ -45,8 +43,6 @@ public class StoreApiController extends Controller {
|
||||
Map<String, Integer> obj = imp.getInventory();
|
||||
JsonNode result = mapper.valueToTree(obj);
|
||||
return ok(result);
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ApiAction
|
||||
@@ -54,8 +50,6 @@ public class StoreApiController extends Controller {
|
||||
Order obj = imp.getOrderById(orderId);
|
||||
JsonNode result = mapper.valueToTree(obj);
|
||||
return ok(result);
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ApiAction
|
||||
@@ -68,7 +62,5 @@ public class StoreApiController extends Controller {
|
||||
Order obj = imp.placeOrder(body);
|
||||
JsonNode result = mapper.valueToTree(obj);
|
||||
return ok(result);
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,6 +9,7 @@ import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
|
||||
|
||||
@SuppressWarnings("RedundantThrows")
|
||||
public interface StoreApiControllerImpInterface {
|
||||
void deleteOrder(String orderId) throws Exception;
|
||||
|
||||
|
||||
@@ -12,7 +12,7 @@ import java.util.ArrayList;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
import com.google.inject.Inject;
|
||||
import java.io.IOException;
|
||||
import java.io.File;
|
||||
import swagger.SwaggerUtils;
|
||||
import com.fasterxml.jackson.core.type.TypeReference;
|
||||
|
||||
@@ -40,9 +40,7 @@ public class UserApiController extends Controller {
|
||||
body = mapper.readValue(nodebody.toString(), User.class);
|
||||
|
||||
imp.createUser(body);
|
||||
|
||||
return ok();
|
||||
|
||||
}
|
||||
|
||||
@ApiAction
|
||||
@@ -53,9 +51,7 @@ public class UserApiController extends Controller {
|
||||
body = mapper.readValue(nodebody.toString(), new TypeReference<List<User>>(){});
|
||||
|
||||
imp.createUsersWithArrayInput(body);
|
||||
|
||||
return ok();
|
||||
|
||||
}
|
||||
|
||||
@ApiAction
|
||||
@@ -66,17 +62,13 @@ public class UserApiController extends Controller {
|
||||
body = mapper.readValue(nodebody.toString(), new TypeReference<List<User>>(){});
|
||||
|
||||
imp.createUsersWithListInput(body);
|
||||
|
||||
return ok();
|
||||
|
||||
}
|
||||
|
||||
@ApiAction
|
||||
public Result deleteUser(String username) throws Exception {
|
||||
imp.deleteUser(username);
|
||||
|
||||
return ok();
|
||||
|
||||
}
|
||||
|
||||
@ApiAction
|
||||
@@ -84,8 +76,6 @@ public class UserApiController extends Controller {
|
||||
User obj = imp.getUserByName(username);
|
||||
JsonNode result = mapper.valueToTree(obj);
|
||||
return ok(result);
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ApiAction
|
||||
@@ -93,26 +83,22 @@ public class UserApiController extends Controller {
|
||||
String valueusername = request().getQueryString("username");
|
||||
String username;
|
||||
|
||||
username = (String)valueusername;
|
||||
username = valueusername;
|
||||
|
||||
String valuepassword = request().getQueryString("password");
|
||||
String password;
|
||||
|
||||
password = (String)valuepassword;
|
||||
password = valuepassword;
|
||||
|
||||
String obj = imp.loginUser(username, password);
|
||||
JsonNode result = mapper.valueToTree(obj);
|
||||
return ok(result);
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ApiAction
|
||||
public Result logoutUser() throws Exception {
|
||||
imp.logoutUser();
|
||||
|
||||
return ok();
|
||||
|
||||
}
|
||||
|
||||
@ApiAction
|
||||
@@ -123,8 +109,6 @@ public class UserApiController extends Controller {
|
||||
body = mapper.readValue(nodebody.toString(), User.class);
|
||||
|
||||
imp.updateUser(username, body);
|
||||
|
||||
return ok();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,6 +9,7 @@ import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
|
||||
|
||||
@SuppressWarnings("RedundantThrows")
|
||||
public interface UserApiControllerImpInterface {
|
||||
void createUser(User body) throws Exception;
|
||||
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
2017-08-08 12:59:36,779 [INFO] from play.api.Play in ForkJoinPool-1-worker-1 - Application started (Dev)
|
||||
Reference in New Issue
Block a user