mirror of
https://github.com/valitydev/openapi-generator.git
synced 2024-11-07 10:58:55 +00:00
updated to 1.2
This commit is contained in:
parent
a7bf8b6314
commit
01ff7be020
@ -6,7 +6,7 @@ import com.wordnik.petstore.model.Pet;
|
||||
import java.util.*;
|
||||
|
||||
public class PetApi {
|
||||
String basePath = "http://hello.com";
|
||||
String basePath = "http://petstore.swagger.wordnik.com/api";
|
||||
ApiInvoker apiInvoker = ApiInvoker.getInstance();
|
||||
|
||||
public ApiInvoker getInvoker() {
|
||||
@ -21,26 +21,24 @@ public class PetApi {
|
||||
return basePath;
|
||||
}
|
||||
|
||||
public List<Pet> findPetsByTags (String tags) throws ApiException {
|
||||
public Pet getPetById (String petId) throws ApiException {
|
||||
// create path and map variables
|
||||
String path = "/pet/findByTags".replaceAll("\\{format\\}","json");
|
||||
String path = "/pet/{petId}".replaceAll("\\{format\\}","json").replaceAll("\\{" + "petId" + "\\}", apiInvoker.escapeString(petId.toString()));
|
||||
|
||||
// query params
|
||||
Map<String, String> queryParams = new HashMap<String, String>();
|
||||
Map<String, String> headerParams = new HashMap<String, String>();
|
||||
|
||||
// verify required params are set
|
||||
if(tags == null ) {
|
||||
if(petId == null ) {
|
||||
throw new ApiException(400, "missing required params");
|
||||
}
|
||||
if(!"null".equals(String.valueOf(tags)))
|
||||
queryParams.put("tags", String.valueOf(tags));
|
||||
String contentType = "application/json";
|
||||
|
||||
try {
|
||||
String response = apiInvoker.invokeAPI(basePath, path, "GET", queryParams, null, headerParams, contentType);
|
||||
if(response != null){
|
||||
return (List<Pet>) ApiInvoker.deserialize(response, "List", Pet.class);
|
||||
return (Pet) ApiInvoker.deserialize(response, "", Pet.class);
|
||||
}
|
||||
else {
|
||||
return null;
|
||||
@ -54,55 +52,22 @@ public class PetApi {
|
||||
}
|
||||
}
|
||||
}
|
||||
public List<Pet> findPetsByStatus (String status) throws ApiException {
|
||||
public void deletePet (String petId) throws ApiException {
|
||||
// create path and map variables
|
||||
String path = "/pet/findByStatus".replaceAll("\\{format\\}","json");
|
||||
String path = "/pet/{petId}".replaceAll("\\{format\\}","json").replaceAll("\\{" + "petId" + "\\}", apiInvoker.escapeString(petId.toString()));
|
||||
|
||||
// query params
|
||||
Map<String, String> queryParams = new HashMap<String, String>();
|
||||
Map<String, String> headerParams = new HashMap<String, String>();
|
||||
|
||||
// verify required params are set
|
||||
if(status == null ) {
|
||||
throw new ApiException(400, "missing required params");
|
||||
}
|
||||
if(!"null".equals(String.valueOf(status)))
|
||||
queryParams.put("status", String.valueOf(status));
|
||||
String contentType = "application/json";
|
||||
|
||||
try {
|
||||
String response = apiInvoker.invokeAPI(basePath, path, "GET", queryParams, null, headerParams, contentType);
|
||||
if(response != null){
|
||||
return (List<Pet>) ApiInvoker.deserialize(response, "List", Pet.class);
|
||||
}
|
||||
else {
|
||||
return null;
|
||||
}
|
||||
} catch (ApiException ex) {
|
||||
if(ex.getCode() == 404) {
|
||||
return null;
|
||||
}
|
||||
else {
|
||||
throw ex;
|
||||
}
|
||||
}
|
||||
}
|
||||
public void updatePet (Pet body) throws ApiException {
|
||||
// create path and map variables
|
||||
String path = "/pet".replaceAll("\\{format\\}","json");
|
||||
|
||||
// query params
|
||||
Map<String, String> queryParams = new HashMap<String, String>();
|
||||
Map<String, String> headerParams = new HashMap<String, String>();
|
||||
|
||||
// verify required params are set
|
||||
if(body == null ) {
|
||||
if(petId == null ) {
|
||||
throw new ApiException(400, "missing required params");
|
||||
}
|
||||
String contentType = "application/json";
|
||||
|
||||
try {
|
||||
String response = apiInvoker.invokeAPI(basePath, path, "PUT", queryParams, body, headerParams, contentType);
|
||||
String response = apiInvoker.invokeAPI(basePath, path, "DELETE", queryParams, null, headerParams, contentType);
|
||||
if(response != null){
|
||||
return ;
|
||||
}
|
||||
@ -149,22 +114,22 @@ public class PetApi {
|
||||
}
|
||||
}
|
||||
}
|
||||
public void deletePet (String petId) throws ApiException {
|
||||
public void updatePet (Pet body) throws ApiException {
|
||||
// create path and map variables
|
||||
String path = "/pet/{petId}".replaceAll("\\{format\\}","json").replaceAll("\\{" + "petId" + "\\}", apiInvoker.escapeString(petId.toString()));
|
||||
String path = "/pet".replaceAll("\\{format\\}","json");
|
||||
|
||||
// query params
|
||||
Map<String, String> queryParams = new HashMap<String, String>();
|
||||
Map<String, String> headerParams = new HashMap<String, String>();
|
||||
|
||||
// verify required params are set
|
||||
if(petId == null ) {
|
||||
if(body == null ) {
|
||||
throw new ApiException(400, "missing required params");
|
||||
}
|
||||
String contentType = "application/json";
|
||||
|
||||
try {
|
||||
String response = apiInvoker.invokeAPI(basePath, path, "DELETE", queryParams, null, headerParams, contentType);
|
||||
String response = apiInvoker.invokeAPI(basePath, path, "PUT", queryParams, body, headerParams, contentType);
|
||||
if(response != null){
|
||||
return ;
|
||||
}
|
||||
@ -180,24 +145,59 @@ public class PetApi {
|
||||
}
|
||||
}
|
||||
}
|
||||
public Pet getPetById (String petId) throws ApiException {
|
||||
public List<Pet> findPetsByStatus (String status) throws ApiException {
|
||||
// create path and map variables
|
||||
String path = "/pet/{petId}".replaceAll("\\{format\\}","json").replaceAll("\\{" + "petId" + "\\}", apiInvoker.escapeString(petId.toString()));
|
||||
String path = "/pet/findByStatus".replaceAll("\\{format\\}","json");
|
||||
|
||||
// query params
|
||||
Map<String, String> queryParams = new HashMap<String, String>();
|
||||
Map<String, String> headerParams = new HashMap<String, String>();
|
||||
|
||||
// verify required params are set
|
||||
if(petId == null ) {
|
||||
if(status == null ) {
|
||||
throw new ApiException(400, "missing required params");
|
||||
}
|
||||
if(!"null".equals(String.valueOf(status)))
|
||||
queryParams.put("status", String.valueOf(status));
|
||||
String contentType = "application/json";
|
||||
|
||||
try {
|
||||
String response = apiInvoker.invokeAPI(basePath, path, "GET", queryParams, null, headerParams, contentType);
|
||||
if(response != null){
|
||||
return (Pet) ApiInvoker.deserialize(response, "", Pet.class);
|
||||
return (List<Pet>) ApiInvoker.deserialize(response, "array", Pet.class);
|
||||
}
|
||||
else {
|
||||
return null;
|
||||
}
|
||||
} catch (ApiException ex) {
|
||||
if(ex.getCode() == 404) {
|
||||
return null;
|
||||
}
|
||||
else {
|
||||
throw ex;
|
||||
}
|
||||
}
|
||||
}
|
||||
public List<Pet> findPetsByTags (String tags) throws ApiException {
|
||||
// create path and map variables
|
||||
String path = "/pet/findByTags".replaceAll("\\{format\\}","json");
|
||||
|
||||
// query params
|
||||
Map<String, String> queryParams = new HashMap<String, String>();
|
||||
Map<String, String> headerParams = new HashMap<String, String>();
|
||||
|
||||
// verify required params are set
|
||||
if(tags == null ) {
|
||||
throw new ApiException(400, "missing required params");
|
||||
}
|
||||
if(!"null".equals(String.valueOf(tags)))
|
||||
queryParams.put("tags", String.valueOf(tags));
|
||||
String contentType = "application/json";
|
||||
|
||||
try {
|
||||
String response = apiInvoker.invokeAPI(basePath, path, "GET", queryParams, null, headerParams, contentType);
|
||||
if(response != null){
|
||||
return (List<Pet>) ApiInvoker.deserialize(response, "array", Pet.class);
|
||||
}
|
||||
else {
|
||||
return null;
|
||||
|
@ -6,7 +6,7 @@ import com.wordnik.petstore.model.Order;
|
||||
import java.util.*;
|
||||
|
||||
public class StoreApi {
|
||||
String basePath = "http://hello.com";
|
||||
String basePath = "http://petstore.swagger.wordnik.com/api";
|
||||
ApiInvoker apiInvoker = ApiInvoker.getInstance();
|
||||
|
||||
public ApiInvoker getInvoker() {
|
||||
|
@ -6,7 +6,7 @@ import com.wordnik.petstore.model.User;
|
||||
import java.util.*;
|
||||
|
||||
public class UserApi {
|
||||
String basePath = "http://hello.com";
|
||||
String basePath = "http://petstore.swagger.wordnik.com/api";
|
||||
ApiInvoker apiInvoker = ApiInvoker.getInstance();
|
||||
|
||||
public ApiInvoker getInvoker() {
|
||||
|
@ -2,33 +2,12 @@ package com.wordnik.petstore.model;
|
||||
|
||||
import java.util.Date;
|
||||
public class Order {
|
||||
private Date shipDate = null;
|
||||
private Integer quantity = null;
|
||||
private Long petId = null;
|
||||
private Long id = null;
|
||||
/* Order Status */
|
||||
private String status = null;
|
||||
public Date getShipDate() {
|
||||
return shipDate;
|
||||
}
|
||||
public void setShipDate(Date shipDate) {
|
||||
this.shipDate = shipDate;
|
||||
}
|
||||
|
||||
public Integer getQuantity() {
|
||||
return quantity;
|
||||
}
|
||||
public void setQuantity(Integer quantity) {
|
||||
this.quantity = quantity;
|
||||
}
|
||||
|
||||
public Long getPetId() {
|
||||
return petId;
|
||||
}
|
||||
public void setPetId(Long petId) {
|
||||
this.petId = petId;
|
||||
}
|
||||
|
||||
private Long petId = null;
|
||||
private Integer quantity = null;
|
||||
private Date shipDate = null;
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
@ -43,15 +22,36 @@ public class Order {
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
public Long getPetId() {
|
||||
return petId;
|
||||
}
|
||||
public void setPetId(Long petId) {
|
||||
this.petId = petId;
|
||||
}
|
||||
|
||||
public Integer getQuantity() {
|
||||
return quantity;
|
||||
}
|
||||
public void setQuantity(Integer quantity) {
|
||||
this.quantity = quantity;
|
||||
}
|
||||
|
||||
public Date getShipDate() {
|
||||
return shipDate;
|
||||
}
|
||||
public void setShipDate(Date shipDate) {
|
||||
this.shipDate = shipDate;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append("class Order {\n");
|
||||
sb.append(" shipDate: ").append(shipDate).append("\n");
|
||||
sb.append(" quantity: ").append(quantity).append("\n");
|
||||
sb.append(" petId: ").append(petId).append("\n");
|
||||
sb.append(" id: ").append(id).append("\n");
|
||||
sb.append(" status: ").append(status).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("}\n");
|
||||
return sb.toString();
|
||||
}
|
||||
|
@ -5,11 +5,11 @@ import com.wordnik.petstore.model.Category;
|
||||
import com.wordnik.petstore.model.Tag;
|
||||
public class Pet {
|
||||
private String name = null;
|
||||
private List<Tag> tags = new ArrayList<Tag>();
|
||||
private List<String> photoUrls = new ArrayList<String>();
|
||||
private Long id = null;
|
||||
private List<Tag> tags = new ArrayList<Tag>();
|
||||
/* pet status in the store */
|
||||
private String status = null;
|
||||
private List<String> photoUrls = new ArrayList<String>();
|
||||
private Category category = null;
|
||||
public String getName() {
|
||||
return name;
|
||||
@ -18,20 +18,6 @@ public class Pet {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public List<Tag> getTags() {
|
||||
return tags;
|
||||
}
|
||||
public void setTags(List<Tag> tags) {
|
||||
this.tags = tags;
|
||||
}
|
||||
|
||||
public List<String> getPhotoUrls() {
|
||||
return photoUrls;
|
||||
}
|
||||
public void setPhotoUrls(List<String> photoUrls) {
|
||||
this.photoUrls = photoUrls;
|
||||
}
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
@ -39,6 +25,13 @@ public class Pet {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public List<Tag> getTags() {
|
||||
return tags;
|
||||
}
|
||||
public void setTags(List<Tag> tags) {
|
||||
this.tags = tags;
|
||||
}
|
||||
|
||||
public String getStatus() {
|
||||
return status;
|
||||
}
|
||||
@ -46,6 +39,13 @@ public class Pet {
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
public List<String> getPhotoUrls() {
|
||||
return photoUrls;
|
||||
}
|
||||
public void setPhotoUrls(List<String> photoUrls) {
|
||||
this.photoUrls = photoUrls;
|
||||
}
|
||||
|
||||
public Category getCategory() {
|
||||
return category;
|
||||
}
|
||||
@ -58,10 +58,10 @@ public class Pet {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append("class Pet {\n");
|
||||
sb.append(" name: ").append(name).append("\n");
|
||||
sb.append(" tags: ").append(tags).append("\n");
|
||||
sb.append(" photoUrls: ").append(photoUrls).append("\n");
|
||||
sb.append(" id: ").append(id).append("\n");
|
||||
sb.append(" tags: ").append(tags).append("\n");
|
||||
sb.append(" status: ").append(status).append("\n");
|
||||
sb.append(" photoUrls: ").append(photoUrls).append("\n");
|
||||
sb.append(" category: ").append(category).append("\n");
|
||||
sb.append("}\n");
|
||||
return sb.toString();
|
||||
|
@ -1,41 +1,20 @@
|
||||
package com.wordnik.petstore.model;
|
||||
|
||||
public class User {
|
||||
private String email = null;
|
||||
private Long id = null;
|
||||
private String firstName = null;
|
||||
private String username = null;
|
||||
private String lastName = null;
|
||||
private String email = null;
|
||||
private String password = null;
|
||||
private String phone = null;
|
||||
/* User Status */
|
||||
private Integer userStatus = null;
|
||||
private String lastName = null;
|
||||
private String firstName = null;
|
||||
private Long id = null;
|
||||
private String phone = null;
|
||||
private String password = null;
|
||||
public String getEmail() {
|
||||
return email;
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
public void setEmail(String email) {
|
||||
this.email = email;
|
||||
}
|
||||
|
||||
public String getUsername() {
|
||||
return username;
|
||||
}
|
||||
public void setUsername(String username) {
|
||||
this.username = username;
|
||||
}
|
||||
|
||||
public Integer getUserStatus() {
|
||||
return userStatus;
|
||||
}
|
||||
public void setUserStatus(Integer userStatus) {
|
||||
this.userStatus = userStatus;
|
||||
}
|
||||
|
||||
public String getLastName() {
|
||||
return lastName;
|
||||
}
|
||||
public void setLastName(String lastName) {
|
||||
this.lastName = lastName;
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getFirstName() {
|
||||
@ -45,18 +24,25 @@ public class User {
|
||||
this.firstName = firstName;
|
||||
}
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
public String getUsername() {
|
||||
return username;
|
||||
}
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
public void setUsername(String username) {
|
||||
this.username = username;
|
||||
}
|
||||
|
||||
public String getPhone() {
|
||||
return phone;
|
||||
public String getLastName() {
|
||||
return lastName;
|
||||
}
|
||||
public void setPhone(String phone) {
|
||||
this.phone = phone;
|
||||
public void setLastName(String lastName) {
|
||||
this.lastName = lastName;
|
||||
}
|
||||
|
||||
public String getEmail() {
|
||||
return email;
|
||||
}
|
||||
public void setEmail(String email) {
|
||||
this.email = email;
|
||||
}
|
||||
|
||||
public String getPassword() {
|
||||
@ -66,18 +52,32 @@ public class User {
|
||||
this.password = password;
|
||||
}
|
||||
|
||||
public String getPhone() {
|
||||
return phone;
|
||||
}
|
||||
public void setPhone(String phone) {
|
||||
this.phone = phone;
|
||||
}
|
||||
|
||||
public Integer getUserStatus() {
|
||||
return userStatus;
|
||||
}
|
||||
public void setUserStatus(Integer userStatus) {
|
||||
this.userStatus = userStatus;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append("class User {\n");
|
||||
sb.append(" email: ").append(email).append("\n");
|
||||
sb.append(" username: ").append(username).append("\n");
|
||||
sb.append(" userStatus: ").append(userStatus).append("\n");
|
||||
sb.append(" lastName: ").append(lastName).append("\n");
|
||||
sb.append(" firstName: ").append(firstName).append("\n");
|
||||
sb.append(" id: ").append(id).append("\n");
|
||||
sb.append(" phone: ").append(phone).append("\n");
|
||||
sb.append(" firstName: ").append(firstName).append("\n");
|
||||
sb.append(" username: ").append(username).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");
|
||||
return sb.toString();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user