Merge pull request #2149 from dhontecillas/master

support latest Retrofit 2 v2.0.0-beta4
This commit is contained in:
wing328 2016-02-29 18:05:14 +08:00
commit d665903b3f
15 changed files with 107 additions and 144 deletions

View File

@ -102,7 +102,7 @@ public class JavaClientCodegen extends DefaultCodegen implements CodegenConfig {
supportedLibraries.put("jersey2", "HTTP client: Jersey client 2.6");
supportedLibraries.put("okhttp-gson", "HTTP client: OkHttp 2.4.0. JSON processing: Gson 2.3.1");
supportedLibraries.put(RETROFIT_1, "HTTP client: OkHttp 2.4.0. JSON processing: Gson 2.3.1 (Retrofit 1.9.0)");
supportedLibraries.put(RETROFIT_2, "HTTP client: OkHttp 2.5.0. JSON processing: Gson 2.4 (Retrofit 2.0.0-beta2). Enable the RxJava adapter using '-DuseRxJava=true'.");
supportedLibraries.put(RETROFIT_2, "HTTP client: OkHttp 2.5.0. JSON processing: Gson 2.4 (Retrofit 2.0.0-beta4). Enable the RxJava adapter using '-DuseRxJava=true'.");
CliOption library = new CliOption(CodegenConstants.LIBRARY, "library template (sub-template) to use");
library.setDefault(DEFAULT_LIBRARY);

View File

@ -12,8 +12,8 @@ import org.apache.oltu.oauth2.client.request.OAuthClientRequest.TokenRequestBuil
import retrofit2.Converter;
import retrofit2.Retrofit;
import retrofit2.GsonConverterFactory;
{{#useRxJava}}import retrofit2.RxJavaCallAdapterFactory;{{/useRxJava}}
import retrofit2.converter.gson.GsonConverterFactory;
{{#useRxJava}}import retrofit2.adapter.rxjava.RxJavaCallAdapterFactory;{{/useRxJava}}
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
@ -339,8 +339,8 @@ class GsonCustomConverterFactory extends Converter.Factory
}
@Override
public Converter<?, RequestBody> requestBodyConverter(Type type, Annotation[] annotations, Retrofit retrofit) {
return gsonConverterFactory.requestBodyConverter(type, annotations, retrofit);
public Converter<?, RequestBody> requestBodyConverter(Type type, Annotation[] parameterAnnotations, Annotation[] methodAnnotations, Retrofit retrofit) {
return gsonConverterFactory.requestBodyConverter(type, parameterAnnotations, methodAnnotations, retrofit);
}
}

View File

@ -90,9 +90,8 @@ if(hasProperty('target') && target == 'android') {
}
ext {
okhttp_version = "3.0.1"
oltu_version = "1.0.0"
retrofit_version = "2.0.0-beta3"
retrofit_version = "2.0.0-beta4"
gson_version = "2.4"
swagger_annotations_version = "1.5.0"
junit_version = "4.12"
@ -103,8 +102,6 @@ ext {
}
dependencies {
compile "com.squareup.okhttp3:okhttp:$okhttp_version"
compile "com.squareup.retrofit2:retrofit:$retrofit_version"
compile "com.squareup.retrofit2:converter-gson:$retrofit_version"
{{#useRxJava}}
@ -113,7 +110,6 @@ dependencies {
{{/useRxJava}}
{{^useRxJava}}{{/useRxJava}}
compile "com.google.code.gson:gson:$gson_version"
compile "io.swagger:swagger-annotations:$swagger_annotations_version"
compile "org.apache.oltu.oauth2:org.apache.oltu.oauth2.client:$oltu_version"

View File

@ -161,7 +161,7 @@
</dependencies>
<properties>
<swagger-annotations-version>1.5.0</swagger-annotations-version>
<retrofit-version>2.0.0-beta3</retrofit-version>
<retrofit-version>2.0.0-beta4</retrofit-version>
{{#useRxJava}}<rxjava-version>1.0.16</rxjava-version>{{/useRxJava}}
<okhttp-version>3.0.1</okhttp-version>
<gson-version>2.4</gson-version>

View File

@ -90,9 +90,8 @@ if(hasProperty('target') && target == 'android') {
}
ext {
okhttp_version = "3.0.1"
oltu_version = "1.0.0"
retrofit_version = "2.0.0-beta3"
retrofit_version = "2.0.0-beta4"
gson_version = "2.4"
swagger_annotations_version = "1.5.0"
junit_version = "4.12"
@ -100,13 +99,10 @@ ext {
}
dependencies {
compile "com.squareup.okhttp3:okhttp:$okhttp_version"
compile "com.squareup.retrofit2:retrofit:$retrofit_version"
compile "com.squareup.retrofit2:converter-gson:$retrofit_version"
compile "com.google.code.gson:gson:$gson_version"
compile "io.swagger:swagger-annotations:$swagger_annotations_version"
compile "org.apache.oltu.oauth2:org.apache.oltu.oauth2.client:$oltu_version"

View File

@ -123,21 +123,11 @@
<artifactId>converter-gson</artifactId>
<version>${retrofit-version}</version>
</dependency>
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>${gson-version}</version>
</dependency>
<dependency>
<groupId>org.apache.oltu.oauth2</groupId>
<artifactId>org.apache.oltu.oauth2.client</artifactId>
<version>${oltu-version}</version>
</dependency>
<dependency>
<groupId>com.squareup.okhttp3</groupId>
<artifactId>okhttp</artifactId>
<version>${okhttp-version}</version>
</dependency>
<!-- test dependencies -->
@ -150,10 +140,7 @@
</dependencies>
<properties>
<swagger-annotations-version>1.5.0</swagger-annotations-version>
<retrofit-version>2.0.0-beta3</retrofit-version>
<okhttp-version>3.0.1</okhttp-version>
<gson-version>2.4</gson-version>
<retrofit-version>2.0.0-beta4</retrofit-version>
<oltu-version>1.0.0</oltu-version>
<maven-plugin-version>1.0.0</maven-plugin-version>
<junit-version>4.12</junit-version>

View File

@ -12,7 +12,7 @@ import org.apache.oltu.oauth2.client.request.OAuthClientRequest.TokenRequestBuil
import retrofit2.Converter;
import retrofit2.Retrofit;
import retrofit2.GsonConverterFactory;
import retrofit2.converter.gson.GsonConverterFactory;
import com.google.gson.Gson;
@ -46,10 +46,10 @@ public class ApiClient {
this();
for(String authName : authNames) {
Interceptor auth;
if (authName == "petstore_auth") {
auth = new OAuth(OAuthFlow.implicit, "http://petstore.swagger.io/api/oauth/dialog", "", "write:pets, read:pets");
} else if (authName == "api_key") {
if (authName == "api_key") {
auth = new ApiKeyAuth("header", "api_key");
} else if (authName == "petstore_auth") {
auth = new OAuth(OAuthFlow.implicit, "http://petstore.swagger.io/api/oauth/dialog", "", "write:pets, read:pets");
} else {
throw new RuntimeException("auth name \"" + authName + "\" not found in available auth names");
}
@ -338,8 +338,8 @@ class GsonCustomConverterFactory extends Converter.Factory
}
@Override
public Converter<?, RequestBody> requestBodyConverter(Type type, Annotation[] annotations, Retrofit retrofit) {
return gsonConverterFactory.requestBodyConverter(type, annotations, retrofit);
public Converter<?, RequestBody> requestBodyConverter(Type type, Annotation[] parameterAnnotations, Annotation[] methodAnnotations, Retrofit retrofit) {
return gsonConverterFactory.requestBodyConverter(type, parameterAnnotations, methodAnnotations, retrofit);
}
}

View File

@ -1,6 +1,6 @@
package io.swagger.client;
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-02-02T15:33:05.826+01:00")
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-02-26T13:30:07.836+01:00")
public class StringUtil {
/**
* Check if the given array contains the given value (with case-insensitive comparison).

View File

@ -90,9 +90,8 @@ if(hasProperty('target') && target == 'android') {
}
ext {
okhttp_version = "3.0.1"
oltu_version = "1.0.0"
retrofit_version = "2.0.0-beta3"
retrofit_version = "2.0.0-beta4"
gson_version = "2.4"
swagger_annotations_version = "1.5.0"
junit_version = "4.12"
@ -101,15 +100,12 @@ ext {
}
dependencies {
compile "com.squareup.okhttp3:okhttp:$okhttp_version"
compile "com.squareup.retrofit2:retrofit:$retrofit_version"
compile "com.squareup.retrofit2:converter-gson:$retrofit_version"
compile "com.squareup.retrofit2:adapter-rxjava:$retrofit_version"
compile "io.reactivex:rxjava:$rx_java_version"
compile "com.google.code.gson:gson:$gson_version"
compile "io.swagger:swagger-annotations:$swagger_annotations_version"
compile "org.apache.oltu.oauth2:org.apache.oltu.oauth2.client:$oltu_version"

View File

@ -123,21 +123,11 @@
<artifactId>converter-gson</artifactId>
<version>${retrofit-version}</version>
</dependency>
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>${gson-version}</version>
</dependency>
<dependency>
<groupId>org.apache.oltu.oauth2</groupId>
<artifactId>org.apache.oltu.oauth2.client</artifactId>
<version>${oltu-version}</version>
</dependency>
<dependency>
<groupId>com.squareup.okhttp3</groupId>
<artifactId>okhttp</artifactId>
<version>${okhttp-version}</version>
</dependency>
<dependency>
<groupId>io.reactivex</groupId>
@ -161,10 +151,8 @@
</dependencies>
<properties>
<swagger-annotations-version>1.5.0</swagger-annotations-version>
<retrofit-version>2.0.0-beta3</retrofit-version>
<retrofit-version>2.0.0-beta4</retrofit-version>
<rxjava-version>1.0.16</rxjava-version>
<okhttp-version>3.0.1</okhttp-version>
<gson-version>2.4</gson-version>
<oltu-version>1.0.0</oltu-version>
<maven-plugin-version>1.0.0</maven-plugin-version>
<junit-version>4.12</junit-version>

View File

@ -12,8 +12,8 @@ import org.apache.oltu.oauth2.client.request.OAuthClientRequest.TokenRequestBuil
import retrofit2.Converter;
import retrofit2.Retrofit;
import retrofit2.GsonConverterFactory;
import retrofit2.RxJavaCallAdapterFactory;
import retrofit2.converter.gson.GsonConverterFactory;
import retrofit2.adapter.rxjava.RxJavaCallAdapterFactory;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
@ -46,10 +46,10 @@ public class ApiClient {
this();
for(String authName : authNames) {
Interceptor auth;
if (authName == "petstore_auth") {
auth = new OAuth(OAuthFlow.implicit, "http://petstore.swagger.io/api/oauth/dialog", "", "write:pets, read:pets");
} else if (authName == "api_key") {
if (authName == "api_key") {
auth = new ApiKeyAuth("header", "api_key");
} else if (authName == "petstore_auth") {
auth = new OAuth(OAuthFlow.implicit, "http://petstore.swagger.io/api/oauth/dialog", "", "write:pets, read:pets");
} else {
throw new RuntimeException("auth name \"" + authName + "\" not found in available auth names");
}
@ -338,8 +338,8 @@ class GsonCustomConverterFactory extends Converter.Factory
}
@Override
public Converter<?, RequestBody> requestBodyConverter(Type type, Annotation[] annotations, Retrofit retrofit) {
return gsonConverterFactory.requestBodyConverter(type, annotations, retrofit);
public Converter<?, RequestBody> requestBodyConverter(Type type, Annotation[] parameterAnnotations, Annotation[] methodAnnotations, Retrofit retrofit) {
return gsonConverterFactory.requestBodyConverter(type, parameterAnnotations, methodAnnotations, retrofit);
}
}

View File

@ -1,6 +1,6 @@
package io.swagger.client;
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-02-02T15:33:07.490+01:00")
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-02-26T13:30:13.630+01:00")
public class StringUtil {
/**
* Check if the given array contains the given value (with case-insensitive comparison).