[Java] Generate OAuth related files only if OAuth security schema is used (#1907)

* optionally include oauth files in java client

* fix java templates

* fix tests

* fix CI issues
This commit is contained in:
William Cheng
2019-01-28 11:05:37 +08:00
committed by GitHub
parent 9029103c94
commit 887b688014
15 changed files with 151 additions and 62 deletions

View File

@@ -95,14 +95,14 @@ public class ApiClient {
* @param username
* @param password
*/
public ApiClient(String authName, String clientId, String secret, String username, String password) {
this(authName);
this.getTokenEndPoint()
.setClientId(clientId)
.setClientSecret(secret)
.setUsername(username)
.setPassword(password);
}
public ApiClient(String authName, String clientId, String secret, String username, String password) {
this(authName);
this.getTokenEndPoint()
.setClientId(clientId)
.setClientSecret(secret)
.setUsername(username)
.setPassword(password);
}
public String getBasePath() {
return basePath;

View File

@@ -95,14 +95,14 @@ public class ApiClient {
* @param username
* @param password
*/
public ApiClient(String authName, String clientId, String secret, String username, String password) {
this(authName);
this.getTokenEndPoint()
.setClientId(clientId)
.setClientSecret(secret)
.setUsername(username)
.setPassword(password);
}
public ApiClient(String authName, String clientId, String secret, String username, String password) {
this(authName);
this.getTokenEndPoint()
.setClientId(clientId)
.setClientSecret(secret)
.setUsername(username)
.setPassword(password);
}
public String getBasePath() {
return basePath;

View File

@@ -38,7 +38,6 @@ import org.openapitools.client.auth.OAuth;
import org.openapitools.client.auth.OAuth.AccessTokenListener;
import org.openapitools.client.auth.OAuthFlow;
public class ApiClient {
private Map<String, Interceptor> apiAuthorizations;
@@ -116,21 +115,21 @@ public class ApiClient {
.setUsername(username)
.setPassword(password);
}
public void createDefaultAdapter() {
Gson gson = new GsonBuilder()
.setDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSZ")
.registerTypeAdapter(DateTime.class, new DateTimeTypeAdapter())
.registerTypeAdapter(LocalDate.class, new LocalDateTypeAdapter())
.create();
okClient = new OkHttpClient();
public void createDefaultAdapter() {
Gson gson = new GsonBuilder()
.setDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSZ")
.registerTypeAdapter(DateTime.class, new DateTimeTypeAdapter())
.registerTypeAdapter(LocalDate.class, new LocalDateTypeAdapter())
.create();
adapterBuilder = new RestAdapter
.Builder()
.setEndpoint("http://petstore.swagger.io:80/v2")
.setClient(new OkClient(okClient))
.setConverter(new GsonConverterWrapper(gson));
okClient = new OkHttpClient();
adapterBuilder = new RestAdapter
.Builder()
.setEndpoint("http://petstore.swagger.io:80/v2")
.setClient(new OkClient(okClient))
.setConverter(new GsonConverterWrapper(gson));
}
public <S> S createService(Class<S> serviceClass) {