mirror of
https://github.com/jlengrand/openapi-generator.git
synced 2026-05-17 00:21:19 +00:00
Java and Android template changes to accommodate query params defined by the collection-format.
This commit is contained in:
@@ -1,6 +1,9 @@
|
||||
package {{invokerPackage}}.auth;
|
||||
|
||||
import {{invokerPackage}}.QueryParam;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
public class ApiKeyAuth implements Authentication {
|
||||
private final String location;
|
||||
@@ -39,7 +42,7 @@ public class ApiKeyAuth implements Authentication {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void applyToParams(Map<String, String> queryParams, Map<String, String> headerParams) {
|
||||
public void applyToParams(Set<QueryParam> queryParams, Map<String, String> headerParams) {
|
||||
String value;
|
||||
if (apiKeyPrefix != null) {
|
||||
value = apiKeyPrefix + " " + apiKey;
|
||||
@@ -47,7 +50,7 @@ public class ApiKeyAuth implements Authentication {
|
||||
value = apiKey;
|
||||
}
|
||||
if (location == "query") {
|
||||
queryParams.put(paramName, value);
|
||||
queryParams.add(new QueryParam(paramName, value));
|
||||
} else if (location == "header") {
|
||||
headerParams.put(paramName, value);
|
||||
}
|
||||
|
||||
@@ -1,8 +1,11 @@
|
||||
package {{invokerPackage}}.auth;
|
||||
|
||||
import {{invokerPackage}}.QueryParam;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
public interface Authentication {
|
||||
/** Apply authentication settings to header and query params. */
|
||||
void applyToParams(Map<String, String> queryParams, Map<String, String> headerParams);
|
||||
void applyToParams(Set<QueryParam> queryParams, Map<String, String> headerParams);
|
||||
}
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
package {{invokerPackage}}.auth;
|
||||
|
||||
import {{invokerPackage}}.QueryParam;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import javax.xml.bind.DatatypeConverter;
|
||||
@@ -26,7 +29,7 @@ public class HttpBasicAuth implements Authentication {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void applyToParams(Map<String, String> queryParams, Map<String, String> headerParams) {
|
||||
public void applyToParams(Set<QueryParam> queryParams, Map<String, String> headerParams) {
|
||||
String str = (username == null ? "" : username) + ":" + (password == null ? "" : password);
|
||||
try {
|
||||
headerParams.put("Authorization", "Basic " + DatatypeConverter.printBase64Binary(str.getBytes("UTF-8")));
|
||||
|
||||
@@ -1,10 +1,13 @@
|
||||
package {{invokerPackage}}.auth;
|
||||
|
||||
import {{invokerPackage}}.QueryParam;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
public class OAuth implements Authentication {
|
||||
@Override
|
||||
public void applyToParams(Map<String, String> queryParams, Map<String, String> headerParams) {
|
||||
public void applyToParams(Set<QueryParam> queryParams, Map<String, String> headerParams) {
|
||||
// TODO: support oauth
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user