forked from loafle/openapi-generator-original
fix templates for retrofit2rx and build.gradle
This commit is contained in:
parent
006092f453
commit
6788c89816
@ -13,7 +13,7 @@ import org.apache.oltu.oauth2.client.request.OAuthClientRequest.TokenRequestBuil
|
||||
import retrofit2.Converter;
|
||||
import retrofit2.Retrofit;
|
||||
import retrofit2.converter.gson.GsonConverterFactory;
|
||||
{{#useRxJava}}import retrofit2.RxJavaCallAdapterFactory;{{/useRxJava}}
|
||||
{{#useRxJava}}import retrofit2.adapter.rxjava.RxJavaCallAdapterFactory;{{/useRxJava}}
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.GsonBuilder;
|
||||
|
@ -92,7 +92,7 @@ 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"
|
||||
@ -113,7 +113,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"
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
package io.swagger.client;
|
||||
|
||||
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-02-25T10:57:20.452+01:00")
|
||||
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-02-25T16:20:24.158+01:00")
|
||||
public class StringUtil {
|
||||
/**
|
||||
* Check if the given array contains the given value (with case-insensitive comparison).
|
||||
|
@ -92,7 +92,7 @@ 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"
|
||||
@ -109,7 +109,6 @@ dependencies {
|
||||
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"
|
||||
|
||||
|
@ -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>
|
||||
|
@ -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");
|
||||
}
|
||||
@ -102,14 +102,14 @@ public class ApiClient {
|
||||
.setUsername(username)
|
||||
.setPassword(password);
|
||||
}
|
||||
|
||||
|
||||
public void createDefaultAdapter() {
|
||||
Gson gson = new GsonBuilder()
|
||||
.setDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSZ")
|
||||
.create();
|
||||
|
||||
okClient = new OkHttpClient();
|
||||
|
||||
|
||||
String baseUrl = "http://petstore.swagger.io/v2";
|
||||
if(!baseUrl.endsWith("/"))
|
||||
baseUrl = baseUrl + "/";
|
||||
@ -124,7 +124,7 @@ public class ApiClient {
|
||||
|
||||
public <S> S createService(Class<S> serviceClass) {
|
||||
return adapterBuilder.build().create(serviceClass);
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@ -202,7 +202,7 @@ public class ApiClient {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Helper method to configure the oauth accessCode/implicit flow parameters
|
||||
* @param clientId
|
||||
@ -224,7 +224,7 @@ public class ApiClient {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Configures a listener which is notified when a new access token is received.
|
||||
* @param accessTokenListener
|
||||
@ -271,7 +271,7 @@ public class ApiClient {
|
||||
public OkHttpClient getOkClient() {
|
||||
return okClient;
|
||||
}
|
||||
|
||||
|
||||
public void addAuthsToOkClient(OkHttpClient okClient) {
|
||||
for(Interceptor apiAuthorization : apiAuthorizations.values()) {
|
||||
okClient.interceptors().add(apiAuthorization);
|
||||
@ -307,14 +307,14 @@ class GsonResponseBodyConverterToString<T> implements Converter<ResponseBody, T>
|
||||
String returned = value.string();
|
||||
try {
|
||||
return gson.fromJson(returned, type);
|
||||
}
|
||||
}
|
||||
catch (JsonParseException e) {
|
||||
return (T) returned;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class GsonCustomConverterFactory extends Converter.Factory
|
||||
class GsonCustomConverterFactory extends Converter.Factory
|
||||
{
|
||||
public static GsonCustomConverterFactory create(Gson gson) {
|
||||
return new GsonCustomConverterFactory(gson);
|
||||
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -4,18 +4,18 @@ import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
public class CollectionFormats {
|
||||
|
||||
|
||||
public static class CSVParams {
|
||||
|
||||
protected List<String> params;
|
||||
|
||||
|
||||
public CSVParams() {
|
||||
}
|
||||
|
||||
|
||||
public CSVParams(List<String> params) {
|
||||
this.params = params;
|
||||
}
|
||||
|
||||
|
||||
public CSVParams(String... params) {
|
||||
this.params = Arrays.asList(params);
|
||||
}
|
||||
@ -27,19 +27,19 @@ public class CollectionFormats {
|
||||
public void setParams(List<String> params) {
|
||||
this.params = params;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return StringUtil.join(params.toArray(new String[0]), ",");
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
public static class SSVParams extends CSVParams {
|
||||
|
||||
|
||||
public SSVParams() {
|
||||
}
|
||||
|
||||
|
||||
public SSVParams(List<String> params) {
|
||||
super(params);
|
||||
}
|
||||
@ -53,16 +53,16 @@ public class CollectionFormats {
|
||||
return StringUtil.join(params.toArray(new String[0]), " ");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static class TSVParams extends CSVParams {
|
||||
|
||||
|
||||
public TSVParams() {
|
||||
}
|
||||
|
||||
|
||||
public TSVParams(List<String> params) {
|
||||
super(params);
|
||||
}
|
||||
|
||||
|
||||
public TSVParams(String... params) {
|
||||
super(params);
|
||||
}
|
||||
@ -72,16 +72,16 @@ public class CollectionFormats {
|
||||
return StringUtil.join( params.toArray(new String[0]), "\t");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static class PIPESParams extends CSVParams {
|
||||
|
||||
|
||||
public PIPESParams() {
|
||||
}
|
||||
|
||||
|
||||
public PIPESParams(List<String> params) {
|
||||
super(params);
|
||||
}
|
||||
|
||||
|
||||
public PIPESParams(String... params) {
|
||||
super(params);
|
||||
}
|
||||
@ -91,5 +91,5 @@ public class CollectionFormats {
|
||||
return StringUtil.join(params.toArray(new String[0]), "|");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -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-25T16:58:59.076+01:00")
|
||||
public class StringUtil {
|
||||
/**
|
||||
* Check if the given array contains the given value (with case-insensitive comparison).
|
||||
|
Loading…
x
Reference in New Issue
Block a user