forked from loafle/openapi-generator-original
fix build.gradle template for retrofit2
This commit is contained in:
parent
6788c89816
commit
0fe8f7e375
@ -90,7 +90,6 @@ if(hasProperty('target') && target == 'android') {
|
|||||||
}
|
}
|
||||||
|
|
||||||
ext {
|
ext {
|
||||||
okhttp_version = "3.0.1"
|
|
||||||
oltu_version = "1.0.0"
|
oltu_version = "1.0.0"
|
||||||
retrofit_version = "2.0.0-beta4"
|
retrofit_version = "2.0.0-beta4"
|
||||||
gson_version = "2.4"
|
gson_version = "2.4"
|
||||||
@ -103,8 +102,6 @@ ext {
|
|||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
compile "com.squareup.okhttp3:okhttp:$okhttp_version"
|
|
||||||
|
|
||||||
compile "com.squareup.retrofit2:retrofit:$retrofit_version"
|
compile "com.squareup.retrofit2:retrofit:$retrofit_version"
|
||||||
compile "com.squareup.retrofit2:converter-gson:$retrofit_version"
|
compile "com.squareup.retrofit2:converter-gson:$retrofit_version"
|
||||||
{{#useRxJava}}
|
{{#useRxJava}}
|
||||||
|
@ -90,9 +90,8 @@ if(hasProperty('target') && target == 'android') {
|
|||||||
}
|
}
|
||||||
|
|
||||||
ext {
|
ext {
|
||||||
okhttp_version = "3.0.1"
|
|
||||||
oltu_version = "1.0.0"
|
oltu_version = "1.0.0"
|
||||||
retrofit_version = "2.0.0-beta3"
|
retrofit_version = "2.0.0-beta4"
|
||||||
gson_version = "2.4"
|
gson_version = "2.4"
|
||||||
swagger_annotations_version = "1.5.0"
|
swagger_annotations_version = "1.5.0"
|
||||||
junit_version = "4.12"
|
junit_version = "4.12"
|
||||||
@ -100,13 +99,10 @@ ext {
|
|||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
compile "com.squareup.okhttp3:okhttp:$okhttp_version"
|
|
||||||
|
|
||||||
compile "com.squareup.retrofit2:retrofit:$retrofit_version"
|
compile "com.squareup.retrofit2:retrofit:$retrofit_version"
|
||||||
compile "com.squareup.retrofit2:converter-gson:$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 "io.swagger:swagger-annotations:$swagger_annotations_version"
|
||||||
compile "org.apache.oltu.oauth2:org.apache.oltu.oauth2.client:$oltu_version"
|
compile "org.apache.oltu.oauth2:org.apache.oltu.oauth2.client:$oltu_version"
|
||||||
|
|
||||||
|
@ -102,14 +102,14 @@ public class ApiClient {
|
|||||||
.setUsername(username)
|
.setUsername(username)
|
||||||
.setPassword(password);
|
.setPassword(password);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void createDefaultAdapter() {
|
public void createDefaultAdapter() {
|
||||||
Gson gson = new GsonBuilder()
|
Gson gson = new GsonBuilder()
|
||||||
.setDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSZ")
|
.setDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSZ")
|
||||||
.create();
|
.create();
|
||||||
|
|
||||||
okClient = new OkHttpClient();
|
okClient = new OkHttpClient();
|
||||||
|
|
||||||
String baseUrl = "http://petstore.swagger.io/v2";
|
String baseUrl = "http://petstore.swagger.io/v2";
|
||||||
if(!baseUrl.endsWith("/"))
|
if(!baseUrl.endsWith("/"))
|
||||||
baseUrl = baseUrl + "/";
|
baseUrl = baseUrl + "/";
|
||||||
@ -124,7 +124,7 @@ public class ApiClient {
|
|||||||
|
|
||||||
public <S> S createService(Class<S> serviceClass) {
|
public <S> S createService(Class<S> serviceClass) {
|
||||||
return adapterBuilder.build().create(serviceClass);
|
return adapterBuilder.build().create(serviceClass);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -202,7 +202,7 @@ public class ApiClient {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Helper method to configure the oauth accessCode/implicit flow parameters
|
* Helper method to configure the oauth accessCode/implicit flow parameters
|
||||||
* @param clientId
|
* @param clientId
|
||||||
@ -224,7 +224,7 @@ public class ApiClient {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Configures a listener which is notified when a new access token is received.
|
* Configures a listener which is notified when a new access token is received.
|
||||||
* @param accessTokenListener
|
* @param accessTokenListener
|
||||||
@ -271,7 +271,7 @@ public class ApiClient {
|
|||||||
public OkHttpClient getOkClient() {
|
public OkHttpClient getOkClient() {
|
||||||
return okClient;
|
return okClient;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addAuthsToOkClient(OkHttpClient okClient) {
|
public void addAuthsToOkClient(OkHttpClient okClient) {
|
||||||
for(Interceptor apiAuthorization : apiAuthorizations.values()) {
|
for(Interceptor apiAuthorization : apiAuthorizations.values()) {
|
||||||
okClient.interceptors().add(apiAuthorization);
|
okClient.interceptors().add(apiAuthorization);
|
||||||
@ -307,14 +307,14 @@ class GsonResponseBodyConverterToString<T> implements Converter<ResponseBody, T>
|
|||||||
String returned = value.string();
|
String returned = value.string();
|
||||||
try {
|
try {
|
||||||
return gson.fromJson(returned, type);
|
return gson.fromJson(returned, type);
|
||||||
}
|
}
|
||||||
catch (JsonParseException e) {
|
catch (JsonParseException e) {
|
||||||
return (T) returned;
|
return (T) returned;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class GsonCustomConverterFactory extends Converter.Factory
|
class GsonCustomConverterFactory extends Converter.Factory
|
||||||
{
|
{
|
||||||
public static GsonCustomConverterFactory create(Gson gson) {
|
public static GsonCustomConverterFactory create(Gson gson) {
|
||||||
return new GsonCustomConverterFactory(gson);
|
return new GsonCustomConverterFactory(gson);
|
||||||
|
@ -4,18 +4,18 @@ import java.util.Arrays;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class CollectionFormats {
|
public class CollectionFormats {
|
||||||
|
|
||||||
public static class CSVParams {
|
public static class CSVParams {
|
||||||
|
|
||||||
protected List<String> params;
|
protected List<String> params;
|
||||||
|
|
||||||
public CSVParams() {
|
public CSVParams() {
|
||||||
}
|
}
|
||||||
|
|
||||||
public CSVParams(List<String> params) {
|
public CSVParams(List<String> params) {
|
||||||
this.params = params;
|
this.params = params;
|
||||||
}
|
}
|
||||||
|
|
||||||
public CSVParams(String... params) {
|
public CSVParams(String... params) {
|
||||||
this.params = Arrays.asList(params);
|
this.params = Arrays.asList(params);
|
||||||
}
|
}
|
||||||
@ -27,19 +27,19 @@ public class CollectionFormats {
|
|||||||
public void setParams(List<String> params) {
|
public void setParams(List<String> params) {
|
||||||
this.params = params;
|
this.params = params;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return StringUtil.join(params.toArray(new String[0]), ",");
|
return StringUtil.join(params.toArray(new String[0]), ",");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class SSVParams extends CSVParams {
|
public static class SSVParams extends CSVParams {
|
||||||
|
|
||||||
public SSVParams() {
|
public SSVParams() {
|
||||||
}
|
}
|
||||||
|
|
||||||
public SSVParams(List<String> params) {
|
public SSVParams(List<String> params) {
|
||||||
super(params);
|
super(params);
|
||||||
}
|
}
|
||||||
@ -53,16 +53,16 @@ public class CollectionFormats {
|
|||||||
return StringUtil.join(params.toArray(new String[0]), " ");
|
return StringUtil.join(params.toArray(new String[0]), " ");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class TSVParams extends CSVParams {
|
public static class TSVParams extends CSVParams {
|
||||||
|
|
||||||
public TSVParams() {
|
public TSVParams() {
|
||||||
}
|
}
|
||||||
|
|
||||||
public TSVParams(List<String> params) {
|
public TSVParams(List<String> params) {
|
||||||
super(params);
|
super(params);
|
||||||
}
|
}
|
||||||
|
|
||||||
public TSVParams(String... params) {
|
public TSVParams(String... params) {
|
||||||
super(params);
|
super(params);
|
||||||
}
|
}
|
||||||
@ -72,16 +72,16 @@ public class CollectionFormats {
|
|||||||
return StringUtil.join( params.toArray(new String[0]), "\t");
|
return StringUtil.join( params.toArray(new String[0]), "\t");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class PIPESParams extends CSVParams {
|
public static class PIPESParams extends CSVParams {
|
||||||
|
|
||||||
public PIPESParams() {
|
public PIPESParams() {
|
||||||
}
|
}
|
||||||
|
|
||||||
public PIPESParams(List<String> params) {
|
public PIPESParams(List<String> params) {
|
||||||
super(params);
|
super(params);
|
||||||
}
|
}
|
||||||
|
|
||||||
public PIPESParams(String... params) {
|
public PIPESParams(String... params) {
|
||||||
super(params);
|
super(params);
|
||||||
}
|
}
|
||||||
@ -91,5 +91,5 @@ public class CollectionFormats {
|
|||||||
return StringUtil.join(params.toArray(new String[0]), "|");
|
return StringUtil.join(params.toArray(new String[0]), "|");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
package io.swagger.client;
|
package io.swagger.client;
|
||||||
|
|
||||||
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-02-25T16:20:24.158+01:00")
|
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-02-26T13:30:07.836+01:00")
|
||||||
public class StringUtil {
|
public class StringUtil {
|
||||||
/**
|
/**
|
||||||
* Check if the given array contains the given value (with case-insensitive comparison).
|
* Check if the given array contains the given value (with case-insensitive comparison).
|
||||||
|
@ -90,7 +90,6 @@ if(hasProperty('target') && target == 'android') {
|
|||||||
}
|
}
|
||||||
|
|
||||||
ext {
|
ext {
|
||||||
okhttp_version = "3.0.1"
|
|
||||||
oltu_version = "1.0.0"
|
oltu_version = "1.0.0"
|
||||||
retrofit_version = "2.0.0-beta4"
|
retrofit_version = "2.0.0-beta4"
|
||||||
gson_version = "2.4"
|
gson_version = "2.4"
|
||||||
@ -101,8 +100,6 @@ ext {
|
|||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
compile "com.squareup.okhttp3:okhttp:$okhttp_version"
|
|
||||||
|
|
||||||
compile "com.squareup.retrofit2:retrofit:$retrofit_version"
|
compile "com.squareup.retrofit2:retrofit:$retrofit_version"
|
||||||
compile "com.squareup.retrofit2:converter-gson:$retrofit_version"
|
compile "com.squareup.retrofit2:converter-gson:$retrofit_version"
|
||||||
compile "com.squareup.retrofit2:adapter-rxjava:$retrofit_version"
|
compile "com.squareup.retrofit2:adapter-rxjava:$retrofit_version"
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
package io.swagger.client;
|
package io.swagger.client;
|
||||||
|
|
||||||
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-02-25T16:58:59.076+01:00")
|
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-02-26T13:30:13.630+01:00")
|
||||||
public class StringUtil {
|
public class StringUtil {
|
||||||
/**
|
/**
|
||||||
* Check if the given array contains the given value (with case-insensitive comparison).
|
* Check if the given array contains the given value (with case-insensitive comparison).
|
||||||
|
Loading…
x
Reference in New Issue
Block a user