[Java][jersey2] replace jersey2 with jersey2-experimental (#6251)

* replace jersey2 with jersey2-experimental

* better handling of oauth

* add jersey2 java8 samples

* add dependency to test pom

* fix test, update doc
This commit is contained in:
William Cheng
2020-05-12 18:27:33 +08:00
committed by GitHub
parent 1f82facf82
commit deec5da8a7
322 changed files with 3311 additions and 27696 deletions

View File

@@ -11,6 +11,7 @@ import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
import javax.ws.rs.core.Response.Status;
import com.github.scribejava.core.model.OAuth2AccessToken;
import org.glassfish.jersey.client.ClientConfig;
import org.glassfish.jersey.client.ClientProperties;
import org.glassfish.jersey.client.HttpUrlConnectorProvider;
@@ -23,6 +24,7 @@ import org.glassfish.jersey.media.multipart.MultiPartFeature;
import java.io.IOException;
import java.io.InputStream;
import java.net.URI;
import org.apache.commons.io.FileUtils;
import org.glassfish.jersey.filter.LoggingFilter;
import java.util.Collection;
@@ -35,7 +37,6 @@ import java.util.List;
import java.util.Arrays;
import java.util.ArrayList;
import java.util.Date;
import java.util.TimeZone;
import java.net.URLEncoder;
@@ -49,9 +50,10 @@ import java.util.regex.Pattern;
import org.openapitools.client.auth.Authentication;
import org.openapitools.client.auth.HttpBasicAuth;
import org.openapitools.client.auth.HttpBearerAuth;
import org.openapitools.client.auth.HttpSignatureAuth;
import org.openapitools.client.auth.ApiKeyAuth;
import org.openapitools.client.auth.OAuth;
import org.openapitools.client.model.AbstractOpenApiSchema;
public class ApiClient {
@@ -98,7 +100,7 @@ public class ApiClient {
authentications.put("api_key", new ApiKeyAuth("header", "api_key"));
authentications.put("api_key_query", new ApiKeyAuth("query", "api_key_query"));
authentications.put("http_basic_test", new HttpBasicAuth());
authentications.put("petstore_auth", new OAuth());
authentications.put("petstore_auth", new OAuth(basePath, ""));
// Prevent the authentications from being modified.
authentications = Collections.unmodifiableMap(authentications);
@@ -108,6 +110,7 @@ public class ApiClient {
/**
* Gets the JSON instance to do JSON serialization and deserialization.
*
* @return JSON
*/
public JSON getJSON() {
@@ -129,6 +132,7 @@ public class ApiClient {
public ApiClient setBasePath(String basePath) {
this.basePath = basePath;
setOauthBasePath(basePath);
return this;
}
@@ -138,6 +142,7 @@ public class ApiClient {
public ApiClient setServers(List<ServerConfiguration> servers) {
this.servers = servers;
updateBasePath();
return this;
}
@@ -147,6 +152,7 @@ public class ApiClient {
public ApiClient setServerIndex(Integer serverIndex) {
this.serverIndex = serverIndex;
updateBasePath();
return this;
}
@@ -156,11 +162,25 @@ public class ApiClient {
public ApiClient setServerVariables(Map<String, String> serverVariables) {
this.serverVariables = serverVariables;
updateBasePath();
return this;
}
private void updateBasePath() {
setBasePath(servers.get(serverIndex).URL(serverVariables));
}
private void setOauthBasePath(String basePath) {
for(Authentication auth : authentications.values()) {
if (auth instanceof OAuth) {
((OAuth) auth).setBasePath(basePath);
}
}
}
/**
* Get authentications (key: authentication name, value: authentication).
*
* @return Map of authentication object
*/
public Map<String, Authentication> getAuthentications() {
@@ -179,13 +199,14 @@ public class ApiClient {
/**
* Helper method to set username for the first HTTP basic authentication.
*
* @param username Username
*/
public void setUsername(String username) {
public ApiClient setUsername(String username) {
for (Authentication auth : authentications.values()) {
if (auth instanceof HttpBasicAuth) {
((HttpBasicAuth) auth).setUsername(username);
return;
return this;
}
}
throw new RuntimeException("No HTTP basic authentication configured!");
@@ -193,13 +214,14 @@ public class ApiClient {
/**
* Helper method to set password for the first HTTP basic authentication.
*
* @param password Password
*/
public void setPassword(String password) {
public ApiClient setPassword(String password) {
for (Authentication auth : authentications.values()) {
if (auth instanceof HttpBasicAuth) {
((HttpBasicAuth) auth).setPassword(password);
return;
return this;
}
}
throw new RuntimeException("No HTTP basic authentication configured!");
@@ -207,13 +229,14 @@ public class ApiClient {
/**
* Helper method to set API key value for the first API key authentication.
*
* @param apiKey API key
*/
public void setApiKey(String apiKey) {
public ApiClient setApiKey(String apiKey) {
for (Authentication auth : authentications.values()) {
if (auth instanceof ApiKeyAuth) {
((ApiKeyAuth) auth).setApiKey(apiKey);
return;
return this;
}
}
throw new RuntimeException("No API key authentication configured!");
@@ -224,29 +247,31 @@ public class ApiClient {
*
* @param secrets Hash map from authentication name to its secret.
*/
public void configureApiKeys(HashMap<String, String> secrets) {
public ApiClient configureApiKeys(HashMap<String, String> secrets) {
for (Map.Entry<String, Authentication> authEntry : authentications.entrySet()) {
Authentication auth = authEntry.getValue();
if (auth instanceof ApiKeyAuth) {
String name = authEntry.getKey();
// respect x-auth-id-alias property
name = authenticationLookup.getOrDefault(name, name);
name = authenticationLookup.containsKey(name) ? authenticationLookup.get(name) : name;
if (secrets.containsKey(name)) {
((ApiKeyAuth) auth).setApiKey(secrets.get(name));
}
}
}
return this;
}
/**
* Helper method to set API key prefix for the first API key authentication.
*
* @param apiKeyPrefix API key prefix
*/
public void setApiKeyPrefix(String apiKeyPrefix) {
public ApiClient setApiKeyPrefix(String apiKeyPrefix) {
for (Authentication auth : authentications.values()) {
if (auth instanceof ApiKeyAuth) {
((ApiKeyAuth) auth).setApiKeyPrefix(apiKeyPrefix);
return;
return this;
}
}
throw new RuntimeException("No API key authentication configured!");
@@ -254,27 +279,91 @@ public class ApiClient {
/**
* Helper method to set bearer token for the first Bearer authentication.
*
* @param bearerToken Bearer token
*/
public void setBearerToken(String bearerToken) {
public ApiClient setBearerToken(String bearerToken) {
for (Authentication auth : authentications.values()) {
if (auth instanceof HttpBearerAuth) {
((HttpBearerAuth) auth).setBearerToken(bearerToken);
return;
return this;
}
}
throw new RuntimeException("No Bearer authentication configured!");
}
/**
* Helper method to set access token for the first OAuth2 authentication.
* @param accessToken Access token
*/
public void setAccessToken(String accessToken) {
public ApiClient setAccessToken(String accessToken) {
for (Authentication auth : authentications.values()) {
if (auth instanceof OAuth) {
((OAuth) auth).setAccessToken(accessToken);
return;
return this;
}
}
throw new RuntimeException("No OAuth2 authentication configured!");
}
/**
* Helper method to set the credentials for the first OAuth2 authentication.
*
* @param clientId the client ID
* @param clientSecret the client secret
*/
public ApiClient setOauthCredentials(String clientId, String clientSecret) {
for (Authentication auth : authentications.values()) {
if (auth instanceof OAuth) {
((OAuth) auth).setCredentials(clientId, clientSecret);
return this;
}
}
throw new RuntimeException("No OAuth2 authentication configured!");
}
/**
* Helper method to set the password flow for the first OAuth2 authentication.
*
* @param username the user name
* @param password the user password
*/
public ApiClient setOauthPasswordFlow(String username, String password) {
for (Authentication auth : authentications.values()) {
if (auth instanceof OAuth) {
((OAuth) auth).usePasswordFlow(username, password);
return this;
}
}
throw new RuntimeException("No OAuth2 authentication configured!");
}
/**
* Helper method to set the authorization code flow for the first OAuth2 authentication.
*
* @param code the authorization code
*/
public ApiClient setOauthAuthorizationCodeFlow(String code) {
for (Authentication auth : authentications.values()) {
if (auth instanceof OAuth) {
((OAuth) auth).useAuthorizationCodeFlow(code);
return this;
}
}
throw new RuntimeException("No OAuth2 authentication configured!");
}
/**
* Helper method to set the scopes for the first OAuth2 authentication.
*
* @param scope the oauth scope
*/
public ApiClient setOauthScope(String scope) {
for (Authentication auth : authentications.values()) {
if (auth instanceof OAuth) {
((OAuth) auth).setScope(scope);
return this;
}
}
throw new RuntimeException("No OAuth2 authentication configured!");
@@ -633,6 +722,87 @@ public class ApiClient {
return entity;
}
/**
* Serialize the given Java object into string according the given
* Content-Type (only JSON, HTTP form is supported for now).
* @param obj Object
* @param formParams Form parameters
* @param contentType Context type
* @return String
* @throws ApiException API exception
*/
public String serializeToString(Object obj, Map<String, Object> formParams, String contentType) throws ApiException {
try {
if (contentType.startsWith("multipart/form-data")) {
throw new ApiException("multipart/form-data not yet supported for serializeToString (http signature authentication)");
} else if (contentType.startsWith("application/x-www-form-urlencoded")) {
String formString = "";
for (Entry<String, Object> param : formParams.entrySet()) {
formString = param.getKey() + "=" + URLEncoder.encode(parameterToString(param.getValue()), "UTF-8") + "&";
}
if (formString.length() == 0) { // empty string
return formString;
} else {
return formString.substring(0, formString.length() - 1);
}
} else {
return json.getMapper().writeValueAsString(obj);
}
} catch (Exception ex) {
throw new ApiException("Failed to perform serializeToString: " + ex.toString());
}
}
public AbstractOpenApiSchema deserializeSchemas(Response response, AbstractOpenApiSchema schema) throws ApiException{
Object result = null;
int matchCounter = 0;
ArrayList<String> matchSchemas = new ArrayList<>();
for (Map.Entry<String, GenericType> entry : schema.getSchemas().entrySet()) {
String schemaName = entry.getKey();
GenericType schemaType = entry.getValue();
if (schemaType instanceof GenericType) { // model
try {
Object deserializedObject = deserialize(response, schemaType);
if (deserializedObject != null) {
result = deserializedObject;
matchCounter++;
if ("anyOf".equals(schema.getSchemaType())) {
break;
} else if ("oneOf".equals(schema.getSchemaType())) {
matchSchemas.add(schemaName);
} else {
throw new ApiException("Unknowe type found while expecting anyOf/oneOf:" + schema.getSchemaType());
}
} else {
// failed to deserialize the response in the schema provided, proceed to the next one if any
}
} catch (Exception ex) {
// failed to deserialize, do nothing and try next one (schema)
}
} else {// unknown type
throw new ApiException(schemaType.getClass() + " is not a GenericType and cannot be handled properly in deserialization.");
}
}
if (matchCounter > 1 && "oneOf".equals(schema.getSchemaType())) {// more than 1 match for oneOf
throw new ApiException("Response body is invalid as it matches more than one schema (" + StringUtil.join(matchSchemas, ", ") + ") defined in the oneOf model: " + schema.getClass().getName());
} else if (matchCounter == 0) { // fail to match any in oneOf/anyOf schemas
throw new ApiException("Response body is invalid as it doens't match any schemas (" + StringUtil.join(schema.getSchemas().keySet(), ", ") + ") defined in the oneOf/anyOf model: " + schema.getClass().getName());
} else { // only one matched
schema.setActualInstance(result);
return schema;
}
}
/**
* Deserialize response body to Java object according to the Content-Type.
* @param <T> Type
@@ -661,6 +831,9 @@ public class ApiClient {
if (contentTypes != null && !contentTypes.isEmpty())
contentType = String.valueOf(contentTypes.get(0));
// read the entity stream multiple times
response.bufferEntity();
return response.readEntity(returnType);
}
@@ -732,33 +905,39 @@ public class ApiClient {
* @param contentType The request's Content-Type header
* @param authNames The authentications to apply
* @param returnType The return type into which to deserialize the response
* @param schema An instance of the response that uses oneOf/anyOf
* @return The response body in type of string
* @throws ApiException API exception
*/
public <T> ApiResponse<T> invokeAPI(String operation, 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, cookieParams);
public <T> ApiResponse<T> invokeAPI(
String operation,
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,
AbstractOpenApiSchema schema)
throws ApiException {
// Not using `.target(targetURL).path(path)` below,
// to support (constant) query string in `path`, e.g. "/posts?draft=1"
String targetURL;
if (serverIndex != null) {
Integer index;
List<ServerConfiguration> serverConfigurations;
Map<String, String> variables;
if (operationServers.containsKey(operation)) {
index = operationServerIndex.getOrDefault(operation, serverIndex);
variables = operationServerVariables.getOrDefault(operation, serverVariables);
serverConfigurations = operationServers.get(operation);
} else {
index = serverIndex;
variables = serverVariables;
serverConfigurations = servers;
}
if (operationServers.containsKey(operation)) {
Integer index = operationServerIndex.containsKey(operation) ? operationServerIndex.get(operation) : serverIndex;
Map<String, String> variables = operationServerVariables.containsKey(operation) ?
operationServerVariables.get(operation) : serverVariables;
List<ServerConfiguration> serverConfigurations = operationServers.get(operation);
if (index < 0 || index >= serverConfigurations.size()) {
throw new ArrayIndexOutOfBoundsException(String.format(
"Invalid index %d when selecting the host settings. Must be less than %d", index, serverConfigurations.size()
));
throw new ArrayIndexOutOfBoundsException(
String.format(
"Invalid index %d when selecting the host settings. Must be less than %d",
index, serverConfigurations.size()));
}
targetURL = serverConfigurations.get(index).URL(variables) + path;
} else {
@@ -776,13 +955,6 @@ public class ApiClient {
Invocation.Builder invocationBuilder = target.request().accept(accept);
for (Entry<String, String> entry : headerParams.entrySet()) {
String value = entry.getValue();
if (value != null) {
invocationBuilder = invocationBuilder.header(entry.getKey(), value);
}
}
for (Entry<String, String> entry : cookieParams.entrySet()) {
String value = entry.getValue();
if (value != null) {
@@ -797,51 +969,63 @@ public class ApiClient {
}
}
for (Entry<String, String> entry : defaultHeaderMap.entrySet()) {
String key = entry.getKey();
if (!headerParams.containsKey(key)) {
String value = entry.getValue();
if (value != null) {
invocationBuilder = invocationBuilder.header(key, value);
}
Entity<?> entity = serialize(body, formParams, contentType);
// put all headers in one place
Map<String, String> allHeaderParams = new HashMap<>(defaultHeaderMap);
allHeaderParams.putAll(headerParams);
// update different parameters (e.g. headers) for authentication
updateParamsForAuth(
authNames,
queryParams,
allHeaderParams,
cookieParams,
serializeToString(body, formParams, contentType),
method,
target.getUri());
for (Entry<String, String> entry : allHeaderParams.entrySet()) {
String value = entry.getValue();
if (value != null) {
invocationBuilder = invocationBuilder.header(entry.getKey(), value);
}
}
Entity<?> entity = serialize(body, formParams, contentType);
Response response = null;
try {
if ("GET".equals(method)) {
response = invocationBuilder.get();
} else if ("POST".equals(method)) {
response = invocationBuilder.post(entity);
} else if ("PUT".equals(method)) {
response = invocationBuilder.put(entity);
} else if ("DELETE".equals(method)) {
response = invocationBuilder.method("DELETE", entity);
} else if ("PATCH".equals(method)) {
response = invocationBuilder.method("PATCH", entity);
} else if ("HEAD".equals(method)) {
response = invocationBuilder.head();
} else if ("OPTIONS".equals(method)) {
response = invocationBuilder.options();
} else if ("TRACE".equals(method)) {
response = invocationBuilder.trace();
} else {
throw new ApiException(500, "unknown method type " + method);
response = sendRequest(method, invocationBuilder, entity);
// If OAuth is used and a status 401 is received, renew the access token and retry the request
if (response.getStatusInfo() == Status.UNAUTHORIZED) {
for (String authName : authNames) {
Authentication authentication = authentications.get(authName);
if (authentication instanceof OAuth) {
OAuth2AccessToken accessToken = ((OAuth) authentication).renewAccessToken();
if (accessToken != null) {
invocationBuilder.header("Authorization", null);
invocationBuilder.header("Authorization", "Bearer " + accessToken.getAccessToken());
response = sendRequest(method, invocationBuilder, entity);
}
break;
}
}
}
int statusCode = response.getStatusInfo().getStatusCode();
Map<String, List<String>> responseHeaders = buildResponseHeaders(response);
if (response.getStatus() == Status.NO_CONTENT.getStatusCode()) {
if (response.getStatusInfo() == Status.NO_CONTENT) {
return new ApiResponse<T>(statusCode, responseHeaders);
} else if (response.getStatusInfo().getFamily() == Status.Family.SUCCESSFUL) {
if (returnType == null)
return new ApiResponse<T>(statusCode, responseHeaders);
else
if (returnType == null) return new ApiResponse<T>(statusCode, responseHeaders);
else if (schema == null) {
return new ApiResponse<T>(statusCode, responseHeaders, deserialize(response, returnType));
} else { // oneOf/anyOf
return new ApiResponse<T>(
statusCode, responseHeaders, (T) deserializeSchemas(response, schema));
}
} else {
String message = "error";
String respBody = null;
@@ -854,26 +1038,40 @@ public class ApiClient {
}
}
throw new ApiException(
response.getStatus(),
message,
buildResponseHeaders(response),
respBody);
response.getStatus(), message, buildResponseHeaders(response), respBody);
}
} finally {
try {
response.close();
} catch (Exception e) {
// it's not critical, since the response object is local in method invokeAPI; that's fine, just continue
// it's not critical, since the response object is local in method invokeAPI; that's fine,
// just continue
}
}
}
private Response sendRequest(String method, Invocation.Builder invocationBuilder, Entity<?> entity) {
Response response;
if ("POST".equals(method)) {
response = invocationBuilder.post(entity);
} else if ("PUT".equals(method)) {
response = invocationBuilder.put(entity);
} else if ("DELETE".equals(method)) {
response = invocationBuilder.method("DELETE", entity);
} else if ("PATCH".equals(method)) {
response = invocationBuilder.method("PATCH", entity);
} else {
response = invocationBuilder.method(method);
}
return response;
}
/**
* @deprecated Add qualified name of the operation as a first parameter.
*/
@Deprecated
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 {
return invokeAPI(null, path, method, queryParams, body, headerParams, cookieParams, formParams, accept, contentType, authNames, returnType);
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, AbstractOpenApiSchema schema) throws ApiException {
return invokeAPI(null, path, method, queryParams, body, headerParams, cookieParams, formParams, accept, contentType, authNames, returnType, schema);
}
/**
@@ -923,12 +1121,17 @@ public class ApiClient {
* @param queryParams List of query parameters
* @param headerParams Map of header parameters
* @param cookieParams Map of cookie parameters
* @param method HTTP method (e.g. POST)
* @param uri HTTP URI
*/
protected void updateParamsForAuth(String[] authNames, List<Pair> queryParams, Map<String, String> headerParams, Map<String, String> cookieParams) {
protected void updateParamsForAuth(String[] authNames, List<Pair> queryParams, Map<String, String> headerParams,
Map<String, String> cookieParams, String payload, String method, URI uri) throws ApiException {
for (String authName : authNames) {
Authentication auth = authentications.get(authName);
if (auth == null) throw new RuntimeException("Authentication undefined: " + authName);
auth.applyToParams(queryParams, headerParams, cookieParams);
if (auth == null) {
throw new RuntimeException("Authentication undefined: " + authName);
}
auth.applyToParams(queryParams, headerParams, cookieParams, payload, method, uri);
}
}
}

View File

@@ -16,6 +16,9 @@ package org.openapitools.client;
import java.util.Map;
import java.util.List;
/**
* API Exception
*/
public class ApiException extends Exception {
private int code = 0;

View File

@@ -45,14 +45,29 @@ public class ApiResponse<T> {
this.data = data;
}
/**
* Get the status code
*
* @return status code
*/
public int getStatusCode() {
return statusCode;
}
/**
* Get the headers
*
* @return map of headers
*/
public Map<String, List<String>> getHeaders() {
return headers;
}
/**
* Get the data
*
* @return data
*/
public T getData() {
return data;
}

View File

@@ -17,8 +17,8 @@ public class JSON implements ContextResolver<ObjectMapper> {
public JSON() {
mapper = new ObjectMapper();
mapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
mapper.configure(DeserializationFeature.FAIL_ON_INVALID_SUBTYPE, false);
mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, true);
mapper.configure(DeserializationFeature.FAIL_ON_INVALID_SUBTYPE, true);
mapper.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS);
mapper.enable(SerializationFeature.WRITE_ENUMS_USING_TO_STRING);
mapper.enable(DeserializationFeature.READ_ENUMS_USING_TO_STRING);
@@ -44,4 +44,11 @@ public class JSON implements ContextResolver<ObjectMapper> {
public ObjectMapper getContext(Class<?> type) {
return mapper;
}
/**
* Get the object mapper
*
* @return object mapper
*/
public ObjectMapper getMapper() { return mapper; }
}

View File

@@ -27,13 +27,24 @@ public class AnotherFakeApi {
this.apiClient = apiClient;
}
/**
* Get the API cilent
*
* @return API client
*/
public ApiClient getApiClient() {
return apiClient;
}
/**
* Set the API cilent
*
* @param apiClient an instance of API client
*/
public void setApiClient(ApiClient apiClient) {
this.apiClient = apiClient;
}
/**
* To test special tags
* To test special tags and operation ID starting with number
@@ -96,6 +107,9 @@ public class AnotherFakeApi {
String[] localVarAuthNames = new String[] { };
GenericType<Client> localVarReturnType = new GenericType<Client>() {};
return apiClient.invokeAPI("AnotherFakeApi.call123testSpecialTags", localVarPath, "PATCH", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, localVarReturnType);
return apiClient.invokeAPI("AnotherFakeApi.call123testSpecialTags", localVarPath, "PATCH", localVarQueryParams, localVarPostBody,
localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType,
localVarAuthNames, localVarReturnType, null);
}
}

View File

@@ -35,13 +35,24 @@ public class FakeApi {
this.apiClient = apiClient;
}
/**
* Get the API cilent
*
* @return API client
*/
public ApiClient getApiClient() {
return apiClient;
}
/**
* Set the API cilent
*
* @param apiClient an instance of API client
*/
public void setApiClient(ApiClient apiClient) {
this.apiClient = apiClient;
}
/**
* creates an XmlItem
* this route creates an XmlItem
@@ -102,8 +113,9 @@ public class FakeApi {
String[] localVarAuthNames = new String[] { };
return apiClient.invokeAPI("FakeApi.createXmlItem", localVarPath, "POST", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, null);
return apiClient.invokeAPI("FakeApi.createXmlItem", localVarPath, "POST", localVarQueryParams, localVarPostBody,
localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType,
localVarAuthNames, null, null);
}
/**
*
@@ -162,7 +174,10 @@ public class FakeApi {
String[] localVarAuthNames = new String[] { };
GenericType<Boolean> localVarReturnType = new GenericType<Boolean>() {};
return apiClient.invokeAPI("FakeApi.fakeOuterBooleanSerialize", localVarPath, "POST", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, localVarReturnType);
return apiClient.invokeAPI("FakeApi.fakeOuterBooleanSerialize", localVarPath, "POST", localVarQueryParams, localVarPostBody,
localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType,
localVarAuthNames, localVarReturnType, null);
}
/**
*
@@ -221,7 +236,10 @@ public class FakeApi {
String[] localVarAuthNames = new String[] { };
GenericType<OuterComposite> localVarReturnType = new GenericType<OuterComposite>() {};
return apiClient.invokeAPI("FakeApi.fakeOuterCompositeSerialize", localVarPath, "POST", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, localVarReturnType);
return apiClient.invokeAPI("FakeApi.fakeOuterCompositeSerialize", localVarPath, "POST", localVarQueryParams, localVarPostBody,
localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType,
localVarAuthNames, localVarReturnType, null);
}
/**
*
@@ -280,7 +298,10 @@ public class FakeApi {
String[] localVarAuthNames = new String[] { };
GenericType<BigDecimal> localVarReturnType = new GenericType<BigDecimal>() {};
return apiClient.invokeAPI("FakeApi.fakeOuterNumberSerialize", localVarPath, "POST", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, localVarReturnType);
return apiClient.invokeAPI("FakeApi.fakeOuterNumberSerialize", localVarPath, "POST", localVarQueryParams, localVarPostBody,
localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType,
localVarAuthNames, localVarReturnType, null);
}
/**
*
@@ -339,7 +360,10 @@ public class FakeApi {
String[] localVarAuthNames = new String[] { };
GenericType<String> localVarReturnType = new GenericType<String>() {};
return apiClient.invokeAPI("FakeApi.fakeOuterStringSerialize", localVarPath, "POST", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, localVarReturnType);
return apiClient.invokeAPI("FakeApi.fakeOuterStringSerialize", localVarPath, "POST", localVarQueryParams, localVarPostBody,
localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType,
localVarAuthNames, localVarReturnType, null);
}
/**
*
@@ -401,8 +425,9 @@ public class FakeApi {
String[] localVarAuthNames = new String[] { };
return apiClient.invokeAPI("FakeApi.testBodyWithFileSchema", localVarPath, "PUT", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, null);
return apiClient.invokeAPI("FakeApi.testBodyWithFileSchema", localVarPath, "PUT", localVarQueryParams, localVarPostBody,
localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType,
localVarAuthNames, null, null);
}
/**
*
@@ -472,8 +497,9 @@ public class FakeApi {
String[] localVarAuthNames = new String[] { };
return apiClient.invokeAPI("FakeApi.testBodyWithQueryParams", localVarPath, "PUT", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, null);
return apiClient.invokeAPI("FakeApi.testBodyWithQueryParams", localVarPath, "PUT", localVarQueryParams, localVarPostBody,
localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType,
localVarAuthNames, null, null);
}
/**
* To test \&quot;client\&quot; model
@@ -537,7 +563,10 @@ public class FakeApi {
String[] localVarAuthNames = new String[] { };
GenericType<Client> localVarReturnType = new GenericType<Client>() {};
return apiClient.invokeAPI("FakeApi.testClientModel", localVarPath, "PATCH", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, localVarReturnType);
return apiClient.invokeAPI("FakeApi.testClientModel", localVarPath, "PATCH", localVarQueryParams, localVarPostBody,
localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType,
localVarAuthNames, localVarReturnType, null);
}
/**
* Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트
@@ -670,8 +699,9 @@ if (paramCallback != null)
String[] localVarAuthNames = new String[] { "http_basic_test" };
return apiClient.invokeAPI("FakeApi.testEndpointParameters", localVarPath, "POST", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, null);
return apiClient.invokeAPI("FakeApi.testEndpointParameters", localVarPath, "POST", localVarQueryParams, localVarPostBody,
localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType,
localVarAuthNames, null, null);
}
/**
* To test enum parameters
@@ -756,8 +786,9 @@ if (enumFormString != null)
String[] localVarAuthNames = new String[] { };
return apiClient.invokeAPI("FakeApi.testEnumParameters", localVarPath, "GET", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, null);
return apiClient.invokeAPI("FakeApi.testEnumParameters", localVarPath, "GET", localVarQueryParams, localVarPostBody,
localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType,
localVarAuthNames, null, null);
}
private ApiResponse<Void> testGroupParametersWithHttpInfo(Integer requiredStringGroup, Boolean requiredBooleanGroup, Long requiredInt64Group, Integer stringGroup, Boolean booleanGroup, Long int64Group) throws ApiException {
@@ -811,8 +842,9 @@ if (booleanGroup != null)
String[] localVarAuthNames = new String[] { };
return apiClient.invokeAPI("FakeApi.testGroupParameters", localVarPath, "DELETE", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, null);
return apiClient.invokeAPI("FakeApi.testGroupParameters", localVarPath, "DELETE", localVarQueryParams, localVarPostBody,
localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType,
localVarAuthNames, null, null);
}
public class APItestGroupParametersRequest {
@@ -825,7 +857,6 @@ if (booleanGroup != null)
private APItestGroupParametersRequest() {
}
/**
* Set requiredStringGroup
@@ -836,7 +867,6 @@ if (booleanGroup != null)
this.requiredStringGroup = requiredStringGroup;
return this;
}
/**
* Set requiredBooleanGroup
@@ -847,7 +877,6 @@ if (booleanGroup != null)
this.requiredBooleanGroup = requiredBooleanGroup;
return this;
}
/**
* Set requiredInt64Group
@@ -858,7 +887,6 @@ if (booleanGroup != null)
this.requiredInt64Group = requiredInt64Group;
return this;
}
/**
* Set stringGroup
@@ -869,7 +897,6 @@ if (booleanGroup != null)
this.stringGroup = stringGroup;
return this;
}
/**
* Set booleanGroup
@@ -880,7 +907,6 @@ if (booleanGroup != null)
this.booleanGroup = booleanGroup;
return this;
}
/**
* Set int64Group
@@ -891,7 +917,6 @@ if (booleanGroup != null)
this.int64Group = int64Group;
return this;
}
/**
* Execute testGroupParameters request
@@ -918,9 +943,8 @@ if (booleanGroup != null)
<tr><td> Status Code </td><td> Description </td><td> Response Headers </td></tr>
<tr><td> 400 </td><td> Someting wrong </td><td> - </td></tr>
</table>
*/
public ApiResponse<Void> executeWithHttpInfo() throws ApiException {
return testGroupParametersWithHttpInfo(requiredStringGroup, requiredBooleanGroup, requiredInt64Group, stringGroup, booleanGroup, int64Group);
}
@@ -934,7 +958,6 @@ if (booleanGroup != null)
*/
public APItestGroupParametersRequest testGroupParameters() throws ApiException {
return new APItestGroupParametersRequest();
}
@@ -998,8 +1021,9 @@ if (booleanGroup != null)
String[] localVarAuthNames = new String[] { };
return apiClient.invokeAPI("FakeApi.testInlineAdditionalProperties", localVarPath, "POST", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, null);
return apiClient.invokeAPI("FakeApi.testInlineAdditionalProperties", localVarPath, "POST", localVarQueryParams, localVarPostBody,
localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType,
localVarAuthNames, null, null);
}
/**
* test json serialization of form data
@@ -1072,8 +1096,9 @@ if (param2 != null)
String[] localVarAuthNames = new String[] { };
return apiClient.invokeAPI("FakeApi.testJsonFormData", localVarPath, "GET", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, null);
return apiClient.invokeAPI("FakeApi.testJsonFormData", localVarPath, "GET", localVarQueryParams, localVarPostBody,
localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType,
localVarAuthNames, null, null);
}
/**
*
@@ -1168,7 +1193,8 @@ if (param2 != null)
String[] localVarAuthNames = new String[] { };
return apiClient.invokeAPI("FakeApi.testQueryParameterCollectionFormat", localVarPath, "PUT", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, null);
return apiClient.invokeAPI("FakeApi.testQueryParameterCollectionFormat", localVarPath, "PUT", localVarQueryParams, localVarPostBody,
localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType,
localVarAuthNames, null, null);
}
}

View File

@@ -27,13 +27,24 @@ public class FakeClassnameTags123Api {
this.apiClient = apiClient;
}
/**
* Get the API cilent
*
* @return API client
*/
public ApiClient getApiClient() {
return apiClient;
}
/**
* Set the API cilent
*
* @param apiClient an instance of API client
*/
public void setApiClient(ApiClient apiClient) {
this.apiClient = apiClient;
}
/**
* To test class name in snake case
* To test class name in snake case
@@ -96,6 +107,9 @@ public class FakeClassnameTags123Api {
String[] localVarAuthNames = new String[] { "api_key_query" };
GenericType<Client> localVarReturnType = new GenericType<Client>() {};
return apiClient.invokeAPI("FakeClassnameTags123Api.testClassname", localVarPath, "PATCH", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, localVarReturnType);
return apiClient.invokeAPI("FakeClassnameTags123Api.testClassname", localVarPath, "PATCH", localVarQueryParams, localVarPostBody,
localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType,
localVarAuthNames, localVarReturnType, null);
}
}

View File

@@ -29,13 +29,24 @@ public class PetApi {
this.apiClient = apiClient;
}
/**
* Get the API cilent
*
* @return API client
*/
public ApiClient getApiClient() {
return apiClient;
}
/**
* Set the API cilent
*
* @param apiClient an instance of API client
*/
public void setApiClient(ApiClient apiClient) {
this.apiClient = apiClient;
}
/**
* Add a new pet to the store
*
@@ -98,8 +109,9 @@ public class PetApi {
String[] localVarAuthNames = new String[] { "petstore_auth" };
return apiClient.invokeAPI("PetApi.addPet", localVarPath, "POST", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, null);
return apiClient.invokeAPI("PetApi.addPet", localVarPath, "POST", localVarQueryParams, localVarPostBody,
localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType,
localVarAuthNames, null, null);
}
/**
* Deletes a pet
@@ -168,8 +180,9 @@ public class PetApi {
String[] localVarAuthNames = new String[] { "petstore_auth" };
return apiClient.invokeAPI("PetApi.deletePet", localVarPath, "DELETE", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, null);
return apiClient.invokeAPI("PetApi.deletePet", localVarPath, "DELETE", localVarQueryParams, localVarPostBody,
localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType,
localVarAuthNames, null, null);
}
/**
* Finds Pets by status
@@ -236,7 +249,10 @@ public class PetApi {
String[] localVarAuthNames = new String[] { "petstore_auth" };
GenericType<List<Pet>> localVarReturnType = new GenericType<List<Pet>>() {};
return apiClient.invokeAPI("PetApi.findPetsByStatus", localVarPath, "GET", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, localVarReturnType);
return apiClient.invokeAPI("PetApi.findPetsByStatus", localVarPath, "GET", localVarQueryParams, localVarPostBody,
localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType,
localVarAuthNames, localVarReturnType, null);
}
/**
* Finds Pets by tags
@@ -307,7 +323,10 @@ public class PetApi {
String[] localVarAuthNames = new String[] { "petstore_auth" };
GenericType<List<Pet>> localVarReturnType = new GenericType<List<Pet>>() {};
return apiClient.invokeAPI("PetApi.findPetsByTags", localVarPath, "GET", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, localVarReturnType);
return apiClient.invokeAPI("PetApi.findPetsByTags", localVarPath, "GET", localVarQueryParams, localVarPostBody,
localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType,
localVarAuthNames, localVarReturnType, null);
}
/**
* Find pet by ID
@@ -376,7 +395,10 @@ public class PetApi {
String[] localVarAuthNames = new String[] { "api_key" };
GenericType<Pet> localVarReturnType = new GenericType<Pet>() {};
return apiClient.invokeAPI("PetApi.getPetById", localVarPath, "GET", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, localVarReturnType);
return apiClient.invokeAPI("PetApi.getPetById", localVarPath, "GET", localVarQueryParams, localVarPostBody,
localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType,
localVarAuthNames, localVarReturnType, null);
}
/**
* Update an existing pet
@@ -444,8 +466,9 @@ public class PetApi {
String[] localVarAuthNames = new String[] { "petstore_auth" };
return apiClient.invokeAPI("PetApi.updatePet", localVarPath, "PUT", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, null);
return apiClient.invokeAPI("PetApi.updatePet", localVarPath, "PUT", localVarQueryParams, localVarPostBody,
localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType,
localVarAuthNames, null, null);
}
/**
* Updates a pet in the store with form data
@@ -516,8 +539,9 @@ if (status != null)
String[] localVarAuthNames = new String[] { "petstore_auth" };
return apiClient.invokeAPI("PetApi.updatePetWithForm", localVarPath, "POST", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, null);
return apiClient.invokeAPI("PetApi.updatePetWithForm", localVarPath, "POST", localVarQueryParams, localVarPostBody,
localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType,
localVarAuthNames, null, null);
}
/**
* uploads an image
@@ -590,7 +614,10 @@ if (file != null)
String[] localVarAuthNames = new String[] { "petstore_auth" };
GenericType<ModelApiResponse> localVarReturnType = new GenericType<ModelApiResponse>() {};
return apiClient.invokeAPI("PetApi.uploadFile", localVarPath, "POST", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, localVarReturnType);
return apiClient.invokeAPI("PetApi.uploadFile", localVarPath, "POST", localVarQueryParams, localVarPostBody,
localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType,
localVarAuthNames, localVarReturnType, null);
}
/**
* uploads an image (required)
@@ -668,6 +695,9 @@ if (requiredFile != null)
String[] localVarAuthNames = new String[] { "petstore_auth" };
GenericType<ModelApiResponse> localVarReturnType = new GenericType<ModelApiResponse>() {};
return apiClient.invokeAPI("PetApi.uploadFileWithRequiredFile", localVarPath, "POST", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, localVarReturnType);
return apiClient.invokeAPI("PetApi.uploadFileWithRequiredFile", localVarPath, "POST", localVarQueryParams, localVarPostBody,
localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType,
localVarAuthNames, localVarReturnType, null);
}
}

View File

@@ -27,13 +27,24 @@ public class StoreApi {
this.apiClient = apiClient;
}
/**
* Get the API cilent
*
* @return API client
*/
public ApiClient getApiClient() {
return apiClient;
}
/**
* Set the API cilent
*
* @param apiClient an instance of API client
*/
public void setApiClient(ApiClient apiClient) {
this.apiClient = apiClient;
}
/**
* Delete purchase order by ID
* For valid response try integer IDs with value &lt; 1000. Anything above 1000 or nonintegers will generate API errors
@@ -97,8 +108,9 @@ public class StoreApi {
String[] localVarAuthNames = new String[] { };
return apiClient.invokeAPI("StoreApi.deleteOrder", localVarPath, "DELETE", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, null);
return apiClient.invokeAPI("StoreApi.deleteOrder", localVarPath, "DELETE", localVarQueryParams, localVarPostBody,
localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType,
localVarAuthNames, null, null);
}
/**
* Returns pet inventories by status
@@ -155,7 +167,10 @@ public class StoreApi {
String[] localVarAuthNames = new String[] { "api_key" };
GenericType<Map<String, Integer>> localVarReturnType = new GenericType<Map<String, Integer>>() {};
return apiClient.invokeAPI("StoreApi.getInventory", localVarPath, "GET", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, localVarReturnType);
return apiClient.invokeAPI("StoreApi.getInventory", localVarPath, "GET", localVarQueryParams, localVarPostBody,
localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType,
localVarAuthNames, localVarReturnType, null);
}
/**
* Find purchase order by ID
@@ -224,7 +239,10 @@ public class StoreApi {
String[] localVarAuthNames = new String[] { };
GenericType<Order> localVarReturnType = new GenericType<Order>() {};
return apiClient.invokeAPI("StoreApi.getOrderById", localVarPath, "GET", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, localVarReturnType);
return apiClient.invokeAPI("StoreApi.getOrderById", localVarPath, "GET", localVarQueryParams, localVarPostBody,
localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType,
localVarAuthNames, localVarReturnType, null);
}
/**
* Place an order for a pet
@@ -290,6 +308,9 @@ public class StoreApi {
String[] localVarAuthNames = new String[] { };
GenericType<Order> localVarReturnType = new GenericType<Order>() {};
return apiClient.invokeAPI("StoreApi.placeOrder", localVarPath, "POST", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, localVarReturnType);
return apiClient.invokeAPI("StoreApi.placeOrder", localVarPath, "POST", localVarQueryParams, localVarPostBody,
localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType,
localVarAuthNames, localVarReturnType, null);
}
}

View File

@@ -27,13 +27,24 @@ public class UserApi {
this.apiClient = apiClient;
}
/**
* Get the API cilent
*
* @return API client
*/
public ApiClient getApiClient() {
return apiClient;
}
/**
* Set the API cilent
*
* @param apiClient an instance of API client
*/
public void setApiClient(ApiClient apiClient) {
this.apiClient = apiClient;
}
/**
* Create user
* This can only be done by the logged in user.
@@ -94,8 +105,9 @@ public class UserApi {
String[] localVarAuthNames = new String[] { };
return apiClient.invokeAPI("UserApi.createUser", localVarPath, "POST", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, null);
return apiClient.invokeAPI("UserApi.createUser", localVarPath, "POST", localVarQueryParams, localVarPostBody,
localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType,
localVarAuthNames, null, null);
}
/**
* Creates list of users with given input array
@@ -157,8 +169,9 @@ public class UserApi {
String[] localVarAuthNames = new String[] { };
return apiClient.invokeAPI("UserApi.createUsersWithArrayInput", localVarPath, "POST", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, null);
return apiClient.invokeAPI("UserApi.createUsersWithArrayInput", localVarPath, "POST", localVarQueryParams, localVarPostBody,
localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType,
localVarAuthNames, null, null);
}
/**
* Creates list of users with given input array
@@ -220,8 +233,9 @@ public class UserApi {
String[] localVarAuthNames = new String[] { };
return apiClient.invokeAPI("UserApi.createUsersWithListInput", localVarPath, "POST", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, null);
return apiClient.invokeAPI("UserApi.createUsersWithListInput", localVarPath, "POST", localVarQueryParams, localVarPostBody,
localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType,
localVarAuthNames, null, null);
}
/**
* Delete user
@@ -286,8 +300,9 @@ public class UserApi {
String[] localVarAuthNames = new String[] { };
return apiClient.invokeAPI("UserApi.deleteUser", localVarPath, "DELETE", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, null);
return apiClient.invokeAPI("UserApi.deleteUser", localVarPath, "DELETE", localVarQueryParams, localVarPostBody,
localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType,
localVarAuthNames, null, null);
}
/**
* Get user by user name
@@ -356,7 +371,10 @@ public class UserApi {
String[] localVarAuthNames = new String[] { };
GenericType<User> localVarReturnType = new GenericType<User>() {};
return apiClient.invokeAPI("UserApi.getUserByName", localVarPath, "GET", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, localVarReturnType);
return apiClient.invokeAPI("UserApi.getUserByName", localVarPath, "GET", localVarQueryParams, localVarPostBody,
localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType,
localVarAuthNames, localVarReturnType, null);
}
/**
* Logs user into the system
@@ -431,7 +449,10 @@ public class UserApi {
String[] localVarAuthNames = new String[] { };
GenericType<String> localVarReturnType = new GenericType<String>() {};
return apiClient.invokeAPI("UserApi.loginUser", localVarPath, "GET", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, localVarReturnType);
return apiClient.invokeAPI("UserApi.loginUser", localVarPath, "GET", localVarQueryParams, localVarPostBody,
localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType,
localVarAuthNames, localVarReturnType, null);
}
/**
* Logs out current logged in user session
@@ -486,8 +507,9 @@ public class UserApi {
String[] localVarAuthNames = new String[] { };
return apiClient.invokeAPI("UserApi.logoutUser", localVarPath, "GET", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, null);
return apiClient.invokeAPI("UserApi.logoutUser", localVarPath, "GET", localVarQueryParams, localVarPostBody,
localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType,
localVarAuthNames, null, null);
}
/**
* Updated user
@@ -559,7 +581,8 @@ public class UserApi {
String[] localVarAuthNames = new String[] { };
return apiClient.invokeAPI("UserApi.updateUser", localVarPath, "PUT", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, null);
return apiClient.invokeAPI("UserApi.updateUser", localVarPath, "PUT", localVarQueryParams, localVarPostBody,
localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAccept, localVarContentType,
localVarAuthNames, null, null);
}
}

View File

@@ -14,7 +14,9 @@
package org.openapitools.client.auth;
import org.openapitools.client.Pair;
import org.openapitools.client.ApiException;
import java.net.URI;
import java.util.Map;
import java.util.List;
@@ -56,7 +58,7 @@ public class ApiKeyAuth implements Authentication {
}
@Override
public void applyToParams(List<Pair> queryParams, Map<String, String> headerParams, Map<String, String> cookieParams) {
public void applyToParams(List<Pair> queryParams, Map<String, String> headerParams, Map<String, String> cookieParams, String payload, String method, URI uri) throws ApiException {
if (apiKey == null) {
return;
}

View File

@@ -14,7 +14,9 @@
package org.openapitools.client.auth;
import org.openapitools.client.Pair;
import org.openapitools.client.ApiException;
import java.net.URI;
import java.util.Map;
import java.util.List;
@@ -26,5 +28,6 @@ public interface Authentication {
* @param headerParams Map of header parameters
* @param cookieParams Map of cookie parameters
*/
void applyToParams(List<Pair> queryParams, Map<String, String> headerParams, Map<String, String> cookieParams);
void applyToParams(List<Pair> queryParams, Map<String, String> headerParams, Map<String, String> cookieParams, String payload, String method, URI uri) throws ApiException;
}

View File

@@ -14,9 +14,11 @@
package org.openapitools.client.auth;
import org.openapitools.client.Pair;
import org.openapitools.client.ApiException;
import com.migcomponents.migbase64.Base64;
import java.net.URI;
import java.util.Map;
import java.util.List;
@@ -44,7 +46,7 @@ public class HttpBasicAuth implements Authentication {
}
@Override
public void applyToParams(List<Pair> queryParams, Map<String, String> headerParams, Map<String, String> cookieParams) {
public void applyToParams(List<Pair> queryParams, Map<String, String> headerParams, Map<String, String> cookieParams, String payload, String method, URI uri) throws ApiException {
if (username == null && password == null) {
return;
}

View File

@@ -14,7 +14,9 @@
package org.openapitools.client.auth;
import org.openapitools.client.Pair;
import org.openapitools.client.ApiException;
import java.net.URI;
import java.util.Map;
import java.util.List;
@@ -46,7 +48,7 @@ public class HttpBearerAuth implements Authentication {
}
@Override
public void applyToParams(List<Pair> queryParams, Map<String, String> headerParams, Map<String, String> cookieParams) {
public void applyToParams(List<Pair> queryParams, Map<String, String> headerParams, Map<String, String> cookieParams, String payload, String method, URI uri) throws ApiException {
if(bearerToken == null) {
return;
}

View File

@@ -0,0 +1,201 @@
/*
* OpenAPI Petstore
* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
*
* The version of the OpenAPI document: 1.0.0
*
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* Do not edit the class manually.
*/
package org.openapitools.client.auth;
import org.openapitools.client.Pair;
import org.openapitools.client.ApiException;
import java.net.URI;
import java.net.URLEncoder;
import java.security.MessageDigest;
import java.security.Key;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Base64;
import java.util.Date;
import java.util.Locale;
import java.util.Map;
import java.util.List;
import org.tomitribe.auth.signatures.*;
/**
* A Configuration object for the HTTP message signature security scheme.
*/
public class HttpSignatureAuth implements Authentication {
private Signer signer;
// An opaque string that the server can use to look up the component they need to validate the signature.
private String keyId;
// The HTTP signature algorithm.
private Algorithm algorithm;
// The list of HTTP headers that should be included in the HTTP signature.
private List<String> headers;
// The digest algorithm which is used to calculate a cryptographic digest of the HTTP request body.
private String digestAlgorithm;
/**
* Construct a new HTTP signature auth configuration object.
*
* @param keyId An opaque string that the server can use to look up the component they need to validate the signature.
* @param algorithm The signature algorithm.
* @param headers The list of HTTP headers that should be included in the HTTP signature.
*/
public HttpSignatureAuth(String keyId, Algorithm algorithm, List<String> headers) {
this.keyId = keyId;
this.algorithm = algorithm;
this.headers = headers;
this.digestAlgorithm = "SHA-256";
}
/**
* Returns the opaque string that the server can use to look up the component they need to validate the signature.
*
* @return The keyId.
*/
public String getKeyId() {
return keyId;
}
/**
* Set the HTTP signature key id.
*
* @param keyId An opaque string that the server can use to look up the component they need to validate the signature.
*/
public void setKeyId(String keyId) {
this.keyId = keyId;
}
/**
* Returns the HTTP signature algorithm which is used to sign HTTP requests.
*/
public Algorithm getAlgorithm() {
return algorithm;
}
/**
* Sets the HTTP signature algorithm which is used to sign HTTP requests.
*
* @param algorithm The HTTP signature algorithm.
*/
public void setAlgorithm(Algorithm algorithm) {
this.algorithm = algorithm;
}
/**
* Returns the digest algorithm which is used to calculate a cryptographic digest of the HTTP request body.
*
* @see java.security.MessageDigest
*/
public String getDigestAlgorithm() {
return digestAlgorithm;
}
/**
* Sets the digest algorithm which is used to calculate a cryptographic digest of the HTTP request body.
*
* The exact list of supported digest algorithms depends on the installed security providers.
* Every implementation of the Java platform is required to support "MD5", "SHA-1" and "SHA-256".
* Do not use "MD5" and "SHA-1", they are vulnerable to multiple known attacks.
* By default, "SHA-256" is used.
*
* @param digestAlgorithm The digest algorithm.
*
* @see java.security.MessageDigest
*/
public void setDigestAlgorithm(String digestAlgorithm) {
this.digestAlgorithm = digestAlgorithm;
}
/**
* Returns the list of HTTP headers that should be included in the HTTP signature.
*/
public List<String> getHeaders() {
return headers;
}
/**
* Sets the list of HTTP headers that should be included in the HTTP signature.
*
* @param headers The HTTP headers.
*/
public void setHeaders(List<String> headers) {
this.headers = headers;
}
public Signer getSigner() {
return signer;
}
public void setSigner(Signer signer) {
this.signer = signer;
}
/**
* Set the private key used to sign HTTP requests using the HTTP signature scheme.
*
* @param key The private key.
*/
public void setPrivateKey(Key key) throws ApiException {
if (key == null) {
throw new ApiException("Private key (java.security.Key) cannot be null");
}
signer = new Signer(key, new Signature(keyId, algorithm, null, headers));
}
@Override
public void applyToParams(List<Pair> queryParams, Map<String, String> headerParams, Map<String, String> cookieParams,
String payload, String method, URI uri) throws ApiException {
try {
if (headers.contains("host")) {
headerParams.put("host", uri.getHost());
}
if (headers.contains("date")) {
headerParams.put("date", new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss zzz", Locale.US).format(new Date()));
}
if (headers.contains("digest")) {
headerParams.put("digest",
this.digestAlgorithm + "=" +
new String(Base64.getEncoder().encode(MessageDigest.getInstance(this.digestAlgorithm).digest(payload.getBytes()))));
}
if (signer == null) {
throw new ApiException("Signer cannot be null. Please call the method `setPrivateKey` to set it up correctly");
}
// construct the path with the URL query string
String path = uri.getPath();
List<String> urlQueries = new ArrayList<String>();
for (Pair queryParam : queryParams) {
urlQueries.add(queryParam.getName() + "=" + URLEncoder.encode(queryParam.getValue(), "utf8").replaceAll("\\+", "%20"));
}
if (!urlQueries.isEmpty()) {
path = path + "?" + String.join("&", urlQueries);
}
headerParams.put("Authorization", signer.sign(method, path, headerParams).toString());
} catch (Exception ex) {
throw new ApiException("Failed to create signature in the HTTP request header: " + ex.toString());
}
}
}

View File

@@ -14,26 +14,170 @@
package org.openapitools.client.auth;
import org.openapitools.client.Pair;
import org.openapitools.client.ApiException;
import com.github.scribejava.core.builder.ServiceBuilder;
import com.github.scribejava.core.builder.api.DefaultApi20;
import com.github.scribejava.core.exceptions.OAuthException;
import com.github.scribejava.core.model.OAuth2AccessToken;
import com.github.scribejava.core.oauth.OAuth20Service;
import java.util.Map;
import javax.ws.rs.core.UriBuilder;
import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URI;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ExecutionException;
import java.util.logging.Level;
import java.util.logging.Logger;
public class OAuth implements Authentication {
private String accessToken;
private static final Logger log = Logger.getLogger(OAuth.class.getName());
public String getAccessToken() {
return accessToken;
private String tokenUrl;
private String absoluteTokenUrl;
private OAuthFlow flow = OAuthFlow.application;
private OAuth20Service service;
private DefaultApi20 authApi;
private String scope;
private String username;
private String password;
private String code;
private volatile OAuth2AccessToken accessToken;
public OAuth(String basePath, String tokenUrl) {
this.tokenUrl = tokenUrl;
this.absoluteTokenUrl = createAbsoluteTokenUrl(basePath, tokenUrl);
authApi = new DefaultApi20() {
@Override
public String getAccessTokenEndpoint() {
return absoluteTokenUrl;
}
@Override
protected String getAuthorizationBaseUrl() {
throw new UnsupportedOperationException("Shouldn't get there !");
}
};
}
public void setAccessToken(String accessToken) {
this.accessToken = accessToken;
private static String createAbsoluteTokenUrl(String basePath, String tokenUrl) {
if (!URI.create(tokenUrl).isAbsolute()) {
try {
return UriBuilder.fromPath(basePath).path(tokenUrl).build().toURL().toString();
} catch (MalformedURLException e) {
log.log(Level.SEVERE, "Couldn't create absolute token URL", e);
}
}
return tokenUrl;
}
@Override
public void applyToParams(List<Pair> queryParams, Map<String, String> headerParams, Map<String, String> cookieParams) {
public void applyToParams(
List<Pair> queryParams,
Map<String, String> headerParams,
Map<String, String> cookieParams,
String payload,
String method,
URI uri)
throws ApiException {
if (accessToken == null) {
obtainAccessToken(null);
}
if (accessToken != null) {
headerParams.put("Authorization", "Bearer " + accessToken);
headerParams.put("Authorization", "Bearer " + accessToken.getAccessToken());
}
}
public OAuth2AccessToken renewAccessToken() throws ApiException {
String refreshToken = null;
if (accessToken != null) {
refreshToken = accessToken.getRefreshToken();
accessToken = null;
}
return obtainAccessToken(refreshToken);
}
public synchronized OAuth2AccessToken obtainAccessToken(String refreshToken) throws ApiException {
if (service == null) {
return null;
}
try {
if (refreshToken != null) {
return service.refreshAccessToken(refreshToken);
}
} catch (OAuthException | InterruptedException | ExecutionException | IOException e) {
log.log(Level.FINE, "Refreshing the access token using the refresh token failed", e);
}
try {
switch (flow) {
case password:
if (username != null && password != null) {
accessToken = service.getAccessTokenPasswordGrant(username, password, scope);
}
break;
case accessCode:
if (code != null) {
accessToken = service.getAccessToken(code);
code = null;
}
break;
case application:
accessToken = service.getAccessTokenClientCredentialsGrant(scope);
}
} catch (OAuthException | InterruptedException | ExecutionException | IOException e) {
throw new ApiException(e);
}
return accessToken;
}
public OAuth2AccessToken getAccessToken() {
return accessToken;
}
public OAuth setAccessToken(OAuth2AccessToken accessToken) {
this.accessToken = accessToken;
return this;
}
public OAuth setAccessToken(String accessToken) {
this.accessToken = new OAuth2AccessToken(accessToken);
return this;
}
public OAuth setScope(String scope) {
this.scope = scope;
return this;
}
public OAuth setCredentials(String clientId, String clientSecret) {
service = new ServiceBuilder(clientId)
.apiSecret(clientSecret)
.build(authApi);
return this;
}
public OAuth usePasswordFlow(String username, String password) {
this.flow = OAuthFlow.password;
this.username = username;
this.password = password;
return this;
}
public OAuth useAuthorizationCodeFlow(String code) {
this.flow = OAuthFlow.accessCode;
this.code = code;
return this;
}
public OAuth setFlow(OAuthFlow flow) {
this.flow = flow;
return this;
}
public void setBasePath(String basePath) {
this.absoluteTokenUrl = createAbsoluteTokenUrl(basePath, tokenUrl);
}
}

View File

@@ -0,0 +1,66 @@
/*
* OpenAPI Petstore
* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
*
* The version of the OpenAPI document: 1.0.0
*
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* Do not edit the class manually.
*/
package org.openapitools.client.model;
import org.openapitools.client.ApiException;
import java.lang.reflect.Type;
import java.util.Map;
import javax.ws.rs.core.GenericType;
/**
* Abstract class for oneOf,anyOf schemas defined in OpenAPI spec
*/
public abstract class AbstractOpenApiSchema {
// store the actual instance of the schema/object
private Object instance;
// schema type (e.g. oneOf, anyOf)
private final String schemaType;
public AbstractOpenApiSchema(String schemaType) {
this.schemaType = schemaType;
}
/***
* Get the list of schemas allowed to be stored in this object
*
* @return an instance of the actual schema/object
*/
public abstract Map<String, GenericType> getSchemas();
/***
* Get the actual instance
*
* @return an instance of the actual schema/object
*/
public Object getActualInstance() {return instance;}
/***
* Set the actual instance
*
* @param instance the actual instance of the schema/object
*/
public void setActualInstance(Object instance) {this.instance = instance;}
/***
* Get the schema type (e.g. anyOf, oneOf)
*
* @return the schema type
*/
public String getSchemaType() {
return schemaType;
}
}

View File

@@ -41,7 +41,7 @@ import com.fasterxml.jackson.annotation.JsonPropertyOrder;
public class Animal {
public static final String JSON_PROPERTY_CLASS_NAME = "className";
protected String className;
private String className;
public static final String JSON_PROPERTY_COLOR = "color";
private String color = "red";