forked from loafle/openapi-generator-original
update retrofit2 samples
This commit is contained in:
parent
69d956f16b
commit
fc1d06d810
@ -1,6 +1,6 @@
|
||||
package io.swagger.client;
|
||||
|
||||
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-28T16:12:35.075+08:00")
|
||||
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-05-17T10:01:17.552+02:00")
|
||||
public class StringUtil {
|
||||
/**
|
||||
* Check if the given array contains the given value (with case-insensitive comparison).
|
||||
|
@ -18,8 +18,8 @@ import java.util.Map;
|
||||
|
||||
public interface FakeApi {
|
||||
/**
|
||||
* Fake endpoint for testing various parameters
|
||||
* Fake endpoint for testing various parameters
|
||||
* Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트
|
||||
* Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트
|
||||
* @param number None (required)
|
||||
* @param _double None (required)
|
||||
* @param string None (required)
|
||||
|
@ -1,6 +1,7 @@
|
||||
package io.swagger.client.auth;
|
||||
|
||||
import static java.net.HttpURLConnection.HTTP_UNAUTHORIZED;
|
||||
import static java.net.HttpURLConnection.HTTP_FORBIDDEN;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Map;
|
||||
@ -85,12 +86,13 @@ public class OAuth implements Interceptor {
|
||||
updateAccessToken(null);
|
||||
}
|
||||
|
||||
if (getAccessToken() != null) {
|
||||
// Build the request
|
||||
Builder rb = request.newBuilder();
|
||||
|
||||
String requestAccessToken = new String(getAccessToken());
|
||||
try {
|
||||
oAuthRequest = new OAuthBearerClientRequest(request.url().toString())
|
||||
oAuthRequest = new OAuthBearerClientRequest(request.urlString())
|
||||
.setAccessToken(requestAccessToken)
|
||||
.buildHeaderMessage();
|
||||
} catch (OAuthSystemException e) {
|
||||
@ -107,27 +109,40 @@ public class OAuth implements Interceptor {
|
||||
|
||||
// 401 most likely indicates that access token has expired.
|
||||
// Time to refresh and resend the request
|
||||
if ( response.code() == HTTP_UNAUTHORIZED ) {
|
||||
updateAccessToken(requestAccessToken);
|
||||
if ( response != null && (response.code() == HTTP_UNAUTHORIZED | response.code() == HTTP_FORBIDDEN) ) {
|
||||
if (updateAccessToken(requestAccessToken)) {
|
||||
return intercept( chain );
|
||||
}
|
||||
}
|
||||
return response;
|
||||
} else {
|
||||
return chain.proceed(chain.request());
|
||||
}
|
||||
}
|
||||
|
||||
public synchronized void updateAccessToken(String requestAccessToken) throws IOException {
|
||||
/*
|
||||
* Returns true if the access token has been updated
|
||||
*/
|
||||
public synchronized boolean updateAccessToken(String requestAccessToken) throws IOException {
|
||||
if (getAccessToken() == null || getAccessToken().equals(requestAccessToken)) {
|
||||
try {
|
||||
OAuthJSONAccessTokenResponse accessTokenResponse = oauthClient.accessToken(this.tokenRequestBuilder.buildBodyMessage());
|
||||
if (accessTokenResponse != null && accessTokenResponse.getAccessToken() != null) {
|
||||
setAccessToken(accessTokenResponse.getAccessToken());
|
||||
if (accessTokenListener != null) {
|
||||
accessTokenListener.notify((BasicOAuthToken) accessTokenResponse.getOAuthToken());
|
||||
}
|
||||
return getAccessToken().equals(requestAccessToken);
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
} catch (OAuthSystemException e) {
|
||||
throw new IOException(e);
|
||||
} catch (OAuthProblemException e) {
|
||||
throw new IOException(e);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public void registerAccessTokenListener(AccessTokenListener accessTokenListener) {
|
||||
|
@ -15,6 +15,9 @@ public class Animal {
|
||||
@SerializedName("className")
|
||||
private String className = null;
|
||||
|
||||
@SerializedName("color")
|
||||
private String color = "red";
|
||||
|
||||
/**
|
||||
**/
|
||||
@ApiModelProperty(required = true, value = "")
|
||||
@ -25,6 +28,16 @@ public class Animal {
|
||||
this.className = className;
|
||||
}
|
||||
|
||||
/**
|
||||
**/
|
||||
@ApiModelProperty(value = "")
|
||||
public String getColor() {
|
||||
return color;
|
||||
}
|
||||
public void setColor(String color) {
|
||||
this.color = color;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
@ -35,12 +48,13 @@ public class Animal {
|
||||
return false;
|
||||
}
|
||||
Animal animal = (Animal) o;
|
||||
return Objects.equals(className, animal.className);
|
||||
return Objects.equals(className, animal.className) &&
|
||||
Objects.equals(color, animal.color);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(className);
|
||||
return Objects.hash(className, color);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -49,6 +63,7 @@ public class Animal {
|
||||
sb.append("class Animal {\n");
|
||||
|
||||
sb.append(" className: ").append(toIndentedString(className)).append("\n");
|
||||
sb.append(" color: ").append(toIndentedString(color)).append("\n");
|
||||
sb.append("}");
|
||||
return sb.toString();
|
||||
}
|
||||
|
@ -16,6 +16,9 @@ public class Cat extends Animal {
|
||||
@SerializedName("className")
|
||||
private String className = null;
|
||||
|
||||
@SerializedName("color")
|
||||
private String color = "red";
|
||||
|
||||
@SerializedName("declawed")
|
||||
private Boolean declawed = null;
|
||||
|
||||
@ -29,6 +32,16 @@ public class Cat extends Animal {
|
||||
this.className = className;
|
||||
}
|
||||
|
||||
/**
|
||||
**/
|
||||
@ApiModelProperty(value = "")
|
||||
public String getColor() {
|
||||
return color;
|
||||
}
|
||||
public void setColor(String color) {
|
||||
this.color = color;
|
||||
}
|
||||
|
||||
/**
|
||||
**/
|
||||
@ApiModelProperty(value = "")
|
||||
@ -50,12 +63,13 @@ public class Cat extends Animal {
|
||||
}
|
||||
Cat cat = (Cat) o;
|
||||
return Objects.equals(className, cat.className) &&
|
||||
Objects.equals(color, cat.color) &&
|
||||
Objects.equals(declawed, cat.declawed);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(className, declawed);
|
||||
return Objects.hash(className, color, declawed);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -64,6 +78,7 @@ public class Cat extends Animal {
|
||||
sb.append("class Cat {\n");
|
||||
sb.append(" ").append(toIndentedString(super.toString())).append("\n");
|
||||
sb.append(" className: ").append(toIndentedString(className)).append("\n");
|
||||
sb.append(" color: ").append(toIndentedString(color)).append("\n");
|
||||
sb.append(" declawed: ").append(toIndentedString(declawed)).append("\n");
|
||||
sb.append("}");
|
||||
return sb.toString();
|
||||
|
@ -16,6 +16,9 @@ public class Dog extends Animal {
|
||||
@SerializedName("className")
|
||||
private String className = null;
|
||||
|
||||
@SerializedName("color")
|
||||
private String color = "red";
|
||||
|
||||
@SerializedName("breed")
|
||||
private String breed = null;
|
||||
|
||||
@ -29,6 +32,16 @@ public class Dog extends Animal {
|
||||
this.className = className;
|
||||
}
|
||||
|
||||
/**
|
||||
**/
|
||||
@ApiModelProperty(value = "")
|
||||
public String getColor() {
|
||||
return color;
|
||||
}
|
||||
public void setColor(String color) {
|
||||
this.color = color;
|
||||
}
|
||||
|
||||
/**
|
||||
**/
|
||||
@ApiModelProperty(value = "")
|
||||
@ -50,12 +63,13 @@ public class Dog extends Animal {
|
||||
}
|
||||
Dog dog = (Dog) o;
|
||||
return Objects.equals(className, dog.className) &&
|
||||
Objects.equals(color, dog.color) &&
|
||||
Objects.equals(breed, dog.breed);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(className, breed);
|
||||
return Objects.hash(className, color, breed);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -64,6 +78,7 @@ public class Dog extends Animal {
|
||||
sb.append("class Dog {\n");
|
||||
sb.append(" ").append(toIndentedString(super.toString())).append("\n");
|
||||
sb.append(" className: ").append(toIndentedString(className)).append("\n");
|
||||
sb.append(" color: ").append(toIndentedString(color)).append("\n");
|
||||
sb.append(" breed: ").append(toIndentedString(breed)).append("\n");
|
||||
sb.append("}");
|
||||
return sb.toString();
|
||||
|
@ -24,6 +24,9 @@ public class Name {
|
||||
@SerializedName("property")
|
||||
private String property = null;
|
||||
|
||||
@SerializedName("123Number")
|
||||
private Integer _123Number = null;
|
||||
|
||||
/**
|
||||
**/
|
||||
@ApiModelProperty(required = true, value = "")
|
||||
@ -51,6 +54,13 @@ public class Name {
|
||||
this.property = property;
|
||||
}
|
||||
|
||||
/**
|
||||
**/
|
||||
@ApiModelProperty(value = "")
|
||||
public Integer get123Number() {
|
||||
return _123Number;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
@ -63,12 +73,13 @@ public class Name {
|
||||
Name name = (Name) o;
|
||||
return Objects.equals(name, name.name) &&
|
||||
Objects.equals(snakeCase, name.snakeCase) &&
|
||||
Objects.equals(property, name.property);
|
||||
Objects.equals(property, name.property) &&
|
||||
Objects.equals(_123Number, name._123Number);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(name, snakeCase, property);
|
||||
return Objects.hash(name, snakeCase, property, _123Number);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -79,6 +90,7 @@ public class Name {
|
||||
sb.append(" name: ").append(toIndentedString(name)).append("\n");
|
||||
sb.append(" snakeCase: ").append(toIndentedString(snakeCase)).append("\n");
|
||||
sb.append(" property: ").append(toIndentedString(property)).append("\n");
|
||||
sb.append(" _123Number: ").append(toIndentedString(_123Number)).append("\n");
|
||||
sb.append("}");
|
||||
return sb.toString();
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
package io.swagger.client;
|
||||
|
||||
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-04-28T23:45:14.234+08:00")
|
||||
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-05-17T10:23:52.848+02:00")
|
||||
public class StringUtil {
|
||||
/**
|
||||
* Check if the given array contains the given value (with case-insensitive comparison).
|
||||
|
@ -8,8 +8,8 @@ import retrofit2.http.*;
|
||||
|
||||
import okhttp3.RequestBody;
|
||||
|
||||
import java.util.Date;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Date;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
@ -18,8 +18,8 @@ import java.util.Map;
|
||||
|
||||
public interface FakeApi {
|
||||
/**
|
||||
* Fake endpoint for testing various parameters
|
||||
* Fake endpoint for testing various parameters
|
||||
* Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트
|
||||
* Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트
|
||||
* @param number None (required)
|
||||
* @param _double None (required)
|
||||
* @param string None (required)
|
||||
|
@ -9,8 +9,8 @@ import retrofit2.http.*;
|
||||
import okhttp3.RequestBody;
|
||||
|
||||
import io.swagger.client.model.Pet;
|
||||
import java.io.File;
|
||||
import io.swagger.client.model.ModelApiResponse;
|
||||
import java.io.File;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
|
@ -1,6 +1,7 @@
|
||||
package io.swagger.client.auth;
|
||||
|
||||
import static java.net.HttpURLConnection.HTTP_UNAUTHORIZED;
|
||||
import static java.net.HttpURLConnection.HTTP_FORBIDDEN;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Map;
|
||||
@ -85,12 +86,13 @@ public class OAuth implements Interceptor {
|
||||
updateAccessToken(null);
|
||||
}
|
||||
|
||||
if (getAccessToken() != null) {
|
||||
// Build the request
|
||||
Builder rb = request.newBuilder();
|
||||
|
||||
String requestAccessToken = new String(getAccessToken());
|
||||
try {
|
||||
oAuthRequest = new OAuthBearerClientRequest(request.url().toString())
|
||||
oAuthRequest = new OAuthBearerClientRequest(request.urlString())
|
||||
.setAccessToken(requestAccessToken)
|
||||
.buildHeaderMessage();
|
||||
} catch (OAuthSystemException e) {
|
||||
@ -107,27 +109,40 @@ public class OAuth implements Interceptor {
|
||||
|
||||
// 401 most likely indicates that access token has expired.
|
||||
// Time to refresh and resend the request
|
||||
if ( response.code() == HTTP_UNAUTHORIZED ) {
|
||||
updateAccessToken(requestAccessToken);
|
||||
if ( response != null && (response.code() == HTTP_UNAUTHORIZED | response.code() == HTTP_FORBIDDEN) ) {
|
||||
if (updateAccessToken(requestAccessToken)) {
|
||||
return intercept( chain );
|
||||
}
|
||||
}
|
||||
return response;
|
||||
} else {
|
||||
return chain.proceed(chain.request());
|
||||
}
|
||||
}
|
||||
|
||||
public synchronized void updateAccessToken(String requestAccessToken) throws IOException {
|
||||
/*
|
||||
* Returns true if the access token has been updated
|
||||
*/
|
||||
public synchronized boolean updateAccessToken(String requestAccessToken) throws IOException {
|
||||
if (getAccessToken() == null || getAccessToken().equals(requestAccessToken)) {
|
||||
try {
|
||||
OAuthJSONAccessTokenResponse accessTokenResponse = oauthClient.accessToken(this.tokenRequestBuilder.buildBodyMessage());
|
||||
if (accessTokenResponse != null && accessTokenResponse.getAccessToken() != null) {
|
||||
setAccessToken(accessTokenResponse.getAccessToken());
|
||||
if (accessTokenListener != null) {
|
||||
accessTokenListener.notify((BasicOAuthToken) accessTokenResponse.getOAuthToken());
|
||||
}
|
||||
return getAccessToken().equals(requestAccessToken);
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
} catch (OAuthSystemException e) {
|
||||
throw new IOException(e);
|
||||
} catch (OAuthProblemException e) {
|
||||
throw new IOException(e);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public void registerAccessTokenListener(AccessTokenListener accessTokenListener) {
|
||||
|
@ -15,6 +15,9 @@ public class Animal {
|
||||
@SerializedName("className")
|
||||
private String className = null;
|
||||
|
||||
@SerializedName("color")
|
||||
private String color = "red";
|
||||
|
||||
/**
|
||||
**/
|
||||
@ApiModelProperty(required = true, value = "")
|
||||
@ -25,6 +28,16 @@ public class Animal {
|
||||
this.className = className;
|
||||
}
|
||||
|
||||
/**
|
||||
**/
|
||||
@ApiModelProperty(value = "")
|
||||
public String getColor() {
|
||||
return color;
|
||||
}
|
||||
public void setColor(String color) {
|
||||
this.color = color;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
@ -35,12 +48,13 @@ public class Animal {
|
||||
return false;
|
||||
}
|
||||
Animal animal = (Animal) o;
|
||||
return Objects.equals(className, animal.className);
|
||||
return Objects.equals(className, animal.className) &&
|
||||
Objects.equals(color, animal.color);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(className);
|
||||
return Objects.hash(className, color);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -49,6 +63,7 @@ public class Animal {
|
||||
sb.append("class Animal {\n");
|
||||
|
||||
sb.append(" className: ").append(toIndentedString(className)).append("\n");
|
||||
sb.append(" color: ").append(toIndentedString(color)).append("\n");
|
||||
sb.append("}");
|
||||
return sb.toString();
|
||||
}
|
||||
|
@ -16,6 +16,9 @@ public class Cat extends Animal {
|
||||
@SerializedName("className")
|
||||
private String className = null;
|
||||
|
||||
@SerializedName("color")
|
||||
private String color = "red";
|
||||
|
||||
@SerializedName("declawed")
|
||||
private Boolean declawed = null;
|
||||
|
||||
@ -29,6 +32,16 @@ public class Cat extends Animal {
|
||||
this.className = className;
|
||||
}
|
||||
|
||||
/**
|
||||
**/
|
||||
@ApiModelProperty(value = "")
|
||||
public String getColor() {
|
||||
return color;
|
||||
}
|
||||
public void setColor(String color) {
|
||||
this.color = color;
|
||||
}
|
||||
|
||||
/**
|
||||
**/
|
||||
@ApiModelProperty(value = "")
|
||||
@ -50,12 +63,13 @@ public class Cat extends Animal {
|
||||
}
|
||||
Cat cat = (Cat) o;
|
||||
return Objects.equals(className, cat.className) &&
|
||||
Objects.equals(color, cat.color) &&
|
||||
Objects.equals(declawed, cat.declawed);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(className, declawed);
|
||||
return Objects.hash(className, color, declawed);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -64,6 +78,7 @@ public class Cat extends Animal {
|
||||
sb.append("class Cat {\n");
|
||||
sb.append(" ").append(toIndentedString(super.toString())).append("\n");
|
||||
sb.append(" className: ").append(toIndentedString(className)).append("\n");
|
||||
sb.append(" color: ").append(toIndentedString(color)).append("\n");
|
||||
sb.append(" declawed: ").append(toIndentedString(declawed)).append("\n");
|
||||
sb.append("}");
|
||||
return sb.toString();
|
||||
|
@ -16,6 +16,9 @@ public class Dog extends Animal {
|
||||
@SerializedName("className")
|
||||
private String className = null;
|
||||
|
||||
@SerializedName("color")
|
||||
private String color = "red";
|
||||
|
||||
@SerializedName("breed")
|
||||
private String breed = null;
|
||||
|
||||
@ -29,6 +32,16 @@ public class Dog extends Animal {
|
||||
this.className = className;
|
||||
}
|
||||
|
||||
/**
|
||||
**/
|
||||
@ApiModelProperty(value = "")
|
||||
public String getColor() {
|
||||
return color;
|
||||
}
|
||||
public void setColor(String color) {
|
||||
this.color = color;
|
||||
}
|
||||
|
||||
/**
|
||||
**/
|
||||
@ApiModelProperty(value = "")
|
||||
@ -50,12 +63,13 @@ public class Dog extends Animal {
|
||||
}
|
||||
Dog dog = (Dog) o;
|
||||
return Objects.equals(className, dog.className) &&
|
||||
Objects.equals(color, dog.color) &&
|
||||
Objects.equals(breed, dog.breed);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(className, breed);
|
||||
return Objects.hash(className, color, breed);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -64,6 +78,7 @@ public class Dog extends Animal {
|
||||
sb.append("class Dog {\n");
|
||||
sb.append(" ").append(toIndentedString(super.toString())).append("\n");
|
||||
sb.append(" className: ").append(toIndentedString(className)).append("\n");
|
||||
sb.append(" color: ").append(toIndentedString(color)).append("\n");
|
||||
sb.append(" breed: ").append(toIndentedString(breed)).append("\n");
|
||||
sb.append("}");
|
||||
return sb.toString();
|
||||
|
@ -24,6 +24,9 @@ public class Name {
|
||||
@SerializedName("property")
|
||||
private String property = null;
|
||||
|
||||
@SerializedName("123Number")
|
||||
private Integer _123Number = null;
|
||||
|
||||
/**
|
||||
**/
|
||||
@ApiModelProperty(required = true, value = "")
|
||||
@ -51,6 +54,13 @@ public class Name {
|
||||
this.property = property;
|
||||
}
|
||||
|
||||
/**
|
||||
**/
|
||||
@ApiModelProperty(value = "")
|
||||
public Integer get123Number() {
|
||||
return _123Number;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
@ -63,12 +73,13 @@ public class Name {
|
||||
Name name = (Name) o;
|
||||
return Objects.equals(name, name.name) &&
|
||||
Objects.equals(snakeCase, name.snakeCase) &&
|
||||
Objects.equals(property, name.property);
|
||||
Objects.equals(property, name.property) &&
|
||||
Objects.equals(_123Number, name._123Number);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(name, snakeCase, property);
|
||||
return Objects.hash(name, snakeCase, property, _123Number);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -79,6 +90,7 @@ public class Name {
|
||||
sb.append(" name: ").append(toIndentedString(name)).append("\n");
|
||||
sb.append(" snakeCase: ").append(toIndentedString(snakeCase)).append("\n");
|
||||
sb.append(" property: ").append(toIndentedString(property)).append("\n");
|
||||
sb.append(" _123Number: ").append(toIndentedString(_123Number)).append("\n");
|
||||
sb.append("}");
|
||||
return sb.toString();
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user