forked from loafle/openapi-generator-original
[Java][Client] Add PATCH method support for jersey2 (#6197)
This commit is contained in:
parent
443b0f142b
commit
a6f981350e
@ -13,6 +13,7 @@ import javax.ws.rs.core.Response.Status;
|
|||||||
|
|
||||||
import org.glassfish.jersey.client.ClientConfig;
|
import org.glassfish.jersey.client.ClientConfig;
|
||||||
import org.glassfish.jersey.client.ClientProperties;
|
import org.glassfish.jersey.client.ClientProperties;
|
||||||
|
import org.glassfish.jersey.client.HttpUrlConnectorProvider;
|
||||||
import org.glassfish.jersey.jackson.JacksonFeature;
|
import org.glassfish.jersey.jackson.JacksonFeature;
|
||||||
import org.glassfish.jersey.logging.LoggingFeature;
|
import org.glassfish.jersey.logging.LoggingFeature;
|
||||||
import org.glassfish.jersey.media.multipart.FormDataBodyPart;
|
import org.glassfish.jersey.media.multipart.FormDataBodyPart;
|
||||||
@ -695,7 +696,7 @@ public class ApiClient {
|
|||||||
} else if ("DELETE".equals(method)) {
|
} else if ("DELETE".equals(method)) {
|
||||||
response = invocationBuilder.delete();
|
response = invocationBuilder.delete();
|
||||||
} else if ("PATCH".equals(method)) {
|
} else if ("PATCH".equals(method)) {
|
||||||
response = invocationBuilder.header("X-HTTP-Method-Override", "PATCH").post(entity);
|
response = invocationBuilder.method("PATCH", entity);
|
||||||
} else {
|
} else {
|
||||||
throw new ApiException(500, "unknown method type " + method);
|
throw new ApiException(500, "unknown method type " + method);
|
||||||
}
|
}
|
||||||
@ -746,6 +747,7 @@ public class ApiClient {
|
|||||||
clientConfig.register(MultiPartFeature.class);
|
clientConfig.register(MultiPartFeature.class);
|
||||||
clientConfig.register(json);
|
clientConfig.register(json);
|
||||||
clientConfig.register(JacksonFeature.class);
|
clientConfig.register(JacksonFeature.class);
|
||||||
|
clientConfig.property(HttpUrlConnectorProvider.SET_METHOD_WORKAROUND, true);
|
||||||
if (debugging) {
|
if (debugging) {
|
||||||
clientConfig.register(new LoggingFeature(java.util.logging.Logger.getLogger(LoggingFeature.DEFAULT_LOGGER_NAME), java.util.logging.Level.INFO, LoggingFeature.Verbosity.PAYLOAD_ANY, 1024*50 /* Log payloads up to 50K */));
|
clientConfig.register(new LoggingFeature(java.util.logging.Logger.getLogger(LoggingFeature.DEFAULT_LOGGER_NAME), java.util.logging.Level.INFO, LoggingFeature.Verbosity.PAYLOAD_ANY, 1024*50 /* Log payloads up to 50K */));
|
||||||
clientConfig.property(LoggingFeature.LOGGING_FEATURE_VERBOSITY, LoggingFeature.Verbosity.PAYLOAD_ANY);
|
clientConfig.property(LoggingFeature.LOGGING_FEATURE_VERBOSITY, LoggingFeature.Verbosity.PAYLOAD_ANY);
|
||||||
|
@ -16,9 +16,19 @@ To test class name in snake case
|
|||||||
### Example
|
### Example
|
||||||
```java
|
```java
|
||||||
// Import classes:
|
// Import classes:
|
||||||
|
//import io.swagger.client.ApiClient;
|
||||||
//import io.swagger.client.ApiException;
|
//import io.swagger.client.ApiException;
|
||||||
|
//import io.swagger.client.Configuration;
|
||||||
|
//import io.swagger.client.auth.*;
|
||||||
//import io.swagger.client.api.FakeClassnameTags123Api;
|
//import io.swagger.client.api.FakeClassnameTags123Api;
|
||||||
|
|
||||||
|
ApiClient defaultClient = Configuration.getDefaultApiClient();
|
||||||
|
|
||||||
|
// Configure API key authorization: api_key_query
|
||||||
|
ApiKeyAuth api_key_query = (ApiKeyAuth) defaultClient.getAuthentication("api_key_query");
|
||||||
|
api_key_query.setApiKey("YOUR API KEY");
|
||||||
|
// Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null)
|
||||||
|
//api_key_query.setApiKeyPrefix("Token");
|
||||||
|
|
||||||
FakeClassnameTags123Api apiInstance = new FakeClassnameTags123Api();
|
FakeClassnameTags123Api apiInstance = new FakeClassnameTags123Api();
|
||||||
Client body = new Client(); // Client | client model
|
Client body = new Client(); // Client | client model
|
||||||
@ -43,7 +53,7 @@ Name | Type | Description | Notes
|
|||||||
|
|
||||||
### Authorization
|
### Authorization
|
||||||
|
|
||||||
No authorization required
|
[api_key_query](../README.md#api_key_query)
|
||||||
|
|
||||||
### HTTP request headers
|
### HTTP request headers
|
||||||
|
|
||||||
|
@ -247,7 +247,7 @@
|
|||||||
</dependencies>
|
</dependencies>
|
||||||
<properties>
|
<properties>
|
||||||
<swagger-core-version>1.5.15</swagger-core-version>
|
<swagger-core-version>1.5.15</swagger-core-version>
|
||||||
<jersey-version>2.6</jersey-version>
|
<jersey-version>2.25.1</jersey-version>
|
||||||
<commons_io_version>2.5</commons_io_version>
|
<commons_io_version>2.5</commons_io_version>
|
||||||
<commons_lang3_version>3.6</commons_lang3_version>
|
<commons_lang3_version>3.6</commons_lang3_version>
|
||||||
<jackson-version>2.6.4</jackson-version>
|
<jackson-version>2.6.4</jackson-version>
|
||||||
|
@ -13,6 +13,7 @@ import javax.ws.rs.core.Response.Status;
|
|||||||
|
|
||||||
import org.glassfish.jersey.client.ClientConfig;
|
import org.glassfish.jersey.client.ClientConfig;
|
||||||
import org.glassfish.jersey.client.ClientProperties;
|
import org.glassfish.jersey.client.ClientProperties;
|
||||||
|
import org.glassfish.jersey.client.HttpUrlConnectorProvider;
|
||||||
import org.glassfish.jersey.jackson.JacksonFeature;
|
import org.glassfish.jersey.jackson.JacksonFeature;
|
||||||
import org.glassfish.jersey.logging.LoggingFeature;
|
import org.glassfish.jersey.logging.LoggingFeature;
|
||||||
import org.glassfish.jersey.media.multipart.FormDataBodyPart;
|
import org.glassfish.jersey.media.multipart.FormDataBodyPart;
|
||||||
@ -78,6 +79,7 @@ public class ApiClient {
|
|||||||
// Setup authentications (key: authentication name, value: authentication).
|
// Setup authentications (key: authentication name, value: authentication).
|
||||||
authentications = new HashMap<String, Authentication>();
|
authentications = new HashMap<String, Authentication>();
|
||||||
authentications.put("api_key", new ApiKeyAuth("header", "api_key"));
|
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("http_basic_test", new HttpBasicAuth());
|
||||||
authentications.put("petstore_auth", new OAuth());
|
authentications.put("petstore_auth", new OAuth());
|
||||||
// Prevent the authentications from being modified.
|
// Prevent the authentications from being modified.
|
||||||
@ -432,13 +434,12 @@ public class ApiClient {
|
|||||||
* application/json; charset=UTF8
|
* application/json; charset=UTF8
|
||||||
* APPLICATION/JSON
|
* APPLICATION/JSON
|
||||||
* application/vnd.company+json
|
* application/vnd.company+json
|
||||||
* "* / *" is also default to JSON
|
|
||||||
* @param mime MIME
|
* @param mime MIME
|
||||||
* @return True if the MIME type is JSON
|
* @return True if the MIME type is JSON
|
||||||
*/
|
*/
|
||||||
public boolean isJsonMime(String mime) {
|
public boolean isJsonMime(String mime) {
|
||||||
String jsonMime = "(?i)^(application/json|[^;/ \t]+/[^;/ \t]+[+]json)[ \t]*(;.*)?$";
|
String jsonMime = "(?i)^(application/json|[^;/ \t]+/[^;/ \t]+[+]json)[ \t]*(;.*)?$";
|
||||||
return mime != null && (mime.matches(jsonMime) || mime.equals("*/*"));
|
return mime != null && (mime.matches(jsonMime) || mime.equalsIgnoreCase("application/json-patch+json"));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -684,7 +685,7 @@ public class ApiClient {
|
|||||||
} else if ("DELETE".equals(method)) {
|
} else if ("DELETE".equals(method)) {
|
||||||
response = invocationBuilder.delete();
|
response = invocationBuilder.delete();
|
||||||
} else if ("PATCH".equals(method)) {
|
} else if ("PATCH".equals(method)) {
|
||||||
response = invocationBuilder.header("X-HTTP-Method-Override", "PATCH").post(entity);
|
response = invocationBuilder.method("PATCH", entity);
|
||||||
} else {
|
} else {
|
||||||
throw new ApiException(500, "unknown method type " + method);
|
throw new ApiException(500, "unknown method type " + method);
|
||||||
}
|
}
|
||||||
@ -735,6 +736,7 @@ public class ApiClient {
|
|||||||
clientConfig.register(MultiPartFeature.class);
|
clientConfig.register(MultiPartFeature.class);
|
||||||
clientConfig.register(json);
|
clientConfig.register(json);
|
||||||
clientConfig.register(JacksonFeature.class);
|
clientConfig.register(JacksonFeature.class);
|
||||||
|
clientConfig.property(HttpUrlConnectorProvider.SET_METHOD_WORKAROUND, true);
|
||||||
if (debugging) {
|
if (debugging) {
|
||||||
clientConfig.register(new LoggingFeature(java.util.logging.Logger.getLogger(LoggingFeature.DEFAULT_LOGGER_NAME), java.util.logging.Level.INFO, LoggingFeature.Verbosity.PAYLOAD_ANY, 1024*50 /* Log payloads up to 50K */));
|
clientConfig.register(new LoggingFeature(java.util.logging.Logger.getLogger(LoggingFeature.DEFAULT_LOGGER_NAME), java.util.logging.Level.INFO, LoggingFeature.Verbosity.PAYLOAD_ANY, 1024*50 /* Log payloads up to 50K */));
|
||||||
clientConfig.property(LoggingFeature.LOGGING_FEATURE_VERBOSITY, LoggingFeature.Verbosity.PAYLOAD_ANY);
|
clientConfig.property(LoggingFeature.LOGGING_FEATURE_VERBOSITY, LoggingFeature.Verbosity.PAYLOAD_ANY);
|
||||||
|
@ -70,7 +70,7 @@ public class FakeClassnameTags123Api {
|
|||||||
};
|
};
|
||||||
final String localVarContentType = apiClient.selectHeaderContentType(localVarContentTypes);
|
final String localVarContentType = apiClient.selectHeaderContentType(localVarContentTypes);
|
||||||
|
|
||||||
String[] localVarAuthNames = new String[] { };
|
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, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, localVarReturnType);
|
||||||
|
@ -39,7 +39,7 @@ public class Cat extends Animal {
|
|||||||
* @return declawed
|
* @return declawed
|
||||||
**/
|
**/
|
||||||
@ApiModelProperty(value = "")
|
@ApiModelProperty(value = "")
|
||||||
public Boolean isDeclawed() {
|
public Boolean getDeclawed() {
|
||||||
return declawed;
|
return declawed;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -181,7 +181,7 @@ public class Order {
|
|||||||
* @return complete
|
* @return complete
|
||||||
**/
|
**/
|
||||||
@ApiModelProperty(value = "")
|
@ApiModelProperty(value = "")
|
||||||
public Boolean isComplete() {
|
public Boolean getComplete() {
|
||||||
return complete;
|
return complete;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -16,9 +16,19 @@ To test class name in snake case
|
|||||||
### Example
|
### Example
|
||||||
```java
|
```java
|
||||||
// Import classes:
|
// Import classes:
|
||||||
|
//import io.swagger.client.ApiClient;
|
||||||
//import io.swagger.client.ApiException;
|
//import io.swagger.client.ApiException;
|
||||||
|
//import io.swagger.client.Configuration;
|
||||||
|
//import io.swagger.client.auth.*;
|
||||||
//import io.swagger.client.api.FakeClassnameTags123Api;
|
//import io.swagger.client.api.FakeClassnameTags123Api;
|
||||||
|
|
||||||
|
ApiClient defaultClient = Configuration.getDefaultApiClient();
|
||||||
|
|
||||||
|
// Configure API key authorization: api_key_query
|
||||||
|
ApiKeyAuth api_key_query = (ApiKeyAuth) defaultClient.getAuthentication("api_key_query");
|
||||||
|
api_key_query.setApiKey("YOUR API KEY");
|
||||||
|
// Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null)
|
||||||
|
//api_key_query.setApiKeyPrefix("Token");
|
||||||
|
|
||||||
FakeClassnameTags123Api apiInstance = new FakeClassnameTags123Api();
|
FakeClassnameTags123Api apiInstance = new FakeClassnameTags123Api();
|
||||||
Client body = new Client(); // Client | client model
|
Client body = new Client(); // Client | client model
|
||||||
@ -43,7 +53,7 @@ Name | Type | Description | Notes
|
|||||||
|
|
||||||
### Authorization
|
### Authorization
|
||||||
|
|
||||||
No authorization required
|
[api_key_query](../README.md#api_key_query)
|
||||||
|
|
||||||
### HTTP request headers
|
### HTTP request headers
|
||||||
|
|
||||||
|
@ -13,6 +13,7 @@ import javax.ws.rs.core.Response.Status;
|
|||||||
|
|
||||||
import org.glassfish.jersey.client.ClientConfig;
|
import org.glassfish.jersey.client.ClientConfig;
|
||||||
import org.glassfish.jersey.client.ClientProperties;
|
import org.glassfish.jersey.client.ClientProperties;
|
||||||
|
import org.glassfish.jersey.client.HttpUrlConnectorProvider;
|
||||||
import org.glassfish.jersey.jackson.JacksonFeature;
|
import org.glassfish.jersey.jackson.JacksonFeature;
|
||||||
import org.glassfish.jersey.logging.LoggingFeature;
|
import org.glassfish.jersey.logging.LoggingFeature;
|
||||||
import org.glassfish.jersey.media.multipart.FormDataBodyPart;
|
import org.glassfish.jersey.media.multipart.FormDataBodyPart;
|
||||||
@ -79,6 +80,7 @@ public class ApiClient {
|
|||||||
// Setup authentications (key: authentication name, value: authentication).
|
// Setup authentications (key: authentication name, value: authentication).
|
||||||
authentications = new HashMap<String, Authentication>();
|
authentications = new HashMap<String, Authentication>();
|
||||||
authentications.put("api_key", new ApiKeyAuth("header", "api_key"));
|
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("http_basic_test", new HttpBasicAuth());
|
||||||
authentications.put("petstore_auth", new OAuth());
|
authentications.put("petstore_auth", new OAuth());
|
||||||
// Prevent the authentications from being modified.
|
// Prevent the authentications from being modified.
|
||||||
@ -433,13 +435,12 @@ public class ApiClient {
|
|||||||
* application/json; charset=UTF8
|
* application/json; charset=UTF8
|
||||||
* APPLICATION/JSON
|
* APPLICATION/JSON
|
||||||
* application/vnd.company+json
|
* application/vnd.company+json
|
||||||
* "* / *" is also default to JSON
|
|
||||||
* @param mime MIME
|
* @param mime MIME
|
||||||
* @return True if the MIME type is JSON
|
* @return True if the MIME type is JSON
|
||||||
*/
|
*/
|
||||||
public boolean isJsonMime(String mime) {
|
public boolean isJsonMime(String mime) {
|
||||||
String jsonMime = "(?i)^(application/json|[^;/ \t]+/[^;/ \t]+[+]json)[ \t]*(;.*)?$";
|
String jsonMime = "(?i)^(application/json|[^;/ \t]+/[^;/ \t]+[+]json)[ \t]*(;.*)?$";
|
||||||
return mime != null && (mime.matches(jsonMime) || mime.equals("*/*"));
|
return mime != null && (mime.matches(jsonMime) || mime.equalsIgnoreCase("application/json-patch+json"));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -684,7 +685,7 @@ public class ApiClient {
|
|||||||
} else if ("DELETE".equals(method)) {
|
} else if ("DELETE".equals(method)) {
|
||||||
response = invocationBuilder.delete();
|
response = invocationBuilder.delete();
|
||||||
} else if ("PATCH".equals(method)) {
|
} else if ("PATCH".equals(method)) {
|
||||||
response = invocationBuilder.header("X-HTTP-Method-Override", "PATCH").post(entity);
|
response = invocationBuilder.method("PATCH", entity);
|
||||||
} else {
|
} else {
|
||||||
throw new ApiException(500, "unknown method type " + method);
|
throw new ApiException(500, "unknown method type " + method);
|
||||||
}
|
}
|
||||||
@ -735,6 +736,7 @@ public class ApiClient {
|
|||||||
clientConfig.register(MultiPartFeature.class);
|
clientConfig.register(MultiPartFeature.class);
|
||||||
clientConfig.register(json);
|
clientConfig.register(json);
|
||||||
clientConfig.register(JacksonFeature.class);
|
clientConfig.register(JacksonFeature.class);
|
||||||
|
clientConfig.property(HttpUrlConnectorProvider.SET_METHOD_WORKAROUND, true);
|
||||||
if (debugging) {
|
if (debugging) {
|
||||||
clientConfig.register(new LoggingFeature(java.util.logging.Logger.getLogger(LoggingFeature.DEFAULT_LOGGER_NAME), java.util.logging.Level.INFO, LoggingFeature.Verbosity.PAYLOAD_ANY, 1024*50 /* Log payloads up to 50K */));
|
clientConfig.register(new LoggingFeature(java.util.logging.Logger.getLogger(LoggingFeature.DEFAULT_LOGGER_NAME), java.util.logging.Level.INFO, LoggingFeature.Verbosity.PAYLOAD_ANY, 1024*50 /* Log payloads up to 50K */));
|
||||||
clientConfig.property(LoggingFeature.LOGGING_FEATURE_VERBOSITY, LoggingFeature.Verbosity.PAYLOAD_ANY);
|
clientConfig.property(LoggingFeature.LOGGING_FEATURE_VERBOSITY, LoggingFeature.Verbosity.PAYLOAD_ANY);
|
||||||
|
@ -70,7 +70,7 @@ public class FakeClassnameTags123Api {
|
|||||||
};
|
};
|
||||||
final String localVarContentType = apiClient.selectHeaderContentType(localVarContentTypes);
|
final String localVarContentType = apiClient.selectHeaderContentType(localVarContentTypes);
|
||||||
|
|
||||||
String[] localVarAuthNames = new String[] { };
|
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, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, localVarReturnType);
|
||||||
|
@ -39,7 +39,7 @@ public class Cat extends Animal {
|
|||||||
* @return declawed
|
* @return declawed
|
||||||
**/
|
**/
|
||||||
@ApiModelProperty(value = "")
|
@ApiModelProperty(value = "")
|
||||||
public Boolean isDeclawed() {
|
public Boolean getDeclawed() {
|
||||||
return declawed;
|
return declawed;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -181,7 +181,7 @@ public class Order {
|
|||||||
* @return complete
|
* @return complete
|
||||||
**/
|
**/
|
||||||
@ApiModelProperty(value = "")
|
@ApiModelProperty(value = "")
|
||||||
public Boolean isComplete() {
|
public Boolean getComplete() {
|
||||||
return complete;
|
return complete;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user