[Java] Support cookie-based security schemas in Java clients (#4155)

* Adding cookie support and cookie-based AuthKeys to Java clients

* Fix indentation

* Revert accidental change

* Updating samples

* Fixing tests and regenerating samples
This commit is contained in:
atsharp 2019-10-19 05:05:02 -05:00 committed by William Cheng
parent ab0b3d9795
commit d75d089bc9
221 changed files with 2555 additions and 799 deletions

View File

@ -15,33 +15,57 @@ public class ApiKeyAuthTest {
public void testApplyToParamsInQuery() { public void testApplyToParamsInQuery() {
List<Pair> queryParams = new ArrayList<Pair>(); List<Pair> queryParams = new ArrayList<Pair>();
Map<String, String> headerParams = new HashMap<String, String>(); Map<String, String> headerParams = new HashMap<String, String>();
Map<String, String> cookieParams = new HashMap<String, String>();
ApiKeyAuth auth = new ApiKeyAuth("query", "api_key"); ApiKeyAuth auth = new ApiKeyAuth("query", "api_key");
auth.setApiKey("my-api-key"); auth.setApiKey("my-api-key");
auth.applyToParams(queryParams, headerParams); auth.applyToParams(queryParams, headerParams, cookieParams);
assertEquals(1, queryParams.size()); assertEquals(1, queryParams.size());
for (Pair queryParam : queryParams) { for (Pair queryParam : queryParams) {
assertEquals("my-api-key", queryParam.getValue()); assertEquals("my-api-key", queryParam.getValue());
} }
// no changes to header parameters // no changes to header or cookie parameters
assertEquals(0, headerParams.size()); assertEquals(0, headerParams.size());
assertEquals(0, cookieParams.size());
} }
@Test @Test
public void testApplyToParamsInHeaderWithPrefix() { public void testApplyToParamsInHeaderWithPrefix() {
List<Pair> queryParams = new ArrayList<Pair>(); List<Pair> queryParams = new ArrayList<Pair>();
Map<String, String> headerParams = new HashMap<String, String>(); Map<String, String> headerParams = new HashMap<String, String>();
Map<String, String> cookieParams = new HashMap<String, String>();
ApiKeyAuth auth = new ApiKeyAuth("header", "X-API-TOKEN"); ApiKeyAuth auth = new ApiKeyAuth("header", "X-API-TOKEN");
auth.setApiKey("my-api-token"); auth.setApiKey("my-api-token");
auth.setApiKeyPrefix("Token"); auth.setApiKeyPrefix("Token");
auth.applyToParams(queryParams, headerParams); auth.applyToParams(queryParams, headerParams, cookieParams);
// no changes to query parameters // no changes to query or cookie parameters
assertEquals(0, queryParams.size()); assertEquals(0, queryParams.size());
assertEquals(0, cookieParams.size());
assertEquals(1, headerParams.size()); assertEquals(1, headerParams.size());
assertEquals("Token my-api-token", headerParams.get("X-API-TOKEN")); assertEquals("Token my-api-token", headerParams.get("X-API-TOKEN"));
} }
@Test
public void testApplyToParamsInCookieWithPrefix() {
List<Pair> queryParams = new ArrayList<Pair>();
Map<String, String> headerParams = new HashMap<String, String>();
Map<String, String> cookieParams = new HashMap<String, String>();
ApiKeyAuth auth = new ApiKeyAuth("cookie", "X-API-TOKEN");
auth.setApiKey("my-api-token");
auth.setApiKeyPrefix("Token");
auth.applyToParams(queryParams, headerParams, cookieParams);
// no changes to query or header parameters
assertEquals(0, queryParams.size());
assertEquals(0, headerParams.size());
assertEquals(1, cookieParams.size());
assertEquals("Token my-api-token", cookieParams.get("X-API-TOKEN"));
}
} }

View File

@ -22,13 +22,15 @@ public class HttpBasicAuthTest {
public void testApplyToParams() { public void testApplyToParams() {
List<Pair> queryParams = new ArrayList<Pair>(); List<Pair> queryParams = new ArrayList<Pair>();
Map<String, String> headerParams = new HashMap<String, String>(); Map<String, String> headerParams = new HashMap<String, String>();
Map<String, String> cookieParams = new HashMap<String, String>();
auth.setUsername("my-username"); auth.setUsername("my-username");
auth.setPassword("my-password"); auth.setPassword("my-password");
auth.applyToParams(queryParams, headerParams); auth.applyToParams(queryParams, headerParams, cookieParams);
// no changes to query parameters // no changes to query or cookie parameters
assertEquals(0, queryParams.size()); assertEquals(0, queryParams.size());
assertEquals(0, cookieParams.size());
assertEquals(1, headerParams.size()); assertEquals(1, headerParams.size());
// the string below is base64-encoded result of "my-username:my-password" with the "Basic " prefix // the string below is base64-encoded result of "my-username:my-password" with the "Basic " prefix
String expected = "Basic bXktdXNlcm5hbWU6bXktcGFzc3dvcmQ="; String expected = "Basic bXktdXNlcm5hbWU6bXktcGFzc3dvcmQ=";
@ -36,7 +38,7 @@ public class HttpBasicAuthTest {
// null username should be treated as empty string // null username should be treated as empty string
auth.setUsername(null); auth.setUsername(null);
auth.applyToParams(queryParams, headerParams); auth.applyToParams(queryParams, headerParams, cookieParams);
// the string below is base64-encoded result of ":my-password" with the "Basic " prefix // the string below is base64-encoded result of ":my-password" with the "Basic " prefix
expected = "Basic Om15LXBhc3N3b3Jk"; expected = "Basic Om15LXBhc3N3b3Jk";
assertEquals(expected, headerParams.get("Authorization")); assertEquals(expected, headerParams.get("Authorization"));
@ -44,7 +46,7 @@ public class HttpBasicAuthTest {
// null password should be treated as empty string // null password should be treated as empty string
auth.setUsername("my-username"); auth.setUsername("my-username");
auth.setPassword(null); auth.setPassword(null);
auth.applyToParams(queryParams, headerParams); auth.applyToParams(queryParams, headerParams, cookieParams);
// the string below is base64-encoded result of "my-username:" with the "Basic " prefix // the string below is base64-encoded result of "my-username:" with the "Basic " prefix
expected = "Basic bXktdXNlcm5hbWU6"; expected = "Basic bXktdXNlcm5hbWU6";
assertEquals(expected, headerParams.get("Authorization")); assertEquals(expected, headerParams.get("Authorization"));

View File

@ -15,33 +15,55 @@ public class ApiKeyAuthTest {
public void testApplyToParamsInQuery() { public void testApplyToParamsInQuery() {
List<Pair> queryParams = new ArrayList<Pair>(); List<Pair> queryParams = new ArrayList<Pair>();
Map<String, String> headerParams = new HashMap<String, String>(); Map<String, String> headerParams = new HashMap<String, String>();
Map<String, String> cookieParams = new HashMap<String, String>();
ApiKeyAuth auth = new ApiKeyAuth("query", "api_key"); ApiKeyAuth auth = new ApiKeyAuth("query", "api_key");
auth.setApiKey("my-api-key"); auth.setApiKey("my-api-key");
auth.applyToParams(queryParams, headerParams); auth.applyToParams(queryParams, headerParams, cookieParams);
assertEquals(1, queryParams.size()); assertEquals(1, queryParams.size());
for (Pair queryParam : queryParams) { for (Pair queryParam : queryParams) {
assertEquals("my-api-key", queryParam.getValue()); assertEquals("my-api-key", queryParam.getValue());
} }
// no changes to header parameters // no changes to header or cookie parameters
assertEquals(0, headerParams.size()); assertEquals(0, headerParams.size());
assertEquals(0, cookieParams.size());
} }
@Test @Test
public void testApplyToParamsInHeaderWithPrefix() { public void testApplyToParamsInHeaderWithPrefix() {
List<Pair> queryParams = new ArrayList<Pair>(); List<Pair> queryParams = new ArrayList<Pair>();
Map<String, String> headerParams = new HashMap<String, String>(); Map<String, String> headerParams = new HashMap<String, String>();
Map<String, String> cookieParams = new HashMap<String, String>();
ApiKeyAuth auth = new ApiKeyAuth("header", "X-API-TOKEN"); ApiKeyAuth auth = new ApiKeyAuth("header", "X-API-TOKEN");
auth.setApiKey("my-api-token"); auth.setApiKey("my-api-token");
auth.setApiKeyPrefix("Token"); auth.setApiKeyPrefix("Token");
auth.applyToParams(queryParams, headerParams); auth.applyToParams(queryParams, headerParams, cookieParams);
// no changes to query parameters // no changes to query parameters
assertEquals(0, queryParams.size()); assertEquals(0, queryParams.size());
assertEquals(0, cookieParams.size());
assertEquals(1, headerParams.size()); assertEquals(1, headerParams.size());
assertEquals("Token my-api-token", headerParams.get("X-API-TOKEN")); assertEquals("Token my-api-token", headerParams.get("X-API-TOKEN"));
} }
@Test
public void testApplyToParamsInCookieWithPrefix() {
List<Pair> queryParams = new ArrayList<Pair>();
Map<String, String> headerParams = new HashMap<String, String>();
Map<String, String> cookieParams = new HashMap<String, String>();
ApiKeyAuth auth = new ApiKeyAuth("cookie", "X-API-TOKEN");
auth.setApiKey("my-api-token");
auth.setApiKeyPrefix("Token");
auth.applyToParams(queryParams, headerParams, cookieParams);
// no changes to query or header parameters
assertEquals(0, queryParams.size());
assertEquals(0, headerParams.size());
assertEquals(1, cookieParams.size());
assertEquals("Token my-api-token", cookieParams.get("X-API-TOKEN"));
}
} }

View File

@ -22,10 +22,11 @@ public class HttpBasicAuthTest {
public void testApplyToParams() { public void testApplyToParams() {
List<Pair> queryParams = new ArrayList<Pair>(); List<Pair> queryParams = new ArrayList<Pair>();
Map<String, String> headerParams = new HashMap<String, String>(); Map<String, String> headerParams = new HashMap<String, String>();
Map<String, String> cookieParams = new HashMap<String, String>();
auth.setUsername("my-username"); auth.setUsername("my-username");
auth.setPassword("my-password"); auth.setPassword("my-password");
auth.applyToParams(queryParams, headerParams); auth.applyToParams(queryParams, headerParams, cookieParams);
// no changes to query parameters // no changes to query parameters
assertEquals(0, queryParams.size()); assertEquals(0, queryParams.size());
@ -36,7 +37,7 @@ public class HttpBasicAuthTest {
// null username should be treated as empty string // null username should be treated as empty string
auth.setUsername(null); auth.setUsername(null);
auth.applyToParams(queryParams, headerParams); auth.applyToParams(queryParams, headerParams, cookieParams);
// the string below is base64-encoded result of ":my-password" with the "Basic " prefix // the string below is base64-encoded result of ":my-password" with the "Basic " prefix
expected = "Basic Om15LXBhc3N3b3Jk"; expected = "Basic Om15LXBhc3N3b3Jk";
assertEquals(expected, headerParams.get("Authorization")); assertEquals(expected, headerParams.get("Authorization"));
@ -44,7 +45,7 @@ public class HttpBasicAuthTest {
// null password should be treated as empty string // null password should be treated as empty string
auth.setUsername("my-username"); auth.setUsername("my-username");
auth.setPassword(null); auth.setPassword(null);
auth.applyToParams(queryParams, headerParams); auth.applyToParams(queryParams, headerParams, cookieParams);
// the string below is base64-encoded result of "my-username:" with the "Basic " prefix // the string below is base64-encoded result of "my-username:" with the "Basic " prefix
expected = "Basic bXktdXNlcm5hbWU6"; expected = "Basic bXktdXNlcm5hbWU6";
assertEquals(expected, headerParams.get("Authorization")); assertEquals(expected, headerParams.get("Authorization"));

View File

@ -15,46 +15,52 @@ public class ApiKeyAuthTest {
public void testApplyToParamsInQuery() { public void testApplyToParamsInQuery() {
List<Pair> queryParams = new ArrayList<Pair>(); List<Pair> queryParams = new ArrayList<Pair>();
Map<String, String> headerParams = new HashMap<String, String>(); Map<String, String> headerParams = new HashMap<String, String>();
Map<String, String> cookieParams = new HashMap<String, String>();
ApiKeyAuth auth = new ApiKeyAuth("query", "api_key"); ApiKeyAuth auth = new ApiKeyAuth("query", "api_key");
auth.setApiKey("my-api-key"); auth.setApiKey("my-api-key");
auth.applyToParams(queryParams, headerParams); auth.applyToParams(queryParams, headerParams, cookieParams);
assertEquals(1, queryParams.size()); assertEquals(1, queryParams.size());
for (Pair queryParam : queryParams) { for (Pair queryParam : queryParams) {
assertEquals("my-api-key", queryParam.getValue()); assertEquals("my-api-key", queryParam.getValue());
} }
// no changes to header parameters // no changes to header or cookie parameters
assertEquals(0, headerParams.size()); assertEquals(0, headerParams.size());
assertEquals(0, cookieParams.size());
} }
@Test @Test
public void testApplyToParamsInQueryWithNullValue() { public void testApplyToParamsInQueryWithNullValue() {
List<Pair> queryParams = new ArrayList<Pair>(); List<Pair> queryParams = new ArrayList<Pair>();
Map<String, String> headerParams = new HashMap<String, String>(); Map<String, String> headerParams = new HashMap<String, String>();
Map<String, String> cookieParams = new HashMap<String, String>();
ApiKeyAuth auth = new ApiKeyAuth("query", "api_key"); ApiKeyAuth auth = new ApiKeyAuth("query", "api_key");
auth.setApiKey(null); auth.setApiKey(null);
auth.applyToParams(queryParams, headerParams); auth.applyToParams(queryParams, headerParams, cookieParams);
// no changes to parameters // no changes to parameters
assertEquals(0, queryParams.size()); assertEquals(0, queryParams.size());
assertEquals(0, headerParams.size()); assertEquals(0, headerParams.size());
assertEquals(0, cookieParams.size());
} }
@Test @Test
public void testApplyToParamsInHeaderWithPrefix() { public void testApplyToParamsInHeaderWithPrefix() {
List<Pair> queryParams = new ArrayList<Pair>(); List<Pair> queryParams = new ArrayList<Pair>();
Map<String, String> headerParams = new HashMap<String, String>(); Map<String, String> headerParams = new HashMap<String, String>();
Map<String, String> cookieParams = new HashMap<String, String>();
ApiKeyAuth auth = new ApiKeyAuth("header", "X-API-TOKEN"); ApiKeyAuth auth = new ApiKeyAuth("header", "X-API-TOKEN");
auth.setApiKey("my-api-token"); auth.setApiKey("my-api-token");
auth.setApiKeyPrefix("Token"); auth.setApiKeyPrefix("Token");
auth.applyToParams(queryParams, headerParams); auth.applyToParams(queryParams, headerParams, cookieParams);
// no changes to query parameters // no changes to query or cookie parameters
assertEquals(0, queryParams.size()); assertEquals(0, queryParams.size());
assertEquals(0, cookieParams.size());
assertEquals(1, headerParams.size()); assertEquals(1, headerParams.size());
assertEquals("Token my-api-token", headerParams.get("X-API-TOKEN")); assertEquals("Token my-api-token", headerParams.get("X-API-TOKEN"));
} }
@ -63,14 +69,51 @@ public class ApiKeyAuthTest {
public void testApplyToParamsInHeaderWithNullValue() { public void testApplyToParamsInHeaderWithNullValue() {
List<Pair> queryParams = new ArrayList<Pair>(); List<Pair> queryParams = new ArrayList<Pair>();
Map<String, String> headerParams = new HashMap<String, String>(); Map<String, String> headerParams = new HashMap<String, String>();
Map<String, String> cookieParams = new HashMap<String, String>();
ApiKeyAuth auth = new ApiKeyAuth("header", "X-API-TOKEN"); ApiKeyAuth auth = new ApiKeyAuth("header", "X-API-TOKEN");
auth.setApiKey(null); auth.setApiKey(null);
auth.setApiKeyPrefix("Token"); auth.setApiKeyPrefix("Token");
auth.applyToParams(queryParams, headerParams); auth.applyToParams(queryParams, headerParams, cookieParams);
// no changes to parameters // no changes to parameters
assertEquals(0, queryParams.size()); assertEquals(0, queryParams.size());
assertEquals(0, cookieParams.size());
assertEquals(0, headerParams.size());
}
@Test
public void testApplyToParamsInCookieWithPrefix() {
List<Pair> queryParams = new ArrayList<Pair>();
Map<String, String> headerParams = new HashMap<String, String>();
Map<String, String> cookieParams = new HashMap<String, String>();
ApiKeyAuth auth = new ApiKeyAuth("cookie", "X-API-TOKEN");
auth.setApiKey("my-api-token");
auth.setApiKeyPrefix("Token");
auth.applyToParams(queryParams, headerParams, cookieParams);
// no changes to query or header parameters
assertEquals(0, queryParams.size());
assertEquals(0, headerParams.size());
assertEquals(1, cookieParams.size());
assertEquals("Token my-api-token", cookieParams.get("X-API-TOKEN"));
}
@Test
public void testApplyToParamsInCookieWithNullValue() {
List<Pair> queryParams = new ArrayList<Pair>();
Map<String, String> headerParams = new HashMap<String, String>();
Map<String, String> cookieParams = new HashMap<String, String>();
ApiKeyAuth auth = new ApiKeyAuth("cookie", "X-API-TOKEN");
auth.setApiKey(null);
auth.setApiKeyPrefix("Token");
auth.applyToParams(queryParams, headerParams, cookieParams);
// no changes to parameters
assertEquals(0, queryParams.size());
assertEquals(0, cookieParams.size());
assertEquals(0, headerParams.size()); assertEquals(0, headerParams.size());
} }
} }

View File

@ -22,13 +22,15 @@ public class HttpBasicAuthTest {
public void testApplyToParams() { public void testApplyToParams() {
List<Pair> queryParams = new ArrayList<Pair>(); List<Pair> queryParams = new ArrayList<Pair>();
Map<String, String> headerParams = new HashMap<String, String>(); Map<String, String> headerParams = new HashMap<String, String>();
Map<String, String> cookieParams = new HashMap<String, String>();
auth.setUsername("my-username"); auth.setUsername("my-username");
auth.setPassword("my-password"); auth.setPassword("my-password");
auth.applyToParams(queryParams, headerParams); auth.applyToParams(queryParams, headerParams, cookieParams);
// no changes to query parameters // no changes to query or cookie parameters
assertEquals(0, queryParams.size()); assertEquals(0, queryParams.size());
assertEquals(0, cookieParams.size());
assertEquals(1, headerParams.size()); assertEquals(1, headerParams.size());
// the string below is base64-encoded result of "my-username:my-password" with the "Basic " prefix // the string below is base64-encoded result of "my-username:my-password" with the "Basic " prefix
String expected = "Basic bXktdXNlcm5hbWU6bXktcGFzc3dvcmQ="; String expected = "Basic bXktdXNlcm5hbWU6bXktcGFzc3dvcmQ=";
@ -36,7 +38,7 @@ public class HttpBasicAuthTest {
// null username should be treated as empty string // null username should be treated as empty string
auth.setUsername(null); auth.setUsername(null);
auth.applyToParams(queryParams, headerParams); auth.applyToParams(queryParams, headerParams, cookieParams);
// the string below is base64-encoded result of ":my-password" with the "Basic " prefix // the string below is base64-encoded result of ":my-password" with the "Basic " prefix
expected = "Basic Om15LXBhc3N3b3Jk"; expected = "Basic Om15LXBhc3N3b3Jk";
assertEquals(expected, headerParams.get("Authorization")); assertEquals(expected, headerParams.get("Authorization"));
@ -44,7 +46,7 @@ public class HttpBasicAuthTest {
// null password should be treated as empty string // null password should be treated as empty string
auth.setUsername("my-username"); auth.setUsername("my-username");
auth.setPassword(null); auth.setPassword(null);
auth.applyToParams(queryParams, headerParams); auth.applyToParams(queryParams, headerParams, cookieParams);
// the string below is base64-encoded result of "my-username:" with the "Basic " prefix // the string below is base64-encoded result of "my-username:" with the "Basic " prefix
expected = "Basic bXktdXNlcm5hbWU6"; expected = "Basic bXktdXNlcm5hbWU6";
assertEquals(expected, headerParams.get("Authorization")); assertEquals(expected, headerParams.get("Authorization"));
@ -54,7 +56,7 @@ public class HttpBasicAuthTest {
headerParams = new HashMap<String, String>(); headerParams = new HashMap<String, String>();
auth.setUsername(null); auth.setUsername(null);
auth.setPassword(null); auth.setPassword(null);
auth.applyToParams(queryParams, headerParams); auth.applyToParams(queryParams, headerParams, cookieParams);
// no changes to parameters // no changes to parameters
assertEquals(0, queryParams.size()); assertEquals(0, queryParams.size());
assertEquals(0, headerParams.size()); assertEquals(0, headerParams.size());

View File

@ -17,31 +17,53 @@ public class ApiKeyAuthTest {
public void testApplyToParamsInQuery() { public void testApplyToParamsInQuery() {
MultiValueMap<String, String> queryParams = new LinkedMultiValueMap<String, String>(); MultiValueMap<String, String> queryParams = new LinkedMultiValueMap<String, String>();
HttpHeaders headerParams = new HttpHeaders(); HttpHeaders headerParams = new HttpHeaders();
MultiValueMap<String, String> cookieParams = new LinkedMultiValueMap<String, String>();
ApiKeyAuth auth = new ApiKeyAuth("query", "api_key"); ApiKeyAuth auth = new ApiKeyAuth("query", "api_key");
auth.setApiKey("my-api-key"); auth.setApiKey("my-api-key");
auth.applyToParams(queryParams, headerParams); auth.applyToParams(queryParams, headerParams, cookieParams);
assertEquals(1, queryParams.size()); assertEquals(1, queryParams.size());
assertEquals("my-api-key", queryParams.get("api_key").get(0)); assertEquals("my-api-key", queryParams.get("api_key").get(0));
// no changes to header parameters // no changes to header or cookie parameters
assertEquals(0, headerParams.size()); assertEquals(0, headerParams.size());
assertEquals(0, cookieParams.size());
} }
@Test @Test
public void testApplyToParamsInHeaderWithPrefix() { public void testApplyToParamsInHeaderWithPrefix() {
MultiValueMap<String, String> queryParams = new LinkedMultiValueMap<String, String>(); MultiValueMap<String, String> queryParams = new LinkedMultiValueMap<String, String>();
HttpHeaders headerParams = new HttpHeaders(); HttpHeaders headerParams = new HttpHeaders();
MultiValueMap<String, String> cookieParams = new LinkedMultiValueMap<String, String>();
ApiKeyAuth auth = new ApiKeyAuth("header", "X-API-TOKEN"); ApiKeyAuth auth = new ApiKeyAuth("header", "X-API-TOKEN");
auth.setApiKey("my-api-token"); auth.setApiKey("my-api-token");
auth.setApiKeyPrefix("Token"); auth.setApiKeyPrefix("Token");
auth.applyToParams(queryParams, headerParams); auth.applyToParams(queryParams, headerParams, cookieParams);
// no changes to query parameters // no changes to query or cookie parameters
assertEquals(0, queryParams.size()); assertEquals(0, queryParams.size());
assertEquals(0, cookieParams.size());
assertEquals(1, headerParams.size()); assertEquals(1, headerParams.size());
assertEquals("Token my-api-token", headerParams.get("X-API-TOKEN").get(0)); assertEquals("Token my-api-token", headerParams.get("X-API-TOKEN").get(0));
} }
@Test
public void testApplyToParamsInCookieWithPrefix() {
MultiValueMap<String, String> queryParams = new LinkedMultiValueMap<String, String>();
HttpHeaders headerParams = new HttpHeaders();
MultiValueMap<String, String> cookieParams = new LinkedMultiValueMap<String, String>();
ApiKeyAuth auth = new ApiKeyAuth("cookie", "X-API-TOKEN");
auth.setApiKey("my-api-token");
auth.setApiKeyPrefix("Token");
auth.applyToParams(queryParams, headerParams, cookieParams);
// no changes to query or cookie parameters
assertEquals(0, queryParams.size());
assertEquals(0, headerParams.size());
assertEquals(1, cookieParams.size());
assertEquals("Token my-api-token", cookieParams.get("X-API-TOKEN").get(0));
}
} }

View File

@ -24,13 +24,15 @@ public class HttpBasicAuthTest {
public void testApplyToParams() { public void testApplyToParams() {
MultiValueMap<String, String> queryParams = new LinkedMultiValueMap<String, String>(); MultiValueMap<String, String> queryParams = new LinkedMultiValueMap<String, String>();
HttpHeaders headerParams = new HttpHeaders(); HttpHeaders headerParams = new HttpHeaders();
MultiValueMap<String, String> cookieParams = new LinkedMultiValueMap<String, String>();
auth.setUsername("my-username"); auth.setUsername("my-username");
auth.setPassword("my-password"); auth.setPassword("my-password");
auth.applyToParams(queryParams, headerParams); auth.applyToParams(queryParams, headerParams, cookieParams);
// no changes to query parameters // no changes to query or cookie parameters
assertEquals(0, queryParams.size()); assertEquals(0, queryParams.size());
assertEquals(0, cookieParams.size());
assertEquals(1, headerParams.size()); assertEquals(1, headerParams.size());
// the string below is base64-encoded result of "my-username:my-password" with the "Basic " prefix // the string below is base64-encoded result of "my-username:my-password" with the "Basic " prefix
String expected = "Basic bXktdXNlcm5hbWU6bXktcGFzc3dvcmQ="; String expected = "Basic bXktdXNlcm5hbWU6bXktcGFzc3dvcmQ=";
@ -38,7 +40,7 @@ public class HttpBasicAuthTest {
// null username should be treated as empty string // null username should be treated as empty string
auth.setUsername(null); auth.setUsername(null);
auth.applyToParams(queryParams, headerParams); auth.applyToParams(queryParams, headerParams, cookieParams);
// the string below is base64-encoded result of ":my-password" with the "Basic " prefix // the string below is base64-encoded result of ":my-password" with the "Basic " prefix
expected = "Basic Om15LXBhc3N3b3Jk"; expected = "Basic Om15LXBhc3N3b3Jk";
assertEquals(expected, headerParams.get("Authorization").get(1)); assertEquals(expected, headerParams.get("Authorization").get(1));
@ -46,7 +48,7 @@ public class HttpBasicAuthTest {
// null password should be treated as empty string // null password should be treated as empty string
auth.setUsername("my-username"); auth.setUsername("my-username");
auth.setPassword(null); auth.setPassword(null);
auth.applyToParams(queryParams, headerParams); auth.applyToParams(queryParams, headerParams, cookieParams);
// the string below is base64-encoded result of "my-username:" with the "Basic " prefix // the string below is base64-encoded result of "my-username:" with the "Basic " prefix
expected = "Basic bXktdXNlcm5hbWU6"; expected = "Basic bXktdXNlcm5hbWU6";
assertEquals(expected, headerParams.get("Authorization").get(2)); assertEquals(expected, headerParams.get("Authorization").get(2));

View File

@ -109,7 +109,7 @@ public abstract class AbstractJavaCodegen extends DefaultCodegen implements Code
"object", "object",
// used as internal variables, can collide with parameter names // used as internal variables, can collide with parameter names
"localVarPath", "localVarQueryParams", "localVarCollectionQueryParams", "localVarPath", "localVarQueryParams", "localVarCollectionQueryParams",
"localVarHeaderParams", "localVarFormParams", "localVarPostBody", "localVarHeaderParams", "localVarCookieParams", "localVarFormParams", "localVarPostBody",
"localVarAccepts", "localVarAccept", "localVarContentTypes", "localVarAccepts", "localVarAccept", "localVarContentTypes",
"localVarContentType", "localVarAuthNames", "localReturnType", "localVarContentType", "localVarAuthNames", "localReturnType",
"ApiClient", "ApiException", "ApiResponse", "Configuration", "StringUtil", "ApiClient", "ApiException", "ApiResponse", "Configuration", "StringUtil",

View File

@ -29,6 +29,7 @@ import com.sun.jersey.api.client.WebResource.Builder;
import com.sun.jersey.multipart.FormDataMultiPart; import com.sun.jersey.multipart.FormDataMultiPart;
import com.sun.jersey.multipart.file.FileDataBodyPart; import com.sun.jersey.multipart.file.FileDataBodyPart;
import javax.ws.rs.core.Cookie;
import javax.ws.rs.core.Response.Status.Family; import javax.ws.rs.core.Response.Status.Family;
import javax.ws.rs.core.MediaType; import javax.ws.rs.core.MediaType;
@ -60,6 +61,7 @@ import {{invokerPackage}}.auth.OAuth;
{{>generatedAnnotation}} {{>generatedAnnotation}}
public class ApiClient { public class ApiClient {
private Map<String, String> defaultHeaderMap = new HashMap<String, String>(); private Map<String, String> defaultHeaderMap = new HashMap<String, String>();
private Map<String, String> defaultCookieMap = new HashMap<String, String>();
private String basePath = "{{{basePath}}}"; private String basePath = "{{{basePath}}}";
private boolean debugging = false; private boolean debugging = false;
private int connectionTimeout = 0; private int connectionTimeout = 0;
@ -239,7 +241,7 @@ public class ApiClient {
/** /**
* Helper method to set API key value for the first API key authentication. * Helper method to set API key value for the first API key authentication.
* @param apiKey API key * @param apiKey the API key
*/ */
public void setApiKey(String apiKey) { public void setApiKey(String apiKey) {
for (Authentication auth : authentications.values()) { for (Authentication auth : authentications.values()) {
@ -250,7 +252,7 @@ public class ApiClient {
} }
throw new RuntimeException("No API key authentication configured!"); throw new RuntimeException("No API key authentication configured!");
} }
/** /**
* Helper method to set API key prefix for the first API key authentication. * Helper method to set API key prefix for the first API key authentication.
* @param apiKeyPrefix API key prefix * @param apiKeyPrefix API key prefix
@ -318,6 +320,18 @@ public class ApiClient {
return this; return this;
} }
/**
* Add a default cookie.
*
* @param key The cookie's key
* @param value The cookie's value
* @return API client
*/
public ApiClient addDefaultCookie(String key, String value) {
defaultCookieMap.put(key, value);
return this;
}
/** /**
* Check that whether debugging is enabled for this API client. * Check that whether debugging is enabled for this API client.
* @return True if debugging is on * @return True if debugging is on
@ -652,12 +666,12 @@ public class ApiClient {
return url.toString(); return url.toString();
} }
private ClientResponse getAPIResponse(String path, String method, List<Pair> queryParams, List<Pair> collectionQueryParams, Object body, Map<String, String> headerParams, Map<String, Object> formParams, String accept, String contentType, String[] authNames) throws ApiException { private ClientResponse getAPIResponse(String path, String method, List<Pair> queryParams, List<Pair> collectionQueryParams, Object body, Map<String, String> headerParams, Map<String, String> cookieParams, Map<String, Object> formParams, String accept, String contentType, String[] authNames) throws ApiException {
if (body != null && !formParams.isEmpty()) { if (body != null && !formParams.isEmpty()) {
throw new ApiException(500, "Cannot have body and form params"); throw new ApiException(500, "Cannot have body and form params");
} }
updateParamsForAuth(authNames, queryParams, headerParams); updateParamsForAuth(authNames, queryParams, headerParams, cookieParams);
final String url = buildUrl(path, queryParams, collectionQueryParams); final String url = buildUrl(path, queryParams, collectionQueryParams);
Builder builder; Builder builder;
@ -676,6 +690,15 @@ public class ApiClient {
} }
} }
for (Entry<String, String> keyValue : cookieParams.entrySet()) {
builder = builder.cookie(new Cookie(keyValue.getKey(), keyValue.getValue()));
}
for (Map.Entry<String,String> keyValue : defaultCookieMap.entrySet()) {
if (!cookieParams.containsKey(keyValue.getKey())) {
builder = builder.cookie(new Cookie(keyValue.getKey(), keyValue.getValue()));
}
}
ClientResponse response = null; ClientResponse response = null;
if ("GET".equals(method)) { if ("GET".equals(method)) {
@ -706,6 +729,7 @@ public class ApiClient {
* @param collectionQueryParams The collection query parameters * @param collectionQueryParams The collection query parameters
* @param body The request body object - if it is not binary, otherwise null * @param body The request body object - if it is not binary, otherwise null
* @param headerParams The header parameters * @param headerParams The header parameters
* @param cookieParams The cookie parameters
* @param formParams The form parameters * @param formParams The form parameters
* @param accept The request's Accept header * @param accept The request's Accept header
* @param contentType The request's Content-Type header * @param contentType The request's Content-Type header
@ -714,9 +738,9 @@ public class ApiClient {
* @return The response body in type of string * @return The response body in type of string
* @throws ApiException API exception * @throws ApiException API exception
*/ */
public <T> T invokeAPI(String path, String method, List<Pair> queryParams, List<Pair> collectionQueryParams, Object body, Map<String, String> headerParams, Map<String, Object> formParams, String accept, String contentType, String[] authNames, GenericType<T> returnType) throws ApiException { public <T> T invokeAPI(String path, String method, List<Pair> queryParams, List<Pair> collectionQueryParams, Object body, Map<String, String> headerParams, Map<String, String> cookieParams, Map<String, Object> formParams, String accept, String contentType, String[] authNames, GenericType<T> returnType) throws ApiException {
ClientResponse response = getAPIResponse(path, method, queryParams, collectionQueryParams, body, headerParams, formParams, accept, contentType, authNames); ClientResponse response = getAPIResponse(path, method, queryParams, collectionQueryParams, body, headerParams, cookieParams, formParams, accept, contentType, authNames);
statusCode = response.getStatusInfo().getStatusCode(); statusCode = response.getStatusInfo().getStatusCode();
responseHeaders = response.getHeaders(); responseHeaders = response.getHeaders();
@ -753,12 +777,13 @@ public class ApiClient {
* @param authNames The authentications to apply * @param authNames The authentications to apply
* @param queryParams Query parameters * @param queryParams Query parameters
* @param headerParams Header parameters * @param headerParams Header parameters
* @param cookieParams Cookie parameters
*/ */
private void updateParamsForAuth(String[] authNames, List<Pair> queryParams, Map<String, String> headerParams) { private void updateParamsForAuth(String[] authNames, List<Pair> queryParams, Map<String, String> headerParams, Map<String, String> cookieParams) {
for (String authName : authNames) { for (String authName : authNames) {
Authentication auth = authentications.get(authName); Authentication auth = authentications.get(authName);
if (auth == null) throw new RuntimeException("Authentication undefined: " + authName); if (auth == null) throw new RuntimeException("Authentication undefined: " + authName);
auth.applyToParams(queryParams, headerParams); auth.applyToParams(queryParams, headerParams, cookieParams);
} }
} }

View File

@ -79,6 +79,7 @@ public class {{classname}} {
{{javaUtilPrefix}}List<Pair> localVarQueryParams = new {{javaUtilPrefix}}ArrayList<Pair>(); {{javaUtilPrefix}}List<Pair> localVarQueryParams = new {{javaUtilPrefix}}ArrayList<Pair>();
{{javaUtilPrefix}}List<Pair> localVarCollectionQueryParams = new {{javaUtilPrefix}}ArrayList<Pair>(); {{javaUtilPrefix}}List<Pair> localVarCollectionQueryParams = new {{javaUtilPrefix}}ArrayList<Pair>();
{{javaUtilPrefix}}Map<String, String> localVarHeaderParams = new {{javaUtilPrefix}}HashMap<String, String>(); {{javaUtilPrefix}}Map<String, String> localVarHeaderParams = new {{javaUtilPrefix}}HashMap<String, String>();
{{javaUtilPrefix}}Map<String, String> localVarCookieParams = new {{javaUtilPrefix}}HashMap<String, String>();
{{javaUtilPrefix}}Map<String, Object> localVarFormParams = new {{javaUtilPrefix}}HashMap<String, Object>(); {{javaUtilPrefix}}Map<String, Object> localVarFormParams = new {{javaUtilPrefix}}HashMap<String, Object>();
{{#queryParams}} {{#queryParams}}
@ -89,6 +90,10 @@ public class {{classname}} {
localVarHeaderParams.put("{{baseName}}", apiClient.parameterToString({{paramName}})); localVarHeaderParams.put("{{baseName}}", apiClient.parameterToString({{paramName}}));
{{/headerParams}} {{/headerParams}}
{{#cookieParams}}if ({{paramName}} != null)
localVarCookieParams.put("{{baseName}}", apiClient.parameterToString({{paramName}}));
{{/cookieParams}}
{{#formParams}}if ({{paramName}} != null) {{#formParams}}if ({{paramName}} != null)
localVarFormParams.put("{{baseName}}", {{paramName}}); localVarFormParams.put("{{baseName}}", {{paramName}});
{{/formParams}} {{/formParams}}
@ -107,9 +112,9 @@ public class {{classname}} {
{{#returnType}} {{#returnType}}
GenericType<{{{returnType}}}> localVarReturnType = new GenericType<{{{returnType}}}>() {}; GenericType<{{{returnType}}}> localVarReturnType = new GenericType<{{{returnType}}}>() {};
return apiClient.invokeAPI(localVarPath, "{{httpMethod}}", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, localVarReturnType); return apiClient.invokeAPI(localVarPath, "{{httpMethod}}", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, localVarReturnType);
{{/returnType}}{{^returnType}} {{/returnType}}{{^returnType}}
apiClient.invokeAPI(localVarPath, "{{httpMethod}}", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, null); apiClient.invokeAPI(localVarPath, "{{httpMethod}}", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, null);
{{/returnType}} {{/returnType}}
} }
{{/operation}} {{/operation}}

View File

@ -45,7 +45,7 @@ public class ApiKeyAuth implements Authentication {
} }
@Override @Override
public void applyToParams(List<Pair> queryParams, Map<String, String> headerParams) { public void applyToParams(List<Pair> queryParams, Map<String, String> headerParams, Map<String, String> cookieParams) {
if (apiKey == null) { if (apiKey == null) {
return; return;
} }
@ -59,6 +59,8 @@ public class ApiKeyAuth implements Authentication {
queryParams.add(new Pair(paramName, value)); queryParams.add(new Pair(paramName, value));
} else if ("header".equals(location)) { } else if ("header".equals(location)) {
headerParams.put(paramName, value); headerParams.put(paramName, value);
} else if ("cookie".equals(location)) {
cookieParams.put(paramName, value);
} }
} }
} }

View File

@ -13,6 +13,7 @@ public interface Authentication {
* *
* @param queryParams List of query parameters * @param queryParams List of query parameters
* @param headerParams Map of header parameters * @param headerParams Map of header parameters
* @param cookieParams Map of cookie parameters
*/ */
void applyToParams(List<Pair> queryParams, Map<String, String> headerParams); void applyToParams(List<Pair> queryParams, Map<String, String> headerParams, Map<String, String> cookieParams);
} }

View File

@ -41,7 +41,7 @@ public class HttpBasicAuth implements Authentication {
} }
@Override @Override
public void applyToParams(List<Pair> queryParams, Map<String, String> headerParams) { public void applyToParams(List<Pair> queryParams, Map<String, String> headerParams, Map<String, String> cookieParams) {
if (username == null && password == null) { if (username == null && password == null) {
return; return;
} }

View File

@ -35,7 +35,7 @@ public class HttpBearerAuth implements Authentication {
} }
@Override @Override
public void applyToParams(List<Pair> queryParams, Map<String, String> headerParams) { public void applyToParams(List<Pair> queryParams, Map<String, String> headerParams, Map<String, String> cookieParams) {
if(bearerToken == null) { if(bearerToken == null) {
return; return;
} }

View File

@ -20,7 +20,7 @@ public class OAuth implements Authentication {
} }
@Override @Override
public void applyToParams(List<Pair> queryParams, Map<String, String> headerParams) { public void applyToParams(List<Pair> queryParams, Map<String, String> headerParams, Map<String, String> cookieParams) {
if (accessToken != null) { if (accessToken != null) {
headerParams.put("Authorization", "Bearer " + accessToken); headerParams.put("Authorization", "Bearer " + accessToken);
} }

View File

@ -70,7 +70,7 @@ public class ApiClient {
{{/isBasicBasic}} {{/isBasicBasic}}
{{/isBasic}} {{/isBasic}}
{{#isApiKey}} {{#isApiKey}}
auth = new ApiKeyAuth({{#isKeyInHeader}}"header"{{/isKeyInHeader}}{{^isKeyInHeader}}"query"{{/isKeyInHeader}}, "{{keyParamName}}"); auth = new ApiKeyAuth({{#isKeyInHeader}}"header"{{/isKeyInHeader}}{{#isKeyInQuery}}"query"{{/isKeyInQuery}}{{#isKeyInCookie}}"cookie"{{/isKeyInCookie}}, "{{keyParamName}}");
{{/isApiKey}} {{/isApiKey}}
{{#isOAuth}} {{#isOAuth}}
auth = new OAuth(OAuthFlow.{{flow}}, "{{authorizationUrl}}", "{{tokenUrl}}", "{{#scopes}}{{scope}}{{#hasMore}}, {{/hasMore}}{{/scopes}}"); auth = new OAuth(OAuthFlow.{{flow}}, "{{authorizationUrl}}", "{{tokenUrl}}", "{{#scopes}}{{scope}}{{#hasMore}}, {{/hasMore}}{{/scopes}}");

View File

@ -36,6 +36,8 @@ public class ApiKeyAuth implements RequestInterceptor {
template.query(paramName, apiKey); template.query(paramName, apiKey);
} else if ("header".equals(location)) { } else if ("header".equals(location)) {
template.header(paramName, apiKey); template.header(paramName, apiKey);
} else if ("cookie".equals(location)) {
template.header("Cookie", String.format("%s=%s", paramName, apiKey));
} }
} }
} }

View File

@ -62,6 +62,7 @@ import {{invokerPackage}}.auth.OAuth;
{{>generatedAnnotation}} {{>generatedAnnotation}}
public class ApiClient { public class ApiClient {
protected Map<String, String> defaultHeaderMap = new HashMap<String, String>(); protected Map<String, String> defaultHeaderMap = new HashMap<String, String>();
protected Map<String, String> defaultCookieMap = new HashMap<String, String>();
protected String basePath = "{{{basePath}}}"; protected String basePath = "{{{basePath}}}";
protected boolean debugging = false; protected boolean debugging = false;
protected int connectionTimeout = 0; protected int connectionTimeout = 0;
@ -246,6 +247,18 @@ public class ApiClient {
return this; return this;
} }
/**
* Add a default cookie.
*
* @param key The cookie's key
* @param value The cookie's value
* @return API client
*/
public ApiClient addDefaultCookie(String key, String value) {
defaultCookieMap.put(key, value);
return this;
}
/** /**
* Check that whether debugging is enabled for this API client. * Check that whether debugging is enabled for this API client.
* @return True if debugging is switched on * @return True if debugging is switched on
@ -316,7 +329,7 @@ public class ApiClient {
public int getReadTimeout() { public int getReadTimeout() {
return readTimeout; return readTimeout;
} }
/** /**
* Set the read timeout (in milliseconds). * Set the read timeout (in milliseconds).
* A value of 0 means no timeout, otherwise values must be between 1 and * A value of 0 means no timeout, otherwise values must be between 1 and
@ -662,6 +675,7 @@ public class ApiClient {
* @param queryParams The query parameters * @param queryParams The query parameters
* @param body The request body object * @param body The request body object
* @param headerParams The header parameters * @param headerParams The header parameters
* @param cookieParams The cookie parameters
* @param formParams The form parameters * @param formParams The form parameters
* @param accept The request's Accept header * @param accept The request's Accept header
* @param contentType The request's Content-Type header * @param contentType The request's Content-Type header
@ -670,8 +684,8 @@ public class ApiClient {
* @return The response body in type of string * @return The response body in type of string
* @throws ApiException API exception * @throws ApiException API exception
*/ */
public <T> ApiResponse<T> invokeAPI(String path, String method, List<Pair> queryParams, Object body, Map<String, String> headerParams, Map<String, Object> formParams, String accept, String contentType, String[] authNames, GenericType<T> returnType) throws ApiException { public <T> ApiResponse<T> invokeAPI(String path, String method, List<Pair> queryParams, Object body, Map<String, String> headerParams, Map<String, String> cookieParams, Map<String, Object> formParams, String accept, String contentType, String[] authNames, GenericType<T> returnType) throws ApiException {
updateParamsForAuth(authNames, queryParams, headerParams); updateParamsForAuth(authNames, queryParams, headerParams, cookieParams);
// Not using `.target(this.basePath).path(path)` below, // Not using `.target(this.basePath).path(path)` below,
// to support (constant) query string in `path`, e.g. "/posts?draft=1" // to support (constant) query string in `path`, e.g. "/posts?draft=1"
@ -694,6 +708,13 @@ public class ApiClient {
} }
} }
for (Entry<String, String> entry : cookieParams.entrySet()) {
String value = entry.getValue();
if (value != null) {
invocationBuilder = invocationBuilder.cookie(entry.getKey(), value);
}
}
for (Entry<String, String> entry : defaultHeaderMap.entrySet()) { for (Entry<String, String> entry : defaultHeaderMap.entrySet()) {
String key = entry.getKey(); String key = entry.getKey();
if (!headerParams.containsKey(key)) { if (!headerParams.containsKey(key)) {
@ -819,12 +840,13 @@ public class ApiClient {
* @param authNames The authentications to apply * @param authNames The authentications to apply
* @param queryParams List of query parameters * @param queryParams List of query parameters
* @param headerParams Map of header parameters * @param headerParams Map of header parameters
* @param cookieParams Map of cookie parameters
*/ */
protected void updateParamsForAuth(String[] authNames, List<Pair> queryParams, Map<String, String> headerParams) { protected void updateParamsForAuth(String[] authNames, List<Pair> queryParams, Map<String, String> headerParams, Map<String, String> cookieParams) {
for (String authName : authNames) { for (String authName : authNames) {
Authentication auth = authentications.get(authName); Authentication auth = authentications.get(authName);
if (auth == null) throw new RuntimeException("Authentication undefined: " + authName); if (auth == null) throw new RuntimeException("Authentication undefined: " + authName);
auth.applyToParams(queryParams, headerParams); auth.applyToParams(queryParams, headerParams, cookieParams);
} }
} }
} }

View File

@ -121,6 +121,7 @@ public class {{classname}} {
// query params // query params
{{javaUtilPrefix}}List<Pair> localVarQueryParams = new {{javaUtilPrefix}}ArrayList<Pair>(); {{javaUtilPrefix}}List<Pair> localVarQueryParams = new {{javaUtilPrefix}}ArrayList<Pair>();
{{javaUtilPrefix}}Map<String, String> localVarHeaderParams = new {{javaUtilPrefix}}HashMap<String, String>(); {{javaUtilPrefix}}Map<String, String> localVarHeaderParams = new {{javaUtilPrefix}}HashMap<String, String>();
{{javaUtilPrefix}}Map<String, String> localVarCookieParams = new {{javaUtilPrefix}}HashMap<String, String>();
{{javaUtilPrefix}}Map<String, Object> localVarFormParams = new {{javaUtilPrefix}}HashMap<String, Object>(); {{javaUtilPrefix}}Map<String, Object> localVarFormParams = new {{javaUtilPrefix}}HashMap<String, Object>();
{{#queryParams}} {{#queryParams}}
@ -131,6 +132,10 @@ public class {{classname}} {
localVarHeaderParams.put("{{baseName}}", apiClient.parameterToString({{paramName}})); localVarHeaderParams.put("{{baseName}}", apiClient.parameterToString({{paramName}}));
{{/headerParams}} {{/headerParams}}
{{#cookieParams}}if ({{paramName}} != null)
localVarCookieParams.put("{{baseName}}", apiClient.parameterToString({{paramName}}));
{{/cookieParams}}
{{#formParams}}if ({{paramName}} != null) {{#formParams}}if ({{paramName}} != null)
localVarFormParams.put("{{baseName}}", {{paramName}}); localVarFormParams.put("{{baseName}}", {{paramName}});
{{/formParams}} {{/formParams}}
@ -149,9 +154,9 @@ public class {{classname}} {
{{#returnType}} {{#returnType}}
GenericType<{{{returnType}}}> localVarReturnType = new GenericType<{{{returnType}}}>() {}; GenericType<{{{returnType}}}> localVarReturnType = new GenericType<{{{returnType}}}>() {};
return apiClient.invokeAPI(localVarPath, "{{httpMethod}}", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, localVarReturnType); return apiClient.invokeAPI(localVarPath, "{{httpMethod}}", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, localVarReturnType);
{{/returnType}}{{^returnType}} {{/returnType}}{{^returnType}}
return apiClient.invokeAPI(localVarPath, "{{httpMethod}}", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, null); return apiClient.invokeAPI(localVarPath, "{{httpMethod}}", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, null);
{{/returnType}} {{/returnType}}
} }
{{/operation}} {{/operation}}

View File

@ -65,6 +65,7 @@ public class ApiClient {
private String basePath = "{{{basePath}}}"; private String basePath = "{{{basePath}}}";
private boolean debugging = false; private boolean debugging = false;
private Map<String, String> defaultHeaderMap = new HashMap<String, String>(); private Map<String, String> defaultHeaderMap = new HashMap<String, String>();
private Map<String, String> defaultCookieMap = new HashMap<String, String>();
private String tempFolderPath = null; private String tempFolderPath = null;
private Map<String, Authentication> authentications; private Map<String, Authentication> authentications;
@ -92,7 +93,7 @@ public class ApiClient {
// Setup authentications (key: authentication name, value: authentication).{{#authMethods}}{{#isBasic}}{{#isBasicBasic}} // Setup authentications (key: authentication name, value: authentication).{{#authMethods}}{{#isBasic}}{{#isBasicBasic}}
authentications.put("{{name}}", new HttpBasicAuth());{{/isBasicBasic}}{{^isBasicBasic}} authentications.put("{{name}}", new HttpBasicAuth());{{/isBasicBasic}}{{^isBasicBasic}}
authentications.put("{{name}}", new HttpBearerAuth("{{scheme}}"));{{/isBasicBasic}}{{/isBasic}}{{#isApiKey}} authentications.put("{{name}}", new HttpBearerAuth("{{scheme}}"));{{/isBasicBasic}}{{/isBasic}}{{#isApiKey}}
authentications.put("{{name}}", new ApiKeyAuth({{#isKeyInHeader}}"header"{{/isKeyInHeader}}{{^isKeyInHeader}}"query"{{/isKeyInHeader}}, "{{keyParamName}}"));{{/isApiKey}}{{#isOAuth}} authentications.put("{{name}}", new ApiKeyAuth({{#isKeyInHeader}}"header"{{/isKeyInHeader}}{{#isKeyInQuery}}"query"{{/isKeyInQuery}}{{#isKeyInCookie}}"cookie"{{/isKeyInCookie}}, "{{keyParamName}}"));{{/isApiKey}}{{#isOAuth}}
authentications.put("{{name}}", new OAuth());{{/isOAuth}}{{/authMethods}} authentications.put("{{name}}", new OAuth());{{/isOAuth}}{{/authMethods}}
// Prevent the authentications from being modified. // Prevent the authentications from being modified.
authentications = Collections.unmodifiableMap(authentications); authentications = Collections.unmodifiableMap(authentications);
@ -442,6 +443,18 @@ public class ApiClient {
return this; return this;
} }
/**
* Add a default cookie.
*
* @param key The cookie's key
* @param value The cookie's value
* @return ApiClient
*/
public ApiClient addDefaultCookie(String key, String value) {
defaultCookieMap.put(key, value);
return this;
}
/** /**
* Check that whether debugging is enabled for this API client. * Check that whether debugging is enabled for this API client.
* *
@ -1069,14 +1082,15 @@ public class ApiClient {
* @param collectionQueryParams The collection query parameters * @param collectionQueryParams The collection query parameters
* @param body The request body object * @param body The request body object
* @param headerParams The header parameters * @param headerParams The header parameters
* @param cookieParams The cookie parameters
* @param formParams The form parameters * @param formParams The form parameters
* @param authNames The authentications to apply * @param authNames The authentications to apply
* @param callback Callback for upload/download progress * @param callback Callback for upload/download progress
* @return The HTTP call * @return The HTTP call
* @throws ApiException If fail to serialize the request body object * @throws ApiException If fail to serialize the request body object
*/ */
public Call buildCall(String path, String method, List<Pair> queryParams, List<Pair> collectionQueryParams, Object body, Map<String, String> headerParams, Map<String, Object> formParams, String[] authNames, ApiCallback callback) throws ApiException { public Call buildCall(String path, String method, List<Pair> queryParams, List<Pair> collectionQueryParams, Object body, Map<String, String> headerParams, Map<String, String> cookieParams, Map<String, Object> formParams, String[] authNames, ApiCallback callback) throws ApiException {
Request request = buildRequest(path, method, queryParams, collectionQueryParams, body, headerParams, formParams, authNames, callback); Request request = buildRequest(path, method, queryParams, collectionQueryParams, body, headerParams, cookieParams, formParams, authNames, callback);
return httpClient.newCall(request); return httpClient.newCall(request);
} }
@ -1090,18 +1104,20 @@ public class ApiClient {
* @param collectionQueryParams The collection query parameters * @param collectionQueryParams The collection query parameters
* @param body The request body object * @param body The request body object
* @param headerParams The header parameters * @param headerParams The header parameters
* @param cookieParams The cookie parameters
* @param formParams The form parameters * @param formParams The form parameters
* @param authNames The authentications to apply * @param authNames The authentications to apply
* @param callback Callback for upload/download progress * @param callback Callback for upload/download progress
* @return The HTTP request * @return The HTTP request
* @throws ApiException If fail to serialize the request body object * @throws ApiException If fail to serialize the request body object
*/ */
public Request buildRequest(String path, String method, List<Pair> queryParams, List<Pair> collectionQueryParams, Object body, Map<String, String> headerParams, Map<String, Object> formParams, String[] authNames, ApiCallback callback) throws ApiException { public Request buildRequest(String path, String method, List<Pair> queryParams, List<Pair> collectionQueryParams, Object body, Map<String, String> headerParams, Map<String, String> cookieParams, Map<String, Object> formParams, String[] authNames, ApiCallback callback) throws ApiException {
updateParamsForAuth(authNames, queryParams, headerParams); updateParamsForAuth(authNames, queryParams, headerParams, cookieParams);
final String url = buildUrl(path, queryParams, collectionQueryParams); final String url = buildUrl(path, queryParams, collectionQueryParams);
final Request.Builder reqBuilder = new Request.Builder().url(url); final Request.Builder reqBuilder = new Request.Builder().url(url);
processHeaderParams(headerParams, reqBuilder); processHeaderParams(headerParams, reqBuilder);
processCookieParams(cookieParams, reqBuilder);
String contentType = (String) headerParams.get("Content-Type"); String contentType = (String) headerParams.get("Content-Type");
// ensuring a default content type // ensuring a default content type
@ -1196,8 +1212,8 @@ public class ApiClient {
/** /**
* Set header parameters to the request builder, including default headers. * Set header parameters to the request builder, including default headers.
* *
* @param headerParams Header parameters in the ofrm of Map * @param headerParams Header parameters in the form of Map
* @param reqBuilder Reqeust.Builder * @param reqBuilder Request.Builder
*/ */
public void processHeaderParams(Map<String, String> headerParams, Request.Builder reqBuilder) { public void processHeaderParams(Map<String, String> headerParams, Request.Builder reqBuilder) {
for (Entry<String, String> param : headerParams.entrySet()) { for (Entry<String, String> param : headerParams.entrySet()) {
@ -1210,20 +1226,38 @@ public class ApiClient {
} }
} }
/**
* Set cookie parameters to the request builder, including default cookies.
*
* @param cookieParams Cookie parameters in the form of Map
* @param reqBuilder Request.Builder
*/
public void processCookieParams(Map<String, String> cookieParams, Request.Builder reqBuilder) {
for (Entry<String, String> param : cookieParams.entrySet()) {
reqBuilder.addHeader("Cookie", String.format("%s=%s", param.getKey(), param.getValue()));
}
for (Entry<String, String> param : defaultCookieMap.entrySet()) {
if (!cookieParams.containsKey(param.getKey())) {
reqBuilder.addHeader("Cookie", String.format("%s=%s", param.getKey(), param.getValue()));
}
}
}
/** /**
* Update query and header parameters based on authentication settings. * Update query and header parameters based on authentication settings.
* *
* @param authNames The authentications to apply * @param authNames The authentications to apply
* @param queryParams List of query parameters * @param queryParams List of query parameters
* @param headerParams Map of header parameters * @param headerParams Map of header parameters
* @param cookieParams Map of cookie parameters
*/ */
public void updateParamsForAuth(String[] authNames, List<Pair> queryParams, Map<String, String> headerParams) { public void updateParamsForAuth(String[] authNames, List<Pair> queryParams, Map<String, String> headerParams, Map<String, String> cookieParams) {
for (String authName : authNames) { for (String authName : authNames) {
Authentication auth = authentications.get(authName); Authentication auth = authentications.get(authName);
if (auth == null) { if (auth == null) {
throw new RuntimeException("Authentication undefined: " + authName); throw new RuntimeException("Authentication undefined: " + authName);
} }
auth.applyToParams(queryParams, headerParams); auth.applyToParams(queryParams, headerParams, cookieParams);
} }
} }

View File

@ -111,6 +111,13 @@ public class {{classname}} {
} }
{{/headerParams}} {{/headerParams}}
{{javaUtilPrefix}}Map<String, String> localVarCookieParams = new {{javaUtilPrefix}}HashMap<String, String>();
{{#cookieParams}}
if ({{paramName}} != null) {
localVarCookieParams.put("{{baseName}}", localVarApiClient.parameterToString({{paramName}}));
}
{{/cookieParams}}
{{javaUtilPrefix}}Map<String, Object> localVarFormParams = new {{javaUtilPrefix}}HashMap<String, Object>(); {{javaUtilPrefix}}Map<String, Object> localVarFormParams = new {{javaUtilPrefix}}HashMap<String, Object>();
{{#formParams}} {{#formParams}}
if ({{paramName}} != null) { if ({{paramName}} != null) {
@ -133,7 +140,7 @@ public class {{classname}} {
localVarHeaderParams.put("Content-Type", localVarContentType); localVarHeaderParams.put("Content-Type", localVarContentType);
String[] localVarAuthNames = new String[] { {{#authMethods}}"{{name}}"{{#hasMore}}, {{/hasMore}}{{/authMethods}} }; String[] localVarAuthNames = new String[] { {{#authMethods}}"{{name}}"{{#hasMore}}, {{/hasMore}}{{/authMethods}} };
return localVarApiClient.buildCall(localVarPath, "{{httpMethod}}", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, _callback); return localVarApiClient.buildCall(localVarPath, "{{httpMethod}}", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback);
} }
{{#isDeprecated}} {{#isDeprecated}}

View File

@ -32,7 +32,7 @@ public class HttpBasicAuth implements Authentication {
} }
@Override @Override
public void applyToParams(List<Pair> queryParams, Map<String, String> headerParams) { public void applyToParams(List<Pair> queryParams, Map<String, String> headerParams, Map<String, String> cookieParams) {
if (username == null && password == null) { if (username == null && password == null) {
return; return;
} }

View File

@ -169,7 +169,7 @@ public class RetryingOAuth extends OAuth implements Interceptor {
// Applying authorization to parameters is performed in the retryingIntercept method // Applying authorization to parameters is performed in the retryingIntercept method
@Override @Override
public void applyToParams(List<Pair> queryParams, Map<String, String> headerParams) { public void applyToParams(List<Pair> queryParams, Map<String, String> headerParams, Map<String, String> cookieParams) {
// No implementation necessary // No implementation necessary
} }
} }

View File

@ -50,6 +50,7 @@ import {{invokerPackage}}.auth.OAuth;
{{>generatedAnnotation}} {{>generatedAnnotation}}
public class ApiClient { public class ApiClient {
private Map<String, String> defaultHeaderMap = new HashMap<String, String>(); private Map<String, String> defaultHeaderMap = new HashMap<String, String>();
private Map<String, String> defaultCookieMap = new HashMap<String, String>();
private String basePath = "{{{basePath}}}"; private String basePath = "{{{basePath}}}";
private boolean debugging = false; private boolean debugging = false;
@ -82,7 +83,7 @@ public class ApiClient {
authentications = new HashMap<String, Authentication>();{{#authMethods}}{{#isBasic}}{{#isBasicBasic}} authentications = new HashMap<String, Authentication>();{{#authMethods}}{{#isBasic}}{{#isBasicBasic}}
authentications.put("{{name}}", new HttpBasicAuth());{{/isBasicBasic}}{{^isBasicBasic}} authentications.put("{{name}}", new HttpBasicAuth());{{/isBasicBasic}}{{^isBasicBasic}}
authentications.put("{{name}}", new HttpBearerAuth("{{scheme}}"));{{/isBasicBasic}}{{/isBasic}}{{#isApiKey}} authentications.put("{{name}}", new HttpBearerAuth("{{scheme}}"));{{/isBasicBasic}}{{/isBasic}}{{#isApiKey}}
authentications.put("{{name}}", new ApiKeyAuth({{#isKeyInHeader}}"header"{{/isKeyInHeader}}{{^isKeyInHeader}}"query"{{/isKeyInHeader}}, "{{keyParamName}}"));{{/isApiKey}}{{#isOAuth}} authentications.put("{{name}}", new ApiKeyAuth({{#isKeyInHeader}}"header"{{/isKeyInHeader}}{{#isKeyInQuery}}"query"{{/isKeyInQuery}}{{#isKeyInCookie}}"cookie"{{/isKeyInCookie}}, "{{keyParamName}}"));{{/isApiKey}}{{#isOAuth}}
authentications.put("{{name}}", new OAuth());{{/isOAuth}}{{/authMethods}} authentications.put("{{name}}", new OAuth());{{/isOAuth}}{{/authMethods}}
// Prevent the authentications from being modified. // Prevent the authentications from being modified.
authentications = Collections.unmodifiableMap(authentications); authentications = Collections.unmodifiableMap(authentications);
@ -611,6 +612,7 @@ public class ApiClient {
* @param queryParams The query parameters * @param queryParams The query parameters
* @param body The request body object * @param body The request body object
* @param headerParams The header parameters * @param headerParams The header parameters
* @param cookieParams The cookie parameters
* @param formParams The form parameters * @param formParams The form parameters
* @param accept The request's Accept header * @param accept The request's Accept header
* @param contentType The request's Content-Type header * @param contentType The request's Content-Type header
@ -619,8 +621,8 @@ public class ApiClient {
* @return The response body in type of string * @return The response body in type of string
* @throws ApiException if the invocation failed * @throws ApiException if the invocation failed
*/ */
public <T> T invokeAPI(String path, String method, List<Pair> queryParams, Object body, Map<String, String> headerParams, Map<String, Object> formParams, String accept, String contentType, String[] authNames, GenericType<T> returnType) throws ApiException { public <T> T invokeAPI(String path, String method, List<Pair> queryParams, Object body, Map<String, String> headerParams, Map<String, String> cookieParams, Map<String, Object> formParams, String accept, String contentType, String[] authNames, GenericType<T> returnType) throws ApiException {
updateParamsForAuth(authNames, queryParams, headerParams); updateParamsForAuth(authNames, queryParams, headerParams, cookieParams);
// Not using `.target(this.basePath).path(path)` below, // Not using `.target(this.basePath).path(path)` below,
// to support (constant) query string in `path`, e.g. "/posts?draft=1" // to support (constant) query string in `path`, e.g. "/posts?draft=1"
@ -652,6 +654,22 @@ public class ApiClient {
} }
} }
for (Entry<String, String> cookieParamsEntry : cookieParams.entrySet()) {
String value = cookieParamsEntry.getValue();
if (value != null) {
invocationBuilder = invocationBuilder.cookie(cookieParamsEntry.getKey(), value);
}
}
for (Entry<String, String> defaultCookieEntry: defaultHeaderMap.entrySet()) {
if (!cookieParams.containsKey(defaultCookieEntry.getKey())) {
String value = defaultCookieEntry.getValue();
if (value != null) {
invocationBuilder = invocationBuilder.cookie(defaultCookieEntry.getKey(), value);
}
}
}
Entity<?> entity = serialize(body, formParams, contentType); Entity<?> entity = serialize(body, formParams, contentType);
Response response = null; Response response = null;
@ -734,11 +752,11 @@ public class ApiClient {
* *
* @param authNames The authentications to apply * @param authNames The authentications to apply
*/ */
private void updateParamsForAuth(String[] authNames, List<Pair> queryParams, Map<String, String> headerParams) { private void updateParamsForAuth(String[] authNames, List<Pair> queryParams, Map<String, String> headerParams, Map<String, String> cookieParams) {
for (String authName : authNames) { for (String authName : authNames) {
Authentication auth = authentications.get(authName); Authentication auth = authentications.get(authName);
if (auth == null) throw new RuntimeException("Authentication undefined: " + authName); if (auth == null) throw new RuntimeException("Authentication undefined: " + authName);
auth.applyToParams(queryParams, headerParams); auth.applyToParams(queryParams, headerParams, cookieParams);
} }
} }
} }

View File

@ -71,6 +71,7 @@ public class {{classname}} {
// query params // query params
{{javaUtilPrefix}}List<Pair> localVarQueryParams = new {{javaUtilPrefix}}ArrayList<Pair>(); {{javaUtilPrefix}}List<Pair> localVarQueryParams = new {{javaUtilPrefix}}ArrayList<Pair>();
{{javaUtilPrefix}}Map<String, String> localVarHeaderParams = new {{javaUtilPrefix}}HashMap<String, String>(); {{javaUtilPrefix}}Map<String, String> localVarHeaderParams = new {{javaUtilPrefix}}HashMap<String, String>();
{{javaUtilPrefix}}Map<String, String> localVarCookieParams = new {{javaUtilPrefix}}HashMap<String, String>();
{{javaUtilPrefix}}Map<String, Object> localVarFormParams = new {{javaUtilPrefix}}HashMap<String, Object>(); {{javaUtilPrefix}}Map<String, Object> localVarFormParams = new {{javaUtilPrefix}}HashMap<String, Object>();
{{#queryParams}} {{#queryParams}}
@ -81,6 +82,10 @@ public class {{classname}} {
localVarHeaderParams.put("{{baseName}}", apiClient.parameterToString({{paramName}})); localVarHeaderParams.put("{{baseName}}", apiClient.parameterToString({{paramName}}));
{{/headerParams}} {{/headerParams}}
{{#cookieParams}}if ({{paramName}} != null)
localVarCookieParams.put("{{baseName}}", apiClient.parameterToString({{paramName}}));
{{/cookieParams}}
{{#formParams}}if ({{paramName}} != null) {{#formParams}}if ({{paramName}} != null)
localVarFormParams.put("{{baseName}}", {{paramName}}); localVarFormParams.put("{{baseName}}", {{paramName}});
{{/formParams}} {{/formParams}}
@ -99,9 +104,9 @@ public class {{classname}} {
{{#returnType}} {{#returnType}}
GenericType<{{{returnType}}}> localVarReturnType = new GenericType<{{{returnType}}}>() {}; GenericType<{{{returnType}}}> localVarReturnType = new GenericType<{{{returnType}}}>() {};
return apiClient.invokeAPI(localVarPath, "{{httpMethod}}", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, localVarReturnType); return apiClient.invokeAPI(localVarPath, "{{httpMethod}}", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, localVarReturnType);
{{/returnType}}{{^returnType}} {{/returnType}}{{^returnType}}
apiClient.invokeAPI(localVarPath, "{{httpMethod}}", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, null); apiClient.invokeAPI(localVarPath, "{{httpMethod}}", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, null);
{{/returnType}} {{/returnType}}
} }
{{/operation}} {{/operation}}

View File

@ -92,6 +92,7 @@ public class ApiClient {
private boolean debugging = false; private boolean debugging = false;
private HttpHeaders defaultHeaders = new HttpHeaders(); private HttpHeaders defaultHeaders = new HttpHeaders();
private MultiValueMap<String, String> defaultCookies = new LinkedMultiValueMap<String, String>();
private String basePath = "{{basePath}}"; private String basePath = "{{basePath}}";
@ -280,6 +281,21 @@ public class ApiClient {
return this; return this;
} }
/**
* Add a default cookie.
*
* @param name The cookie's name
* @param value The cookie's value
* @return ApiClient this client
*/
public ApiClient addDefaultCookie(String name, String value) {
if (defaultCookies.containsKey(name)) {
defaultCookies.remove(name);
}
defaultCookies.add(name, value);
return this;
}
public void setDebugging(boolean debugging) { public void setDebugging(boolean debugging) {
List<ClientHttpRequestInterceptor> currentInterceptors = this.restTemplate.getInterceptors(); List<ClientHttpRequestInterceptor> currentInterceptors = this.restTemplate.getInterceptors();
if(debugging) { if(debugging) {
@ -556,6 +572,7 @@ public class ApiClient {
* @param queryParams The query parameters * @param queryParams The query parameters
* @param body The request body object * @param body The request body object
* @param headerParams The header parameters * @param headerParams The header parameters
* @param cookieParams The cookie parameters
* @param formParams The form parameters * @param formParams The form parameters
* @param accept The request's Accept header * @param accept The request's Accept header
* @param contentType The request's Content-Type header * @param contentType The request's Content-Type header
@ -563,8 +580,8 @@ public class ApiClient {
* @param returnType The return type into which to deserialize the response * @param returnType The return type into which to deserialize the response
* @return ResponseEntity&lt;T&gt; The response of the chosen type * @return ResponseEntity&lt;T&gt; The response of the chosen type
*/ */
public <T> ResponseEntity<T> invokeAPI(String path, HttpMethod method, MultiValueMap<String, String> queryParams, Object body, HttpHeaders headerParams, MultiValueMap<String, Object> formParams, List<MediaType> accept, MediaType contentType, String[] authNames, ParameterizedTypeReference<T> returnType) throws RestClientException { public <T> ResponseEntity<T> invokeAPI(String path, HttpMethod method, MultiValueMap<String, String> queryParams, Object body, HttpHeaders headerParams, MultiValueMap<String, String> cookieParams, MultiValueMap<String, Object> formParams, List<MediaType> accept, MediaType contentType, String[] authNames, ParameterizedTypeReference<T> returnType) throws RestClientException {
updateParamsForAuth(authNames, queryParams, headerParams); updateParamsForAuth(authNames, queryParams, headerParams, cookieParams);
final UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(basePath).path(path); final UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(basePath).path(path);
if (queryParams != null) { if (queryParams != null) {
@ -600,6 +617,8 @@ public class ApiClient {
addHeadersToRequest(headerParams, requestBuilder); addHeadersToRequest(headerParams, requestBuilder);
addHeadersToRequest(defaultHeaders, requestBuilder); addHeadersToRequest(defaultHeaders, requestBuilder);
addCookiesToRequest(cookieParams, requestBuilder);
addCookiesToRequest(defaultCookies, requestBuilder);
RequestEntity<Object> requestEntity = requestBuilder.body(selectBody(body, formParams, contentType)); RequestEntity<Object> requestEntity = requestBuilder.body(selectBody(body, formParams, contentType));
@ -629,6 +648,29 @@ public class ApiClient {
} }
} }
/**
* Add cookies to the request that is being built
* @param cookies The cookies to add
* @param requestBuilder The current request
*/
protected void addCookiesToRequest(MultiValueMap<String, String> cookies, BodyBuilder requestBuilder) {
if (!cookies.isEmpty()) {
requestBuilder.header("Cookie", buildCookieHeader(cookies));
}
}
private String buildCookieHeader(MultiValueMap<String, String> cookies) {
final StringBuilder cookieValue = new StringBuilder();
String delimiter = "";
for (final Map.Entry<String, List<String>> entry : cookies.entrySet()) {
for (String value : entry.getValue()) {
cookieValue.append(String.format("%s%s=%s", delimiter, entry.getKey(), entry.getValue()));
delimiter = "; ";
}
}
return cookieValue.toString();
}
/** /**
* Build the RestTemplate used to make HTTP requests. * Build the RestTemplate used to make HTTP requests.
* @return RestTemplate * @return RestTemplate
@ -668,13 +710,13 @@ public class ApiClient {
* @param queryParams The query parameters * @param queryParams The query parameters
* @param headerParams The header parameters * @param headerParams The header parameters
*/ */
private void updateParamsForAuth(String[] authNames, MultiValueMap<String, String> queryParams, HttpHeaders headerParams) { private void updateParamsForAuth(String[] authNames, MultiValueMap<String, String> queryParams, HttpHeaders headerParams, MultiValueMap<String, String> cookieParams) {
for (String authName : authNames) { for (String authName : authNames) {
Authentication auth = authentications.get(authName); Authentication auth = authentications.get(authName);
if (auth == null) { if (auth == null) {
throw new RestClientException("Authentication undefined: " + authName); throw new RestClientException("Authentication undefined: " + authName);
} }
auth.applyToParams(queryParams, headerParams); auth.applyToParams(queryParams, headerParams, cookieParams);
} }
} }

View File

@ -115,6 +115,7 @@ public class {{classname}} {
final MultiValueMap<String, String> queryParams = new LinkedMultiValueMap<String, String>(); final MultiValueMap<String, String> queryParams = new LinkedMultiValueMap<String, String>();
final HttpHeaders headerParams = new HttpHeaders(); final HttpHeaders headerParams = new HttpHeaders();
final MultiValueMap<String, String> cookieParams = new LinkedMultiValueMap<String, String>();
final MultiValueMap<String, Object> formParams = new LinkedMultiValueMap<String, Object>();{{#hasQueryParams}} final MultiValueMap<String, Object> formParams = new LinkedMultiValueMap<String, Object>();{{#hasQueryParams}}
{{#queryParams}}queryParams.putAll(apiClient.parameterToMultiValueMap({{#collectionFormat}}ApiClient.CollectionFormat.valueOf("{{{collectionFormat}}}".toUpperCase(Locale.ROOT)){{/collectionFormat}}{{^collectionFormat}}null{{/collectionFormat}}, "{{baseName}}", {{paramName}}));{{#hasMore}} {{#queryParams}}queryParams.putAll(apiClient.parameterToMultiValueMap({{#collectionFormat}}ApiClient.CollectionFormat.valueOf("{{{collectionFormat}}}".toUpperCase(Locale.ROOT)){{/collectionFormat}}{{^collectionFormat}}null{{/collectionFormat}}, "{{baseName}}", {{paramName}}));{{#hasMore}}
@ -122,7 +123,11 @@ public class {{classname}} {
{{#headerParams}}if ({{paramName}} != null) {{#headerParams}}if ({{paramName}} != null)
headerParams.add("{{baseName}}", apiClient.parameterToString({{paramName}}));{{#hasMore}} headerParams.add("{{baseName}}", apiClient.parameterToString({{paramName}}));{{#hasMore}}
{{/hasMore}}{{/headerParams}}{{/hasHeaderParams}}{{#hasFormParams}} {{/hasMore}}{{/headerParams}}{{/hasHeaderParams}}{{#hasCookieParams}}
{{#cookieParams}}if ({{paramName}} != null)
cookieParams.add("{{baseName}}", apiClient.parameterToString({{paramName}}));{{#hasMore}}
{{/hasMore}}{{/cookieParams}}{{/hasCookieParams}}{{#hasFormParams}}
{{#formParams}}if ({{paramName}} != null) {{#formParams}}if ({{paramName}} != null)
formParams.add("{{baseName}}", {{#isFile}}new FileSystemResource({{paramName}}){{/isFile}}{{^isFile}}{{paramName}}{{/isFile}});{{#hasMore}} formParams.add("{{baseName}}", {{#isFile}}new FileSystemResource({{paramName}}){{/isFile}}{{^isFile}}{{paramName}}{{/isFile}});{{#hasMore}}
@ -140,7 +145,7 @@ public class {{classname}} {
String[] authNames = new String[] { {{#authMethods}}"{{name}}"{{#hasMore}}, {{/hasMore}}{{/authMethods}} }; String[] authNames = new String[] { {{#authMethods}}"{{name}}"{{#hasMore}}, {{/hasMore}}{{/authMethods}} };
{{#returnType}}ParameterizedTypeReference<{{{returnType}}}> returnType = new ParameterizedTypeReference<{{{returnType}}}>() {};{{/returnType}}{{^returnType}}ParameterizedTypeReference<Void> returnType = new ParameterizedTypeReference<Void>() {};{{/returnType}} {{#returnType}}ParameterizedTypeReference<{{{returnType}}}> returnType = new ParameterizedTypeReference<{{{returnType}}}>() {};{{/returnType}}{{^returnType}}ParameterizedTypeReference<Void> returnType = new ParameterizedTypeReference<Void>() {};{{/returnType}}
return apiClient.invokeAPI(path, HttpMethod.{{httpMethod}}, queryParams, postBody, headerParams, formParams, accept, contentType, authNames, returnType); return apiClient.invokeAPI(path, HttpMethod.{{httpMethod}}, queryParams, postBody, headerParams, cookieParams, formParams, accept, contentType, authNames, returnType);
} }
{{/operation}} {{/operation}}
} }

View File

@ -41,7 +41,7 @@ public class ApiKeyAuth implements Authentication {
} }
@Override @Override
public void applyToParams(MultiValueMap<String, String> queryParams, HttpHeaders headerParams) { public void applyToParams(MultiValueMap<String, String> queryParams, HttpHeaders headerParams, MultiValueMap<String, String> cookieParams) {
if (apiKey == null) { if (apiKey == null) {
return; return;
} }
@ -55,6 +55,8 @@ public class ApiKeyAuth implements Authentication {
queryParams.add(paramName, value); queryParams.add(paramName, value);
} else if (location.equals("header")) { } else if (location.equals("header")) {
headerParams.add(paramName, value); headerParams.add(paramName, value);
} } else if (location.equals("cookie")) {
cookieParams.add(paramName, value);
}
} }
} }

View File

@ -4,10 +4,11 @@ import org.springframework.http.HttpHeaders;
import org.springframework.util.MultiValueMap; import org.springframework.util.MultiValueMap;
public interface Authentication { public interface Authentication {
/** /**
* Apply authentication settings to header and / or query parameters. * Apply authentication settings to header and / or query parameters.
* @param queryParams The query parameters for the request * @param queryParams The query parameters for the request
* @param headerParams The header parameters for the request * @param headerParams The header parameters for the request
* @param cookieParams The cookie parameters for the request
*/ */
public void applyToParams(MultiValueMap<String, String> queryParams, HttpHeaders headerParams); public void applyToParams(MultiValueMap<String, String> queryParams, HttpHeaders headerParams, MultiValueMap<String, String> cookieParams);
} }

View File

@ -29,7 +29,7 @@ public class HttpBasicAuth implements Authentication {
} }
@Override @Override
public void applyToParams(MultiValueMap<String, String> queryParams, HttpHeaders headerParams) { public void applyToParams(MultiValueMap<String, String> queryParams, HttpHeaders headerParams, MultiValueMap<String, String> cookieParams) {
if (username == null && password == null) { if (username == null && password == null) {
return; return;
} }

View File

@ -25,7 +25,7 @@ public class HttpBearerAuth implements Authentication {
} }
@Override @Override
public void applyToParams(MultiValueMap<String, String> queryParams, HttpHeaders headerParams) { public void applyToParams(MultiValueMap<String, String> queryParams, HttpHeaders headerParams, MultiValueMap<String, String> cookieParams) {
if (bearerToken == null) { if (bearerToken == null) {
return; return;
} }

View File

@ -16,7 +16,7 @@ public class OAuth implements Authentication {
} }
@Override @Override
public void applyToParams(MultiValueMap<String, String> queryParams, HttpHeaders headerParams) { public void applyToParams(MultiValueMap<String, String> queryParams, HttpHeaders headerParams, MultiValueMap<String, String> cookieParams) {
if (accessToken != null) { if (accessToken != null) {
headerParams.add(HttpHeaders.AUTHORIZATION, "Bearer " + accessToken); headerParams.add(HttpHeaders.AUTHORIZATION, "Bearer " + accessToken);
} }

View File

@ -70,7 +70,7 @@ public class ApiClient {
{{/isBasicBasic}} {{/isBasicBasic}}
{{/isBasic}} {{/isBasic}}
{{#isApiKey}} {{#isApiKey}}
auth = new ApiKeyAuth({{#isKeyInHeader}}"header"{{/isKeyInHeader}}{{^isKeyInHeader}}"query"{{/isKeyInHeader}}, "{{keyParamName}}"); auth = new ApiKeyAuth({{#isKeyInHeader}}"header"{{/isKeyInHeader}}{{#isKeyInQuery}}"query"{{/isKeyInQuery}}{{#isKeyInCookie}}"cookie"{{/isKeyInCookie}}, "{{keyParamName}}");
{{/isApiKey}} {{/isApiKey}}
{{#isOAuth}} {{#isOAuth}}
auth = new OAuth(OAuthFlow.{{flow}}, "{{authorizationUrl}}", "{{tokenUrl}}", "{{#scopes}}{{scope}}{{#hasMore}}, {{/hasMore}}{{/scopes}}"); auth = new OAuth(OAuthFlow.{{flow}}, "{{authorizationUrl}}", "{{tokenUrl}}", "{{#scopes}}{{scope}}{{#hasMore}}, {{/hasMore}}{{/scopes}}");
@ -152,7 +152,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);
} }
/** /**
@ -246,7 +246,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 Client ID * @param clientId Client ID
@ -268,7 +268,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 Access token listener * @param accessTokenListener Access token listener
@ -316,7 +316,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);

View File

@ -46,7 +46,7 @@ public class ApiKeyAuth implements Interceptor {
if (newQuery == null) { if (newQuery == null) {
newQuery = paramValue; newQuery = paramValue;
} else { } else {
newQuery += "&" + paramValue; newQuery += "&" + paramValue;
} }
URI newUri; URI newUri;
@ -62,6 +62,10 @@ public class ApiKeyAuth implements Interceptor {
request = request.newBuilder() request = request.newBuilder()
.addHeader(paramName, apiKey) .addHeader(paramName, apiKey)
.build(); .build();
} else if ("cookie".equals(location)) {
request = request.newBuilder()
.addHeader("Cookie", String.format("%s=%s", paramName, apiKey))
.build();
} }
return chain.proceed(request); return chain.proceed(request);
} }

View File

@ -71,7 +71,7 @@ public class ApiClient {
auth = new HttpBearerAuth("{{scheme}}"); auth = new HttpBearerAuth("{{scheme}}");
{{/isBasicBasic}}{{/isBasic}} {{/isBasicBasic}}{{/isBasic}}
{{#isApiKey}} {{#isApiKey}}
auth = new ApiKeyAuth({{#isKeyInHeader}}"header"{{/isKeyInHeader}}{{^isKeyInHeader}}"query"{{/isKeyInHeader}}, "{{keyParamName}}"); auth = new ApiKeyAuth({{#isKeyInHeader}}"header"{{/isKeyInHeader}}{{#isKeyInQuery}}"query"{{/isKeyInQuery}}{{#isKeyInCookie}}"cookie"{{/isKeyInCookie}}, "{{keyParamName}}");
{{/isApiKey}} {{/isApiKey}}
{{#isOAuth}} {{#isOAuth}}
auth = new OAuth(OAuthFlow.{{flow}}, "{{authorizationUrl}}", "{{tokenUrl}}", "{{#scopes}}{{scope}}{{#hasMore}}, {{/hasMore}}{{/scopes}}"); auth = new OAuth(OAuthFlow.{{flow}}, "{{authorizationUrl}}", "{{tokenUrl}}", "{{#scopes}}{{scope}}{{#hasMore}}, {{/hasMore}}{{/scopes}}");

View File

@ -62,6 +62,10 @@ public class ApiKeyAuth implements Interceptor {
request = request.newBuilder() request = request.newBuilder()
.addHeader(paramName, apiKey) .addHeader(paramName, apiKey)
.build(); .build();
} else if ("cookie".equals(location)) {
request = request.newBuilder()
.addHeader("Cookie", String.format("%s=%s", paramName, apiKey))
.build();
} }
return chain.proceed(request); return chain.proceed(request);
} }

View File

@ -48,7 +48,7 @@ public class ApiKeyAuth implements Authentication {
} }
@Override @Override
public void applyToParams(List<Pair> queryParams, Map<String, String> headerParams) { public void applyToParams(List<Pair> queryParams, Map<String, String> headerParams, Map<String, String> cookieParams) {
if (apiKey == null) { if (apiKey == null) {
return; return;
} }
@ -62,6 +62,8 @@ public class ApiKeyAuth implements Authentication {
queryParams.add(new Pair(paramName, value)); queryParams.add(new Pair(paramName, value));
} else if ("header".equals(location)) { } else if ("header".equals(location)) {
headerParams.put(paramName, value); headerParams.put(paramName, value);
} else if ("cookie".equals(location)) {
cookieParams.put(paramName, value);
} }
} }
} }

View File

@ -45,7 +45,7 @@ public class ApiClient {
authentications = new HashMap<{{#supportJava6}}String, Authentication{{/supportJava6}}>();{{#authMethods}}{{#isBasic}}{{#isBasicBasic}} authentications = new HashMap<{{#supportJava6}}String, Authentication{{/supportJava6}}>();{{#authMethods}}{{#isBasic}}{{#isBasicBasic}}
// authentications.put("{{name}}", new HttpBasicAuth());{{/isBasicBasic}}{{^isBasicBasic}} // authentications.put("{{name}}", new HttpBasicAuth());{{/isBasicBasic}}{{^isBasicBasic}}
// authentications.put("{{name}}", new HttpBearerAuth("{{scheme}}"));{{/isBasicBasic}}{{/isBasic}}{{#isApiKey}} // authentications.put("{{name}}", new HttpBearerAuth("{{scheme}}"));{{/isBasicBasic}}{{/isBasic}}{{#isApiKey}}
authentications.put("{{name}}", new ApiKeyAuth({{#isKeyInHeader}}"header"{{/isKeyInHeader}}{{^isKeyInHeader}}"query"{{/isKeyInHeader}}, "{{keyParamName}}"));{{/isApiKey}}{{#isOAuth}} authentications.put("{{name}}", new ApiKeyAuth({{#isKeyInHeader}}"header"{{/isKeyInHeader}}{{#isKeyInQuery}}"query"{{/isKeyInQuery}}{{#isKeyInCookie}}"cookie"{{/isKeyInCookie}}, "{{keyParamName}}"));{{/isApiKey}}{{#isOAuth}}
// authentications.put("{{name}}", new OAuth());{{/isOAuth}}{{/authMethods}} // authentications.put("{{name}}", new OAuth());{{/isOAuth}}{{/authMethods}}
// Prevent the authentications from being modified. // Prevent the authentications from being modified.
authentications = Collections.unmodifiableMap(authentications); authentications = Collections.unmodifiableMap(authentications);
@ -61,13 +61,14 @@ public class ApiClient {
} }
Map<String, String> extraHeaders = new HashMap<{{#supportJava6}}String, String{{/supportJava6}}>(); Map<String, String> extraHeaders = new HashMap<{{#supportJava6}}String, String{{/supportJava6}}>();
Map<String, String> extraCookies = new HashMap<{{#supportJava6}}String, String{{/supportJava6}}>();
List<Pair> extraQueryParams = new ArrayList<{{#supportJava6}}Pair{{/supportJava6}}>(); List<Pair> extraQueryParams = new ArrayList<{{#supportJava6}}Pair{{/supportJava6}}>();
for (String authName : authentications.keySet()) { for (String authName : authentications.keySet()) {
Authentication auth = authentications.get(authName); Authentication auth = authentications.get(authName);
if (auth == null) throw new RuntimeException("Authentication undefined: " + authName); if (auth == null) throw new RuntimeException("Authentication undefined: " + authName);
auth.applyToParams(extraQueryParams, extraHeaders); auth.applyToParams(extraQueryParams, extraHeaders, extraCookies);
} }
ObjectMapper mapper = Json.mapper(); ObjectMapper mapper = Json.mapper();
@ -78,7 +79,7 @@ public class ApiClient {
.baseUrl(basePath) .baseUrl(basePath)
.addConverterFactory(ScalarsConverterFactory.create()) .addConverterFactory(ScalarsConverterFactory.create())
.addConverterFactory(JacksonConverterFactory.create(mapper)) .addConverterFactory(JacksonConverterFactory.create(mapper))
.callFactory(new Play24CallFactory(wsClient, extraHeaders, extraQueryParams)) .callFactory(new Play24CallFactory(wsClient, extraHeaders, extraCookies, extraQueryParams))
.addCallAdapterFactory(new Play24CallAdapterFactory()) .addCallAdapterFactory(new Play24CallAdapterFactory())
.build() .build()
.create(serviceClass); .create(serviceClass);
@ -139,5 +140,3 @@ public class ApiClient {
} }

View File

@ -7,6 +7,7 @@ import play.libs.F;
import play.libs.ws.WSClient; import play.libs.ws.WSClient;
import play.libs.ws.WSRequest; import play.libs.ws.WSRequest;
import play.libs.ws.WSResponse; import play.libs.ws.WSResponse;
import play.libs.ws.WSCookie;
import java.io.IOException; import java.io.IOException;
import java.net.MalformedURLException; import java.net.MalformedURLException;
@ -29,6 +30,9 @@ public class Play24CallFactory implements okhttp3.Call.Factory {
/** Extra headers to add to request */ /** Extra headers to add to request */
private Map<String, String> extraHeaders = new HashMap<>(); private Map<String, String> extraHeaders = new HashMap<>();
/** Extra cookies to add to request */
private Map<String, String> extraCookies = new HashMap<>();
/** Extra query parameters to add to request */ /** Extra query parameters to add to request */
private List<Pair> extraQueryParams = new ArrayList<>(); private List<Pair> extraQueryParams = new ArrayList<>();
@ -37,10 +41,12 @@ public class Play24CallFactory implements okhttp3.Call.Factory {
} }
public Play24CallFactory(WSClient wsClient, Map<String, String> extraHeaders, public Play24CallFactory(WSClient wsClient, Map<String, String> extraHeaders,
Map<String, String> extraCookies,
List<Pair> extraQueryParams) { List<Pair> extraQueryParams) {
this.wsClient = wsClient; this.wsClient = wsClient;
this.extraHeaders.putAll(extraHeaders); this.extraHeaders.putAll(extraHeaders);
this.extraCookies.putAll(extraCookies);
this.extraQueryParams.addAll(extraQueryParams); this.extraQueryParams.addAll(extraQueryParams);
} }
@ -51,6 +57,9 @@ public class Play24CallFactory implements okhttp3.Call.Factory {
for (Map.Entry<String, String> header : this.extraHeaders.entrySet()) { for (Map.Entry<String, String> header : this.extraHeaders.entrySet()) {
rb.addHeader(header.getKey(), header.getValue()); rb.addHeader(header.getKey(), header.getValue());
} }
for (Map.Entry<String, String> cookie : this.extraCookies.entrySet()) {
rb.addHeader("Cookie", String.format("%s=%s", cookie.getKey(), cookie.getValue()));
}
// add extra query params // add extra query params
if (!this.extraQueryParams.isEmpty()) { if (!this.extraQueryParams.isEmpty()) {
@ -130,6 +139,7 @@ public class Play24CallFactory implements okhttp3.Call.Factory {
try { try {
wsRequest = wsClient.url(request.url().uri().toString()); wsRequest = wsClient.url(request.url().uri().toString());
addHeaders(wsRequest); addHeaders(wsRequest);
addCookies(wsRequest);
if (request.body() != null) { if (request.body() != null) {
addBody(wsRequest); addBody(wsRequest);
} }
@ -149,6 +159,19 @@ public class Play24CallFactory implements okhttp3.Call.Factory {
} }
} }
private void addCookies(WSRequest wsRequest) {
final List<String> cookies = request.headers("Cookie");
if (!cookies.isEmpty()) {
String delimiter = "";
final StringBuilder cookieHeader = new StringBuilder();
for (final String cookie : cookies) {
cookieHeader.append(String.format("%s%s", delimiter, cookie));
delimiter = "; ";
}
wsRequest.setHeader("Cookie", cookieHeader.toString());
}
}
private void addBody(WSRequest wsRequest) throws IOException { private void addBody(WSRequest wsRequest) throws IOException {
Buffer buffer = new Buffer(); Buffer buffer = new Buffer();
request.body().writeTo(buffer); request.body().writeTo(buffer);
@ -186,6 +209,9 @@ public class Play24CallFactory implements okhttp3.Call.Factory {
builder.addHeader(entry.getKey(), value); builder.addHeader(entry.getKey(), value);
} }
} }
for (final WSCookie cookie : r.getCookies()) {
builder.addHeader("Cookie", String.format("%s=%s", cookie.getName(), cookie.getValue()));
}
builder.protocol(Protocol.HTTP_1_1); builder.protocol(Protocol.HTTP_1_1);
return builder.build(); return builder.build();

View File

@ -44,7 +44,7 @@ public class ApiClient {
// Setup authentications (key: authentication name, value: authentication). // Setup authentications (key: authentication name, value: authentication).
authentications = new HashMap<{{#supportJava6}}String, Authentication{{/supportJava6}}>();{{#authMethods}}{{#isBasic}} authentications = new HashMap<{{#supportJava6}}String, Authentication{{/supportJava6}}>();{{#authMethods}}{{#isBasic}}
// authentications.put("{{name}}", new HttpBasicAuth());{{/isBasic}}{{#isApiKey}} // authentications.put("{{name}}", new HttpBasicAuth());{{/isBasic}}{{#isApiKey}}
authentications.put("{{name}}", new ApiKeyAuth({{#isKeyInHeader}}"header"{{/isKeyInHeader}}{{^isKeyInHeader}}"query"{{/isKeyInHeader}}, "{{keyParamName}}"));{{/isApiKey}}{{#isOAuth}} authentications.put("{{name}}", new ApiKeyAuth({{#isKeyInHeader}}"header"{{/isKeyInHeader}}{{#isKeyInQuery}}"query"{{/isKeyInQuery}}{{#isKeyInCookie}}"query"{{/isKeyInCookie}}, "{{keyParamName}}"));{{/isApiKey}}{{#isOAuth}}
// authentications.put("{{name}}", new OAuth());{{/isOAuth}}{{/authMethods}} // authentications.put("{{name}}", new OAuth());{{/isOAuth}}{{/authMethods}}
// Prevent the authentications from being modified. // Prevent the authentications from being modified.
authentications = Collections.unmodifiableMap(authentications); authentications = Collections.unmodifiableMap(authentications);
@ -60,13 +60,14 @@ public class ApiClient {
} }
Map<String, String> extraHeaders = new HashMap<{{#supportJava6}}String, String{{/supportJava6}}>(); Map<String, String> extraHeaders = new HashMap<{{#supportJava6}}String, String{{/supportJava6}}>();
Map<String, String> extraCookies = new HashMap<{{#supportJava6}}String, String{{/supportJava6}}>();
List<Pair> extraQueryParams = new ArrayList<{{#supportJava6}}Pair{{/supportJava6}}>(); List<Pair> extraQueryParams = new ArrayList<{{#supportJava6}}Pair{{/supportJava6}}>();
for (String authName : authentications.keySet()) { for (String authName : authentications.keySet()) {
Authentication auth = authentications.get(authName); Authentication auth = authentications.get(authName);
if (auth == null) throw new RuntimeException("Authentication undefined: " + authName); if (auth == null) throw new RuntimeException("Authentication undefined: " + authName);
auth.applyToParams(extraQueryParams, extraHeaders); auth.applyToParams(extraQueryParams, extraHeaders, extraCookies);
} }
ObjectMapper mapper = Json.mapper(); ObjectMapper mapper = Json.mapper();
@ -77,7 +78,7 @@ public class ApiClient {
.baseUrl(basePath) .baseUrl(basePath)
.addConverterFactory(ScalarsConverterFactory.create()) .addConverterFactory(ScalarsConverterFactory.create())
.addConverterFactory(JacksonConverterFactory.create(mapper)) .addConverterFactory(JacksonConverterFactory.create(mapper))
.callFactory(new Play25CallFactory(wsClient, extraHeaders, extraQueryParams)) .callFactory(new Play25CallFactory(wsClient, extraHeaders, extraCookies, extraQueryParams))
.addCallAdapterFactory(new Play25CallAdapterFactory()) .addCallAdapterFactory(new Play25CallAdapterFactory())
.build() .build()
.create(serviceClass); .create(serviceClass);
@ -138,5 +139,3 @@ public class ApiClient {
} }

View File

@ -9,6 +9,7 @@ import play.libs.ws.WSClient;
import play.libs.ws.WSRequest; import play.libs.ws.WSRequest;
import play.libs.ws.WSResponse; import play.libs.ws.WSResponse;
import play.libs.ws.WSRequestFilter; import play.libs.ws.WSRequestFilter;
import play.libs.ws.WSCookie;
import java.io.IOException; import java.io.IOException;
import java.net.MalformedURLException; import java.net.MalformedURLException;
@ -32,9 +33,12 @@ public class Play25CallFactory implements okhttp3.Call.Factory {
/** Extra headers to add to request */ /** Extra headers to add to request */
private Map<String, String> extraHeaders = new HashMap<>(); private Map<String, String> extraHeaders = new HashMap<>();
/** Extra cookies to add to request */
private Map<String, String> extraCookies = new HashMap<>();
/** Extra query parameters to add to request */ /** Extra query parameters to add to request */
private List<Pair> extraQueryParams = new ArrayList<>(); private List<Pair> extraQueryParams = new ArrayList<>();
/** Filters (interceptors) */ /** Filters (interceptors) */
private List<WSRequestFilter> filters = new ArrayList<>(); private List<WSRequestFilter> filters = new ArrayList<>();
@ -48,10 +52,12 @@ public class Play25CallFactory implements okhttp3.Call.Factory {
} }
public Play25CallFactory(WSClient wsClient, Map<String, String> extraHeaders, public Play25CallFactory(WSClient wsClient, Map<String, String> extraHeaders,
Map<String, String> extraCookies,
List<Pair> extraQueryParams) { List<Pair> extraQueryParams) {
this.wsClient = wsClient; this.wsClient = wsClient;
this.extraHeaders.putAll(extraHeaders); this.extraHeaders.putAll(extraHeaders);
this.extraCookies.putAll(extraCookies);
this.extraQueryParams.addAll(extraQueryParams); this.extraQueryParams.addAll(extraQueryParams);
} }
@ -62,6 +68,9 @@ public class Play25CallFactory implements okhttp3.Call.Factory {
for (Map.Entry<String, String> header : this.extraHeaders.entrySet()) { for (Map.Entry<String, String> header : this.extraHeaders.entrySet()) {
rb.addHeader(header.getKey(), header.getValue()); rb.addHeader(header.getKey(), header.getValue());
} }
for (Map.Entry<String, String> cookie : this.extraCookies.entrySet()) {
rb.addHeader("Cookie", String.format("%s=%s", cookie.getKey(), cookie.getValue()));
}
// add extra query params // add extra query params
if (!this.extraQueryParams.isEmpty()) { if (!this.extraQueryParams.isEmpty()) {
@ -143,6 +152,7 @@ public class Play25CallFactory implements okhttp3.Call.Factory {
try { try {
wsRequest = wsClient.url(request.url().uri().toString()); wsRequest = wsClient.url(request.url().uri().toString());
addHeaders(wsRequest); addHeaders(wsRequest);
addCookies(wsRequest);
if (request.body() != null) { if (request.body() != null) {
addBody(wsRequest); addBody(wsRequest);
} }
@ -163,6 +173,19 @@ public class Play25CallFactory implements okhttp3.Call.Factory {
} }
} }
private void addCookies(WSRequest wsRequest) {
final List<String> cookies = request.headers("Cookie");
if (!cookies.isEmpty()) {
String delimiter = "";
final StringBuilder cookieHeader = new StringBuilder();
for (final String cookie : cookies) {
cookieHeader.append(String.format("%s%s", delimiter, cookie));
delimiter = "; ";
}
wsRequest.setHeader("Cookie", cookieHeader.toString());
}
}
private void addBody(WSRequest wsRequest) throws IOException { private void addBody(WSRequest wsRequest) throws IOException {
Buffer buffer = new Buffer(); Buffer buffer = new Buffer();
request.body().writeTo(buffer); request.body().writeTo(buffer);
@ -198,12 +221,16 @@ public class Play25CallFactory implements okhttp3.Call.Factory {
} }
}); });
for (Map.Entry<String, List<String>> entry : r.getAllHeaders().entrySet()) { for (Map.Entry<String, List<String>> entry : r.getAllHeaders().entrySet()) {
for (String value : entry.getValue()) { for (String value : entry.getValue()) {
builder.addHeader(entry.getKey(), value); builder.addHeader(entry.getKey(), value);
} }
} }
for (final WSCookie cookie : r.getCookies()) {
builder.addHeader("Cookie", String.format("%s=%s", cookie.getName(), cookie.getValue()));
}
builder.protocol(Protocol.HTTP_1_1); builder.protocol(Protocol.HTTP_1_1);
return builder.build(); return builder.build();

View File

@ -58,7 +58,7 @@ public class ApiClient {
// Setup authentications (key: authentication name, value: authentication). // Setup authentications (key: authentication name, value: authentication).
authentications = new HashMap<>();{{#authMethods}}{{#isBasic}} authentications = new HashMap<>();{{#authMethods}}{{#isBasic}}
// authentications.put("{{name}}", new HttpBasicAuth());{{/isBasic}}{{#isApiKey}} // authentications.put("{{name}}", new HttpBasicAuth());{{/isBasic}}{{#isApiKey}}
authentications.put("{{name}}", new ApiKeyAuth({{#isKeyInHeader}}"header"{{/isKeyInHeader}}{{^isKeyInHeader}}"query"{{/isKeyInHeader}}, "{{keyParamName}}"));{{/isApiKey}}{{#isOAuth}} authentications.put("{{name}}", new ApiKeyAuth({{#isKeyInHeader}}"header"{{/isKeyInHeader}}{{#isKeyInQuery}}"query"{{/isKeyInQuery}}{{#isKeyInCookie}}"cookie"{{/isKeyInCookie}}, "{{keyParamName}}"));{{/isApiKey}}{{#isOAuth}}
// authentications.put("{{name}}", new OAuth());{{/isOAuth}}{{/authMethods}} // authentications.put("{{name}}", new OAuth());{{/isOAuth}}{{/authMethods}}
// Prevent the authentications from being modified. // Prevent the authentications from being modified.
authentications = Collections.unmodifiableMap(authentications); authentications = Collections.unmodifiableMap(authentications);
@ -73,17 +73,18 @@ public class ApiClient {
} }
Map<String, String> extraHeaders = new HashMap<>(); Map<String, String> extraHeaders = new HashMap<>();
Map<String, String> extraCookies = new HashMap<>();
List<Pair> extraQueryParams = new ArrayList<>(); List<Pair> extraQueryParams = new ArrayList<>();
for (String authName : authentications.keySet()) { for (String authName : authentications.keySet()) {
Authentication auth = authentications.get(authName); Authentication auth = authentications.get(authName);
if (auth == null) throw new RuntimeException("Authentication undefined: " + authName); if (auth == null) throw new RuntimeException("Authentication undefined: " + authName);
auth.applyToParams(extraQueryParams, extraHeaders); auth.applyToParams(extraQueryParams, extraHeaders, extraCookies);
} }
if (callFactory == null) { if (callFactory == null) {
callFactory = new Play26CallFactory(wsClient, extraHeaders, extraQueryParams); callFactory = new Play26CallFactory(wsClient, extraHeaders, extraCookies, extraQueryParams);
} }
if (callAdapterFactory == null) { if (callAdapterFactory == null) {
callAdapterFactory = new Play26CallAdapterFactory(); callAdapterFactory = new Play26CallAdapterFactory();

View File

@ -9,6 +9,8 @@ import play.libs.ws.WSClient;
import play.libs.ws.WSRequest; import play.libs.ws.WSRequest;
import play.libs.ws.WSResponse; import play.libs.ws.WSResponse;
import play.libs.ws.WSRequestFilter; import play.libs.ws.WSRequestFilter;
import play.libs.ws.WSCookie;
import play.libs.ws.WSCookieBuilder;
import java.io.IOException; import java.io.IOException;
import java.net.MalformedURLException; import java.net.MalformedURLException;
@ -32,6 +34,9 @@ public class Play26CallFactory implements okhttp3.Call.Factory {
/** Extra headers to add to request */ /** Extra headers to add to request */
private Map<String, String> extraHeaders = new HashMap<>(); private Map<String, String> extraHeaders = new HashMap<>();
/** Extra cookies to add to request */
private Map<String, String> extraCookies = new HashMap<>();
/** Extra query parameters to add to request */ /** Extra query parameters to add to request */
private List<Pair> extraQueryParams = new ArrayList<>(); private List<Pair> extraQueryParams = new ArrayList<>();
@ -51,10 +56,12 @@ public class Play26CallFactory implements okhttp3.Call.Factory {
} }
public Play26CallFactory(WSClient wsClient, Map<String, String> extraHeaders, public Play26CallFactory(WSClient wsClient, Map<String, String> extraHeaders,
Map<String, String> extraCookies,
List<Pair> extraQueryParams) { List<Pair> extraQueryParams) {
this.wsClient = wsClient; this.wsClient = wsClient;
this.extraHeaders.putAll(extraHeaders); this.extraHeaders.putAll(extraHeaders);
this.extraCookies.putAll(extraCookies);
this.extraQueryParams.addAll(extraQueryParams); this.extraQueryParams.addAll(extraQueryParams);
} }
@ -70,6 +77,9 @@ public class Play26CallFactory implements okhttp3.Call.Factory {
for (Map.Entry<String, String> header : this.extraHeaders.entrySet()) { for (Map.Entry<String, String> header : this.extraHeaders.entrySet()) {
rb.addHeader(header.getKey(), header.getValue()); rb.addHeader(header.getKey(), header.getValue());
} }
for (Map.Entry<String, String> cookie : this.extraCookies.entrySet()) {
rb.addHeader("Cookie", String.format("%s=%s", cookie.getKey(), cookie.getValue()));
}
// add extra query params // add extra query params
if (!this.extraQueryParams.isEmpty()) { if (!this.extraQueryParams.isEmpty()) {
@ -160,6 +170,7 @@ public class Play26CallFactory implements okhttp3.Call.Factory {
wsRequest.addQueryParameter(queryParam, url.queryParameter(queryParam)); wsRequest.addQueryParameter(queryParam, url.queryParameter(queryParam));
}); });
addHeaders(wsRequest); addHeaders(wsRequest);
addCookies(wsRequest);
if (request.body() != null) { if (request.body() != null) {
addBody(wsRequest); addBody(wsRequest);
} }
@ -180,6 +191,32 @@ public class Play26CallFactory implements okhttp3.Call.Factory {
} }
} }
private void addCookies(WSRequest wsRequest) {
for (final WSCookie cookie : getCookies()) {
wsRequest.addCookie(cookie);
}
}
List<WSCookie> getCookies() {
final List<WSCookie> cookies = new ArrayList<>();
for (final String cookieString : request.headers("Cookie")) {
for (String cookie : cookieString.split(";")) {
cookie = cookie.trim();
final String[] nameAndValue = cookie.split("=");
if (nameAndValue.length != 2) {
continue;
}
cookies.add(
new WSCookieBuilder()
.setName(nameAndValue[0])
.setValue(nameAndValue[1])
.build()
);
}
}
return cookies;
}
private void addBody(WSRequest wsRequest) throws IOException { private void addBody(WSRequest wsRequest) throws IOException {
MediaType mediaType = request.body().contentType(); MediaType mediaType = request.body().contentType();
if (mediaType != null) { if (mediaType != null) {
@ -220,6 +257,9 @@ public class Play26CallFactory implements okhttp3.Call.Factory {
builder.addHeader(entry.getKey(), value); builder.addHeader(entry.getKey(), value);
} }
} }
for (final WSCookie cookie : r.getCookies()) {
builder.addHeader("Cookie", String.format("%s=%s", cookie.getName(), cookie.getValue()));
}
builder.message(r.getStatusText()); builder.message(r.getStatusText());
builder.protocol(Protocol.HTTP_1_1); builder.protocol(Protocol.HTTP_1_1);

View File

@ -49,6 +49,7 @@ public class ApiClient {
private final String identifier; private final String identifier;
private MultiMap defaultHeaders = MultiMap.caseInsensitiveMultiMap(); private MultiMap defaultHeaders = MultiMap.caseInsensitiveMultiMap();
private MultiMap defaultCookies = MultiMap.caseInsensitiveMultiMap();
private Map<String, Authentication> authentications; private Map<String, Authentication> authentications;
private String basePath = "{{{basePath}}}"; private String basePath = "{{{basePath}}}";
private DateFormat dateFormat; private DateFormat dateFormat;
@ -85,7 +86,7 @@ public class ApiClient {
this.authentications = new HashMap<>();{{#authMethods}}{{#isBasic}}{{#isBasicBasic}} this.authentications = new HashMap<>();{{#authMethods}}{{#isBasic}}{{#isBasicBasic}}
authentications.put("{{name}}", new HttpBasicAuth());{{/isBasicBasic}}{{^isBasicBasic}} authentications.put("{{name}}", new HttpBasicAuth());{{/isBasicBasic}}{{^isBasicBasic}}
authentications.put("{{name}}", new HttpBearerAuth("{{scheme}}"));{{/isBasicBasic}}{{/isBasic}}{{#isApiKey}} authentications.put("{{name}}", new HttpBearerAuth("{{scheme}}"));{{/isBasicBasic}}{{/isBasic}}{{#isApiKey}}
authentications.put("{{name}}", new ApiKeyAuth({{#isKeyInHeader}}"header"{{/isKeyInHeader}}{{^isKeyInHeader}}"query"{{/isKeyInHeader}}, "{{keyParamName}}"));{{/isApiKey}}{{#isOAuth}} authentications.put("{{name}}", new ApiKeyAuth({{#isKeyInHeader}}"header"{{/isKeyInHeader}}{{#isKeyInQuery}}"query"{{/isKeyInQuery}}{{#isKeyInCookie}}"cookie"{{/isKeyInCookie}}, "{{keyParamName}}"));{{/isApiKey}}{{#isOAuth}}
authentications.put("{{name}}", new OAuth());{{/isOAuth}}{{/authMethods}} authentications.put("{{name}}", new OAuth());{{/isOAuth}}{{/authMethods}}
// Prevent the authentications from being modified. // Prevent the authentications from being modified.
this.authentications = Collections.unmodifiableMap(authentications); this.authentications = Collections.unmodifiableMap(authentications);
@ -147,6 +148,15 @@ public class ApiClient {
return this; return this;
} }
public MultiMap getDefaultCookies() {
return defaultHeaders;
}
public ApiClient addDefaultCookie(String key, String value) {
defaultCookies.add(key, value);
return this;
}
/** /**
* Get authentications (key: authentication name, value: authentication). * Get authentications (key: authentication name, value: authentication).
* *
@ -431,6 +441,7 @@ public class ApiClient {
* @param queryParams The query parameters * @param queryParams The query parameters
* @param body The request body object * @param body The request body object
* @param headerParams The header parameters * @param headerParams The header parameters
* @param cookieParams The cookie parameters
* @param formParams The form parameters * @param formParams The form parameters
* @param accepts The request's Accept headers * @param accepts The request's Accept headers
* @param contentTypes The request's Content-Type headers * @param contentTypes The request's Content-Type headers
@ -439,10 +450,10 @@ public class ApiClient {
* @param resultHandler The asynchronous response handler * @param resultHandler The asynchronous response handler
*/ */
public <T> void invokeAPI(String path, String method, List<Pair> queryParams, Object body, MultiMap headerParams, public <T> void invokeAPI(String path, String method, List<Pair> queryParams, Object body, MultiMap headerParams,
Map<String, Object> formParams, String[] accepts, String[] contentTypes, String[] authNames, MultiMap cookieParams, Map<String, Object> formParams, String[] accepts, String[] contentTypes, String[] authNames,
TypeReference<T> returnType, Handler<AsyncResult<T>> resultHandler) { TypeReference<T> returnType, Handler<AsyncResult<T>> resultHandler) {
updateParamsForAuth(authNames, queryParams, headerParams); updateParamsForAuth(authNames, queryParams, headerParams, cookieParams);
if (accepts != null && accepts.length > 0) { if (accepts != null && accepts.length > 0) {
headerParams.add(HttpHeaders.ACCEPT, selectHeaderAccept(accepts)); headerParams.add(HttpHeaders.ACCEPT, selectHeaderAccept(accepts));
@ -477,6 +488,9 @@ public class ApiClient {
} }
}); });
final MultiMap cookies = MultiMap.caseInsensitiveMultiMap().addAll(cookieParams).addAll(defaultCookies);
request.putHeader("Cookie", buildCookieHeader(cookies));
Handler<AsyncResult<HttpResponse<Buffer>>> responseHandler = buildResponseHandler(returnType, resultHandler); Handler<AsyncResult<HttpResponse<Buffer>>> responseHandler = buildResponseHandler(returnType, resultHandler);
if (body != null) { if (body != null) {
sendBody(request, responseHandler, body); sendBody(request, responseHandler, body);
@ -489,6 +503,18 @@ public class ApiClient {
} }
} }
private String buildCookieHeader(MultiMap cookies) {
final StringBuilder cookieValue = new StringBuilder();
String delimiter = "";
for (final Map.Entry<String, String> entry : cookies.entries()) {
if (entry.getValue() != null) {
cookieValue.append(String.format("%s%s=%s", delimiter, entry.getKey(), entry.getValue()));
delimiter = "; ";
}
}
return cookieValue.toString();
}
/** /**
* Sanitize filename by removing path. * Sanitize filename by removing path.
* e.g. ../../sun.gif becomes sun.gif * e.g. ../../sun.gif becomes sun.gif
@ -619,11 +645,11 @@ public class ApiClient {
* *
* @param authNames The authentications to apply * @param authNames The authentications to apply
*/ */
protected void updateParamsForAuth(String[] authNames, List<Pair> queryParams, MultiMap headerParams) { protected void updateParamsForAuth(String[] authNames, List<Pair> queryParams, MultiMap headerParams, MultiMap cookieParams) {
for (String authName : authNames) { for (String authName : authNames) {
Authentication auth = authentications.get(authName); Authentication auth = authentications.get(authName);
if (auth == null) throw new RuntimeException("Authentication undefined: " + authName); if (auth == null) throw new RuntimeException("Authentication undefined: " + authName);
auth.applyToParams(queryParams, headerParams); auth.applyToParams(queryParams, headerParams, cookieParams);
} }
} }
} }

View File

@ -72,6 +72,12 @@ public class {{classname}}Impl implements {{classname}} {
localVarHeaderParams.add("{{baseName}}", apiClient.parameterToString({{paramName}})); localVarHeaderParams.add("{{baseName}}", apiClient.parameterToString({{paramName}}));
{{/headerParams}} {{/headerParams}}
// cookie params
MultiMap localVarCookieParams = MultiMap.caseInsensitiveMultiMap();
{{#cookieParams}}if ({{paramName}} != null)
localVarCookieParams.add("{{baseName}}", apiClient.parameterToString({{paramName}}));
{{/cookieParams}}
// form params // form params
// TODO: sending files within multipart/form-data is not supported yet (because of vertx web-client) // TODO: sending files within multipart/form-data is not supported yet (because of vertx web-client)
Map<String, Object> localVarFormParams = new HashMap<>(); Map<String, Object> localVarFormParams = new HashMap<>();
@ -83,8 +89,8 @@ public class {{classname}}Impl implements {{classname}} {
String[] localVarAuthNames = new String[] { {{#authMethods}}"{{name}}"{{#hasMore}}, {{/hasMore}}{{/authMethods}} }; String[] localVarAuthNames = new String[] { {{#authMethods}}"{{name}}"{{#hasMore}}, {{/hasMore}}{{/authMethods}} };
{{#returnType}} {{#returnType}}
TypeReference<{{{returnType}}}> localVarReturnType = new TypeReference<{{{returnType}}}>() {}; TypeReference<{{{returnType}}}> localVarReturnType = new TypeReference<{{{returnType}}}>() {};
apiClient.invokeAPI(localVarPath, "{{httpMethod}}", localVarQueryParams, localVarBody, localVarHeaderParams, localVarFormParams, localVarAccepts, localVarContentTypes, localVarAuthNames, localVarReturnType, resultHandler);{{/returnType}}{{^returnType}} apiClient.invokeAPI(localVarPath, "{{httpMethod}}", localVarQueryParams, localVarBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccepts, localVarContentTypes, localVarAuthNames, localVarReturnType, resultHandler);{{/returnType}}{{^returnType}}
apiClient.invokeAPI(localVarPath, "{{httpMethod}}", localVarQueryParams, localVarBody, localVarHeaderParams, localVarFormParams, localVarAccepts, localVarContentTypes, localVarAuthNames, null, resultHandler);{{/returnType}} apiClient.invokeAPI(localVarPath, "{{httpMethod}}", localVarQueryParams, localVarBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccepts, localVarContentTypes, localVarAuthNames, null, resultHandler);{{/returnType}}
} }
{{/operation}} {{/operation}}
} }

View File

@ -45,7 +45,7 @@ public class ApiKeyAuth implements Authentication {
} }
@Override @Override
public void applyToParams(List<Pair> queryParams, MultiMap headerParams) { public void applyToParams(List<Pair> queryParams, MultiMap headerParams, MultiMap cookieParams) {
if (apiKey == null) { if (apiKey == null) {
return; return;
} }
@ -59,6 +59,8 @@ public class ApiKeyAuth implements Authentication {
queryParams.add(new Pair(paramName, value)); queryParams.add(new Pair(paramName, value));
} else if ("header".equals(location)) { } else if ("header".equals(location)) {
headerParams.add(paramName, value); headerParams.add(paramName, value);
} else if ("cookie".equals(location)) {
cookieParams.add(paramName, value);
} }
} }
} }

View File

@ -13,6 +13,7 @@ public interface Authentication {
* *
* @param queryParams List of query parameters * @param queryParams List of query parameters
* @param headerParams Map of header parameters * @param headerParams Map of header parameters
* @param cookieParams Map of cookie parameters
*/ */
void applyToParams(List<Pair> queryParams, MultiMap headerParams); void applyToParams(List<Pair> queryParams, MultiMap headerParams, MultiMap cookieParams);
} }

View File

@ -30,7 +30,7 @@ public class HttpBasicAuth implements Authentication {
} }
@Override @Override
public void applyToParams(List<Pair> queryParams, MultiMap headerParams) { public void applyToParams(List<Pair> queryParams, MultiMap headerParams, MultiMap cookieParams) {
if (username == null && password == null) { if (username == null && password == null) {
return; return;
} }

View File

@ -26,7 +26,7 @@ public class HttpBearerAuth implements Authentication {
} }
@Override @Override
public void applyToParams(List<Pair> queryParams, MultiMap headerParams) { public void applyToParams(List<Pair> queryParams, MultiMap headerParams, MultiMap cookieParams) {
if (bearerToken == null) { if (bearerToken == null) {
return; return;
} }

View File

@ -20,7 +20,7 @@ public class OAuth implements Authentication {
} }
@Override @Override
public void applyToParams(List<Pair> queryParams, MultiMap headerParams) { public void applyToParams(List<Pair> queryParams, MultiMap headerParams, MultiMap cookieParams) {
if (accessToken != null) { if (accessToken != null) {
headerParams.add("Authorization", "Bearer " + accessToken); headerParams.add("Authorization", "Bearer " + accessToken);
} }

View File

@ -82,6 +82,7 @@ public class ApiClient {
} }
private HttpHeaders defaultHeaders = new HttpHeaders(); private HttpHeaders defaultHeaders = new HttpHeaders();
private MultiValueMap<String, String> defaultCookies = new LinkedMultiValueMap<String, String>();
private String basePath = "{{basePath}}"; private String basePath = "{{basePath}}";
@ -129,7 +130,7 @@ public class ApiClient {
authentications = new HashMap<String, Authentication>();{{#authMethods}}{{#isBasic}}{{#isBasicBasic}} authentications = new HashMap<String, Authentication>();{{#authMethods}}{{#isBasic}}{{#isBasicBasic}}
authentications.put("{{name}}", new HttpBasicAuth());{{/isBasicBasic}}{{^isBasicBasic}} authentications.put("{{name}}", new HttpBasicAuth());{{/isBasicBasic}}{{^isBasicBasic}}
authentications.put("{{name}}", new HttpBearerAuth("{{scheme}}"));{{/isBasicBasic}}{{/isBasic}}{{#isApiKey}} authentications.put("{{name}}", new HttpBearerAuth("{{scheme}}"));{{/isBasicBasic}}{{/isBasic}}{{#isApiKey}}
authentications.put("{{name}}", new ApiKeyAuth({{#isKeyInHeader}}"header"{{/isKeyInHeader}}{{^isKeyInHeader}}"query"{{/isKeyInHeader}}, "{{keyParamName}}"));{{/isApiKey}}{{#isOAuth}} authentications.put("{{name}}", new ApiKeyAuth({{#isKeyInHeader}}"header"{{/isKeyInHeader}}{{#isKeyInQuery}}"query"{{/isKeyInQuery}}{{#isKeyInCookie}}"cookie"{{/isKeyInCookie}}, "{{keyParamName}}"));{{/isApiKey}}{{#isOAuth}}
authentications.put("{{name}}", new OAuth());{{/isOAuth}}{{/authMethods}} authentications.put("{{name}}", new OAuth());{{/isOAuth}}{{/authMethods}}
// Prevent the authentications from being modified. // Prevent the authentications from being modified.
authentications = Collections.unmodifiableMap(authentications); authentications = Collections.unmodifiableMap(authentications);
@ -298,6 +299,21 @@ public class ApiClient {
return this; return this;
} }
/**
* Add a default cookie.
*
* @param name The cookie's name
* @param value The cookie's value
* @return ApiClient this client
*/
public ApiClient addDefaultCookie(String name, String value) {
if (defaultCookies.containsKey(name)) {
defaultCookies.remove(name);
}
defaultCookies.add(name, value);
return this;
}
/** /**
* Get the date format used to parse/format date parameters. * Get the date format used to parse/format date parameters.
* @return DateFormat format * @return DateFormat format
@ -507,8 +523,8 @@ public class ApiClient {
* @param returnType The return type into which to deserialize the response * @param returnType The return type into which to deserialize the response
* @return The response body in chosen type * @return The response body in chosen type
*/ */
public <T> Mono<T> invokeAPI(String path, HttpMethod method, MultiValueMap<String, String> queryParams, Object body, HttpHeaders headerParams, MultiValueMap<String, Object> formParams, List<MediaType> accept, MediaType contentType, String[] authNames, ParameterizedTypeReference<T> returnType) throws RestClientException { public <T> Mono<T> invokeAPI(String path, HttpMethod method, MultiValueMap<String, String> queryParams, Object body, HttpHeaders headerParams, MultiValueMap<String, String> cookieParams, MultiValueMap<String, Object> formParams, List<MediaType> accept, MediaType contentType, String[] authNames, ParameterizedTypeReference<T> returnType) throws RestClientException {
final WebClient.RequestBodySpec requestBuilder = prepareRequest(path, method, queryParams, body, headerParams, formParams, accept, contentType, authNames); final WebClient.RequestBodySpec requestBuilder = prepareRequest(path, method, queryParams, body, headerParams, cookieParams, formParams, accept, contentType, authNames);
return requestBuilder.retrieve().bodyToMono(returnType); return requestBuilder.retrieve().bodyToMono(returnType);
} }
@ -528,13 +544,13 @@ public class ApiClient {
* @param returnType The return type into which to deserialize the response * @param returnType The return type into which to deserialize the response
* @return The response body in chosen type * @return The response body in chosen type
*/ */
public <T> Flux<T> invokeFluxAPI(String path, HttpMethod method, MultiValueMap<String, String> queryParams, Object body, HttpHeaders headerParams, MultiValueMap<String, Object> formParams, List<MediaType> accept, MediaType contentType, String[] authNames, ParameterizedTypeReference<T> returnType) throws RestClientException { public <T> Flux<T> invokeFluxAPI(String path, HttpMethod method, MultiValueMap<String, String> queryParams, Object body, HttpHeaders headerParams, MultiValueMap<String, String> cookieParams, MultiValueMap<String, Object> formParams, List<MediaType> accept, MediaType contentType, String[] authNames, ParameterizedTypeReference<T> returnType) throws RestClientException {
final WebClient.RequestBodySpec requestBuilder = prepareRequest(path, method, queryParams, body, headerParams, formParams, accept, contentType, authNames); final WebClient.RequestBodySpec requestBuilder = prepareRequest(path, method, queryParams, body, headerParams, cookieParams, formParams, accept, contentType, authNames);
return requestBuilder.retrieve().bodyToFlux(returnType); return requestBuilder.retrieve().bodyToFlux(returnType);
} }
private WebClient.RequestBodySpec prepareRequest(String path, HttpMethod method, MultiValueMap<String, String> queryParams, Object body, HttpHeaders headerParams, MultiValueMap<String, Object> formParams, List<MediaType> accept, MediaType contentType, String[] authNames) { private WebClient.RequestBodySpec prepareRequest(String path, HttpMethod method, MultiValueMap<String, String> queryParams, Object body, HttpHeaders headerParams, MultiValueMap<String, String> cookieParams, MultiValueMap<String, Object> formParams, List<MediaType> accept, MediaType contentType, String[] authNames) {
updateParamsForAuth(authNames, queryParams, headerParams); updateParamsForAuth(authNames, queryParams, headerParams, cookieParams);
final UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(basePath).path(path); final UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(basePath).path(path);
if (queryParams != null) { if (queryParams != null) {
@ -563,6 +579,8 @@ public class ApiClient {
addHeadersToRequest(headerParams, requestBuilder); addHeadersToRequest(headerParams, requestBuilder);
addHeadersToRequest(defaultHeaders, requestBuilder); addHeadersToRequest(defaultHeaders, requestBuilder);
addCookiesToRequest(cookieParams, requestBuilder);
addCookiesToRequest(defaultCookies, requestBuilder);
requestBuilder.body(selectBody(body, formParams, contentType)); requestBuilder.body(selectBody(body, formParams, contentType));
return requestBuilder; return requestBuilder;
@ -584,20 +602,37 @@ public class ApiClient {
} }
} }
/**
* Add cookies to the request that is being built
* @param cookies The cookies to add
* @param requestBuilder The current request
*/
protected void addCookiesToRequest(MultiValueMap<String, String> cookies, WebClient.RequestBodySpec requestBuilder) {
for (Entry<String, List<String>> entry : cookies.entrySet()) {
List<String> values = entry.getValue();
for(String value : values) {
if (value != null) {
requestBuilder.cookie(entry.getKey(), value);
}
}
}
}
/** /**
* Update query and header parameters based on authentication settings. * Update query and header parameters based on authentication settings.
* *
* @param authNames The authentications to apply * @param authNames The authentications to apply
* @param queryParams The query parameters * @param queryParams The query parameters
* @param headerParams The header parameters * @param headerParams The header parameters
* @param cookieParams the cookie parameters
*/ */
private void updateParamsForAuth(String[] authNames, MultiValueMap<String, String> queryParams, HttpHeaders headerParams) { private void updateParamsForAuth(String[] authNames, MultiValueMap<String, String> queryParams, HttpHeaders headerParams, MultiValueMap<String, String> cookieParams) {
for (String authName : authNames) { for (String authName : authNames) {
Authentication auth = authentications.get(authName); Authentication auth = authentications.get(authName);
if (auth == null) { if (auth == null) {
throw new RestClientException("Authentication undefined: " + authName); throw new RestClientException("Authentication undefined: " + authName);
} }
auth.applyToParams(queryParams, headerParams); auth.applyToParams(queryParams, headerParams, cookieParams);
} }
} }

View File

@ -72,18 +72,22 @@ public class {{classname}} {
final Map<String, Object> uriVariables = new HashMap<String, Object>();{{#pathParams}} final Map<String, Object> uriVariables = new HashMap<String, Object>();{{#pathParams}}
uriVariables.put("{{baseName}}", {{{paramName}}});{{/pathParams}}{{/hasPathParams}} uriVariables.put("{{baseName}}", {{{paramName}}});{{/pathParams}}{{/hasPathParams}}
String path = UriComponentsBuilder.fromPath("{{{path}}}"){{#hasPathParams}}.buildAndExpand(uriVariables){{/hasPathParams}}{{^hasPathParams}}.build(){{/hasPathParams}}.toUriString(); String path = UriComponentsBuilder.fromPath("{{{path}}}"){{#hasPathParams}}.buildAndExpand(uriVariables){{/hasPathParams}}{{^hasPathParams}}.build(){{/hasPathParams}}.toUriString();
final MultiValueMap<String, String> queryParams = new LinkedMultiValueMap<String, String>(); final MultiValueMap<String, String> queryParams = new LinkedMultiValueMap<String, String>();
final HttpHeaders headerParams = new HttpHeaders(); final HttpHeaders headerParams = new HttpHeaders();
final MultiValueMap<String, String> cookieParams = new LinkedMultiValueMap<String, String>();
final MultiValueMap<String, Object> formParams = new LinkedMultiValueMap<String, Object>();{{#hasQueryParams}} final MultiValueMap<String, Object> formParams = new LinkedMultiValueMap<String, Object>();{{#hasQueryParams}}
{{#queryParams}}queryParams.putAll(apiClient.parameterToMultiValueMap({{#collectionFormat}}ApiClient.CollectionFormat.valueOf("{{{collectionFormat}}}".toUpperCase(Locale.ROOT)){{/collectionFormat}}{{^collectionFormat}}null{{/collectionFormat}}, "{{baseName}}", {{paramName}}));{{#hasMore}} {{#queryParams}}queryParams.putAll(apiClient.parameterToMultiValueMap({{#collectionFormat}}ApiClient.CollectionFormat.valueOf("{{{collectionFormat}}}".toUpperCase(Locale.ROOT)){{/collectionFormat}}{{^collectionFormat}}null{{/collectionFormat}}, "{{baseName}}", {{paramName}}));{{#hasMore}}
{{/hasMore}}{{/queryParams}}{{/hasQueryParams}}{{#hasHeaderParams}} {{/hasMore}}{{/queryParams}}{{/hasQueryParams}}{{#hasHeaderParams}}
{{#headerParams}}if ({{paramName}} != null) {{#headerParams}}if ({{paramName}} != null)
headerParams.add("{{baseName}}", apiClient.parameterToString({{paramName}}));{{#hasMore}} headerParams.add("{{baseName}}", apiClient.parameterToString({{paramName}}));{{#hasMore}}
{{/hasMore}}{{/headerParams}}{{/hasHeaderParams}}{{#hasFormParams}} {{/hasMore}}{{/headerParams}}{{/hasHeaderParams}}{{#hasCookieParams}}
{{#cookieParams}}cookieParams.putAll(apiClient.parameterToMultiValueMap({{#collectionFormat}}ApiClient.CollectionFormat.valueOf("{{{collectionFormat}}}".toUpperCase(Locale.ROOT)){{/collectionFormat}}{{^collectionFormat}}null{{/collectionFormat}}, "{{baseName}}", {{paramName}}));{{#hasMore}}
{{/hasMore}}{{/cookieParams}}{{/hasCookieParams}}{{#hasFormParams}}
{{#formParams}}if ({{paramName}} != null) {{#formParams}}if ({{paramName}} != null)
formParams.add("{{baseName}}", {{#isFile}}new FileSystemResource({{paramName}}){{/isFile}}{{^isFile}}{{paramName}}{{/isFile}});{{#hasMore}} formParams.add("{{baseName}}", {{#isFile}}new FileSystemResource({{paramName}}){{/isFile}}{{^isFile}}{{paramName}}{{/isFile}});{{#hasMore}}
{{/hasMore}}{{/formParams}}{{/hasFormParams}} {{/hasMore}}{{/formParams}}{{/hasFormParams}}
@ -100,7 +104,7 @@ public class {{classname}} {
String[] authNames = new String[] { {{#authMethods}}"{{name}}"{{#hasMore}}, {{/hasMore}}{{/authMethods}} }; String[] authNames = new String[] { {{#authMethods}}"{{name}}"{{#hasMore}}, {{/hasMore}}{{/authMethods}} };
{{#returnType}}ParameterizedTypeReference<{{#isListContainer}}{{{returnBaseType}}}{{/isListContainer}}{{^isListContainer}}{{{returnType}}}{{/isListContainer}}> returnType = new ParameterizedTypeReference<{{#isListContainer}}{{{returnBaseType}}}{{/isListContainer}}{{^isListContainer}}{{{returnType}}}{{/isListContainer}}>() {};{{/returnType}}{{^returnType}}ParameterizedTypeReference<Void> returnType = new ParameterizedTypeReference<Void>() {};{{/returnType}} {{#returnType}}ParameterizedTypeReference<{{#isListContainer}}{{{returnBaseType}}}{{/isListContainer}}{{^isListContainer}}{{{returnType}}}{{/isListContainer}}> returnType = new ParameterizedTypeReference<{{#isListContainer}}{{{returnBaseType}}}{{/isListContainer}}{{^isListContainer}}{{{returnType}}}{{/isListContainer}}>() {};{{/returnType}}{{^returnType}}ParameterizedTypeReference<Void> returnType = new ParameterizedTypeReference<Void>() {};{{/returnType}}
return apiClient.{{#isListContainer}}invokeFluxAPI{{/isListContainer}}{{^isListContainer}}invokeAPI{{/isListContainer}}(path, HttpMethod.{{httpMethod}}, queryParams, postBody, headerParams, formParams, accept, contentType, authNames, returnType); return apiClient.{{#isListContainer}}invokeFluxAPI{{/isListContainer}}{{^isListContainer}}invokeAPI{{/isListContainer}}(path, HttpMethod.{{httpMethod}}, queryParams, postBody, headerParams, cookieParams, formParams, accept, contentType, authNames, returnType);
} }
{{/operation}} {{/operation}}
} }

View File

@ -41,7 +41,7 @@ public class ApiKeyAuth implements Authentication {
} }
@Override @Override
public void applyToParams(MultiValueMap<String, String> queryParams, HttpHeaders headerParams) { public void applyToParams(MultiValueMap<String, String> queryParams, HttpHeaders headerParams, MultiValueMap<String, String> cookieParams) {
if (apiKey == null) { if (apiKey == null) {
return; return;
} }
@ -55,6 +55,8 @@ public class ApiKeyAuth implements Authentication {
queryParams.add(paramName, value); queryParams.add(paramName, value);
} else if (location.equals("header")) { } else if (location.equals("header")) {
headerParams.add(paramName, value); headerParams.add(paramName, value);
} } else if (location.equals("cookie")) {
cookieParams.add(paramName, value);
}
} }
} }

View File

@ -4,10 +4,11 @@ import org.springframework.http.HttpHeaders;
import org.springframework.util.MultiValueMap; import org.springframework.util.MultiValueMap;
public interface Authentication { public interface Authentication {
/** /**
* Apply authentication settings to header and / or query parameters. * Apply authentication settings to header and / or query parameters.
* @param queryParams The query parameters for the request * @param queryParams The query parameters for the request
* @param headerParams The header parameters for the request * @param headerParams The header parameters for the request
* @param cookieParams The cookie parameters for the request
*/ */
public void applyToParams(MultiValueMap<String, String> queryParams, HttpHeaders headerParams); public void applyToParams(MultiValueMap<String, String> queryParams, HttpHeaders headerParams, MultiValueMap<String, String> cookieParams);
} }

View File

@ -29,7 +29,7 @@ public class HttpBasicAuth implements Authentication {
} }
@Override @Override
public void applyToParams(MultiValueMap<String, String> queryParams, HttpHeaders headerParams) { public void applyToParams(MultiValueMap<String, String> queryParams, HttpHeaders headerParams, MultiValueMap<String, String> cookieParams) {
if (username == null && password == null) { if (username == null && password == null) {
return; return;
} }

View File

@ -25,7 +25,7 @@ public class HttpBearerAuth implements Authentication {
} }
@Override @Override
public void applyToParams(MultiValueMap<String, String> queryParams, HttpHeaders headerParams) { public void applyToParams(MultiValueMap<String, String> queryParams, HttpHeaders headerParams, MultiValueMap<String, String> cookieParams) {
if (bearerToken == null) { if (bearerToken == null) {
return; return;
} }

View File

@ -16,7 +16,7 @@ public class OAuth implements Authentication {
} }
@Override @Override
public void applyToParams(MultiValueMap<String, String> queryParams, HttpHeaders headerParams) { public void applyToParams(MultiValueMap<String, String> queryParams, HttpHeaders headerParams, MultiValueMap<String, String> cookieParams) {
if (accessToken != null) { if (accessToken != null) {
headerParams.add(HttpHeaders.AUTHORIZATION, "Bearer " + accessToken); headerParams.add(HttpHeaders.AUTHORIZATION, "Bearer " + accessToken);
} }

View File

@ -36,6 +36,8 @@ public class ApiKeyAuth implements RequestInterceptor {
template.query(paramName, apiKey); template.query(paramName, apiKey);
} else if ("header".equals(location)) { } else if ("header".equals(location)) {
template.header(paramName, apiKey); template.header(paramName, apiKey);
} else if ("cookie".equals(location)) {
template.header("Cookie", String.format("%s=%s", paramName, apiKey));
} }
} }
} }

View File

@ -36,6 +36,8 @@ public class ApiKeyAuth implements RequestInterceptor {
template.query(paramName, apiKey); template.query(paramName, apiKey);
} else if ("header".equals(location)) { } else if ("header".equals(location)) {
template.header(paramName, apiKey); template.header(paramName, apiKey);
} else if ("cookie".equals(location)) {
template.header("Cookie", String.format("%s=%s", paramName, apiKey));
} }
} }
} }

View File

@ -30,6 +30,7 @@ import com.sun.jersey.api.client.WebResource.Builder;
import com.sun.jersey.multipart.FormDataMultiPart; import com.sun.jersey.multipart.FormDataMultiPart;
import com.sun.jersey.multipart.file.FileDataBodyPart; import com.sun.jersey.multipart.file.FileDataBodyPart;
import javax.ws.rs.core.Cookie;
import javax.ws.rs.core.Response.Status.Family; import javax.ws.rs.core.Response.Status.Family;
import javax.ws.rs.core.MediaType; import javax.ws.rs.core.MediaType;
@ -59,6 +60,7 @@ import org.openapitools.client.auth.OAuth;
public class ApiClient { public class ApiClient {
private Map<String, String> defaultHeaderMap = new HashMap<String, String>(); private Map<String, String> defaultHeaderMap = new HashMap<String, String>();
private Map<String, String> defaultCookieMap = new HashMap<String, String>();
private String basePath = "http://petstore.swagger.io:80/v2"; private String basePath = "http://petstore.swagger.io:80/v2";
private boolean debugging = false; private boolean debugging = false;
private int connectionTimeout = 0; private int connectionTimeout = 0;
@ -230,7 +232,7 @@ public class ApiClient {
/** /**
* Helper method to set API key value for the first API key authentication. * Helper method to set API key value for the first API key authentication.
* @param apiKey API key * @param apiKey the API key
*/ */
public void setApiKey(String apiKey) { public void setApiKey(String apiKey) {
for (Authentication auth : authentications.values()) { for (Authentication auth : authentications.values()) {
@ -241,7 +243,7 @@ public class ApiClient {
} }
throw new RuntimeException("No API key authentication configured!"); throw new RuntimeException("No API key authentication configured!");
} }
/** /**
* Helper method to set API key prefix for the first API key authentication. * Helper method to set API key prefix for the first API key authentication.
* @param apiKeyPrefix API key prefix * @param apiKeyPrefix API key prefix
@ -307,6 +309,18 @@ public class ApiClient {
return this; return this;
} }
/**
* Add a default cookie.
*
* @param key The cookie's key
* @param value The cookie's value
* @return API client
*/
public ApiClient addDefaultCookie(String key, String value) {
defaultCookieMap.put(key, value);
return this;
}
/** /**
* Check that whether debugging is enabled for this API client. * Check that whether debugging is enabled for this API client.
* @return True if debugging is on * @return True if debugging is on
@ -641,12 +655,12 @@ public class ApiClient {
return url.toString(); return url.toString();
} }
private ClientResponse getAPIResponse(String path, String method, List<Pair> queryParams, List<Pair> collectionQueryParams, Object body, Map<String, String> headerParams, Map<String, Object> formParams, String accept, String contentType, String[] authNames) throws ApiException { private ClientResponse getAPIResponse(String path, String method, List<Pair> queryParams, List<Pair> collectionQueryParams, Object body, Map<String, String> headerParams, Map<String, String> cookieParams, Map<String, Object> formParams, String accept, String contentType, String[] authNames) throws ApiException {
if (body != null && !formParams.isEmpty()) { if (body != null && !formParams.isEmpty()) {
throw new ApiException(500, "Cannot have body and form params"); throw new ApiException(500, "Cannot have body and form params");
} }
updateParamsForAuth(authNames, queryParams, headerParams); updateParamsForAuth(authNames, queryParams, headerParams, cookieParams);
final String url = buildUrl(path, queryParams, collectionQueryParams); final String url = buildUrl(path, queryParams, collectionQueryParams);
Builder builder; Builder builder;
@ -665,6 +679,15 @@ public class ApiClient {
} }
} }
for (Entry<String, String> keyValue : cookieParams.entrySet()) {
builder = builder.cookie(new Cookie(keyValue.getKey(), keyValue.getValue()));
}
for (Map.Entry<String,String> keyValue : defaultCookieMap.entrySet()) {
if (!cookieParams.containsKey(keyValue.getKey())) {
builder = builder.cookie(new Cookie(keyValue.getKey(), keyValue.getValue()));
}
}
ClientResponse response = null; ClientResponse response = null;
if ("GET".equals(method)) { if ("GET".equals(method)) {
@ -695,6 +718,7 @@ public class ApiClient {
* @param collectionQueryParams The collection query parameters * @param collectionQueryParams The collection query parameters
* @param body The request body object - if it is not binary, otherwise null * @param body The request body object - if it is not binary, otherwise null
* @param headerParams The header parameters * @param headerParams The header parameters
* @param cookieParams The cookie parameters
* @param formParams The form parameters * @param formParams The form parameters
* @param accept The request's Accept header * @param accept The request's Accept header
* @param contentType The request's Content-Type header * @param contentType The request's Content-Type header
@ -703,9 +727,9 @@ public class ApiClient {
* @return The response body in type of string * @return The response body in type of string
* @throws ApiException API exception * @throws ApiException API exception
*/ */
public <T> T invokeAPI(String path, String method, List<Pair> queryParams, List<Pair> collectionQueryParams, Object body, Map<String, String> headerParams, Map<String, Object> formParams, String accept, String contentType, String[] authNames, GenericType<T> returnType) throws ApiException { public <T> T invokeAPI(String path, String method, List<Pair> queryParams, List<Pair> collectionQueryParams, Object body, Map<String, String> headerParams, Map<String, String> cookieParams, Map<String, Object> formParams, String accept, String contentType, String[] authNames, GenericType<T> returnType) throws ApiException {
ClientResponse response = getAPIResponse(path, method, queryParams, collectionQueryParams, body, headerParams, formParams, accept, contentType, authNames); ClientResponse response = getAPIResponse(path, method, queryParams, collectionQueryParams, body, headerParams, cookieParams, formParams, accept, contentType, authNames);
statusCode = response.getStatusInfo().getStatusCode(); statusCode = response.getStatusInfo().getStatusCode();
responseHeaders = response.getHeaders(); responseHeaders = response.getHeaders();
@ -742,12 +766,13 @@ public class ApiClient {
* @param authNames The authentications to apply * @param authNames The authentications to apply
* @param queryParams Query parameters * @param queryParams Query parameters
* @param headerParams Header parameters * @param headerParams Header parameters
* @param cookieParams Cookie parameters
*/ */
private void updateParamsForAuth(String[] authNames, List<Pair> queryParams, Map<String, String> headerParams) { private void updateParamsForAuth(String[] authNames, List<Pair> queryParams, Map<String, String> headerParams, Map<String, String> cookieParams) {
for (String authName : authNames) { for (String authName : authNames) {
Authentication auth = authentications.get(authName); Authentication auth = authentications.get(authName);
if (auth == null) throw new RuntimeException("Authentication undefined: " + authName); if (auth == null) throw new RuntimeException("Authentication undefined: " + authName);
auth.applyToParams(queryParams, headerParams); auth.applyToParams(queryParams, headerParams, cookieParams);
} }
} }

View File

@ -70,11 +70,13 @@ public class AnotherFakeApi {
List<Pair> localVarQueryParams = new ArrayList<Pair>(); List<Pair> localVarQueryParams = new ArrayList<Pair>();
List<Pair> localVarCollectionQueryParams = new ArrayList<Pair>(); List<Pair> localVarCollectionQueryParams = new ArrayList<Pair>();
Map<String, String> localVarHeaderParams = new HashMap<String, String>(); Map<String, String> localVarHeaderParams = new HashMap<String, String>();
Map<String, String> localVarCookieParams = new HashMap<String, String>();
Map<String, Object> localVarFormParams = new HashMap<String, Object>(); Map<String, Object> localVarFormParams = new HashMap<String, Object>();
final String[] localVarAccepts = { final String[] localVarAccepts = {
"application/json" "application/json"
}; };
@ -88,6 +90,6 @@ public class AnotherFakeApi {
String[] localVarAuthNames = new String[] { }; String[] localVarAuthNames = new String[] { };
GenericType<Client> localVarReturnType = new GenericType<Client>() {}; GenericType<Client> localVarReturnType = new GenericType<Client>() {};
return apiClient.invokeAPI(localVarPath, "PATCH", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, localVarReturnType); return apiClient.invokeAPI(localVarPath, "PATCH", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, localVarReturnType);
} }
} }

View File

@ -77,11 +77,13 @@ public class FakeApi {
List<Pair> localVarQueryParams = new ArrayList<Pair>(); List<Pair> localVarQueryParams = new ArrayList<Pair>();
List<Pair> localVarCollectionQueryParams = new ArrayList<Pair>(); List<Pair> localVarCollectionQueryParams = new ArrayList<Pair>();
Map<String, String> localVarHeaderParams = new HashMap<String, String>(); Map<String, String> localVarHeaderParams = new HashMap<String, String>();
Map<String, String> localVarCookieParams = new HashMap<String, String>();
Map<String, Object> localVarFormParams = new HashMap<String, Object>(); Map<String, Object> localVarFormParams = new HashMap<String, Object>();
final String[] localVarAccepts = { final String[] localVarAccepts = {
}; };
@ -95,7 +97,7 @@ public class FakeApi {
String[] localVarAuthNames = new String[] { }; String[] localVarAuthNames = new String[] { };
apiClient.invokeAPI(localVarPath, "POST", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, null); apiClient.invokeAPI(localVarPath, "POST", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, null);
} }
/** /**
* *
@ -114,11 +116,13 @@ public class FakeApi {
List<Pair> localVarQueryParams = new ArrayList<Pair>(); List<Pair> localVarQueryParams = new ArrayList<Pair>();
List<Pair> localVarCollectionQueryParams = new ArrayList<Pair>(); List<Pair> localVarCollectionQueryParams = new ArrayList<Pair>();
Map<String, String> localVarHeaderParams = new HashMap<String, String>(); Map<String, String> localVarHeaderParams = new HashMap<String, String>();
Map<String, String> localVarCookieParams = new HashMap<String, String>();
Map<String, Object> localVarFormParams = new HashMap<String, Object>(); Map<String, Object> localVarFormParams = new HashMap<String, Object>();
final String[] localVarAccepts = { final String[] localVarAccepts = {
"*/*" "*/*"
}; };
@ -132,7 +136,7 @@ public class FakeApi {
String[] localVarAuthNames = new String[] { }; String[] localVarAuthNames = new String[] { };
GenericType<Boolean> localVarReturnType = new GenericType<Boolean>() {}; GenericType<Boolean> localVarReturnType = new GenericType<Boolean>() {};
return apiClient.invokeAPI(localVarPath, "POST", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, localVarReturnType); return apiClient.invokeAPI(localVarPath, "POST", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, localVarReturnType);
} }
/** /**
* *
@ -151,11 +155,13 @@ public class FakeApi {
List<Pair> localVarQueryParams = new ArrayList<Pair>(); List<Pair> localVarQueryParams = new ArrayList<Pair>();
List<Pair> localVarCollectionQueryParams = new ArrayList<Pair>(); List<Pair> localVarCollectionQueryParams = new ArrayList<Pair>();
Map<String, String> localVarHeaderParams = new HashMap<String, String>(); Map<String, String> localVarHeaderParams = new HashMap<String, String>();
Map<String, String> localVarCookieParams = new HashMap<String, String>();
Map<String, Object> localVarFormParams = new HashMap<String, Object>(); Map<String, Object> localVarFormParams = new HashMap<String, Object>();
final String[] localVarAccepts = { final String[] localVarAccepts = {
"*/*" "*/*"
}; };
@ -169,7 +175,7 @@ public class FakeApi {
String[] localVarAuthNames = new String[] { }; String[] localVarAuthNames = new String[] { };
GenericType<OuterComposite> localVarReturnType = new GenericType<OuterComposite>() {}; GenericType<OuterComposite> localVarReturnType = new GenericType<OuterComposite>() {};
return apiClient.invokeAPI(localVarPath, "POST", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, localVarReturnType); return apiClient.invokeAPI(localVarPath, "POST", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, localVarReturnType);
} }
/** /**
* *
@ -188,11 +194,13 @@ public class FakeApi {
List<Pair> localVarQueryParams = new ArrayList<Pair>(); List<Pair> localVarQueryParams = new ArrayList<Pair>();
List<Pair> localVarCollectionQueryParams = new ArrayList<Pair>(); List<Pair> localVarCollectionQueryParams = new ArrayList<Pair>();
Map<String, String> localVarHeaderParams = new HashMap<String, String>(); Map<String, String> localVarHeaderParams = new HashMap<String, String>();
Map<String, String> localVarCookieParams = new HashMap<String, String>();
Map<String, Object> localVarFormParams = new HashMap<String, Object>(); Map<String, Object> localVarFormParams = new HashMap<String, Object>();
final String[] localVarAccepts = { final String[] localVarAccepts = {
"*/*" "*/*"
}; };
@ -206,7 +214,7 @@ public class FakeApi {
String[] localVarAuthNames = new String[] { }; String[] localVarAuthNames = new String[] { };
GenericType<BigDecimal> localVarReturnType = new GenericType<BigDecimal>() {}; GenericType<BigDecimal> localVarReturnType = new GenericType<BigDecimal>() {};
return apiClient.invokeAPI(localVarPath, "POST", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, localVarReturnType); return apiClient.invokeAPI(localVarPath, "POST", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, localVarReturnType);
} }
/** /**
* *
@ -225,11 +233,13 @@ public class FakeApi {
List<Pair> localVarQueryParams = new ArrayList<Pair>(); List<Pair> localVarQueryParams = new ArrayList<Pair>();
List<Pair> localVarCollectionQueryParams = new ArrayList<Pair>(); List<Pair> localVarCollectionQueryParams = new ArrayList<Pair>();
Map<String, String> localVarHeaderParams = new HashMap<String, String>(); Map<String, String> localVarHeaderParams = new HashMap<String, String>();
Map<String, String> localVarCookieParams = new HashMap<String, String>();
Map<String, Object> localVarFormParams = new HashMap<String, Object>(); Map<String, Object> localVarFormParams = new HashMap<String, Object>();
final String[] localVarAccepts = { final String[] localVarAccepts = {
"*/*" "*/*"
}; };
@ -243,7 +253,7 @@ public class FakeApi {
String[] localVarAuthNames = new String[] { }; String[] localVarAuthNames = new String[] { };
GenericType<String> localVarReturnType = new GenericType<String>() {}; GenericType<String> localVarReturnType = new GenericType<String>() {};
return apiClient.invokeAPI(localVarPath, "POST", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, localVarReturnType); return apiClient.invokeAPI(localVarPath, "POST", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, localVarReturnType);
} }
/** /**
* *
@ -266,11 +276,13 @@ public class FakeApi {
List<Pair> localVarQueryParams = new ArrayList<Pair>(); List<Pair> localVarQueryParams = new ArrayList<Pair>();
List<Pair> localVarCollectionQueryParams = new ArrayList<Pair>(); List<Pair> localVarCollectionQueryParams = new ArrayList<Pair>();
Map<String, String> localVarHeaderParams = new HashMap<String, String>(); Map<String, String> localVarHeaderParams = new HashMap<String, String>();
Map<String, String> localVarCookieParams = new HashMap<String, String>();
Map<String, Object> localVarFormParams = new HashMap<String, Object>(); Map<String, Object> localVarFormParams = new HashMap<String, Object>();
final String[] localVarAccepts = { final String[] localVarAccepts = {
}; };
@ -284,7 +296,7 @@ public class FakeApi {
String[] localVarAuthNames = new String[] { }; String[] localVarAuthNames = new String[] { };
apiClient.invokeAPI(localVarPath, "PUT", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, null); apiClient.invokeAPI(localVarPath, "PUT", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, null);
} }
/** /**
* *
@ -313,12 +325,14 @@ public class FakeApi {
List<Pair> localVarQueryParams = new ArrayList<Pair>(); List<Pair> localVarQueryParams = new ArrayList<Pair>();
List<Pair> localVarCollectionQueryParams = new ArrayList<Pair>(); List<Pair> localVarCollectionQueryParams = new ArrayList<Pair>();
Map<String, String> localVarHeaderParams = new HashMap<String, String>(); Map<String, String> localVarHeaderParams = new HashMap<String, String>();
Map<String, String> localVarCookieParams = new HashMap<String, String>();
Map<String, Object> localVarFormParams = new HashMap<String, Object>(); Map<String, Object> localVarFormParams = new HashMap<String, Object>();
localVarQueryParams.addAll(apiClient.parameterToPair("query", query)); localVarQueryParams.addAll(apiClient.parameterToPair("query", query));
final String[] localVarAccepts = { final String[] localVarAccepts = {
}; };
@ -332,7 +346,7 @@ public class FakeApi {
String[] localVarAuthNames = new String[] { }; String[] localVarAuthNames = new String[] { };
apiClient.invokeAPI(localVarPath, "PUT", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, null); apiClient.invokeAPI(localVarPath, "PUT", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, null);
} }
/** /**
* To test \&quot;client\&quot; model * To test \&quot;client\&quot; model
@ -356,11 +370,13 @@ public class FakeApi {
List<Pair> localVarQueryParams = new ArrayList<Pair>(); List<Pair> localVarQueryParams = new ArrayList<Pair>();
List<Pair> localVarCollectionQueryParams = new ArrayList<Pair>(); List<Pair> localVarCollectionQueryParams = new ArrayList<Pair>();
Map<String, String> localVarHeaderParams = new HashMap<String, String>(); Map<String, String> localVarHeaderParams = new HashMap<String, String>();
Map<String, String> localVarCookieParams = new HashMap<String, String>();
Map<String, Object> localVarFormParams = new HashMap<String, Object>(); Map<String, Object> localVarFormParams = new HashMap<String, Object>();
final String[] localVarAccepts = { final String[] localVarAccepts = {
"application/json" "application/json"
}; };
@ -374,7 +390,7 @@ public class FakeApi {
String[] localVarAuthNames = new String[] { }; String[] localVarAuthNames = new String[] { };
GenericType<Client> localVarReturnType = new GenericType<Client>() {}; GenericType<Client> localVarReturnType = new GenericType<Client>() {};
return apiClient.invokeAPI(localVarPath, "PATCH", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, localVarReturnType); return apiClient.invokeAPI(localVarPath, "PATCH", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, localVarReturnType);
} }
/** /**
* Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 * Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트
@ -425,10 +441,12 @@ public class FakeApi {
List<Pair> localVarQueryParams = new ArrayList<Pair>(); List<Pair> localVarQueryParams = new ArrayList<Pair>();
List<Pair> localVarCollectionQueryParams = new ArrayList<Pair>(); List<Pair> localVarCollectionQueryParams = new ArrayList<Pair>();
Map<String, String> localVarHeaderParams = new HashMap<String, String>(); Map<String, String> localVarHeaderParams = new HashMap<String, String>();
Map<String, String> localVarCookieParams = new HashMap<String, String>();
Map<String, Object> localVarFormParams = new HashMap<String, Object>(); Map<String, Object> localVarFormParams = new HashMap<String, Object>();
if (integer != null) if (integer != null)
localVarFormParams.put("integer", integer); localVarFormParams.put("integer", integer);
if (int32 != null) if (int32 != null)
@ -471,7 +489,7 @@ if (paramCallback != null)
String[] localVarAuthNames = new String[] { "http_basic_test" }; String[] localVarAuthNames = new String[] { "http_basic_test" };
apiClient.invokeAPI(localVarPath, "POST", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, null); apiClient.invokeAPI(localVarPath, "POST", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, null);
} }
/** /**
* To test enum parameters * To test enum parameters
@ -496,6 +514,7 @@ if (paramCallback != null)
List<Pair> localVarQueryParams = new ArrayList<Pair>(); List<Pair> localVarQueryParams = new ArrayList<Pair>();
List<Pair> localVarCollectionQueryParams = new ArrayList<Pair>(); List<Pair> localVarCollectionQueryParams = new ArrayList<Pair>();
Map<String, String> localVarHeaderParams = new HashMap<String, String>(); Map<String, String> localVarHeaderParams = new HashMap<String, String>();
Map<String, String> localVarCookieParams = new HashMap<String, String>();
Map<String, Object> localVarFormParams = new HashMap<String, Object>(); Map<String, Object> localVarFormParams = new HashMap<String, Object>();
localVarCollectionQueryParams.addAll(apiClient.parameterToPairs("csv", "enum_query_string_array", enumQueryStringArray)); localVarCollectionQueryParams.addAll(apiClient.parameterToPairs("csv", "enum_query_string_array", enumQueryStringArray));
@ -508,6 +527,7 @@ if (paramCallback != null)
if (enumHeaderString != null) if (enumHeaderString != null)
localVarHeaderParams.put("enum_header_string", apiClient.parameterToString(enumHeaderString)); localVarHeaderParams.put("enum_header_string", apiClient.parameterToString(enumHeaderString));
if (enumFormStringArray != null) if (enumFormStringArray != null)
localVarFormParams.put("enum_form_string_array", enumFormStringArray); localVarFormParams.put("enum_form_string_array", enumFormStringArray);
if (enumFormString != null) if (enumFormString != null)
@ -526,7 +546,7 @@ if (enumFormString != null)
String[] localVarAuthNames = new String[] { }; String[] localVarAuthNames = new String[] { };
apiClient.invokeAPI(localVarPath, "GET", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, null); apiClient.invokeAPI(localVarPath, "GET", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, null);
} }
/** /**
* Fake endpoint to test group parameters (optional) * Fake endpoint to test group parameters (optional)
@ -564,6 +584,7 @@ if (enumFormString != null)
List<Pair> localVarQueryParams = new ArrayList<Pair>(); List<Pair> localVarQueryParams = new ArrayList<Pair>();
List<Pair> localVarCollectionQueryParams = new ArrayList<Pair>(); List<Pair> localVarCollectionQueryParams = new ArrayList<Pair>();
Map<String, String> localVarHeaderParams = new HashMap<String, String>(); Map<String, String> localVarHeaderParams = new HashMap<String, String>();
Map<String, String> localVarCookieParams = new HashMap<String, String>();
Map<String, Object> localVarFormParams = new HashMap<String, Object>(); Map<String, Object> localVarFormParams = new HashMap<String, Object>();
localVarQueryParams.addAll(apiClient.parameterToPair("required_string_group", requiredStringGroup)); localVarQueryParams.addAll(apiClient.parameterToPair("required_string_group", requiredStringGroup));
@ -577,6 +598,7 @@ if (booleanGroup != null)
localVarHeaderParams.put("boolean_group", apiClient.parameterToString(booleanGroup)); localVarHeaderParams.put("boolean_group", apiClient.parameterToString(booleanGroup));
final String[] localVarAccepts = { final String[] localVarAccepts = {
}; };
@ -590,7 +612,7 @@ if (booleanGroup != null)
String[] localVarAuthNames = new String[] { }; String[] localVarAuthNames = new String[] { };
apiClient.invokeAPI(localVarPath, "DELETE", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, null); apiClient.invokeAPI(localVarPath, "DELETE", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, null);
} }
/** /**
* test inline additionalProperties * test inline additionalProperties
@ -613,11 +635,13 @@ if (booleanGroup != null)
List<Pair> localVarQueryParams = new ArrayList<Pair>(); List<Pair> localVarQueryParams = new ArrayList<Pair>();
List<Pair> localVarCollectionQueryParams = new ArrayList<Pair>(); List<Pair> localVarCollectionQueryParams = new ArrayList<Pair>();
Map<String, String> localVarHeaderParams = new HashMap<String, String>(); Map<String, String> localVarHeaderParams = new HashMap<String, String>();
Map<String, String> localVarCookieParams = new HashMap<String, String>();
Map<String, Object> localVarFormParams = new HashMap<String, Object>(); Map<String, Object> localVarFormParams = new HashMap<String, Object>();
final String[] localVarAccepts = { final String[] localVarAccepts = {
}; };
@ -631,7 +655,7 @@ if (booleanGroup != null)
String[] localVarAuthNames = new String[] { }; String[] localVarAuthNames = new String[] { };
apiClient.invokeAPI(localVarPath, "POST", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, null); apiClient.invokeAPI(localVarPath, "POST", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, null);
} }
/** /**
* test json serialization of form data * test json serialization of form data
@ -660,10 +684,12 @@ if (booleanGroup != null)
List<Pair> localVarQueryParams = new ArrayList<Pair>(); List<Pair> localVarQueryParams = new ArrayList<Pair>();
List<Pair> localVarCollectionQueryParams = new ArrayList<Pair>(); List<Pair> localVarCollectionQueryParams = new ArrayList<Pair>();
Map<String, String> localVarHeaderParams = new HashMap<String, String>(); Map<String, String> localVarHeaderParams = new HashMap<String, String>();
Map<String, String> localVarCookieParams = new HashMap<String, String>();
Map<String, Object> localVarFormParams = new HashMap<String, Object>(); Map<String, Object> localVarFormParams = new HashMap<String, Object>();
if (param != null) if (param != null)
localVarFormParams.put("param", param); localVarFormParams.put("param", param);
if (param2 != null) if (param2 != null)
@ -682,7 +708,7 @@ if (param2 != null)
String[] localVarAuthNames = new String[] { }; String[] localVarAuthNames = new String[] { };
apiClient.invokeAPI(localVarPath, "GET", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, null); apiClient.invokeAPI(localVarPath, "GET", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, null);
} }
/** /**
* *
@ -729,6 +755,7 @@ if (param2 != null)
List<Pair> localVarQueryParams = new ArrayList<Pair>(); List<Pair> localVarQueryParams = new ArrayList<Pair>();
List<Pair> localVarCollectionQueryParams = new ArrayList<Pair>(); List<Pair> localVarCollectionQueryParams = new ArrayList<Pair>();
Map<String, String> localVarHeaderParams = new HashMap<String, String>(); Map<String, String> localVarHeaderParams = new HashMap<String, String>();
Map<String, String> localVarCookieParams = new HashMap<String, String>();
Map<String, Object> localVarFormParams = new HashMap<String, Object>(); Map<String, Object> localVarFormParams = new HashMap<String, Object>();
localVarCollectionQueryParams.addAll(apiClient.parameterToPairs("csv", "pipe", pipe)); localVarCollectionQueryParams.addAll(apiClient.parameterToPairs("csv", "pipe", pipe));
@ -739,6 +766,7 @@ if (param2 != null)
final String[] localVarAccepts = { final String[] localVarAccepts = {
}; };
@ -752,6 +780,6 @@ if (param2 != null)
String[] localVarAuthNames = new String[] { }; String[] localVarAuthNames = new String[] { };
apiClient.invokeAPI(localVarPath, "PUT", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, null); apiClient.invokeAPI(localVarPath, "PUT", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, null);
} }
} }

View File

@ -70,11 +70,13 @@ public class FakeClassnameTags123Api {
List<Pair> localVarQueryParams = new ArrayList<Pair>(); List<Pair> localVarQueryParams = new ArrayList<Pair>();
List<Pair> localVarCollectionQueryParams = new ArrayList<Pair>(); List<Pair> localVarCollectionQueryParams = new ArrayList<Pair>();
Map<String, String> localVarHeaderParams = new HashMap<String, String>(); Map<String, String> localVarHeaderParams = new HashMap<String, String>();
Map<String, String> localVarCookieParams = new HashMap<String, String>();
Map<String, Object> localVarFormParams = new HashMap<String, Object>(); Map<String, Object> localVarFormParams = new HashMap<String, Object>();
final String[] localVarAccepts = { final String[] localVarAccepts = {
"application/json" "application/json"
}; };
@ -88,6 +90,6 @@ public class FakeClassnameTags123Api {
String[] localVarAuthNames = new String[] { "api_key_query" }; String[] localVarAuthNames = new String[] { "api_key_query" };
GenericType<Client> localVarReturnType = new GenericType<Client>() {}; GenericType<Client> localVarReturnType = new GenericType<Client>() {};
return apiClient.invokeAPI(localVarPath, "PATCH", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, localVarReturnType); return apiClient.invokeAPI(localVarPath, "PATCH", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, localVarReturnType);
} }
} }

View File

@ -71,11 +71,13 @@ public class PetApi {
List<Pair> localVarQueryParams = new ArrayList<Pair>(); List<Pair> localVarQueryParams = new ArrayList<Pair>();
List<Pair> localVarCollectionQueryParams = new ArrayList<Pair>(); List<Pair> localVarCollectionQueryParams = new ArrayList<Pair>();
Map<String, String> localVarHeaderParams = new HashMap<String, String>(); Map<String, String> localVarHeaderParams = new HashMap<String, String>();
Map<String, String> localVarCookieParams = new HashMap<String, String>();
Map<String, Object> localVarFormParams = new HashMap<String, Object>(); Map<String, Object> localVarFormParams = new HashMap<String, Object>();
final String[] localVarAccepts = { final String[] localVarAccepts = {
}; };
@ -89,7 +91,7 @@ public class PetApi {
String[] localVarAuthNames = new String[] { "petstore_auth" }; String[] localVarAuthNames = new String[] { "petstore_auth" };
apiClient.invokeAPI(localVarPath, "POST", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, null); apiClient.invokeAPI(localVarPath, "POST", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, null);
} }
/** /**
* Deletes a pet * Deletes a pet
@ -114,6 +116,7 @@ public class PetApi {
List<Pair> localVarQueryParams = new ArrayList<Pair>(); List<Pair> localVarQueryParams = new ArrayList<Pair>();
List<Pair> localVarCollectionQueryParams = new ArrayList<Pair>(); List<Pair> localVarCollectionQueryParams = new ArrayList<Pair>();
Map<String, String> localVarHeaderParams = new HashMap<String, String>(); Map<String, String> localVarHeaderParams = new HashMap<String, String>();
Map<String, String> localVarCookieParams = new HashMap<String, String>();
Map<String, Object> localVarFormParams = new HashMap<String, Object>(); Map<String, Object> localVarFormParams = new HashMap<String, Object>();
@ -121,6 +124,7 @@ public class PetApi {
localVarHeaderParams.put("api_key", apiClient.parameterToString(apiKey)); localVarHeaderParams.put("api_key", apiClient.parameterToString(apiKey));
final String[] localVarAccepts = { final String[] localVarAccepts = {
}; };
@ -134,7 +138,7 @@ public class PetApi {
String[] localVarAuthNames = new String[] { "petstore_auth" }; String[] localVarAuthNames = new String[] { "petstore_auth" };
apiClient.invokeAPI(localVarPath, "DELETE", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, null); apiClient.invokeAPI(localVarPath, "DELETE", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, null);
} }
/** /**
* Finds Pets by status * Finds Pets by status
@ -158,12 +162,14 @@ public class PetApi {
List<Pair> localVarQueryParams = new ArrayList<Pair>(); List<Pair> localVarQueryParams = new ArrayList<Pair>();
List<Pair> localVarCollectionQueryParams = new ArrayList<Pair>(); List<Pair> localVarCollectionQueryParams = new ArrayList<Pair>();
Map<String, String> localVarHeaderParams = new HashMap<String, String>(); Map<String, String> localVarHeaderParams = new HashMap<String, String>();
Map<String, String> localVarCookieParams = new HashMap<String, String>();
Map<String, Object> localVarFormParams = new HashMap<String, Object>(); Map<String, Object> localVarFormParams = new HashMap<String, Object>();
localVarCollectionQueryParams.addAll(apiClient.parameterToPairs("csv", "status", status)); localVarCollectionQueryParams.addAll(apiClient.parameterToPairs("csv", "status", status));
final String[] localVarAccepts = { final String[] localVarAccepts = {
"application/xml", "application/json" "application/xml", "application/json"
}; };
@ -177,7 +183,7 @@ public class PetApi {
String[] localVarAuthNames = new String[] { "petstore_auth" }; String[] localVarAuthNames = new String[] { "petstore_auth" };
GenericType<List<Pet>> localVarReturnType = new GenericType<List<Pet>>() {}; GenericType<List<Pet>> localVarReturnType = new GenericType<List<Pet>>() {};
return apiClient.invokeAPI(localVarPath, "GET", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, localVarReturnType); return apiClient.invokeAPI(localVarPath, "GET", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, localVarReturnType);
} }
/** /**
* Finds Pets by tags * Finds Pets by tags
@ -203,12 +209,14 @@ public class PetApi {
List<Pair> localVarQueryParams = new ArrayList<Pair>(); List<Pair> localVarQueryParams = new ArrayList<Pair>();
List<Pair> localVarCollectionQueryParams = new ArrayList<Pair>(); List<Pair> localVarCollectionQueryParams = new ArrayList<Pair>();
Map<String, String> localVarHeaderParams = new HashMap<String, String>(); Map<String, String> localVarHeaderParams = new HashMap<String, String>();
Map<String, String> localVarCookieParams = new HashMap<String, String>();
Map<String, Object> localVarFormParams = new HashMap<String, Object>(); Map<String, Object> localVarFormParams = new HashMap<String, Object>();
localVarCollectionQueryParams.addAll(apiClient.parameterToPairs("csv", "tags", tags)); localVarCollectionQueryParams.addAll(apiClient.parameterToPairs("csv", "tags", tags));
final String[] localVarAccepts = { final String[] localVarAccepts = {
"application/xml", "application/json" "application/xml", "application/json"
}; };
@ -222,7 +230,7 @@ public class PetApi {
String[] localVarAuthNames = new String[] { "petstore_auth" }; String[] localVarAuthNames = new String[] { "petstore_auth" };
GenericType<List<Pet>> localVarReturnType = new GenericType<List<Pet>>() {}; GenericType<List<Pet>> localVarReturnType = new GenericType<List<Pet>>() {};
return apiClient.invokeAPI(localVarPath, "GET", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, localVarReturnType); return apiClient.invokeAPI(localVarPath, "GET", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, localVarReturnType);
} }
/** /**
* Find pet by ID * Find pet by ID
@ -247,11 +255,13 @@ public class PetApi {
List<Pair> localVarQueryParams = new ArrayList<Pair>(); List<Pair> localVarQueryParams = new ArrayList<Pair>();
List<Pair> localVarCollectionQueryParams = new ArrayList<Pair>(); List<Pair> localVarCollectionQueryParams = new ArrayList<Pair>();
Map<String, String> localVarHeaderParams = new HashMap<String, String>(); Map<String, String> localVarHeaderParams = new HashMap<String, String>();
Map<String, String> localVarCookieParams = new HashMap<String, String>();
Map<String, Object> localVarFormParams = new HashMap<String, Object>(); Map<String, Object> localVarFormParams = new HashMap<String, Object>();
final String[] localVarAccepts = { final String[] localVarAccepts = {
"application/xml", "application/json" "application/xml", "application/json"
}; };
@ -265,7 +275,7 @@ public class PetApi {
String[] localVarAuthNames = new String[] { "api_key" }; String[] localVarAuthNames = new String[] { "api_key" };
GenericType<Pet> localVarReturnType = new GenericType<Pet>() {}; GenericType<Pet> localVarReturnType = new GenericType<Pet>() {};
return apiClient.invokeAPI(localVarPath, "GET", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, localVarReturnType); return apiClient.invokeAPI(localVarPath, "GET", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, localVarReturnType);
} }
/** /**
* Update an existing pet * Update an existing pet
@ -288,11 +298,13 @@ public class PetApi {
List<Pair> localVarQueryParams = new ArrayList<Pair>(); List<Pair> localVarQueryParams = new ArrayList<Pair>();
List<Pair> localVarCollectionQueryParams = new ArrayList<Pair>(); List<Pair> localVarCollectionQueryParams = new ArrayList<Pair>();
Map<String, String> localVarHeaderParams = new HashMap<String, String>(); Map<String, String> localVarHeaderParams = new HashMap<String, String>();
Map<String, String> localVarCookieParams = new HashMap<String, String>();
Map<String, Object> localVarFormParams = new HashMap<String, Object>(); Map<String, Object> localVarFormParams = new HashMap<String, Object>();
final String[] localVarAccepts = { final String[] localVarAccepts = {
}; };
@ -306,7 +318,7 @@ public class PetApi {
String[] localVarAuthNames = new String[] { "petstore_auth" }; String[] localVarAuthNames = new String[] { "petstore_auth" };
apiClient.invokeAPI(localVarPath, "PUT", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, null); apiClient.invokeAPI(localVarPath, "PUT", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, null);
} }
/** /**
* Updates a pet in the store with form data * Updates a pet in the store with form data
@ -332,10 +344,12 @@ public class PetApi {
List<Pair> localVarQueryParams = new ArrayList<Pair>(); List<Pair> localVarQueryParams = new ArrayList<Pair>();
List<Pair> localVarCollectionQueryParams = new ArrayList<Pair>(); List<Pair> localVarCollectionQueryParams = new ArrayList<Pair>();
Map<String, String> localVarHeaderParams = new HashMap<String, String>(); Map<String, String> localVarHeaderParams = new HashMap<String, String>();
Map<String, String> localVarCookieParams = new HashMap<String, String>();
Map<String, Object> localVarFormParams = new HashMap<String, Object>(); Map<String, Object> localVarFormParams = new HashMap<String, Object>();
if (name != null) if (name != null)
localVarFormParams.put("name", name); localVarFormParams.put("name", name);
if (status != null) if (status != null)
@ -354,7 +368,7 @@ if (status != null)
String[] localVarAuthNames = new String[] { "petstore_auth" }; String[] localVarAuthNames = new String[] { "petstore_auth" };
apiClient.invokeAPI(localVarPath, "POST", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, null); apiClient.invokeAPI(localVarPath, "POST", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, null);
} }
/** /**
* uploads an image * uploads an image
@ -381,10 +395,12 @@ if (status != null)
List<Pair> localVarQueryParams = new ArrayList<Pair>(); List<Pair> localVarQueryParams = new ArrayList<Pair>();
List<Pair> localVarCollectionQueryParams = new ArrayList<Pair>(); List<Pair> localVarCollectionQueryParams = new ArrayList<Pair>();
Map<String, String> localVarHeaderParams = new HashMap<String, String>(); Map<String, String> localVarHeaderParams = new HashMap<String, String>();
Map<String, String> localVarCookieParams = new HashMap<String, String>();
Map<String, Object> localVarFormParams = new HashMap<String, Object>(); Map<String, Object> localVarFormParams = new HashMap<String, Object>();
if (additionalMetadata != null) if (additionalMetadata != null)
localVarFormParams.put("additionalMetadata", additionalMetadata); localVarFormParams.put("additionalMetadata", additionalMetadata);
if (file != null) if (file != null)
@ -403,7 +419,7 @@ if (file != null)
String[] localVarAuthNames = new String[] { "petstore_auth" }; String[] localVarAuthNames = new String[] { "petstore_auth" };
GenericType<ModelApiResponse> localVarReturnType = new GenericType<ModelApiResponse>() {}; GenericType<ModelApiResponse> localVarReturnType = new GenericType<ModelApiResponse>() {};
return apiClient.invokeAPI(localVarPath, "POST", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, localVarReturnType); return apiClient.invokeAPI(localVarPath, "POST", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, localVarReturnType);
} }
/** /**
* uploads an image (required) * uploads an image (required)
@ -435,10 +451,12 @@ if (file != null)
List<Pair> localVarQueryParams = new ArrayList<Pair>(); List<Pair> localVarQueryParams = new ArrayList<Pair>();
List<Pair> localVarCollectionQueryParams = new ArrayList<Pair>(); List<Pair> localVarCollectionQueryParams = new ArrayList<Pair>();
Map<String, String> localVarHeaderParams = new HashMap<String, String>(); Map<String, String> localVarHeaderParams = new HashMap<String, String>();
Map<String, String> localVarCookieParams = new HashMap<String, String>();
Map<String, Object> localVarFormParams = new HashMap<String, Object>(); Map<String, Object> localVarFormParams = new HashMap<String, Object>();
if (additionalMetadata != null) if (additionalMetadata != null)
localVarFormParams.put("additionalMetadata", additionalMetadata); localVarFormParams.put("additionalMetadata", additionalMetadata);
if (requiredFile != null) if (requiredFile != null)
@ -457,6 +475,6 @@ if (requiredFile != null)
String[] localVarAuthNames = new String[] { "petstore_auth" }; String[] localVarAuthNames = new String[] { "petstore_auth" };
GenericType<ModelApiResponse> localVarReturnType = new GenericType<ModelApiResponse>() {}; GenericType<ModelApiResponse> localVarReturnType = new GenericType<ModelApiResponse>() {};
return apiClient.invokeAPI(localVarPath, "POST", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, localVarReturnType); return apiClient.invokeAPI(localVarPath, "POST", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, localVarReturnType);
} }
} }

View File

@ -70,11 +70,13 @@ public class StoreApi {
List<Pair> localVarQueryParams = new ArrayList<Pair>(); List<Pair> localVarQueryParams = new ArrayList<Pair>();
List<Pair> localVarCollectionQueryParams = new ArrayList<Pair>(); List<Pair> localVarCollectionQueryParams = new ArrayList<Pair>();
Map<String, String> localVarHeaderParams = new HashMap<String, String>(); Map<String, String> localVarHeaderParams = new HashMap<String, String>();
Map<String, String> localVarCookieParams = new HashMap<String, String>();
Map<String, Object> localVarFormParams = new HashMap<String, Object>(); Map<String, Object> localVarFormParams = new HashMap<String, Object>();
final String[] localVarAccepts = { final String[] localVarAccepts = {
}; };
@ -88,7 +90,7 @@ public class StoreApi {
String[] localVarAuthNames = new String[] { }; String[] localVarAuthNames = new String[] { };
apiClient.invokeAPI(localVarPath, "DELETE", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, null); apiClient.invokeAPI(localVarPath, "DELETE", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, null);
} }
/** /**
* Returns pet inventories by status * Returns pet inventories by status
@ -106,11 +108,13 @@ public class StoreApi {
List<Pair> localVarQueryParams = new ArrayList<Pair>(); List<Pair> localVarQueryParams = new ArrayList<Pair>();
List<Pair> localVarCollectionQueryParams = new ArrayList<Pair>(); List<Pair> localVarCollectionQueryParams = new ArrayList<Pair>();
Map<String, String> localVarHeaderParams = new HashMap<String, String>(); Map<String, String> localVarHeaderParams = new HashMap<String, String>();
Map<String, String> localVarCookieParams = new HashMap<String, String>();
Map<String, Object> localVarFormParams = new HashMap<String, Object>(); Map<String, Object> localVarFormParams = new HashMap<String, Object>();
final String[] localVarAccepts = { final String[] localVarAccepts = {
"application/json" "application/json"
}; };
@ -124,7 +128,7 @@ public class StoreApi {
String[] localVarAuthNames = new String[] { "api_key" }; String[] localVarAuthNames = new String[] { "api_key" };
GenericType<Map<String, Integer>> localVarReturnType = new GenericType<Map<String, Integer>>() {}; GenericType<Map<String, Integer>> localVarReturnType = new GenericType<Map<String, Integer>>() {};
return apiClient.invokeAPI(localVarPath, "GET", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, localVarReturnType); return apiClient.invokeAPI(localVarPath, "GET", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, localVarReturnType);
} }
/** /**
* Find purchase order by ID * Find purchase order by ID
@ -149,11 +153,13 @@ public class StoreApi {
List<Pair> localVarQueryParams = new ArrayList<Pair>(); List<Pair> localVarQueryParams = new ArrayList<Pair>();
List<Pair> localVarCollectionQueryParams = new ArrayList<Pair>(); List<Pair> localVarCollectionQueryParams = new ArrayList<Pair>();
Map<String, String> localVarHeaderParams = new HashMap<String, String>(); Map<String, String> localVarHeaderParams = new HashMap<String, String>();
Map<String, String> localVarCookieParams = new HashMap<String, String>();
Map<String, Object> localVarFormParams = new HashMap<String, Object>(); Map<String, Object> localVarFormParams = new HashMap<String, Object>();
final String[] localVarAccepts = { final String[] localVarAccepts = {
"application/xml", "application/json" "application/xml", "application/json"
}; };
@ -167,7 +173,7 @@ public class StoreApi {
String[] localVarAuthNames = new String[] { }; String[] localVarAuthNames = new String[] { };
GenericType<Order> localVarReturnType = new GenericType<Order>() {}; GenericType<Order> localVarReturnType = new GenericType<Order>() {};
return apiClient.invokeAPI(localVarPath, "GET", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, localVarReturnType); return apiClient.invokeAPI(localVarPath, "GET", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, localVarReturnType);
} }
/** /**
* Place an order for a pet * Place an order for a pet
@ -191,11 +197,13 @@ public class StoreApi {
List<Pair> localVarQueryParams = new ArrayList<Pair>(); List<Pair> localVarQueryParams = new ArrayList<Pair>();
List<Pair> localVarCollectionQueryParams = new ArrayList<Pair>(); List<Pair> localVarCollectionQueryParams = new ArrayList<Pair>();
Map<String, String> localVarHeaderParams = new HashMap<String, String>(); Map<String, String> localVarHeaderParams = new HashMap<String, String>();
Map<String, String> localVarCookieParams = new HashMap<String, String>();
Map<String, Object> localVarFormParams = new HashMap<String, Object>(); Map<String, Object> localVarFormParams = new HashMap<String, Object>();
final String[] localVarAccepts = { final String[] localVarAccepts = {
"application/xml", "application/json" "application/xml", "application/json"
}; };
@ -209,6 +217,6 @@ public class StoreApi {
String[] localVarAuthNames = new String[] { }; String[] localVarAuthNames = new String[] { };
GenericType<Order> localVarReturnType = new GenericType<Order>() {}; GenericType<Order> localVarReturnType = new GenericType<Order>() {};
return apiClient.invokeAPI(localVarPath, "POST", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, localVarReturnType); return apiClient.invokeAPI(localVarPath, "POST", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, localVarReturnType);
} }
} }

View File

@ -69,11 +69,13 @@ public class UserApi {
List<Pair> localVarQueryParams = new ArrayList<Pair>(); List<Pair> localVarQueryParams = new ArrayList<Pair>();
List<Pair> localVarCollectionQueryParams = new ArrayList<Pair>(); List<Pair> localVarCollectionQueryParams = new ArrayList<Pair>();
Map<String, String> localVarHeaderParams = new HashMap<String, String>(); Map<String, String> localVarHeaderParams = new HashMap<String, String>();
Map<String, String> localVarCookieParams = new HashMap<String, String>();
Map<String, Object> localVarFormParams = new HashMap<String, Object>(); Map<String, Object> localVarFormParams = new HashMap<String, Object>();
final String[] localVarAccepts = { final String[] localVarAccepts = {
}; };
@ -87,7 +89,7 @@ public class UserApi {
String[] localVarAuthNames = new String[] { }; String[] localVarAuthNames = new String[] { };
apiClient.invokeAPI(localVarPath, "POST", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, null); apiClient.invokeAPI(localVarPath, "POST", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, null);
} }
/** /**
* Creates list of users with given input array * Creates list of users with given input array
@ -110,11 +112,13 @@ public class UserApi {
List<Pair> localVarQueryParams = new ArrayList<Pair>(); List<Pair> localVarQueryParams = new ArrayList<Pair>();
List<Pair> localVarCollectionQueryParams = new ArrayList<Pair>(); List<Pair> localVarCollectionQueryParams = new ArrayList<Pair>();
Map<String, String> localVarHeaderParams = new HashMap<String, String>(); Map<String, String> localVarHeaderParams = new HashMap<String, String>();
Map<String, String> localVarCookieParams = new HashMap<String, String>();
Map<String, Object> localVarFormParams = new HashMap<String, Object>(); Map<String, Object> localVarFormParams = new HashMap<String, Object>();
final String[] localVarAccepts = { final String[] localVarAccepts = {
}; };
@ -128,7 +132,7 @@ public class UserApi {
String[] localVarAuthNames = new String[] { }; String[] localVarAuthNames = new String[] { };
apiClient.invokeAPI(localVarPath, "POST", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, null); apiClient.invokeAPI(localVarPath, "POST", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, null);
} }
/** /**
* Creates list of users with given input array * Creates list of users with given input array
@ -151,11 +155,13 @@ public class UserApi {
List<Pair> localVarQueryParams = new ArrayList<Pair>(); List<Pair> localVarQueryParams = new ArrayList<Pair>();
List<Pair> localVarCollectionQueryParams = new ArrayList<Pair>(); List<Pair> localVarCollectionQueryParams = new ArrayList<Pair>();
Map<String, String> localVarHeaderParams = new HashMap<String, String>(); Map<String, String> localVarHeaderParams = new HashMap<String, String>();
Map<String, String> localVarCookieParams = new HashMap<String, String>();
Map<String, Object> localVarFormParams = new HashMap<String, Object>(); Map<String, Object> localVarFormParams = new HashMap<String, Object>();
final String[] localVarAccepts = { final String[] localVarAccepts = {
}; };
@ -169,7 +175,7 @@ public class UserApi {
String[] localVarAuthNames = new String[] { }; String[] localVarAuthNames = new String[] { };
apiClient.invokeAPI(localVarPath, "POST", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, null); apiClient.invokeAPI(localVarPath, "POST", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, null);
} }
/** /**
* Delete user * Delete user
@ -193,11 +199,13 @@ public class UserApi {
List<Pair> localVarQueryParams = new ArrayList<Pair>(); List<Pair> localVarQueryParams = new ArrayList<Pair>();
List<Pair> localVarCollectionQueryParams = new ArrayList<Pair>(); List<Pair> localVarCollectionQueryParams = new ArrayList<Pair>();
Map<String, String> localVarHeaderParams = new HashMap<String, String>(); Map<String, String> localVarHeaderParams = new HashMap<String, String>();
Map<String, String> localVarCookieParams = new HashMap<String, String>();
Map<String, Object> localVarFormParams = new HashMap<String, Object>(); Map<String, Object> localVarFormParams = new HashMap<String, Object>();
final String[] localVarAccepts = { final String[] localVarAccepts = {
}; };
@ -211,7 +219,7 @@ public class UserApi {
String[] localVarAuthNames = new String[] { }; String[] localVarAuthNames = new String[] { };
apiClient.invokeAPI(localVarPath, "DELETE", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, null); apiClient.invokeAPI(localVarPath, "DELETE", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, null);
} }
/** /**
* Get user by user name * Get user by user name
@ -236,11 +244,13 @@ public class UserApi {
List<Pair> localVarQueryParams = new ArrayList<Pair>(); List<Pair> localVarQueryParams = new ArrayList<Pair>();
List<Pair> localVarCollectionQueryParams = new ArrayList<Pair>(); List<Pair> localVarCollectionQueryParams = new ArrayList<Pair>();
Map<String, String> localVarHeaderParams = new HashMap<String, String>(); Map<String, String> localVarHeaderParams = new HashMap<String, String>();
Map<String, String> localVarCookieParams = new HashMap<String, String>();
Map<String, Object> localVarFormParams = new HashMap<String, Object>(); Map<String, Object> localVarFormParams = new HashMap<String, Object>();
final String[] localVarAccepts = { final String[] localVarAccepts = {
"application/xml", "application/json" "application/xml", "application/json"
}; };
@ -254,7 +264,7 @@ public class UserApi {
String[] localVarAuthNames = new String[] { }; String[] localVarAuthNames = new String[] { };
GenericType<User> localVarReturnType = new GenericType<User>() {}; GenericType<User> localVarReturnType = new GenericType<User>() {};
return apiClient.invokeAPI(localVarPath, "GET", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, localVarReturnType); return apiClient.invokeAPI(localVarPath, "GET", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, localVarReturnType);
} }
/** /**
* Logs user into the system * Logs user into the system
@ -284,6 +294,7 @@ public class UserApi {
List<Pair> localVarQueryParams = new ArrayList<Pair>(); List<Pair> localVarQueryParams = new ArrayList<Pair>();
List<Pair> localVarCollectionQueryParams = new ArrayList<Pair>(); List<Pair> localVarCollectionQueryParams = new ArrayList<Pair>();
Map<String, String> localVarHeaderParams = new HashMap<String, String>(); Map<String, String> localVarHeaderParams = new HashMap<String, String>();
Map<String, String> localVarCookieParams = new HashMap<String, String>();
Map<String, Object> localVarFormParams = new HashMap<String, Object>(); Map<String, Object> localVarFormParams = new HashMap<String, Object>();
localVarQueryParams.addAll(apiClient.parameterToPair("username", username)); localVarQueryParams.addAll(apiClient.parameterToPair("username", username));
@ -291,6 +302,7 @@ public class UserApi {
final String[] localVarAccepts = { final String[] localVarAccepts = {
"application/xml", "application/json" "application/xml", "application/json"
}; };
@ -304,7 +316,7 @@ public class UserApi {
String[] localVarAuthNames = new String[] { }; String[] localVarAuthNames = new String[] { };
GenericType<String> localVarReturnType = new GenericType<String>() {}; GenericType<String> localVarReturnType = new GenericType<String>() {};
return apiClient.invokeAPI(localVarPath, "GET", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, localVarReturnType); return apiClient.invokeAPI(localVarPath, "GET", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, localVarReturnType);
} }
/** /**
* Logs out current logged in user session * Logs out current logged in user session
@ -321,11 +333,13 @@ public class UserApi {
List<Pair> localVarQueryParams = new ArrayList<Pair>(); List<Pair> localVarQueryParams = new ArrayList<Pair>();
List<Pair> localVarCollectionQueryParams = new ArrayList<Pair>(); List<Pair> localVarCollectionQueryParams = new ArrayList<Pair>();
Map<String, String> localVarHeaderParams = new HashMap<String, String>(); Map<String, String> localVarHeaderParams = new HashMap<String, String>();
Map<String, String> localVarCookieParams = new HashMap<String, String>();
Map<String, Object> localVarFormParams = new HashMap<String, Object>(); Map<String, Object> localVarFormParams = new HashMap<String, Object>();
final String[] localVarAccepts = { final String[] localVarAccepts = {
}; };
@ -339,7 +353,7 @@ public class UserApi {
String[] localVarAuthNames = new String[] { }; String[] localVarAuthNames = new String[] { };
apiClient.invokeAPI(localVarPath, "GET", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, null); apiClient.invokeAPI(localVarPath, "GET", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, null);
} }
/** /**
* Updated user * Updated user
@ -369,11 +383,13 @@ public class UserApi {
List<Pair> localVarQueryParams = new ArrayList<Pair>(); List<Pair> localVarQueryParams = new ArrayList<Pair>();
List<Pair> localVarCollectionQueryParams = new ArrayList<Pair>(); List<Pair> localVarCollectionQueryParams = new ArrayList<Pair>();
Map<String, String> localVarHeaderParams = new HashMap<String, String>(); Map<String, String> localVarHeaderParams = new HashMap<String, String>();
Map<String, String> localVarCookieParams = new HashMap<String, String>();
Map<String, Object> localVarFormParams = new HashMap<String, Object>(); Map<String, Object> localVarFormParams = new HashMap<String, Object>();
final String[] localVarAccepts = { final String[] localVarAccepts = {
}; };
@ -387,6 +403,6 @@ public class UserApi {
String[] localVarAuthNames = new String[] { }; String[] localVarAuthNames = new String[] { };
apiClient.invokeAPI(localVarPath, "PUT", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, null); apiClient.invokeAPI(localVarPath, "PUT", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, null);
} }
} }

View File

@ -56,7 +56,7 @@ public class ApiKeyAuth implements Authentication {
} }
@Override @Override
public void applyToParams(List<Pair> queryParams, Map<String, String> headerParams) { public void applyToParams(List<Pair> queryParams, Map<String, String> headerParams, Map<String, String> cookieParams) {
if (apiKey == null) { if (apiKey == null) {
return; return;
} }
@ -70,6 +70,8 @@ public class ApiKeyAuth implements Authentication {
queryParams.add(new Pair(paramName, value)); queryParams.add(new Pair(paramName, value));
} else if ("header".equals(location)) { } else if ("header".equals(location)) {
headerParams.put(paramName, value); headerParams.put(paramName, value);
} else if ("cookie".equals(location)) {
cookieParams.put(paramName, value);
} }
} }
} }

View File

@ -24,6 +24,7 @@ public interface Authentication {
* *
* @param queryParams List of query parameters * @param queryParams List of query parameters
* @param headerParams Map of header parameters * @param headerParams Map of header parameters
* @param cookieParams Map of cookie parameters
*/ */
void applyToParams(List<Pair> queryParams, Map<String, String> headerParams); void applyToParams(List<Pair> queryParams, Map<String, String> headerParams, Map<String, String> cookieParams);
} }

View File

@ -44,7 +44,7 @@ public class HttpBasicAuth implements Authentication {
} }
@Override @Override
public void applyToParams(List<Pair> queryParams, Map<String, String> headerParams) { public void applyToParams(List<Pair> queryParams, Map<String, String> headerParams, Map<String, String> cookieParams) {
if (username == null && password == null) { if (username == null && password == null) {
return; return;
} }

View File

@ -46,7 +46,7 @@ public class HttpBearerAuth implements Authentication {
} }
@Override @Override
public void applyToParams(List<Pair> queryParams, Map<String, String> headerParams) { public void applyToParams(List<Pair> queryParams, Map<String, String> headerParams, Map<String, String> cookieParams) {
if(bearerToken == null) { if(bearerToken == null) {
return; return;
} }

View File

@ -31,7 +31,7 @@ public class OAuth implements Authentication {
} }
@Override @Override
public void applyToParams(List<Pair> queryParams, Map<String, String> headerParams) { public void applyToParams(List<Pair> queryParams, Map<String, String> headerParams, Map<String, String> cookieParams) {
if (accessToken != null) { if (accessToken != null) {
headerParams.put("Authorization", "Bearer " + accessToken); headerParams.put("Authorization", "Bearer " + accessToken);
} }

View File

@ -15,33 +15,57 @@ public class ApiKeyAuthTest {
public void testApplyToParamsInQuery() { public void testApplyToParamsInQuery() {
List<Pair> queryParams = new ArrayList<Pair>(); List<Pair> queryParams = new ArrayList<Pair>();
Map<String, String> headerParams = new HashMap<String, String>(); Map<String, String> headerParams = new HashMap<String, String>();
Map<String, String> cookieParams = new HashMap<String, String>();
ApiKeyAuth auth = new ApiKeyAuth("query", "api_key"); ApiKeyAuth auth = new ApiKeyAuth("query", "api_key");
auth.setApiKey("my-api-key"); auth.setApiKey("my-api-key");
auth.applyToParams(queryParams, headerParams); auth.applyToParams(queryParams, headerParams, cookieParams);
assertEquals(1, queryParams.size()); assertEquals(1, queryParams.size());
for (Pair queryParam : queryParams) { for (Pair queryParam : queryParams) {
assertEquals("my-api-key", queryParam.getValue()); assertEquals("my-api-key", queryParam.getValue());
} }
// no changes to header parameters // no changes to header or cookie parameters
assertEquals(0, headerParams.size()); assertEquals(0, headerParams.size());
assertEquals(0, cookieParams.size());
} }
@Test @Test
public void testApplyToParamsInHeaderWithPrefix() { public void testApplyToParamsInHeaderWithPrefix() {
List<Pair> queryParams = new ArrayList<Pair>(); List<Pair> queryParams = new ArrayList<Pair>();
Map<String, String> headerParams = new HashMap<String, String>(); Map<String, String> headerParams = new HashMap<String, String>();
Map<String, String> cookieParams = new HashMap<String, String>();
ApiKeyAuth auth = new ApiKeyAuth("header", "X-API-TOKEN"); ApiKeyAuth auth = new ApiKeyAuth("header", "X-API-TOKEN");
auth.setApiKey("my-api-token"); auth.setApiKey("my-api-token");
auth.setApiKeyPrefix("Token"); auth.setApiKeyPrefix("Token");
auth.applyToParams(queryParams, headerParams); auth.applyToParams(queryParams, headerParams, cookieParams);
// no changes to query parameters // no changes to query or cookie parameters
assertEquals(0, queryParams.size()); assertEquals(0, queryParams.size());
assertEquals(0, cookieParams.size());
assertEquals(1, headerParams.size()); assertEquals(1, headerParams.size());
assertEquals("Token my-api-token", headerParams.get("X-API-TOKEN")); assertEquals("Token my-api-token", headerParams.get("X-API-TOKEN"));
} }
@Test
public void testApplyToParamsInCookieWithPrefix() {
List<Pair> queryParams = new ArrayList<Pair>();
Map<String, String> headerParams = new HashMap<String, String>();
Map<String, String> cookieParams = new HashMap<String, String>();
ApiKeyAuth auth = new ApiKeyAuth("cookie", "X-API-TOKEN");
auth.setApiKey("my-api-token");
auth.setApiKeyPrefix("Token");
auth.applyToParams(queryParams, headerParams, cookieParams);
// no changes to query or header parameters
assertEquals(0, queryParams.size());
assertEquals(0, headerParams.size());
assertEquals(1, cookieParams.size());
assertEquals("Token my-api-token", cookieParams.get("X-API-TOKEN"));
}
} }

View File

@ -22,13 +22,15 @@ public class HttpBasicAuthTest {
public void testApplyToParams() { public void testApplyToParams() {
List<Pair> queryParams = new ArrayList<Pair>(); List<Pair> queryParams = new ArrayList<Pair>();
Map<String, String> headerParams = new HashMap<String, String>(); Map<String, String> headerParams = new HashMap<String, String>();
Map<String, String> cookieParams = new HashMap<String, String>();
auth.setUsername("my-username"); auth.setUsername("my-username");
auth.setPassword("my-password"); auth.setPassword("my-password");
auth.applyToParams(queryParams, headerParams); auth.applyToParams(queryParams, headerParams, cookieParams);
// no changes to query parameters // no changes to query or cookie parameters
assertEquals(0, queryParams.size()); assertEquals(0, queryParams.size());
assertEquals(0, cookieParams.size());
assertEquals(1, headerParams.size()); assertEquals(1, headerParams.size());
// the string below is base64-encoded result of "my-username:my-password" with the "Basic " prefix // the string below is base64-encoded result of "my-username:my-password" with the "Basic " prefix
String expected = "Basic bXktdXNlcm5hbWU6bXktcGFzc3dvcmQ="; String expected = "Basic bXktdXNlcm5hbWU6bXktcGFzc3dvcmQ=";
@ -36,7 +38,7 @@ public class HttpBasicAuthTest {
// null username should be treated as empty string // null username should be treated as empty string
auth.setUsername(null); auth.setUsername(null);
auth.applyToParams(queryParams, headerParams); auth.applyToParams(queryParams, headerParams, cookieParams);
// the string below is base64-encoded result of ":my-password" with the "Basic " prefix // the string below is base64-encoded result of ":my-password" with the "Basic " prefix
expected = "Basic Om15LXBhc3N3b3Jk"; expected = "Basic Om15LXBhc3N3b3Jk";
assertEquals(expected, headerParams.get("Authorization")); assertEquals(expected, headerParams.get("Authorization"));
@ -44,7 +46,7 @@ public class HttpBasicAuthTest {
// null password should be treated as empty string // null password should be treated as empty string
auth.setUsername("my-username"); auth.setUsername("my-username");
auth.setPassword(null); auth.setPassword(null);
auth.applyToParams(queryParams, headerParams); auth.applyToParams(queryParams, headerParams, cookieParams);
// the string below is base64-encoded result of "my-username:" with the "Basic " prefix // the string below is base64-encoded result of "my-username:" with the "Basic " prefix
expected = "Basic bXktdXNlcm5hbWU6"; expected = "Basic bXktdXNlcm5hbWU6";
assertEquals(expected, headerParams.get("Authorization")); assertEquals(expected, headerParams.get("Authorization"));

View File

@ -53,6 +53,7 @@ import org.openapitools.client.auth.OAuth;
public class ApiClient { public class ApiClient {
protected Map<String, String> defaultHeaderMap = new HashMap<String, String>(); protected Map<String, String> defaultHeaderMap = new HashMap<String, String>();
protected Map<String, String> defaultCookieMap = new HashMap<String, String>();
protected String basePath = "http://petstore.swagger.io:80/v2"; protected String basePath = "http://petstore.swagger.io:80/v2";
protected boolean debugging = false; protected boolean debugging = false;
protected int connectionTimeout = 0; protected int connectionTimeout = 0;
@ -235,6 +236,18 @@ public class ApiClient {
return this; return this;
} }
/**
* Add a default cookie.
*
* @param key The cookie's key
* @param value The cookie's value
* @return API client
*/
public ApiClient addDefaultCookie(String key, String value) {
defaultCookieMap.put(key, value);
return this;
}
/** /**
* Check that whether debugging is enabled for this API client. * Check that whether debugging is enabled for this API client.
* @return True if debugging is switched on * @return True if debugging is switched on
@ -305,7 +318,7 @@ public class ApiClient {
public int getReadTimeout() { public int getReadTimeout() {
return readTimeout; return readTimeout;
} }
/** /**
* Set the read timeout (in milliseconds). * Set the read timeout (in milliseconds).
* A value of 0 means no timeout, otherwise values must be between 1 and * A value of 0 means no timeout, otherwise values must be between 1 and
@ -646,6 +659,7 @@ public class ApiClient {
* @param queryParams The query parameters * @param queryParams The query parameters
* @param body The request body object * @param body The request body object
* @param headerParams The header parameters * @param headerParams The header parameters
* @param cookieParams The cookie parameters
* @param formParams The form parameters * @param formParams The form parameters
* @param accept The request's Accept header * @param accept The request's Accept header
* @param contentType The request's Content-Type header * @param contentType The request's Content-Type header
@ -654,8 +668,8 @@ public class ApiClient {
* @return The response body in type of string * @return The response body in type of string
* @throws ApiException API exception * @throws ApiException API exception
*/ */
public <T> ApiResponse<T> invokeAPI(String path, String method, List<Pair> queryParams, Object body, Map<String, String> headerParams, Map<String, Object> formParams, String accept, String contentType, String[] authNames, GenericType<T> returnType) throws ApiException { public <T> ApiResponse<T> invokeAPI(String path, String method, List<Pair> queryParams, Object body, Map<String, String> headerParams, Map<String, String> cookieParams, Map<String, Object> formParams, String accept, String contentType, String[] authNames, GenericType<T> returnType) throws ApiException {
updateParamsForAuth(authNames, queryParams, headerParams); updateParamsForAuth(authNames, queryParams, headerParams, cookieParams);
// Not using `.target(this.basePath).path(path)` below, // Not using `.target(this.basePath).path(path)` below,
// to support (constant) query string in `path`, e.g. "/posts?draft=1" // to support (constant) query string in `path`, e.g. "/posts?draft=1"
@ -678,6 +692,13 @@ public class ApiClient {
} }
} }
for (Entry<String, String> entry : cookieParams.entrySet()) {
String value = entry.getValue();
if (value != null) {
invocationBuilder = invocationBuilder.cookie(entry.getKey(), value);
}
}
for (Entry<String, String> entry : defaultHeaderMap.entrySet()) { for (Entry<String, String> entry : defaultHeaderMap.entrySet()) {
String key = entry.getKey(); String key = entry.getKey();
if (!headerParams.containsKey(key)) { if (!headerParams.containsKey(key)) {
@ -795,12 +816,13 @@ public class ApiClient {
* @param authNames The authentications to apply * @param authNames The authentications to apply
* @param queryParams List of query parameters * @param queryParams List of query parameters
* @param headerParams Map of header parameters * @param headerParams Map of header parameters
* @param cookieParams Map of cookie parameters
*/ */
protected void updateParamsForAuth(String[] authNames, List<Pair> queryParams, Map<String, String> headerParams) { protected void updateParamsForAuth(String[] authNames, List<Pair> queryParams, Map<String, String> headerParams, Map<String, String> cookieParams) {
for (String authName : authNames) { for (String authName : authNames) {
Authentication auth = authentications.get(authName); Authentication auth = authentications.get(authName);
if (auth == null) throw new RuntimeException("Authentication undefined: " + authName); if (auth == null) throw new RuntimeException("Authentication undefined: " + authName);
auth.applyToParams(queryParams, headerParams); auth.applyToParams(queryParams, headerParams, cookieParams);
} }
} }
} }

View File

@ -77,11 +77,13 @@ public class AnotherFakeApi {
// query params // query params
List<Pair> localVarQueryParams = new ArrayList<Pair>(); List<Pair> localVarQueryParams = new ArrayList<Pair>();
Map<String, String> localVarHeaderParams = new HashMap<String, String>(); Map<String, String> localVarHeaderParams = new HashMap<String, String>();
Map<String, String> localVarCookieParams = new HashMap<String, String>();
Map<String, Object> localVarFormParams = new HashMap<String, Object>(); Map<String, Object> localVarFormParams = new HashMap<String, Object>();
final String[] localVarAccepts = { final String[] localVarAccepts = {
"application/json" "application/json"
}; };
@ -95,6 +97,6 @@ public class AnotherFakeApi {
String[] localVarAuthNames = new String[] { }; String[] localVarAuthNames = new String[] { };
GenericType<Client> localVarReturnType = new GenericType<Client>() {}; GenericType<Client> localVarReturnType = new GenericType<Client>() {};
return apiClient.invokeAPI(localVarPath, "PATCH", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, localVarReturnType); return apiClient.invokeAPI(localVarPath, "PATCH", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, localVarReturnType);
} }
} }

View File

@ -85,11 +85,13 @@ public class FakeApi {
// query params // query params
List<Pair> localVarQueryParams = new ArrayList<Pair>(); List<Pair> localVarQueryParams = new ArrayList<Pair>();
Map<String, String> localVarHeaderParams = new HashMap<String, String>(); Map<String, String> localVarHeaderParams = new HashMap<String, String>();
Map<String, String> localVarCookieParams = new HashMap<String, String>();
Map<String, Object> localVarFormParams = new HashMap<String, Object>(); Map<String, Object> localVarFormParams = new HashMap<String, Object>();
final String[] localVarAccepts = { final String[] localVarAccepts = {
}; };
@ -103,7 +105,7 @@ public class FakeApi {
String[] localVarAuthNames = new String[] { }; String[] localVarAuthNames = new String[] { };
return apiClient.invokeAPI(localVarPath, "POST", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, null); return apiClient.invokeAPI(localVarPath, "POST", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, null);
} }
/** /**
* *
@ -142,11 +144,13 @@ public class FakeApi {
// query params // query params
List<Pair> localVarQueryParams = new ArrayList<Pair>(); List<Pair> localVarQueryParams = new ArrayList<Pair>();
Map<String, String> localVarHeaderParams = new HashMap<String, String>(); Map<String, String> localVarHeaderParams = new HashMap<String, String>();
Map<String, String> localVarCookieParams = new HashMap<String, String>();
Map<String, Object> localVarFormParams = new HashMap<String, Object>(); Map<String, Object> localVarFormParams = new HashMap<String, Object>();
final String[] localVarAccepts = { final String[] localVarAccepts = {
"*/*" "*/*"
}; };
@ -160,7 +164,7 @@ public class FakeApi {
String[] localVarAuthNames = new String[] { }; String[] localVarAuthNames = new String[] { };
GenericType<Boolean> localVarReturnType = new GenericType<Boolean>() {}; GenericType<Boolean> localVarReturnType = new GenericType<Boolean>() {};
return apiClient.invokeAPI(localVarPath, "POST", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, localVarReturnType); return apiClient.invokeAPI(localVarPath, "POST", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, localVarReturnType);
} }
/** /**
* *
@ -199,11 +203,13 @@ public class FakeApi {
// query params // query params
List<Pair> localVarQueryParams = new ArrayList<Pair>(); List<Pair> localVarQueryParams = new ArrayList<Pair>();
Map<String, String> localVarHeaderParams = new HashMap<String, String>(); Map<String, String> localVarHeaderParams = new HashMap<String, String>();
Map<String, String> localVarCookieParams = new HashMap<String, String>();
Map<String, Object> localVarFormParams = new HashMap<String, Object>(); Map<String, Object> localVarFormParams = new HashMap<String, Object>();
final String[] localVarAccepts = { final String[] localVarAccepts = {
"*/*" "*/*"
}; };
@ -217,7 +223,7 @@ public class FakeApi {
String[] localVarAuthNames = new String[] { }; String[] localVarAuthNames = new String[] { };
GenericType<OuterComposite> localVarReturnType = new GenericType<OuterComposite>() {}; GenericType<OuterComposite> localVarReturnType = new GenericType<OuterComposite>() {};
return apiClient.invokeAPI(localVarPath, "POST", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, localVarReturnType); return apiClient.invokeAPI(localVarPath, "POST", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, localVarReturnType);
} }
/** /**
* *
@ -256,11 +262,13 @@ public class FakeApi {
// query params // query params
List<Pair> localVarQueryParams = new ArrayList<Pair>(); List<Pair> localVarQueryParams = new ArrayList<Pair>();
Map<String, String> localVarHeaderParams = new HashMap<String, String>(); Map<String, String> localVarHeaderParams = new HashMap<String, String>();
Map<String, String> localVarCookieParams = new HashMap<String, String>();
Map<String, Object> localVarFormParams = new HashMap<String, Object>(); Map<String, Object> localVarFormParams = new HashMap<String, Object>();
final String[] localVarAccepts = { final String[] localVarAccepts = {
"*/*" "*/*"
}; };
@ -274,7 +282,7 @@ public class FakeApi {
String[] localVarAuthNames = new String[] { }; String[] localVarAuthNames = new String[] { };
GenericType<BigDecimal> localVarReturnType = new GenericType<BigDecimal>() {}; GenericType<BigDecimal> localVarReturnType = new GenericType<BigDecimal>() {};
return apiClient.invokeAPI(localVarPath, "POST", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, localVarReturnType); return apiClient.invokeAPI(localVarPath, "POST", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, localVarReturnType);
} }
/** /**
* *
@ -313,11 +321,13 @@ public class FakeApi {
// query params // query params
List<Pair> localVarQueryParams = new ArrayList<Pair>(); List<Pair> localVarQueryParams = new ArrayList<Pair>();
Map<String, String> localVarHeaderParams = new HashMap<String, String>(); Map<String, String> localVarHeaderParams = new HashMap<String, String>();
Map<String, String> localVarCookieParams = new HashMap<String, String>();
Map<String, Object> localVarFormParams = new HashMap<String, Object>(); Map<String, Object> localVarFormParams = new HashMap<String, Object>();
final String[] localVarAccepts = { final String[] localVarAccepts = {
"*/*" "*/*"
}; };
@ -331,7 +341,7 @@ public class FakeApi {
String[] localVarAuthNames = new String[] { }; String[] localVarAuthNames = new String[] { };
GenericType<String> localVarReturnType = new GenericType<String>() {}; GenericType<String> localVarReturnType = new GenericType<String>() {};
return apiClient.invokeAPI(localVarPath, "POST", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, localVarReturnType); return apiClient.invokeAPI(localVarPath, "POST", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, localVarReturnType);
} }
/** /**
* *
@ -375,11 +385,13 @@ public class FakeApi {
// query params // query params
List<Pair> localVarQueryParams = new ArrayList<Pair>(); List<Pair> localVarQueryParams = new ArrayList<Pair>();
Map<String, String> localVarHeaderParams = new HashMap<String, String>(); Map<String, String> localVarHeaderParams = new HashMap<String, String>();
Map<String, String> localVarCookieParams = new HashMap<String, String>();
Map<String, Object> localVarFormParams = new HashMap<String, Object>(); Map<String, Object> localVarFormParams = new HashMap<String, Object>();
final String[] localVarAccepts = { final String[] localVarAccepts = {
}; };
@ -393,7 +405,7 @@ public class FakeApi {
String[] localVarAuthNames = new String[] { }; String[] localVarAuthNames = new String[] { };
return apiClient.invokeAPI(localVarPath, "PUT", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, null); return apiClient.invokeAPI(localVarPath, "PUT", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, null);
} }
/** /**
* *
@ -444,12 +456,14 @@ public class FakeApi {
// query params // query params
List<Pair> localVarQueryParams = new ArrayList<Pair>(); List<Pair> localVarQueryParams = new ArrayList<Pair>();
Map<String, String> localVarHeaderParams = new HashMap<String, String>(); Map<String, String> localVarHeaderParams = new HashMap<String, String>();
Map<String, String> localVarCookieParams = new HashMap<String, String>();
Map<String, Object> localVarFormParams = new HashMap<String, Object>(); Map<String, Object> localVarFormParams = new HashMap<String, Object>();
localVarQueryParams.addAll(apiClient.parameterToPairs("", "query", query)); localVarQueryParams.addAll(apiClient.parameterToPairs("", "query", query));
final String[] localVarAccepts = { final String[] localVarAccepts = {
}; };
@ -463,7 +477,7 @@ public class FakeApi {
String[] localVarAuthNames = new String[] { }; String[] localVarAuthNames = new String[] { };
return apiClient.invokeAPI(localVarPath, "PUT", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, null); return apiClient.invokeAPI(localVarPath, "PUT", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, null);
} }
/** /**
* To test \&quot;client\&quot; model * To test \&quot;client\&quot; model
@ -507,11 +521,13 @@ public class FakeApi {
// query params // query params
List<Pair> localVarQueryParams = new ArrayList<Pair>(); List<Pair> localVarQueryParams = new ArrayList<Pair>();
Map<String, String> localVarHeaderParams = new HashMap<String, String>(); Map<String, String> localVarHeaderParams = new HashMap<String, String>();
Map<String, String> localVarCookieParams = new HashMap<String, String>();
Map<String, Object> localVarFormParams = new HashMap<String, Object>(); Map<String, Object> localVarFormParams = new HashMap<String, Object>();
final String[] localVarAccepts = { final String[] localVarAccepts = {
"application/json" "application/json"
}; };
@ -525,7 +541,7 @@ public class FakeApi {
String[] localVarAuthNames = new String[] { }; String[] localVarAuthNames = new String[] { };
GenericType<Client> localVarReturnType = new GenericType<Client>() {}; GenericType<Client> localVarReturnType = new GenericType<Client>() {};
return apiClient.invokeAPI(localVarPath, "PATCH", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, localVarReturnType); return apiClient.invokeAPI(localVarPath, "PATCH", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, localVarReturnType);
} }
/** /**
* Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 * Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트
@ -612,10 +628,12 @@ public class FakeApi {
// query params // query params
List<Pair> localVarQueryParams = new ArrayList<Pair>(); List<Pair> localVarQueryParams = new ArrayList<Pair>();
Map<String, String> localVarHeaderParams = new HashMap<String, String>(); Map<String, String> localVarHeaderParams = new HashMap<String, String>();
Map<String, String> localVarCookieParams = new HashMap<String, String>();
Map<String, Object> localVarFormParams = new HashMap<String, Object>(); Map<String, Object> localVarFormParams = new HashMap<String, Object>();
if (integer != null) if (integer != null)
localVarFormParams.put("integer", integer); localVarFormParams.put("integer", integer);
if (int32 != null) if (int32 != null)
@ -658,7 +676,7 @@ if (paramCallback != null)
String[] localVarAuthNames = new String[] { "http_basic_test" }; String[] localVarAuthNames = new String[] { "http_basic_test" };
return apiClient.invokeAPI(localVarPath, "POST", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, null); return apiClient.invokeAPI(localVarPath, "POST", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, null);
} }
/** /**
* To test enum parameters * To test enum parameters
@ -713,6 +731,7 @@ if (paramCallback != null)
// query params // query params
List<Pair> localVarQueryParams = new ArrayList<Pair>(); List<Pair> localVarQueryParams = new ArrayList<Pair>();
Map<String, String> localVarHeaderParams = new HashMap<String, String>(); Map<String, String> localVarHeaderParams = new HashMap<String, String>();
Map<String, String> localVarCookieParams = new HashMap<String, String>();
Map<String, Object> localVarFormParams = new HashMap<String, Object>(); Map<String, Object> localVarFormParams = new HashMap<String, Object>();
localVarQueryParams.addAll(apiClient.parameterToPairs("csv", "enum_query_string_array", enumQueryStringArray)); localVarQueryParams.addAll(apiClient.parameterToPairs("csv", "enum_query_string_array", enumQueryStringArray));
@ -725,6 +744,7 @@ if (paramCallback != null)
if (enumHeaderString != null) if (enumHeaderString != null)
localVarHeaderParams.put("enum_header_string", apiClient.parameterToString(enumHeaderString)); localVarHeaderParams.put("enum_header_string", apiClient.parameterToString(enumHeaderString));
if (enumFormStringArray != null) if (enumFormStringArray != null)
localVarFormParams.put("enum_form_string_array", enumFormStringArray); localVarFormParams.put("enum_form_string_array", enumFormStringArray);
if (enumFormString != null) if (enumFormString != null)
@ -743,7 +763,7 @@ if (enumFormString != null)
String[] localVarAuthNames = new String[] { }; String[] localVarAuthNames = new String[] { };
return apiClient.invokeAPI(localVarPath, "GET", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, null); return apiClient.invokeAPI(localVarPath, "GET", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, null);
} }
/** /**
* Fake endpoint to test group parameters (optional) * Fake endpoint to test group parameters (optional)
@ -807,6 +827,7 @@ if (enumFormString != null)
// query params // query params
List<Pair> localVarQueryParams = new ArrayList<Pair>(); List<Pair> localVarQueryParams = new ArrayList<Pair>();
Map<String, String> localVarHeaderParams = new HashMap<String, String>(); Map<String, String> localVarHeaderParams = new HashMap<String, String>();
Map<String, String> localVarCookieParams = new HashMap<String, String>();
Map<String, Object> localVarFormParams = new HashMap<String, Object>(); Map<String, Object> localVarFormParams = new HashMap<String, Object>();
localVarQueryParams.addAll(apiClient.parameterToPairs("", "required_string_group", requiredStringGroup)); localVarQueryParams.addAll(apiClient.parameterToPairs("", "required_string_group", requiredStringGroup));
@ -820,6 +841,7 @@ if (booleanGroup != null)
localVarHeaderParams.put("boolean_group", apiClient.parameterToString(booleanGroup)); localVarHeaderParams.put("boolean_group", apiClient.parameterToString(booleanGroup));
final String[] localVarAccepts = { final String[] localVarAccepts = {
}; };
@ -833,7 +855,7 @@ if (booleanGroup != null)
String[] localVarAuthNames = new String[] { }; String[] localVarAuthNames = new String[] { };
return apiClient.invokeAPI(localVarPath, "DELETE", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, null); return apiClient.invokeAPI(localVarPath, "DELETE", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, null);
} }
/** /**
* test inline additionalProperties * test inline additionalProperties
@ -877,11 +899,13 @@ if (booleanGroup != null)
// query params // query params
List<Pair> localVarQueryParams = new ArrayList<Pair>(); List<Pair> localVarQueryParams = new ArrayList<Pair>();
Map<String, String> localVarHeaderParams = new HashMap<String, String>(); Map<String, String> localVarHeaderParams = new HashMap<String, String>();
Map<String, String> localVarCookieParams = new HashMap<String, String>();
Map<String, Object> localVarFormParams = new HashMap<String, Object>(); Map<String, Object> localVarFormParams = new HashMap<String, Object>();
final String[] localVarAccepts = { final String[] localVarAccepts = {
}; };
@ -895,7 +919,7 @@ if (booleanGroup != null)
String[] localVarAuthNames = new String[] { }; String[] localVarAuthNames = new String[] { };
return apiClient.invokeAPI(localVarPath, "POST", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, null); return apiClient.invokeAPI(localVarPath, "POST", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, null);
} }
/** /**
* test json serialization of form data * test json serialization of form data
@ -946,10 +970,12 @@ if (booleanGroup != null)
// query params // query params
List<Pair> localVarQueryParams = new ArrayList<Pair>(); List<Pair> localVarQueryParams = new ArrayList<Pair>();
Map<String, String> localVarHeaderParams = new HashMap<String, String>(); Map<String, String> localVarHeaderParams = new HashMap<String, String>();
Map<String, String> localVarCookieParams = new HashMap<String, String>();
Map<String, Object> localVarFormParams = new HashMap<String, Object>(); Map<String, Object> localVarFormParams = new HashMap<String, Object>();
if (param != null) if (param != null)
localVarFormParams.put("param", param); localVarFormParams.put("param", param);
if (param2 != null) if (param2 != null)
@ -968,7 +994,7 @@ if (param2 != null)
String[] localVarAuthNames = new String[] { }; String[] localVarAuthNames = new String[] { };
return apiClient.invokeAPI(localVarPath, "GET", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, null); return apiClient.invokeAPI(localVarPath, "GET", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, null);
} }
/** /**
* *
@ -1040,6 +1066,7 @@ if (param2 != null)
// query params // query params
List<Pair> localVarQueryParams = new ArrayList<Pair>(); List<Pair> localVarQueryParams = new ArrayList<Pair>();
Map<String, String> localVarHeaderParams = new HashMap<String, String>(); Map<String, String> localVarHeaderParams = new HashMap<String, String>();
Map<String, String> localVarCookieParams = new HashMap<String, String>();
Map<String, Object> localVarFormParams = new HashMap<String, Object>(); Map<String, Object> localVarFormParams = new HashMap<String, Object>();
localVarQueryParams.addAll(apiClient.parameterToPairs("csv", "pipe", pipe)); localVarQueryParams.addAll(apiClient.parameterToPairs("csv", "pipe", pipe));
@ -1050,6 +1077,7 @@ if (param2 != null)
final String[] localVarAccepts = { final String[] localVarAccepts = {
}; };
@ -1063,6 +1091,6 @@ if (param2 != null)
String[] localVarAuthNames = new String[] { }; String[] localVarAuthNames = new String[] { };
return apiClient.invokeAPI(localVarPath, "PUT", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, null); return apiClient.invokeAPI(localVarPath, "PUT", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, null);
} }
} }

View File

@ -77,11 +77,13 @@ public class FakeClassnameTags123Api {
// query params // query params
List<Pair> localVarQueryParams = new ArrayList<Pair>(); List<Pair> localVarQueryParams = new ArrayList<Pair>();
Map<String, String> localVarHeaderParams = new HashMap<String, String>(); Map<String, String> localVarHeaderParams = new HashMap<String, String>();
Map<String, String> localVarCookieParams = new HashMap<String, String>();
Map<String, Object> localVarFormParams = new HashMap<String, Object>(); Map<String, Object> localVarFormParams = new HashMap<String, Object>();
final String[] localVarAccepts = { final String[] localVarAccepts = {
"application/json" "application/json"
}; };
@ -95,6 +97,6 @@ public class FakeClassnameTags123Api {
String[] localVarAuthNames = new String[] { "api_key_query" }; String[] localVarAuthNames = new String[] { "api_key_query" };
GenericType<Client> localVarReturnType = new GenericType<Client>() {}; GenericType<Client> localVarReturnType = new GenericType<Client>() {};
return apiClient.invokeAPI(localVarPath, "PATCH", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, localVarReturnType); return apiClient.invokeAPI(localVarPath, "PATCH", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, localVarReturnType);
} }
} }

View File

@ -81,11 +81,13 @@ public class PetApi {
// query params // query params
List<Pair> localVarQueryParams = new ArrayList<Pair>(); List<Pair> localVarQueryParams = new ArrayList<Pair>();
Map<String, String> localVarHeaderParams = new HashMap<String, String>(); Map<String, String> localVarHeaderParams = new HashMap<String, String>();
Map<String, String> localVarCookieParams = new HashMap<String, String>();
Map<String, Object> localVarFormParams = new HashMap<String, Object>(); Map<String, Object> localVarFormParams = new HashMap<String, Object>();
final String[] localVarAccepts = { final String[] localVarAccepts = {
}; };
@ -99,7 +101,7 @@ public class PetApi {
String[] localVarAuthNames = new String[] { "petstore_auth" }; String[] localVarAuthNames = new String[] { "petstore_auth" };
return apiClient.invokeAPI(localVarPath, "POST", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, null); return apiClient.invokeAPI(localVarPath, "POST", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, null);
} }
/** /**
* Deletes a pet * Deletes a pet
@ -148,6 +150,7 @@ public class PetApi {
// query params // query params
List<Pair> localVarQueryParams = new ArrayList<Pair>(); List<Pair> localVarQueryParams = new ArrayList<Pair>();
Map<String, String> localVarHeaderParams = new HashMap<String, String>(); Map<String, String> localVarHeaderParams = new HashMap<String, String>();
Map<String, String> localVarCookieParams = new HashMap<String, String>();
Map<String, Object> localVarFormParams = new HashMap<String, Object>(); Map<String, Object> localVarFormParams = new HashMap<String, Object>();
@ -155,6 +158,7 @@ public class PetApi {
localVarHeaderParams.put("api_key", apiClient.parameterToString(apiKey)); localVarHeaderParams.put("api_key", apiClient.parameterToString(apiKey));
final String[] localVarAccepts = { final String[] localVarAccepts = {
}; };
@ -168,7 +172,7 @@ public class PetApi {
String[] localVarAuthNames = new String[] { "petstore_auth" }; String[] localVarAuthNames = new String[] { "petstore_auth" };
return apiClient.invokeAPI(localVarPath, "DELETE", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, null); return apiClient.invokeAPI(localVarPath, "DELETE", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, null);
} }
/** /**
* Finds Pets by status * Finds Pets by status
@ -214,12 +218,14 @@ public class PetApi {
// query params // query params
List<Pair> localVarQueryParams = new ArrayList<Pair>(); List<Pair> localVarQueryParams = new ArrayList<Pair>();
Map<String, String> localVarHeaderParams = new HashMap<String, String>(); Map<String, String> localVarHeaderParams = new HashMap<String, String>();
Map<String, String> localVarCookieParams = new HashMap<String, String>();
Map<String, Object> localVarFormParams = new HashMap<String, Object>(); Map<String, Object> localVarFormParams = new HashMap<String, Object>();
localVarQueryParams.addAll(apiClient.parameterToPairs("csv", "status", status)); localVarQueryParams.addAll(apiClient.parameterToPairs("csv", "status", status));
final String[] localVarAccepts = { final String[] localVarAccepts = {
"application/xml", "application/json" "application/xml", "application/json"
}; };
@ -233,7 +239,7 @@ public class PetApi {
String[] localVarAuthNames = new String[] { "petstore_auth" }; String[] localVarAuthNames = new String[] { "petstore_auth" };
GenericType<List<Pet>> localVarReturnType = new GenericType<List<Pet>>() {}; GenericType<List<Pet>> localVarReturnType = new GenericType<List<Pet>>() {};
return apiClient.invokeAPI(localVarPath, "GET", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, localVarReturnType); return apiClient.invokeAPI(localVarPath, "GET", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, localVarReturnType);
} }
/** /**
* Finds Pets by tags * Finds Pets by tags
@ -283,12 +289,14 @@ public class PetApi {
// query params // query params
List<Pair> localVarQueryParams = new ArrayList<Pair>(); List<Pair> localVarQueryParams = new ArrayList<Pair>();
Map<String, String> localVarHeaderParams = new HashMap<String, String>(); Map<String, String> localVarHeaderParams = new HashMap<String, String>();
Map<String, String> localVarCookieParams = new HashMap<String, String>();
Map<String, Object> localVarFormParams = new HashMap<String, Object>(); Map<String, Object> localVarFormParams = new HashMap<String, Object>();
localVarQueryParams.addAll(apiClient.parameterToPairs("csv", "tags", tags)); localVarQueryParams.addAll(apiClient.parameterToPairs("csv", "tags", tags));
final String[] localVarAccepts = { final String[] localVarAccepts = {
"application/xml", "application/json" "application/xml", "application/json"
}; };
@ -302,7 +310,7 @@ public class PetApi {
String[] localVarAuthNames = new String[] { "petstore_auth" }; String[] localVarAuthNames = new String[] { "petstore_auth" };
GenericType<List<Pet>> localVarReturnType = new GenericType<List<Pet>>() {}; GenericType<List<Pet>> localVarReturnType = new GenericType<List<Pet>>() {};
return apiClient.invokeAPI(localVarPath, "GET", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, localVarReturnType); return apiClient.invokeAPI(localVarPath, "GET", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, localVarReturnType);
} }
/** /**
* Find pet by ID * Find pet by ID
@ -351,11 +359,13 @@ public class PetApi {
// query params // query params
List<Pair> localVarQueryParams = new ArrayList<Pair>(); List<Pair> localVarQueryParams = new ArrayList<Pair>();
Map<String, String> localVarHeaderParams = new HashMap<String, String>(); Map<String, String> localVarHeaderParams = new HashMap<String, String>();
Map<String, String> localVarCookieParams = new HashMap<String, String>();
Map<String, Object> localVarFormParams = new HashMap<String, Object>(); Map<String, Object> localVarFormParams = new HashMap<String, Object>();
final String[] localVarAccepts = { final String[] localVarAccepts = {
"application/xml", "application/json" "application/xml", "application/json"
}; };
@ -369,7 +379,7 @@ public class PetApi {
String[] localVarAuthNames = new String[] { "api_key" }; String[] localVarAuthNames = new String[] { "api_key" };
GenericType<Pet> localVarReturnType = new GenericType<Pet>() {}; GenericType<Pet> localVarReturnType = new GenericType<Pet>() {};
return apiClient.invokeAPI(localVarPath, "GET", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, localVarReturnType); return apiClient.invokeAPI(localVarPath, "GET", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, localVarReturnType);
} }
/** /**
* Update an existing pet * Update an existing pet
@ -419,11 +429,13 @@ public class PetApi {
// query params // query params
List<Pair> localVarQueryParams = new ArrayList<Pair>(); List<Pair> localVarQueryParams = new ArrayList<Pair>();
Map<String, String> localVarHeaderParams = new HashMap<String, String>(); Map<String, String> localVarHeaderParams = new HashMap<String, String>();
Map<String, String> localVarCookieParams = new HashMap<String, String>();
Map<String, Object> localVarFormParams = new HashMap<String, Object>(); Map<String, Object> localVarFormParams = new HashMap<String, Object>();
final String[] localVarAccepts = { final String[] localVarAccepts = {
}; };
@ -437,7 +449,7 @@ public class PetApi {
String[] localVarAuthNames = new String[] { "petstore_auth" }; String[] localVarAuthNames = new String[] { "petstore_auth" };
return apiClient.invokeAPI(localVarPath, "PUT", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, null); return apiClient.invokeAPI(localVarPath, "PUT", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, null);
} }
/** /**
* Updates a pet in the store with form data * Updates a pet in the store with form data
@ -486,10 +498,12 @@ public class PetApi {
// query params // query params
List<Pair> localVarQueryParams = new ArrayList<Pair>(); List<Pair> localVarQueryParams = new ArrayList<Pair>();
Map<String, String> localVarHeaderParams = new HashMap<String, String>(); Map<String, String> localVarHeaderParams = new HashMap<String, String>();
Map<String, String> localVarCookieParams = new HashMap<String, String>();
Map<String, Object> localVarFormParams = new HashMap<String, Object>(); Map<String, Object> localVarFormParams = new HashMap<String, Object>();
if (name != null) if (name != null)
localVarFormParams.put("name", name); localVarFormParams.put("name", name);
if (status != null) if (status != null)
@ -508,7 +522,7 @@ if (status != null)
String[] localVarAuthNames = new String[] { "petstore_auth" }; String[] localVarAuthNames = new String[] { "petstore_auth" };
return apiClient.invokeAPI(localVarPath, "POST", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, null); return apiClient.invokeAPI(localVarPath, "POST", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, null);
} }
/** /**
* uploads an image * uploads an image
@ -557,10 +571,12 @@ if (status != null)
// query params // query params
List<Pair> localVarQueryParams = new ArrayList<Pair>(); List<Pair> localVarQueryParams = new ArrayList<Pair>();
Map<String, String> localVarHeaderParams = new HashMap<String, String>(); Map<String, String> localVarHeaderParams = new HashMap<String, String>();
Map<String, String> localVarCookieParams = new HashMap<String, String>();
Map<String, Object> localVarFormParams = new HashMap<String, Object>(); Map<String, Object> localVarFormParams = new HashMap<String, Object>();
if (additionalMetadata != null) if (additionalMetadata != null)
localVarFormParams.put("additionalMetadata", additionalMetadata); localVarFormParams.put("additionalMetadata", additionalMetadata);
if (file != null) if (file != null)
@ -579,7 +595,7 @@ if (file != null)
String[] localVarAuthNames = new String[] { "petstore_auth" }; String[] localVarAuthNames = new String[] { "petstore_auth" };
GenericType<ModelApiResponse> localVarReturnType = new GenericType<ModelApiResponse>() {}; GenericType<ModelApiResponse> localVarReturnType = new GenericType<ModelApiResponse>() {};
return apiClient.invokeAPI(localVarPath, "POST", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, localVarReturnType); return apiClient.invokeAPI(localVarPath, "POST", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, localVarReturnType);
} }
/** /**
* uploads an image (required) * uploads an image (required)
@ -633,10 +649,12 @@ if (file != null)
// query params // query params
List<Pair> localVarQueryParams = new ArrayList<Pair>(); List<Pair> localVarQueryParams = new ArrayList<Pair>();
Map<String, String> localVarHeaderParams = new HashMap<String, String>(); Map<String, String> localVarHeaderParams = new HashMap<String, String>();
Map<String, String> localVarCookieParams = new HashMap<String, String>();
Map<String, Object> localVarFormParams = new HashMap<String, Object>(); Map<String, Object> localVarFormParams = new HashMap<String, Object>();
if (additionalMetadata != null) if (additionalMetadata != null)
localVarFormParams.put("additionalMetadata", additionalMetadata); localVarFormParams.put("additionalMetadata", additionalMetadata);
if (requiredFile != null) if (requiredFile != null)
@ -655,6 +673,6 @@ if (requiredFile != null)
String[] localVarAuthNames = new String[] { "petstore_auth" }; String[] localVarAuthNames = new String[] { "petstore_auth" };
GenericType<ModelApiResponse> localVarReturnType = new GenericType<ModelApiResponse>() {}; GenericType<ModelApiResponse> localVarReturnType = new GenericType<ModelApiResponse>() {};
return apiClient.invokeAPI(localVarPath, "POST", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, localVarReturnType); return apiClient.invokeAPI(localVarPath, "POST", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, localVarReturnType);
} }
} }

View File

@ -80,11 +80,13 @@ public class StoreApi {
// query params // query params
List<Pair> localVarQueryParams = new ArrayList<Pair>(); List<Pair> localVarQueryParams = new ArrayList<Pair>();
Map<String, String> localVarHeaderParams = new HashMap<String, String>(); Map<String, String> localVarHeaderParams = new HashMap<String, String>();
Map<String, String> localVarCookieParams = new HashMap<String, String>();
Map<String, Object> localVarFormParams = new HashMap<String, Object>(); Map<String, Object> localVarFormParams = new HashMap<String, Object>();
final String[] localVarAccepts = { final String[] localVarAccepts = {
}; };
@ -98,7 +100,7 @@ public class StoreApi {
String[] localVarAuthNames = new String[] { }; String[] localVarAuthNames = new String[] { };
return apiClient.invokeAPI(localVarPath, "DELETE", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, null); return apiClient.invokeAPI(localVarPath, "DELETE", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, null);
} }
/** /**
* Returns pet inventories by status * Returns pet inventories by status
@ -135,11 +137,13 @@ public class StoreApi {
// query params // query params
List<Pair> localVarQueryParams = new ArrayList<Pair>(); List<Pair> localVarQueryParams = new ArrayList<Pair>();
Map<String, String> localVarHeaderParams = new HashMap<String, String>(); Map<String, String> localVarHeaderParams = new HashMap<String, String>();
Map<String, String> localVarCookieParams = new HashMap<String, String>();
Map<String, Object> localVarFormParams = new HashMap<String, Object>(); Map<String, Object> localVarFormParams = new HashMap<String, Object>();
final String[] localVarAccepts = { final String[] localVarAccepts = {
"application/json" "application/json"
}; };
@ -153,7 +157,7 @@ public class StoreApi {
String[] localVarAuthNames = new String[] { "api_key" }; String[] localVarAuthNames = new String[] { "api_key" };
GenericType<Map<String, Integer>> localVarReturnType = new GenericType<Map<String, Integer>>() {}; GenericType<Map<String, Integer>> localVarReturnType = new GenericType<Map<String, Integer>>() {};
return apiClient.invokeAPI(localVarPath, "GET", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, localVarReturnType); return apiClient.invokeAPI(localVarPath, "GET", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, localVarReturnType);
} }
/** /**
* Find purchase order by ID * Find purchase order by ID
@ -202,11 +206,13 @@ public class StoreApi {
// query params // query params
List<Pair> localVarQueryParams = new ArrayList<Pair>(); List<Pair> localVarQueryParams = new ArrayList<Pair>();
Map<String, String> localVarHeaderParams = new HashMap<String, String>(); Map<String, String> localVarHeaderParams = new HashMap<String, String>();
Map<String, String> localVarCookieParams = new HashMap<String, String>();
Map<String, Object> localVarFormParams = new HashMap<String, Object>(); Map<String, Object> localVarFormParams = new HashMap<String, Object>();
final String[] localVarAccepts = { final String[] localVarAccepts = {
"application/xml", "application/json" "application/xml", "application/json"
}; };
@ -220,7 +226,7 @@ public class StoreApi {
String[] localVarAuthNames = new String[] { }; String[] localVarAuthNames = new String[] { };
GenericType<Order> localVarReturnType = new GenericType<Order>() {}; GenericType<Order> localVarReturnType = new GenericType<Order>() {};
return apiClient.invokeAPI(localVarPath, "GET", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, localVarReturnType); return apiClient.invokeAPI(localVarPath, "GET", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, localVarReturnType);
} }
/** /**
* Place an order for a pet * Place an order for a pet
@ -266,11 +272,13 @@ public class StoreApi {
// query params // query params
List<Pair> localVarQueryParams = new ArrayList<Pair>(); List<Pair> localVarQueryParams = new ArrayList<Pair>();
Map<String, String> localVarHeaderParams = new HashMap<String, String>(); Map<String, String> localVarHeaderParams = new HashMap<String, String>();
Map<String, String> localVarCookieParams = new HashMap<String, String>();
Map<String, Object> localVarFormParams = new HashMap<String, Object>(); Map<String, Object> localVarFormParams = new HashMap<String, Object>();
final String[] localVarAccepts = { final String[] localVarAccepts = {
"application/xml", "application/json" "application/xml", "application/json"
}; };
@ -284,6 +292,6 @@ public class StoreApi {
String[] localVarAuthNames = new String[] { }; String[] localVarAuthNames = new String[] { };
GenericType<Order> localVarReturnType = new GenericType<Order>() {}; GenericType<Order> localVarReturnType = new GenericType<Order>() {};
return apiClient.invokeAPI(localVarPath, "POST", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, localVarReturnType); return apiClient.invokeAPI(localVarPath, "POST", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, localVarReturnType);
} }
} }

View File

@ -77,11 +77,13 @@ public class UserApi {
// query params // query params
List<Pair> localVarQueryParams = new ArrayList<Pair>(); List<Pair> localVarQueryParams = new ArrayList<Pair>();
Map<String, String> localVarHeaderParams = new HashMap<String, String>(); Map<String, String> localVarHeaderParams = new HashMap<String, String>();
Map<String, String> localVarCookieParams = new HashMap<String, String>();
Map<String, Object> localVarFormParams = new HashMap<String, Object>(); Map<String, Object> localVarFormParams = new HashMap<String, Object>();
final String[] localVarAccepts = { final String[] localVarAccepts = {
}; };
@ -95,7 +97,7 @@ public class UserApi {
String[] localVarAuthNames = new String[] { }; String[] localVarAuthNames = new String[] { };
return apiClient.invokeAPI(localVarPath, "POST", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, null); return apiClient.invokeAPI(localVarPath, "POST", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, null);
} }
/** /**
* Creates list of users with given input array * Creates list of users with given input array
@ -139,11 +141,13 @@ public class UserApi {
// query params // query params
List<Pair> localVarQueryParams = new ArrayList<Pair>(); List<Pair> localVarQueryParams = new ArrayList<Pair>();
Map<String, String> localVarHeaderParams = new HashMap<String, String>(); Map<String, String> localVarHeaderParams = new HashMap<String, String>();
Map<String, String> localVarCookieParams = new HashMap<String, String>();
Map<String, Object> localVarFormParams = new HashMap<String, Object>(); Map<String, Object> localVarFormParams = new HashMap<String, Object>();
final String[] localVarAccepts = { final String[] localVarAccepts = {
}; };
@ -157,7 +161,7 @@ public class UserApi {
String[] localVarAuthNames = new String[] { }; String[] localVarAuthNames = new String[] { };
return apiClient.invokeAPI(localVarPath, "POST", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, null); return apiClient.invokeAPI(localVarPath, "POST", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, null);
} }
/** /**
* Creates list of users with given input array * Creates list of users with given input array
@ -201,11 +205,13 @@ public class UserApi {
// query params // query params
List<Pair> localVarQueryParams = new ArrayList<Pair>(); List<Pair> localVarQueryParams = new ArrayList<Pair>();
Map<String, String> localVarHeaderParams = new HashMap<String, String>(); Map<String, String> localVarHeaderParams = new HashMap<String, String>();
Map<String, String> localVarCookieParams = new HashMap<String, String>();
Map<String, Object> localVarFormParams = new HashMap<String, Object>(); Map<String, Object> localVarFormParams = new HashMap<String, Object>();
final String[] localVarAccepts = { final String[] localVarAccepts = {
}; };
@ -219,7 +225,7 @@ public class UserApi {
String[] localVarAuthNames = new String[] { }; String[] localVarAuthNames = new String[] { };
return apiClient.invokeAPI(localVarPath, "POST", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, null); return apiClient.invokeAPI(localVarPath, "POST", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, null);
} }
/** /**
* Delete user * Delete user
@ -266,11 +272,13 @@ public class UserApi {
// query params // query params
List<Pair> localVarQueryParams = new ArrayList<Pair>(); List<Pair> localVarQueryParams = new ArrayList<Pair>();
Map<String, String> localVarHeaderParams = new HashMap<String, String>(); Map<String, String> localVarHeaderParams = new HashMap<String, String>();
Map<String, String> localVarCookieParams = new HashMap<String, String>();
Map<String, Object> localVarFormParams = new HashMap<String, Object>(); Map<String, Object> localVarFormParams = new HashMap<String, Object>();
final String[] localVarAccepts = { final String[] localVarAccepts = {
}; };
@ -284,7 +292,7 @@ public class UserApi {
String[] localVarAuthNames = new String[] { }; String[] localVarAuthNames = new String[] { };
return apiClient.invokeAPI(localVarPath, "DELETE", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, null); return apiClient.invokeAPI(localVarPath, "DELETE", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, null);
} }
/** /**
* Get user by user name * Get user by user name
@ -333,11 +341,13 @@ public class UserApi {
// query params // query params
List<Pair> localVarQueryParams = new ArrayList<Pair>(); List<Pair> localVarQueryParams = new ArrayList<Pair>();
Map<String, String> localVarHeaderParams = new HashMap<String, String>(); Map<String, String> localVarHeaderParams = new HashMap<String, String>();
Map<String, String> localVarCookieParams = new HashMap<String, String>();
Map<String, Object> localVarFormParams = new HashMap<String, Object>(); Map<String, Object> localVarFormParams = new HashMap<String, Object>();
final String[] localVarAccepts = { final String[] localVarAccepts = {
"application/xml", "application/json" "application/xml", "application/json"
}; };
@ -351,7 +361,7 @@ public class UserApi {
String[] localVarAuthNames = new String[] { }; String[] localVarAuthNames = new String[] { };
GenericType<User> localVarReturnType = new GenericType<User>() {}; GenericType<User> localVarReturnType = new GenericType<User>() {};
return apiClient.invokeAPI(localVarPath, "GET", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, localVarReturnType); return apiClient.invokeAPI(localVarPath, "GET", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, localVarReturnType);
} }
/** /**
* Logs user into the system * Logs user into the system
@ -404,6 +414,7 @@ public class UserApi {
// query params // query params
List<Pair> localVarQueryParams = new ArrayList<Pair>(); List<Pair> localVarQueryParams = new ArrayList<Pair>();
Map<String, String> localVarHeaderParams = new HashMap<String, String>(); Map<String, String> localVarHeaderParams = new HashMap<String, String>();
Map<String, String> localVarCookieParams = new HashMap<String, String>();
Map<String, Object> localVarFormParams = new HashMap<String, Object>(); Map<String, Object> localVarFormParams = new HashMap<String, Object>();
localVarQueryParams.addAll(apiClient.parameterToPairs("", "username", username)); localVarQueryParams.addAll(apiClient.parameterToPairs("", "username", username));
@ -411,6 +422,7 @@ public class UserApi {
final String[] localVarAccepts = { final String[] localVarAccepts = {
"application/xml", "application/json" "application/xml", "application/json"
}; };
@ -424,7 +436,7 @@ public class UserApi {
String[] localVarAuthNames = new String[] { }; String[] localVarAuthNames = new String[] { };
GenericType<String> localVarReturnType = new GenericType<String>() {}; GenericType<String> localVarReturnType = new GenericType<String>() {};
return apiClient.invokeAPI(localVarPath, "GET", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, localVarReturnType); return apiClient.invokeAPI(localVarPath, "GET", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, localVarReturnType);
} }
/** /**
* Logs out current logged in user session * Logs out current logged in user session
@ -461,11 +473,13 @@ public class UserApi {
// query params // query params
List<Pair> localVarQueryParams = new ArrayList<Pair>(); List<Pair> localVarQueryParams = new ArrayList<Pair>();
Map<String, String> localVarHeaderParams = new HashMap<String, String>(); Map<String, String> localVarHeaderParams = new HashMap<String, String>();
Map<String, String> localVarCookieParams = new HashMap<String, String>();
Map<String, Object> localVarFormParams = new HashMap<String, Object>(); Map<String, Object> localVarFormParams = new HashMap<String, Object>();
final String[] localVarAccepts = { final String[] localVarAccepts = {
}; };
@ -479,7 +493,7 @@ public class UserApi {
String[] localVarAuthNames = new String[] { }; String[] localVarAuthNames = new String[] { };
return apiClient.invokeAPI(localVarPath, "GET", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, null); return apiClient.invokeAPI(localVarPath, "GET", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, null);
} }
/** /**
* Updated user * Updated user
@ -533,11 +547,13 @@ public class UserApi {
// query params // query params
List<Pair> localVarQueryParams = new ArrayList<Pair>(); List<Pair> localVarQueryParams = new ArrayList<Pair>();
Map<String, String> localVarHeaderParams = new HashMap<String, String>(); Map<String, String> localVarHeaderParams = new HashMap<String, String>();
Map<String, String> localVarCookieParams = new HashMap<String, String>();
Map<String, Object> localVarFormParams = new HashMap<String, Object>(); Map<String, Object> localVarFormParams = new HashMap<String, Object>();
final String[] localVarAccepts = { final String[] localVarAccepts = {
}; };
@ -551,6 +567,6 @@ public class UserApi {
String[] localVarAuthNames = new String[] { }; String[] localVarAuthNames = new String[] { };
return apiClient.invokeAPI(localVarPath, "PUT", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, null); return apiClient.invokeAPI(localVarPath, "PUT", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, null);
} }
} }

View File

@ -56,7 +56,7 @@ public class ApiKeyAuth implements Authentication {
} }
@Override @Override
public void applyToParams(List<Pair> queryParams, Map<String, String> headerParams) { public void applyToParams(List<Pair> queryParams, Map<String, String> headerParams, Map<String, String> cookieParams) {
if (apiKey == null) { if (apiKey == null) {
return; return;
} }
@ -70,6 +70,8 @@ public class ApiKeyAuth implements Authentication {
queryParams.add(new Pair(paramName, value)); queryParams.add(new Pair(paramName, value));
} else if ("header".equals(location)) { } else if ("header".equals(location)) {
headerParams.put(paramName, value); headerParams.put(paramName, value);
} else if ("cookie".equals(location)) {
cookieParams.put(paramName, value);
} }
} }
} }

View File

@ -24,6 +24,7 @@ public interface Authentication {
* *
* @param queryParams List of query parameters * @param queryParams List of query parameters
* @param headerParams Map of header parameters * @param headerParams Map of header parameters
* @param cookieParams Map of cookie parameters
*/ */
void applyToParams(List<Pair> queryParams, Map<String, String> headerParams); void applyToParams(List<Pair> queryParams, Map<String, String> headerParams, Map<String, String> cookieParams);
} }

View File

@ -44,7 +44,7 @@ public class HttpBasicAuth implements Authentication {
} }
@Override @Override
public void applyToParams(List<Pair> queryParams, Map<String, String> headerParams) { public void applyToParams(List<Pair> queryParams, Map<String, String> headerParams, Map<String, String> cookieParams) {
if (username == null && password == null) { if (username == null && password == null) {
return; return;
} }

View File

@ -46,7 +46,7 @@ public class HttpBearerAuth implements Authentication {
} }
@Override @Override
public void applyToParams(List<Pair> queryParams, Map<String, String> headerParams) { public void applyToParams(List<Pair> queryParams, Map<String, String> headerParams, Map<String, String> cookieParams) {
if(bearerToken == null) { if(bearerToken == null) {
return; return;
} }

View File

@ -31,7 +31,7 @@ public class OAuth implements Authentication {
} }
@Override @Override
public void applyToParams(List<Pair> queryParams, Map<String, String> headerParams) { public void applyToParams(List<Pair> queryParams, Map<String, String> headerParams, Map<String, String> cookieParams) {
if (accessToken != null) { if (accessToken != null) {
headerParams.put("Authorization", "Bearer " + accessToken); headerParams.put("Authorization", "Bearer " + accessToken);
} }

View File

@ -54,6 +54,7 @@ import org.openapitools.client.auth.OAuth;
public class ApiClient { public class ApiClient {
protected Map<String, String> defaultHeaderMap = new HashMap<String, String>(); protected Map<String, String> defaultHeaderMap = new HashMap<String, String>();
protected Map<String, String> defaultCookieMap = new HashMap<String, String>();
protected String basePath = "http://petstore.swagger.io:80/v2"; protected String basePath = "http://petstore.swagger.io:80/v2";
protected boolean debugging = false; protected boolean debugging = false;
protected int connectionTimeout = 0; protected int connectionTimeout = 0;
@ -236,6 +237,18 @@ public class ApiClient {
return this; return this;
} }
/**
* Add a default cookie.
*
* @param key The cookie's key
* @param value The cookie's value
* @return API client
*/
public ApiClient addDefaultCookie(String key, String value) {
defaultCookieMap.put(key, value);
return this;
}
/** /**
* Check that whether debugging is enabled for this API client. * Check that whether debugging is enabled for this API client.
* @return True if debugging is switched on * @return True if debugging is switched on
@ -306,7 +319,7 @@ public class ApiClient {
public int getReadTimeout() { public int getReadTimeout() {
return readTimeout; return readTimeout;
} }
/** /**
* Set the read timeout (in milliseconds). * Set the read timeout (in milliseconds).
* A value of 0 means no timeout, otherwise values must be between 1 and * A value of 0 means no timeout, otherwise values must be between 1 and
@ -646,6 +659,7 @@ public class ApiClient {
* @param queryParams The query parameters * @param queryParams The query parameters
* @param body The request body object * @param body The request body object
* @param headerParams The header parameters * @param headerParams The header parameters
* @param cookieParams The cookie parameters
* @param formParams The form parameters * @param formParams The form parameters
* @param accept The request's Accept header * @param accept The request's Accept header
* @param contentType The request's Content-Type header * @param contentType The request's Content-Type header
@ -654,8 +668,8 @@ public class ApiClient {
* @return The response body in type of string * @return The response body in type of string
* @throws ApiException API exception * @throws ApiException API exception
*/ */
public <T> ApiResponse<T> invokeAPI(String path, String method, List<Pair> queryParams, Object body, Map<String, String> headerParams, Map<String, Object> formParams, String accept, String contentType, String[] authNames, GenericType<T> returnType) throws ApiException { public <T> ApiResponse<T> invokeAPI(String path, String method, List<Pair> queryParams, Object body, Map<String, String> headerParams, Map<String, String> cookieParams, Map<String, Object> formParams, String accept, String contentType, String[] authNames, GenericType<T> returnType) throws ApiException {
updateParamsForAuth(authNames, queryParams, headerParams); updateParamsForAuth(authNames, queryParams, headerParams, cookieParams);
// Not using `.target(this.basePath).path(path)` below, // Not using `.target(this.basePath).path(path)` below,
// to support (constant) query string in `path`, e.g. "/posts?draft=1" // to support (constant) query string in `path`, e.g. "/posts?draft=1"
@ -678,6 +692,13 @@ public class ApiClient {
} }
} }
for (Entry<String, String> entry : cookieParams.entrySet()) {
String value = entry.getValue();
if (value != null) {
invocationBuilder = invocationBuilder.cookie(entry.getKey(), value);
}
}
for (Entry<String, String> entry : defaultHeaderMap.entrySet()) { for (Entry<String, String> entry : defaultHeaderMap.entrySet()) {
String key = entry.getKey(); String key = entry.getKey();
if (!headerParams.containsKey(key)) { if (!headerParams.containsKey(key)) {
@ -798,12 +819,13 @@ public class ApiClient {
* @param authNames The authentications to apply * @param authNames The authentications to apply
* @param queryParams List of query parameters * @param queryParams List of query parameters
* @param headerParams Map of header parameters * @param headerParams Map of header parameters
* @param cookieParams Map of cookie parameters
*/ */
protected void updateParamsForAuth(String[] authNames, List<Pair> queryParams, Map<String, String> headerParams) { protected void updateParamsForAuth(String[] authNames, List<Pair> queryParams, Map<String, String> headerParams, Map<String, String> cookieParams) {
for (String authName : authNames) { for (String authName : authNames) {
Authentication auth = authentications.get(authName); Authentication auth = authentications.get(authName);
if (auth == null) throw new RuntimeException("Authentication undefined: " + authName); if (auth == null) throw new RuntimeException("Authentication undefined: " + authName);
auth.applyToParams(queryParams, headerParams); auth.applyToParams(queryParams, headerParams, cookieParams);
} }
} }
} }

View File

@ -77,11 +77,13 @@ public class AnotherFakeApi {
// query params // query params
List<Pair> localVarQueryParams = new ArrayList<Pair>(); List<Pair> localVarQueryParams = new ArrayList<Pair>();
Map<String, String> localVarHeaderParams = new HashMap<String, String>(); Map<String, String> localVarHeaderParams = new HashMap<String, String>();
Map<String, String> localVarCookieParams = new HashMap<String, String>();
Map<String, Object> localVarFormParams = new HashMap<String, Object>(); Map<String, Object> localVarFormParams = new HashMap<String, Object>();
final String[] localVarAccepts = { final String[] localVarAccepts = {
"application/json" "application/json"
}; };
@ -95,6 +97,6 @@ public class AnotherFakeApi {
String[] localVarAuthNames = new String[] { }; String[] localVarAuthNames = new String[] { };
GenericType<Client> localVarReturnType = new GenericType<Client>() {}; GenericType<Client> localVarReturnType = new GenericType<Client>() {};
return apiClient.invokeAPI(localVarPath, "PATCH", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, localVarReturnType); return apiClient.invokeAPI(localVarPath, "PATCH", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, localVarReturnType);
} }
} }

View File

@ -85,11 +85,13 @@ public class FakeApi {
// query params // query params
List<Pair> localVarQueryParams = new ArrayList<Pair>(); List<Pair> localVarQueryParams = new ArrayList<Pair>();
Map<String, String> localVarHeaderParams = new HashMap<String, String>(); Map<String, String> localVarHeaderParams = new HashMap<String, String>();
Map<String, String> localVarCookieParams = new HashMap<String, String>();
Map<String, Object> localVarFormParams = new HashMap<String, Object>(); Map<String, Object> localVarFormParams = new HashMap<String, Object>();
final String[] localVarAccepts = { final String[] localVarAccepts = {
}; };
@ -103,7 +105,7 @@ public class FakeApi {
String[] localVarAuthNames = new String[] { }; String[] localVarAuthNames = new String[] { };
return apiClient.invokeAPI(localVarPath, "POST", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, null); return apiClient.invokeAPI(localVarPath, "POST", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, null);
} }
/** /**
* *
@ -142,11 +144,13 @@ public class FakeApi {
// query params // query params
List<Pair> localVarQueryParams = new ArrayList<Pair>(); List<Pair> localVarQueryParams = new ArrayList<Pair>();
Map<String, String> localVarHeaderParams = new HashMap<String, String>(); Map<String, String> localVarHeaderParams = new HashMap<String, String>();
Map<String, String> localVarCookieParams = new HashMap<String, String>();
Map<String, Object> localVarFormParams = new HashMap<String, Object>(); Map<String, Object> localVarFormParams = new HashMap<String, Object>();
final String[] localVarAccepts = { final String[] localVarAccepts = {
"*/*" "*/*"
}; };
@ -160,7 +164,7 @@ public class FakeApi {
String[] localVarAuthNames = new String[] { }; String[] localVarAuthNames = new String[] { };
GenericType<Boolean> localVarReturnType = new GenericType<Boolean>() {}; GenericType<Boolean> localVarReturnType = new GenericType<Boolean>() {};
return apiClient.invokeAPI(localVarPath, "POST", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, localVarReturnType); return apiClient.invokeAPI(localVarPath, "POST", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, localVarReturnType);
} }
/** /**
* *
@ -199,11 +203,13 @@ public class FakeApi {
// query params // query params
List<Pair> localVarQueryParams = new ArrayList<Pair>(); List<Pair> localVarQueryParams = new ArrayList<Pair>();
Map<String, String> localVarHeaderParams = new HashMap<String, String>(); Map<String, String> localVarHeaderParams = new HashMap<String, String>();
Map<String, String> localVarCookieParams = new HashMap<String, String>();
Map<String, Object> localVarFormParams = new HashMap<String, Object>(); Map<String, Object> localVarFormParams = new HashMap<String, Object>();
final String[] localVarAccepts = { final String[] localVarAccepts = {
"*/*" "*/*"
}; };
@ -217,7 +223,7 @@ public class FakeApi {
String[] localVarAuthNames = new String[] { }; String[] localVarAuthNames = new String[] { };
GenericType<OuterComposite> localVarReturnType = new GenericType<OuterComposite>() {}; GenericType<OuterComposite> localVarReturnType = new GenericType<OuterComposite>() {};
return apiClient.invokeAPI(localVarPath, "POST", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, localVarReturnType); return apiClient.invokeAPI(localVarPath, "POST", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, localVarReturnType);
} }
/** /**
* *
@ -256,11 +262,13 @@ public class FakeApi {
// query params // query params
List<Pair> localVarQueryParams = new ArrayList<Pair>(); List<Pair> localVarQueryParams = new ArrayList<Pair>();
Map<String, String> localVarHeaderParams = new HashMap<String, String>(); Map<String, String> localVarHeaderParams = new HashMap<String, String>();
Map<String, String> localVarCookieParams = new HashMap<String, String>();
Map<String, Object> localVarFormParams = new HashMap<String, Object>(); Map<String, Object> localVarFormParams = new HashMap<String, Object>();
final String[] localVarAccepts = { final String[] localVarAccepts = {
"*/*" "*/*"
}; };
@ -274,7 +282,7 @@ public class FakeApi {
String[] localVarAuthNames = new String[] { }; String[] localVarAuthNames = new String[] { };
GenericType<BigDecimal> localVarReturnType = new GenericType<BigDecimal>() {}; GenericType<BigDecimal> localVarReturnType = new GenericType<BigDecimal>() {};
return apiClient.invokeAPI(localVarPath, "POST", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, localVarReturnType); return apiClient.invokeAPI(localVarPath, "POST", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, localVarReturnType);
} }
/** /**
* *
@ -313,11 +321,13 @@ public class FakeApi {
// query params // query params
List<Pair> localVarQueryParams = new ArrayList<Pair>(); List<Pair> localVarQueryParams = new ArrayList<Pair>();
Map<String, String> localVarHeaderParams = new HashMap<String, String>(); Map<String, String> localVarHeaderParams = new HashMap<String, String>();
Map<String, String> localVarCookieParams = new HashMap<String, String>();
Map<String, Object> localVarFormParams = new HashMap<String, Object>(); Map<String, Object> localVarFormParams = new HashMap<String, Object>();
final String[] localVarAccepts = { final String[] localVarAccepts = {
"*/*" "*/*"
}; };
@ -331,7 +341,7 @@ public class FakeApi {
String[] localVarAuthNames = new String[] { }; String[] localVarAuthNames = new String[] { };
GenericType<String> localVarReturnType = new GenericType<String>() {}; GenericType<String> localVarReturnType = new GenericType<String>() {};
return apiClient.invokeAPI(localVarPath, "POST", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, localVarReturnType); return apiClient.invokeAPI(localVarPath, "POST", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, localVarReturnType);
} }
/** /**
* *
@ -375,11 +385,13 @@ public class FakeApi {
// query params // query params
List<Pair> localVarQueryParams = new ArrayList<Pair>(); List<Pair> localVarQueryParams = new ArrayList<Pair>();
Map<String, String> localVarHeaderParams = new HashMap<String, String>(); Map<String, String> localVarHeaderParams = new HashMap<String, String>();
Map<String, String> localVarCookieParams = new HashMap<String, String>();
Map<String, Object> localVarFormParams = new HashMap<String, Object>(); Map<String, Object> localVarFormParams = new HashMap<String, Object>();
final String[] localVarAccepts = { final String[] localVarAccepts = {
}; };
@ -393,7 +405,7 @@ public class FakeApi {
String[] localVarAuthNames = new String[] { }; String[] localVarAuthNames = new String[] { };
return apiClient.invokeAPI(localVarPath, "PUT", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, null); return apiClient.invokeAPI(localVarPath, "PUT", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, null);
} }
/** /**
* *
@ -444,12 +456,14 @@ public class FakeApi {
// query params // query params
List<Pair> localVarQueryParams = new ArrayList<Pair>(); List<Pair> localVarQueryParams = new ArrayList<Pair>();
Map<String, String> localVarHeaderParams = new HashMap<String, String>(); Map<String, String> localVarHeaderParams = new HashMap<String, String>();
Map<String, String> localVarCookieParams = new HashMap<String, String>();
Map<String, Object> localVarFormParams = new HashMap<String, Object>(); Map<String, Object> localVarFormParams = new HashMap<String, Object>();
localVarQueryParams.addAll(apiClient.parameterToPairs("", "query", query)); localVarQueryParams.addAll(apiClient.parameterToPairs("", "query", query));
final String[] localVarAccepts = { final String[] localVarAccepts = {
}; };
@ -463,7 +477,7 @@ public class FakeApi {
String[] localVarAuthNames = new String[] { }; String[] localVarAuthNames = new String[] { };
return apiClient.invokeAPI(localVarPath, "PUT", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, null); return apiClient.invokeAPI(localVarPath, "PUT", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, null);
} }
/** /**
* To test \&quot;client\&quot; model * To test \&quot;client\&quot; model
@ -507,11 +521,13 @@ public class FakeApi {
// query params // query params
List<Pair> localVarQueryParams = new ArrayList<Pair>(); List<Pair> localVarQueryParams = new ArrayList<Pair>();
Map<String, String> localVarHeaderParams = new HashMap<String, String>(); Map<String, String> localVarHeaderParams = new HashMap<String, String>();
Map<String, String> localVarCookieParams = new HashMap<String, String>();
Map<String, Object> localVarFormParams = new HashMap<String, Object>(); Map<String, Object> localVarFormParams = new HashMap<String, Object>();
final String[] localVarAccepts = { final String[] localVarAccepts = {
"application/json" "application/json"
}; };
@ -525,7 +541,7 @@ public class FakeApi {
String[] localVarAuthNames = new String[] { }; String[] localVarAuthNames = new String[] { };
GenericType<Client> localVarReturnType = new GenericType<Client>() {}; GenericType<Client> localVarReturnType = new GenericType<Client>() {};
return apiClient.invokeAPI(localVarPath, "PATCH", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, localVarReturnType); return apiClient.invokeAPI(localVarPath, "PATCH", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, localVarReturnType);
} }
/** /**
* Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 * Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트
@ -612,10 +628,12 @@ public class FakeApi {
// query params // query params
List<Pair> localVarQueryParams = new ArrayList<Pair>(); List<Pair> localVarQueryParams = new ArrayList<Pair>();
Map<String, String> localVarHeaderParams = new HashMap<String, String>(); Map<String, String> localVarHeaderParams = new HashMap<String, String>();
Map<String, String> localVarCookieParams = new HashMap<String, String>();
Map<String, Object> localVarFormParams = new HashMap<String, Object>(); Map<String, Object> localVarFormParams = new HashMap<String, Object>();
if (integer != null) if (integer != null)
localVarFormParams.put("integer", integer); localVarFormParams.put("integer", integer);
if (int32 != null) if (int32 != null)
@ -658,7 +676,7 @@ if (paramCallback != null)
String[] localVarAuthNames = new String[] { "http_basic_test" }; String[] localVarAuthNames = new String[] { "http_basic_test" };
return apiClient.invokeAPI(localVarPath, "POST", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, null); return apiClient.invokeAPI(localVarPath, "POST", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, null);
} }
/** /**
* To test enum parameters * To test enum parameters
@ -713,6 +731,7 @@ if (paramCallback != null)
// query params // query params
List<Pair> localVarQueryParams = new ArrayList<Pair>(); List<Pair> localVarQueryParams = new ArrayList<Pair>();
Map<String, String> localVarHeaderParams = new HashMap<String, String>(); Map<String, String> localVarHeaderParams = new HashMap<String, String>();
Map<String, String> localVarCookieParams = new HashMap<String, String>();
Map<String, Object> localVarFormParams = new HashMap<String, Object>(); Map<String, Object> localVarFormParams = new HashMap<String, Object>();
localVarQueryParams.addAll(apiClient.parameterToPairs("csv", "enum_query_string_array", enumQueryStringArray)); localVarQueryParams.addAll(apiClient.parameterToPairs("csv", "enum_query_string_array", enumQueryStringArray));
@ -725,6 +744,7 @@ if (paramCallback != null)
if (enumHeaderString != null) if (enumHeaderString != null)
localVarHeaderParams.put("enum_header_string", apiClient.parameterToString(enumHeaderString)); localVarHeaderParams.put("enum_header_string", apiClient.parameterToString(enumHeaderString));
if (enumFormStringArray != null) if (enumFormStringArray != null)
localVarFormParams.put("enum_form_string_array", enumFormStringArray); localVarFormParams.put("enum_form_string_array", enumFormStringArray);
if (enumFormString != null) if (enumFormString != null)
@ -743,7 +763,7 @@ if (enumFormString != null)
String[] localVarAuthNames = new String[] { }; String[] localVarAuthNames = new String[] { };
return apiClient.invokeAPI(localVarPath, "GET", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, null); return apiClient.invokeAPI(localVarPath, "GET", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, null);
} }
/** /**
* Fake endpoint to test group parameters (optional) * Fake endpoint to test group parameters (optional)
@ -807,6 +827,7 @@ if (enumFormString != null)
// query params // query params
List<Pair> localVarQueryParams = new ArrayList<Pair>(); List<Pair> localVarQueryParams = new ArrayList<Pair>();
Map<String, String> localVarHeaderParams = new HashMap<String, String>(); Map<String, String> localVarHeaderParams = new HashMap<String, String>();
Map<String, String> localVarCookieParams = new HashMap<String, String>();
Map<String, Object> localVarFormParams = new HashMap<String, Object>(); Map<String, Object> localVarFormParams = new HashMap<String, Object>();
localVarQueryParams.addAll(apiClient.parameterToPairs("", "required_string_group", requiredStringGroup)); localVarQueryParams.addAll(apiClient.parameterToPairs("", "required_string_group", requiredStringGroup));
@ -820,6 +841,7 @@ if (booleanGroup != null)
localVarHeaderParams.put("boolean_group", apiClient.parameterToString(booleanGroup)); localVarHeaderParams.put("boolean_group", apiClient.parameterToString(booleanGroup));
final String[] localVarAccepts = { final String[] localVarAccepts = {
}; };
@ -833,7 +855,7 @@ if (booleanGroup != null)
String[] localVarAuthNames = new String[] { }; String[] localVarAuthNames = new String[] { };
return apiClient.invokeAPI(localVarPath, "DELETE", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, null); return apiClient.invokeAPI(localVarPath, "DELETE", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, null);
} }
/** /**
* test inline additionalProperties * test inline additionalProperties
@ -877,11 +899,13 @@ if (booleanGroup != null)
// query params // query params
List<Pair> localVarQueryParams = new ArrayList<Pair>(); List<Pair> localVarQueryParams = new ArrayList<Pair>();
Map<String, String> localVarHeaderParams = new HashMap<String, String>(); Map<String, String> localVarHeaderParams = new HashMap<String, String>();
Map<String, String> localVarCookieParams = new HashMap<String, String>();
Map<String, Object> localVarFormParams = new HashMap<String, Object>(); Map<String, Object> localVarFormParams = new HashMap<String, Object>();
final String[] localVarAccepts = { final String[] localVarAccepts = {
}; };
@ -895,7 +919,7 @@ if (booleanGroup != null)
String[] localVarAuthNames = new String[] { }; String[] localVarAuthNames = new String[] { };
return apiClient.invokeAPI(localVarPath, "POST", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, null); return apiClient.invokeAPI(localVarPath, "POST", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, null);
} }
/** /**
* test json serialization of form data * test json serialization of form data
@ -946,10 +970,12 @@ if (booleanGroup != null)
// query params // query params
List<Pair> localVarQueryParams = new ArrayList<Pair>(); List<Pair> localVarQueryParams = new ArrayList<Pair>();
Map<String, String> localVarHeaderParams = new HashMap<String, String>(); Map<String, String> localVarHeaderParams = new HashMap<String, String>();
Map<String, String> localVarCookieParams = new HashMap<String, String>();
Map<String, Object> localVarFormParams = new HashMap<String, Object>(); Map<String, Object> localVarFormParams = new HashMap<String, Object>();
if (param != null) if (param != null)
localVarFormParams.put("param", param); localVarFormParams.put("param", param);
if (param2 != null) if (param2 != null)
@ -968,7 +994,7 @@ if (param2 != null)
String[] localVarAuthNames = new String[] { }; String[] localVarAuthNames = new String[] { };
return apiClient.invokeAPI(localVarPath, "GET", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, null); return apiClient.invokeAPI(localVarPath, "GET", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, null);
} }
/** /**
* *
@ -1040,6 +1066,7 @@ if (param2 != null)
// query params // query params
List<Pair> localVarQueryParams = new ArrayList<Pair>(); List<Pair> localVarQueryParams = new ArrayList<Pair>();
Map<String, String> localVarHeaderParams = new HashMap<String, String>(); Map<String, String> localVarHeaderParams = new HashMap<String, String>();
Map<String, String> localVarCookieParams = new HashMap<String, String>();
Map<String, Object> localVarFormParams = new HashMap<String, Object>(); Map<String, Object> localVarFormParams = new HashMap<String, Object>();
localVarQueryParams.addAll(apiClient.parameterToPairs("csv", "pipe", pipe)); localVarQueryParams.addAll(apiClient.parameterToPairs("csv", "pipe", pipe));
@ -1050,6 +1077,7 @@ if (param2 != null)
final String[] localVarAccepts = { final String[] localVarAccepts = {
}; };
@ -1063,6 +1091,6 @@ if (param2 != null)
String[] localVarAuthNames = new String[] { }; String[] localVarAuthNames = new String[] { };
return apiClient.invokeAPI(localVarPath, "PUT", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, null); return apiClient.invokeAPI(localVarPath, "PUT", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, null);
} }
} }

View File

@ -77,11 +77,13 @@ public class FakeClassnameTags123Api {
// query params // query params
List<Pair> localVarQueryParams = new ArrayList<Pair>(); List<Pair> localVarQueryParams = new ArrayList<Pair>();
Map<String, String> localVarHeaderParams = new HashMap<String, String>(); Map<String, String> localVarHeaderParams = new HashMap<String, String>();
Map<String, String> localVarCookieParams = new HashMap<String, String>();
Map<String, Object> localVarFormParams = new HashMap<String, Object>(); Map<String, Object> localVarFormParams = new HashMap<String, Object>();
final String[] localVarAccepts = { final String[] localVarAccepts = {
"application/json" "application/json"
}; };
@ -95,6 +97,6 @@ public class FakeClassnameTags123Api {
String[] localVarAuthNames = new String[] { "api_key_query" }; String[] localVarAuthNames = new String[] { "api_key_query" };
GenericType<Client> localVarReturnType = new GenericType<Client>() {}; GenericType<Client> localVarReturnType = new GenericType<Client>() {};
return apiClient.invokeAPI(localVarPath, "PATCH", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, localVarReturnType); return apiClient.invokeAPI(localVarPath, "PATCH", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, localVarReturnType);
} }
} }

View File

@ -81,11 +81,13 @@ public class PetApi {
// query params // query params
List<Pair> localVarQueryParams = new ArrayList<Pair>(); List<Pair> localVarQueryParams = new ArrayList<Pair>();
Map<String, String> localVarHeaderParams = new HashMap<String, String>(); Map<String, String> localVarHeaderParams = new HashMap<String, String>();
Map<String, String> localVarCookieParams = new HashMap<String, String>();
Map<String, Object> localVarFormParams = new HashMap<String, Object>(); Map<String, Object> localVarFormParams = new HashMap<String, Object>();
final String[] localVarAccepts = { final String[] localVarAccepts = {
}; };
@ -99,7 +101,7 @@ public class PetApi {
String[] localVarAuthNames = new String[] { "petstore_auth" }; String[] localVarAuthNames = new String[] { "petstore_auth" };
return apiClient.invokeAPI(localVarPath, "POST", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, null); return apiClient.invokeAPI(localVarPath, "POST", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, null);
} }
/** /**
* Deletes a pet * Deletes a pet
@ -148,6 +150,7 @@ public class PetApi {
// query params // query params
List<Pair> localVarQueryParams = new ArrayList<Pair>(); List<Pair> localVarQueryParams = new ArrayList<Pair>();
Map<String, String> localVarHeaderParams = new HashMap<String, String>(); Map<String, String> localVarHeaderParams = new HashMap<String, String>();
Map<String, String> localVarCookieParams = new HashMap<String, String>();
Map<String, Object> localVarFormParams = new HashMap<String, Object>(); Map<String, Object> localVarFormParams = new HashMap<String, Object>();
@ -155,6 +158,7 @@ public class PetApi {
localVarHeaderParams.put("api_key", apiClient.parameterToString(apiKey)); localVarHeaderParams.put("api_key", apiClient.parameterToString(apiKey));
final String[] localVarAccepts = { final String[] localVarAccepts = {
}; };
@ -168,7 +172,7 @@ public class PetApi {
String[] localVarAuthNames = new String[] { "petstore_auth" }; String[] localVarAuthNames = new String[] { "petstore_auth" };
return apiClient.invokeAPI(localVarPath, "DELETE", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, null); return apiClient.invokeAPI(localVarPath, "DELETE", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, null);
} }
/** /**
* Finds Pets by status * Finds Pets by status
@ -214,12 +218,14 @@ public class PetApi {
// query params // query params
List<Pair> localVarQueryParams = new ArrayList<Pair>(); List<Pair> localVarQueryParams = new ArrayList<Pair>();
Map<String, String> localVarHeaderParams = new HashMap<String, String>(); Map<String, String> localVarHeaderParams = new HashMap<String, String>();
Map<String, String> localVarCookieParams = new HashMap<String, String>();
Map<String, Object> localVarFormParams = new HashMap<String, Object>(); Map<String, Object> localVarFormParams = new HashMap<String, Object>();
localVarQueryParams.addAll(apiClient.parameterToPairs("csv", "status", status)); localVarQueryParams.addAll(apiClient.parameterToPairs("csv", "status", status));
final String[] localVarAccepts = { final String[] localVarAccepts = {
"application/xml", "application/json" "application/xml", "application/json"
}; };
@ -233,7 +239,7 @@ public class PetApi {
String[] localVarAuthNames = new String[] { "petstore_auth" }; String[] localVarAuthNames = new String[] { "petstore_auth" };
GenericType<List<Pet>> localVarReturnType = new GenericType<List<Pet>>() {}; GenericType<List<Pet>> localVarReturnType = new GenericType<List<Pet>>() {};
return apiClient.invokeAPI(localVarPath, "GET", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, localVarReturnType); return apiClient.invokeAPI(localVarPath, "GET", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, localVarReturnType);
} }
/** /**
* Finds Pets by tags * Finds Pets by tags
@ -283,12 +289,14 @@ public class PetApi {
// query params // query params
List<Pair> localVarQueryParams = new ArrayList<Pair>(); List<Pair> localVarQueryParams = new ArrayList<Pair>();
Map<String, String> localVarHeaderParams = new HashMap<String, String>(); Map<String, String> localVarHeaderParams = new HashMap<String, String>();
Map<String, String> localVarCookieParams = new HashMap<String, String>();
Map<String, Object> localVarFormParams = new HashMap<String, Object>(); Map<String, Object> localVarFormParams = new HashMap<String, Object>();
localVarQueryParams.addAll(apiClient.parameterToPairs("csv", "tags", tags)); localVarQueryParams.addAll(apiClient.parameterToPairs("csv", "tags", tags));
final String[] localVarAccepts = { final String[] localVarAccepts = {
"application/xml", "application/json" "application/xml", "application/json"
}; };
@ -302,7 +310,7 @@ public class PetApi {
String[] localVarAuthNames = new String[] { "petstore_auth" }; String[] localVarAuthNames = new String[] { "petstore_auth" };
GenericType<List<Pet>> localVarReturnType = new GenericType<List<Pet>>() {}; GenericType<List<Pet>> localVarReturnType = new GenericType<List<Pet>>() {};
return apiClient.invokeAPI(localVarPath, "GET", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, localVarReturnType); return apiClient.invokeAPI(localVarPath, "GET", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, localVarReturnType);
} }
/** /**
* Find pet by ID * Find pet by ID
@ -351,11 +359,13 @@ public class PetApi {
// query params // query params
List<Pair> localVarQueryParams = new ArrayList<Pair>(); List<Pair> localVarQueryParams = new ArrayList<Pair>();
Map<String, String> localVarHeaderParams = new HashMap<String, String>(); Map<String, String> localVarHeaderParams = new HashMap<String, String>();
Map<String, String> localVarCookieParams = new HashMap<String, String>();
Map<String, Object> localVarFormParams = new HashMap<String, Object>(); Map<String, Object> localVarFormParams = new HashMap<String, Object>();
final String[] localVarAccepts = { final String[] localVarAccepts = {
"application/xml", "application/json" "application/xml", "application/json"
}; };
@ -369,7 +379,7 @@ public class PetApi {
String[] localVarAuthNames = new String[] { "api_key" }; String[] localVarAuthNames = new String[] { "api_key" };
GenericType<Pet> localVarReturnType = new GenericType<Pet>() {}; GenericType<Pet> localVarReturnType = new GenericType<Pet>() {};
return apiClient.invokeAPI(localVarPath, "GET", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, localVarReturnType); return apiClient.invokeAPI(localVarPath, "GET", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, localVarReturnType);
} }
/** /**
* Update an existing pet * Update an existing pet
@ -419,11 +429,13 @@ public class PetApi {
// query params // query params
List<Pair> localVarQueryParams = new ArrayList<Pair>(); List<Pair> localVarQueryParams = new ArrayList<Pair>();
Map<String, String> localVarHeaderParams = new HashMap<String, String>(); Map<String, String> localVarHeaderParams = new HashMap<String, String>();
Map<String, String> localVarCookieParams = new HashMap<String, String>();
Map<String, Object> localVarFormParams = new HashMap<String, Object>(); Map<String, Object> localVarFormParams = new HashMap<String, Object>();
final String[] localVarAccepts = { final String[] localVarAccepts = {
}; };
@ -437,7 +449,7 @@ public class PetApi {
String[] localVarAuthNames = new String[] { "petstore_auth" }; String[] localVarAuthNames = new String[] { "petstore_auth" };
return apiClient.invokeAPI(localVarPath, "PUT", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, null); return apiClient.invokeAPI(localVarPath, "PUT", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, null);
} }
/** /**
* Updates a pet in the store with form data * Updates a pet in the store with form data
@ -486,10 +498,12 @@ public class PetApi {
// query params // query params
List<Pair> localVarQueryParams = new ArrayList<Pair>(); List<Pair> localVarQueryParams = new ArrayList<Pair>();
Map<String, String> localVarHeaderParams = new HashMap<String, String>(); Map<String, String> localVarHeaderParams = new HashMap<String, String>();
Map<String, String> localVarCookieParams = new HashMap<String, String>();
Map<String, Object> localVarFormParams = new HashMap<String, Object>(); Map<String, Object> localVarFormParams = new HashMap<String, Object>();
if (name != null) if (name != null)
localVarFormParams.put("name", name); localVarFormParams.put("name", name);
if (status != null) if (status != null)
@ -508,7 +522,7 @@ if (status != null)
String[] localVarAuthNames = new String[] { "petstore_auth" }; String[] localVarAuthNames = new String[] { "petstore_auth" };
return apiClient.invokeAPI(localVarPath, "POST", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, null); return apiClient.invokeAPI(localVarPath, "POST", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, null);
} }
/** /**
* uploads an image * uploads an image
@ -557,10 +571,12 @@ if (status != null)
// query params // query params
List<Pair> localVarQueryParams = new ArrayList<Pair>(); List<Pair> localVarQueryParams = new ArrayList<Pair>();
Map<String, String> localVarHeaderParams = new HashMap<String, String>(); Map<String, String> localVarHeaderParams = new HashMap<String, String>();
Map<String, String> localVarCookieParams = new HashMap<String, String>();
Map<String, Object> localVarFormParams = new HashMap<String, Object>(); Map<String, Object> localVarFormParams = new HashMap<String, Object>();
if (additionalMetadata != null) if (additionalMetadata != null)
localVarFormParams.put("additionalMetadata", additionalMetadata); localVarFormParams.put("additionalMetadata", additionalMetadata);
if (file != null) if (file != null)
@ -579,7 +595,7 @@ if (file != null)
String[] localVarAuthNames = new String[] { "petstore_auth" }; String[] localVarAuthNames = new String[] { "petstore_auth" };
GenericType<ModelApiResponse> localVarReturnType = new GenericType<ModelApiResponse>() {}; GenericType<ModelApiResponse> localVarReturnType = new GenericType<ModelApiResponse>() {};
return apiClient.invokeAPI(localVarPath, "POST", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, localVarReturnType); return apiClient.invokeAPI(localVarPath, "POST", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, localVarReturnType);
} }
/** /**
* uploads an image (required) * uploads an image (required)
@ -633,10 +649,12 @@ if (file != null)
// query params // query params
List<Pair> localVarQueryParams = new ArrayList<Pair>(); List<Pair> localVarQueryParams = new ArrayList<Pair>();
Map<String, String> localVarHeaderParams = new HashMap<String, String>(); Map<String, String> localVarHeaderParams = new HashMap<String, String>();
Map<String, String> localVarCookieParams = new HashMap<String, String>();
Map<String, Object> localVarFormParams = new HashMap<String, Object>(); Map<String, Object> localVarFormParams = new HashMap<String, Object>();
if (additionalMetadata != null) if (additionalMetadata != null)
localVarFormParams.put("additionalMetadata", additionalMetadata); localVarFormParams.put("additionalMetadata", additionalMetadata);
if (requiredFile != null) if (requiredFile != null)
@ -655,6 +673,6 @@ if (requiredFile != null)
String[] localVarAuthNames = new String[] { "petstore_auth" }; String[] localVarAuthNames = new String[] { "petstore_auth" };
GenericType<ModelApiResponse> localVarReturnType = new GenericType<ModelApiResponse>() {}; GenericType<ModelApiResponse> localVarReturnType = new GenericType<ModelApiResponse>() {};
return apiClient.invokeAPI(localVarPath, "POST", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, localVarReturnType); return apiClient.invokeAPI(localVarPath, "POST", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, localVarReturnType);
} }
} }

View File

@ -80,11 +80,13 @@ public class StoreApi {
// query params // query params
List<Pair> localVarQueryParams = new ArrayList<Pair>(); List<Pair> localVarQueryParams = new ArrayList<Pair>();
Map<String, String> localVarHeaderParams = new HashMap<String, String>(); Map<String, String> localVarHeaderParams = new HashMap<String, String>();
Map<String, String> localVarCookieParams = new HashMap<String, String>();
Map<String, Object> localVarFormParams = new HashMap<String, Object>(); Map<String, Object> localVarFormParams = new HashMap<String, Object>();
final String[] localVarAccepts = { final String[] localVarAccepts = {
}; };
@ -98,7 +100,7 @@ public class StoreApi {
String[] localVarAuthNames = new String[] { }; String[] localVarAuthNames = new String[] { };
return apiClient.invokeAPI(localVarPath, "DELETE", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, null); return apiClient.invokeAPI(localVarPath, "DELETE", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, null);
} }
/** /**
* Returns pet inventories by status * Returns pet inventories by status
@ -135,11 +137,13 @@ public class StoreApi {
// query params // query params
List<Pair> localVarQueryParams = new ArrayList<Pair>(); List<Pair> localVarQueryParams = new ArrayList<Pair>();
Map<String, String> localVarHeaderParams = new HashMap<String, String>(); Map<String, String> localVarHeaderParams = new HashMap<String, String>();
Map<String, String> localVarCookieParams = new HashMap<String, String>();
Map<String, Object> localVarFormParams = new HashMap<String, Object>(); Map<String, Object> localVarFormParams = new HashMap<String, Object>();
final String[] localVarAccepts = { final String[] localVarAccepts = {
"application/json" "application/json"
}; };
@ -153,7 +157,7 @@ public class StoreApi {
String[] localVarAuthNames = new String[] { "api_key" }; String[] localVarAuthNames = new String[] { "api_key" };
GenericType<Map<String, Integer>> localVarReturnType = new GenericType<Map<String, Integer>>() {}; GenericType<Map<String, Integer>> localVarReturnType = new GenericType<Map<String, Integer>>() {};
return apiClient.invokeAPI(localVarPath, "GET", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, localVarReturnType); return apiClient.invokeAPI(localVarPath, "GET", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, localVarReturnType);
} }
/** /**
* Find purchase order by ID * Find purchase order by ID
@ -202,11 +206,13 @@ public class StoreApi {
// query params // query params
List<Pair> localVarQueryParams = new ArrayList<Pair>(); List<Pair> localVarQueryParams = new ArrayList<Pair>();
Map<String, String> localVarHeaderParams = new HashMap<String, String>(); Map<String, String> localVarHeaderParams = new HashMap<String, String>();
Map<String, String> localVarCookieParams = new HashMap<String, String>();
Map<String, Object> localVarFormParams = new HashMap<String, Object>(); Map<String, Object> localVarFormParams = new HashMap<String, Object>();
final String[] localVarAccepts = { final String[] localVarAccepts = {
"application/xml", "application/json" "application/xml", "application/json"
}; };
@ -220,7 +226,7 @@ public class StoreApi {
String[] localVarAuthNames = new String[] { }; String[] localVarAuthNames = new String[] { };
GenericType<Order> localVarReturnType = new GenericType<Order>() {}; GenericType<Order> localVarReturnType = new GenericType<Order>() {};
return apiClient.invokeAPI(localVarPath, "GET", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, localVarReturnType); return apiClient.invokeAPI(localVarPath, "GET", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, localVarReturnType);
} }
/** /**
* Place an order for a pet * Place an order for a pet
@ -266,11 +272,13 @@ public class StoreApi {
// query params // query params
List<Pair> localVarQueryParams = new ArrayList<Pair>(); List<Pair> localVarQueryParams = new ArrayList<Pair>();
Map<String, String> localVarHeaderParams = new HashMap<String, String>(); Map<String, String> localVarHeaderParams = new HashMap<String, String>();
Map<String, String> localVarCookieParams = new HashMap<String, String>();
Map<String, Object> localVarFormParams = new HashMap<String, Object>(); Map<String, Object> localVarFormParams = new HashMap<String, Object>();
final String[] localVarAccepts = { final String[] localVarAccepts = {
"application/xml", "application/json" "application/xml", "application/json"
}; };
@ -284,6 +292,6 @@ public class StoreApi {
String[] localVarAuthNames = new String[] { }; String[] localVarAuthNames = new String[] { };
GenericType<Order> localVarReturnType = new GenericType<Order>() {}; GenericType<Order> localVarReturnType = new GenericType<Order>() {};
return apiClient.invokeAPI(localVarPath, "POST", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, localVarReturnType); return apiClient.invokeAPI(localVarPath, "POST", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, localVarReturnType);
} }
} }

View File

@ -77,11 +77,13 @@ public class UserApi {
// query params // query params
List<Pair> localVarQueryParams = new ArrayList<Pair>(); List<Pair> localVarQueryParams = new ArrayList<Pair>();
Map<String, String> localVarHeaderParams = new HashMap<String, String>(); Map<String, String> localVarHeaderParams = new HashMap<String, String>();
Map<String, String> localVarCookieParams = new HashMap<String, String>();
Map<String, Object> localVarFormParams = new HashMap<String, Object>(); Map<String, Object> localVarFormParams = new HashMap<String, Object>();
final String[] localVarAccepts = { final String[] localVarAccepts = {
}; };
@ -95,7 +97,7 @@ public class UserApi {
String[] localVarAuthNames = new String[] { }; String[] localVarAuthNames = new String[] { };
return apiClient.invokeAPI(localVarPath, "POST", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, null); return apiClient.invokeAPI(localVarPath, "POST", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, null);
} }
/** /**
* Creates list of users with given input array * Creates list of users with given input array
@ -139,11 +141,13 @@ public class UserApi {
// query params // query params
List<Pair> localVarQueryParams = new ArrayList<Pair>(); List<Pair> localVarQueryParams = new ArrayList<Pair>();
Map<String, String> localVarHeaderParams = new HashMap<String, String>(); Map<String, String> localVarHeaderParams = new HashMap<String, String>();
Map<String, String> localVarCookieParams = new HashMap<String, String>();
Map<String, Object> localVarFormParams = new HashMap<String, Object>(); Map<String, Object> localVarFormParams = new HashMap<String, Object>();
final String[] localVarAccepts = { final String[] localVarAccepts = {
}; };
@ -157,7 +161,7 @@ public class UserApi {
String[] localVarAuthNames = new String[] { }; String[] localVarAuthNames = new String[] { };
return apiClient.invokeAPI(localVarPath, "POST", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, null); return apiClient.invokeAPI(localVarPath, "POST", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, null);
} }
/** /**
* Creates list of users with given input array * Creates list of users with given input array
@ -201,11 +205,13 @@ public class UserApi {
// query params // query params
List<Pair> localVarQueryParams = new ArrayList<Pair>(); List<Pair> localVarQueryParams = new ArrayList<Pair>();
Map<String, String> localVarHeaderParams = new HashMap<String, String>(); Map<String, String> localVarHeaderParams = new HashMap<String, String>();
Map<String, String> localVarCookieParams = new HashMap<String, String>();
Map<String, Object> localVarFormParams = new HashMap<String, Object>(); Map<String, Object> localVarFormParams = new HashMap<String, Object>();
final String[] localVarAccepts = { final String[] localVarAccepts = {
}; };
@ -219,7 +225,7 @@ public class UserApi {
String[] localVarAuthNames = new String[] { }; String[] localVarAuthNames = new String[] { };
return apiClient.invokeAPI(localVarPath, "POST", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, null); return apiClient.invokeAPI(localVarPath, "POST", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, null);
} }
/** /**
* Delete user * Delete user
@ -266,11 +272,13 @@ public class UserApi {
// query params // query params
List<Pair> localVarQueryParams = new ArrayList<Pair>(); List<Pair> localVarQueryParams = new ArrayList<Pair>();
Map<String, String> localVarHeaderParams = new HashMap<String, String>(); Map<String, String> localVarHeaderParams = new HashMap<String, String>();
Map<String, String> localVarCookieParams = new HashMap<String, String>();
Map<String, Object> localVarFormParams = new HashMap<String, Object>(); Map<String, Object> localVarFormParams = new HashMap<String, Object>();
final String[] localVarAccepts = { final String[] localVarAccepts = {
}; };
@ -284,7 +292,7 @@ public class UserApi {
String[] localVarAuthNames = new String[] { }; String[] localVarAuthNames = new String[] { };
return apiClient.invokeAPI(localVarPath, "DELETE", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, null); return apiClient.invokeAPI(localVarPath, "DELETE", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, null);
} }
/** /**
* Get user by user name * Get user by user name
@ -333,11 +341,13 @@ public class UserApi {
// query params // query params
List<Pair> localVarQueryParams = new ArrayList<Pair>(); List<Pair> localVarQueryParams = new ArrayList<Pair>();
Map<String, String> localVarHeaderParams = new HashMap<String, String>(); Map<String, String> localVarHeaderParams = new HashMap<String, String>();
Map<String, String> localVarCookieParams = new HashMap<String, String>();
Map<String, Object> localVarFormParams = new HashMap<String, Object>(); Map<String, Object> localVarFormParams = new HashMap<String, Object>();
final String[] localVarAccepts = { final String[] localVarAccepts = {
"application/xml", "application/json" "application/xml", "application/json"
}; };
@ -351,7 +361,7 @@ public class UserApi {
String[] localVarAuthNames = new String[] { }; String[] localVarAuthNames = new String[] { };
GenericType<User> localVarReturnType = new GenericType<User>() {}; GenericType<User> localVarReturnType = new GenericType<User>() {};
return apiClient.invokeAPI(localVarPath, "GET", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, localVarReturnType); return apiClient.invokeAPI(localVarPath, "GET", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, localVarReturnType);
} }
/** /**
* Logs user into the system * Logs user into the system
@ -404,6 +414,7 @@ public class UserApi {
// query params // query params
List<Pair> localVarQueryParams = new ArrayList<Pair>(); List<Pair> localVarQueryParams = new ArrayList<Pair>();
Map<String, String> localVarHeaderParams = new HashMap<String, String>(); Map<String, String> localVarHeaderParams = new HashMap<String, String>();
Map<String, String> localVarCookieParams = new HashMap<String, String>();
Map<String, Object> localVarFormParams = new HashMap<String, Object>(); Map<String, Object> localVarFormParams = new HashMap<String, Object>();
localVarQueryParams.addAll(apiClient.parameterToPairs("", "username", username)); localVarQueryParams.addAll(apiClient.parameterToPairs("", "username", username));
@ -411,6 +422,7 @@ public class UserApi {
final String[] localVarAccepts = { final String[] localVarAccepts = {
"application/xml", "application/json" "application/xml", "application/json"
}; };
@ -424,7 +436,7 @@ public class UserApi {
String[] localVarAuthNames = new String[] { }; String[] localVarAuthNames = new String[] { };
GenericType<String> localVarReturnType = new GenericType<String>() {}; GenericType<String> localVarReturnType = new GenericType<String>() {};
return apiClient.invokeAPI(localVarPath, "GET", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, localVarReturnType); return apiClient.invokeAPI(localVarPath, "GET", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, localVarReturnType);
} }
/** /**
* Logs out current logged in user session * Logs out current logged in user session
@ -461,11 +473,13 @@ public class UserApi {
// query params // query params
List<Pair> localVarQueryParams = new ArrayList<Pair>(); List<Pair> localVarQueryParams = new ArrayList<Pair>();
Map<String, String> localVarHeaderParams = new HashMap<String, String>(); Map<String, String> localVarHeaderParams = new HashMap<String, String>();
Map<String, String> localVarCookieParams = new HashMap<String, String>();
Map<String, Object> localVarFormParams = new HashMap<String, Object>(); Map<String, Object> localVarFormParams = new HashMap<String, Object>();
final String[] localVarAccepts = { final String[] localVarAccepts = {
}; };
@ -479,7 +493,7 @@ public class UserApi {
String[] localVarAuthNames = new String[] { }; String[] localVarAuthNames = new String[] { };
return apiClient.invokeAPI(localVarPath, "GET", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, null); return apiClient.invokeAPI(localVarPath, "GET", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, null);
} }
/** /**
* Updated user * Updated user
@ -533,11 +547,13 @@ public class UserApi {
// query params // query params
List<Pair> localVarQueryParams = new ArrayList<Pair>(); List<Pair> localVarQueryParams = new ArrayList<Pair>();
Map<String, String> localVarHeaderParams = new HashMap<String, String>(); Map<String, String> localVarHeaderParams = new HashMap<String, String>();
Map<String, String> localVarCookieParams = new HashMap<String, String>();
Map<String, Object> localVarFormParams = new HashMap<String, Object>(); Map<String, Object> localVarFormParams = new HashMap<String, Object>();
final String[] localVarAccepts = { final String[] localVarAccepts = {
}; };
@ -551,6 +567,6 @@ public class UserApi {
String[] localVarAuthNames = new String[] { }; String[] localVarAuthNames = new String[] { };
return apiClient.invokeAPI(localVarPath, "PUT", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, null); return apiClient.invokeAPI(localVarPath, "PUT", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, null);
} }
} }

View File

@ -56,7 +56,7 @@ public class ApiKeyAuth implements Authentication {
} }
@Override @Override
public void applyToParams(List<Pair> queryParams, Map<String, String> headerParams) { public void applyToParams(List<Pair> queryParams, Map<String, String> headerParams, Map<String, String> cookieParams) {
if (apiKey == null) { if (apiKey == null) {
return; return;
} }
@ -70,6 +70,8 @@ public class ApiKeyAuth implements Authentication {
queryParams.add(new Pair(paramName, value)); queryParams.add(new Pair(paramName, value));
} else if ("header".equals(location)) { } else if ("header".equals(location)) {
headerParams.put(paramName, value); headerParams.put(paramName, value);
} else if ("cookie".equals(location)) {
cookieParams.put(paramName, value);
} }
} }
} }

View File

@ -24,6 +24,7 @@ public interface Authentication {
* *
* @param queryParams List of query parameters * @param queryParams List of query parameters
* @param headerParams Map of header parameters * @param headerParams Map of header parameters
* @param cookieParams Map of cookie parameters
*/ */
void applyToParams(List<Pair> queryParams, Map<String, String> headerParams); void applyToParams(List<Pair> queryParams, Map<String, String> headerParams, Map<String, String> cookieParams);
} }

View File

@ -44,7 +44,7 @@ public class HttpBasicAuth implements Authentication {
} }
@Override @Override
public void applyToParams(List<Pair> queryParams, Map<String, String> headerParams) { public void applyToParams(List<Pair> queryParams, Map<String, String> headerParams, Map<String, String> cookieParams) {
if (username == null && password == null) { if (username == null && password == null) {
return; return;
} }

View File

@ -46,7 +46,7 @@ public class HttpBearerAuth implements Authentication {
} }
@Override @Override
public void applyToParams(List<Pair> queryParams, Map<String, String> headerParams) { public void applyToParams(List<Pair> queryParams, Map<String, String> headerParams, Map<String, String> cookieParams) {
if(bearerToken == null) { if(bearerToken == null) {
return; return;
} }

View File

@ -31,7 +31,7 @@ public class OAuth implements Authentication {
} }
@Override @Override
public void applyToParams(List<Pair> queryParams, Map<String, String> headerParams) { public void applyToParams(List<Pair> queryParams, Map<String, String> headerParams, Map<String, String> cookieParams) {
if (accessToken != null) { if (accessToken != null) {
headerParams.put("Authorization", "Bearer " + accessToken); headerParams.put("Authorization", "Bearer " + accessToken);
} }

View File

@ -15,33 +15,55 @@ public class ApiKeyAuthTest {
public void testApplyToParamsInQuery() { public void testApplyToParamsInQuery() {
List<Pair> queryParams = new ArrayList<Pair>(); List<Pair> queryParams = new ArrayList<Pair>();
Map<String, String> headerParams = new HashMap<String, String>(); Map<String, String> headerParams = new HashMap<String, String>();
Map<String, String> cookieParams = new HashMap<String, String>();
ApiKeyAuth auth = new ApiKeyAuth("query", "api_key"); ApiKeyAuth auth = new ApiKeyAuth("query", "api_key");
auth.setApiKey("my-api-key"); auth.setApiKey("my-api-key");
auth.applyToParams(queryParams, headerParams); auth.applyToParams(queryParams, headerParams, cookieParams);
assertEquals(1, queryParams.size()); assertEquals(1, queryParams.size());
for (Pair queryParam : queryParams) { for (Pair queryParam : queryParams) {
assertEquals("my-api-key", queryParam.getValue()); assertEquals("my-api-key", queryParam.getValue());
} }
// no changes to header parameters // no changes to header or cookie parameters
assertEquals(0, headerParams.size()); assertEquals(0, headerParams.size());
assertEquals(0, cookieParams.size());
} }
@Test @Test
public void testApplyToParamsInHeaderWithPrefix() { public void testApplyToParamsInHeaderWithPrefix() {
List<Pair> queryParams = new ArrayList<Pair>(); List<Pair> queryParams = new ArrayList<Pair>();
Map<String, String> headerParams = new HashMap<String, String>(); Map<String, String> headerParams = new HashMap<String, String>();
Map<String, String> cookieParams = new HashMap<String, String>();
ApiKeyAuth auth = new ApiKeyAuth("header", "X-API-TOKEN"); ApiKeyAuth auth = new ApiKeyAuth("header", "X-API-TOKEN");
auth.setApiKey("my-api-token"); auth.setApiKey("my-api-token");
auth.setApiKeyPrefix("Token"); auth.setApiKeyPrefix("Token");
auth.applyToParams(queryParams, headerParams); auth.applyToParams(queryParams, headerParams, cookieParams);
// no changes to query parameters // no changes to query parameters
assertEquals(0, queryParams.size()); assertEquals(0, queryParams.size());
assertEquals(0, cookieParams.size());
assertEquals(1, headerParams.size()); assertEquals(1, headerParams.size());
assertEquals("Token my-api-token", headerParams.get("X-API-TOKEN")); assertEquals("Token my-api-token", headerParams.get("X-API-TOKEN"));
} }
@Test
public void testApplyToParamsInCookieWithPrefix() {
List<Pair> queryParams = new ArrayList<Pair>();
Map<String, String> headerParams = new HashMap<String, String>();
Map<String, String> cookieParams = new HashMap<String, String>();
ApiKeyAuth auth = new ApiKeyAuth("cookie", "X-API-TOKEN");
auth.setApiKey("my-api-token");
auth.setApiKeyPrefix("Token");
auth.applyToParams(queryParams, headerParams, cookieParams);
// no changes to query or header parameters
assertEquals(0, queryParams.size());
assertEquals(0, headerParams.size());
assertEquals(1, cookieParams.size());
assertEquals("Token my-api-token", cookieParams.get("X-API-TOKEN"));
}
} }

View File

@ -22,10 +22,11 @@ public class HttpBasicAuthTest {
public void testApplyToParams() { public void testApplyToParams() {
List<Pair> queryParams = new ArrayList<Pair>(); List<Pair> queryParams = new ArrayList<Pair>();
Map<String, String> headerParams = new HashMap<String, String>(); Map<String, String> headerParams = new HashMap<String, String>();
Map<String, String> cookieParams = new HashMap<String, String>();
auth.setUsername("my-username"); auth.setUsername("my-username");
auth.setPassword("my-password"); auth.setPassword("my-password");
auth.applyToParams(queryParams, headerParams); auth.applyToParams(queryParams, headerParams, cookieParams);
// no changes to query parameters // no changes to query parameters
assertEquals(0, queryParams.size()); assertEquals(0, queryParams.size());
@ -36,7 +37,7 @@ public class HttpBasicAuthTest {
// null username should be treated as empty string // null username should be treated as empty string
auth.setUsername(null); auth.setUsername(null);
auth.applyToParams(queryParams, headerParams); auth.applyToParams(queryParams, headerParams, cookieParams);
// the string below is base64-encoded result of ":my-password" with the "Basic " prefix // the string below is base64-encoded result of ":my-password" with the "Basic " prefix
expected = "Basic Om15LXBhc3N3b3Jk"; expected = "Basic Om15LXBhc3N3b3Jk";
assertEquals(expected, headerParams.get("Authorization")); assertEquals(expected, headerParams.get("Authorization"));
@ -44,7 +45,7 @@ public class HttpBasicAuthTest {
// null password should be treated as empty string // null password should be treated as empty string
auth.setUsername("my-username"); auth.setUsername("my-username");
auth.setPassword(null); auth.setPassword(null);
auth.applyToParams(queryParams, headerParams); auth.applyToParams(queryParams, headerParams, cookieParams);
// the string below is base64-encoded result of "my-username:" with the "Basic " prefix // the string below is base64-encoded result of "my-username:" with the "Basic " prefix
expected = "Basic bXktdXNlcm5hbWU6"; expected = "Basic bXktdXNlcm5hbWU6";
assertEquals(expected, headerParams.get("Authorization")); assertEquals(expected, headerParams.get("Authorization"));

Some files were not shown because too many files have changed in this diff Show More