Skip to content

Commit

Permalink
update Java jersey 1,2 to handle */*
Browse files Browse the repository at this point in the history
  • Loading branch information
wing328 committed Jul 31, 2017
1 parent 182807e commit fab49e8
Show file tree
Hide file tree
Showing 11 changed files with 24 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -488,7 +488,7 @@ public class ApiClient {
*/
public boolean isJsonMime(String mime) {
String jsonMime = "(?i)^(application/json|[^;/ \t]+/[^;/ \t]+[+]json)[ \t]*(;.*)?$";
return mime != null && (mime.matches(jsonMime) || mime.equalsIgnoreCase("application/json-patch+json"));
return mime != null && (mime.matches(jsonMime) || mime.equals("*/*"));
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,19 @@ To test class name in snake case
### Example
```java
// Import classes:
//import io.swagger.client.ApiClient;
//import io.swagger.client.ApiException;
//import io.swagger.client.Configuration;
//import io.swagger.client.auth.*;
//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();
Client body = new Client(); // Client | client model
Expand All @@ -43,7 +53,7 @@ Name | Type | Description | Notes

### Authorization

No authorization required
[api_key_query](../README.md#api_key_query)

### HTTP request headers

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ public ApiClient() {
// Setup authentications (key: authentication name, value: authentication).
authentications = new HashMap<String, Authentication>();
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());
// Prevent the authentications from being modified.
Expand Down Expand Up @@ -481,7 +482,7 @@ public List<Pair> parameterToPairs(String collectionFormat, String name, Collect
*/
public boolean isJsonMime(String mime) {
String jsonMime = "(?i)^(application/json|[^;/ \t]+/[^;/ \t]+[+]json)[ \t]*(;.*)?$";
return mime != null && (mime.matches(jsonMime) || mime.equalsIgnoreCase("application/json-patch+json"));
return mime != null && (mime.matches(jsonMime) || mime.equals("*/*"));
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ public Client testClassname(Client body) throws ApiException {
};
final String localVarContentType = apiClient.selectHeaderContentType(localVarContentTypes);

String[] localVarAuthNames = new String[] { };
String[] localVarAuthNames = new String[] { "api_key_query" };

GenericType<Client> localVarReturnType = new GenericType<Client>() {};
return apiClient.invokeAPI(localVarPath, "PATCH", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, localVarReturnType);
Expand Down
2 changes: 1 addition & 1 deletion samples/client/petstore/java/jersey2-java6/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@
</dependencies>
<properties>
<swagger-core-version>1.5.15</swagger-core-version>
<jersey-version>2.25.1</jersey-version>
<jersey-version>2.6</jersey-version>
<commons_io_version>2.5</commons_io_version>
<commons_lang3_version>3.6</commons_lang3_version>
<jackson-version>2.6.4</jackson-version>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -434,12 +434,13 @@ public List<Pair> parameterToPairs(String collectionFormat, String name, Object
* application/json; charset=UTF8
* APPLICATION/JSON
* application/vnd.company+json
* "* / *" is also default to JSON
* @param mime MIME
* @return True if the MIME type is JSON
*/
public boolean isJsonMime(String mime) {
String jsonMime = "(?i)^(application/json|[^;/ \t]+/[^;/ \t]+[+]json)[ \t]*(;.*)?$";
return mime != null && (mime.matches(jsonMime) || mime.equalsIgnoreCase("application/json-patch+json"));
return mime != null && (mime.matches(jsonMime) || mime.equals("*/*"));
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public Cat declawed(Boolean declawed) {
* @return declawed
**/
@ApiModelProperty(value = "")
public Boolean getDeclawed() {
public Boolean isDeclawed() {
return declawed;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ public Order complete(Boolean complete) {
* @return complete
**/
@ApiModelProperty(value = "")
public Boolean getComplete() {
public Boolean isComplete() {
return complete;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -435,12 +435,13 @@ public List<Pair> parameterToPairs(String collectionFormat, String name, Object
* application/json; charset=UTF8
* APPLICATION/JSON
* application/vnd.company+json
* "* / *" is also default to JSON
* @param mime MIME
* @return True if the MIME type is JSON
*/
public boolean isJsonMime(String mime) {
String jsonMime = "(?i)^(application/json|[^;/ \t]+/[^;/ \t]+[+]json)[ \t]*(;.*)?$";
return mime != null && (mime.matches(jsonMime) || mime.equalsIgnoreCase("application/json-patch+json"));
return mime != null && (mime.matches(jsonMime) || mime.equals("*/*"));
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public Cat declawed(Boolean declawed) {
* @return declawed
**/
@ApiModelProperty(value = "")
public Boolean getDeclawed() {
public Boolean isDeclawed() {
return declawed;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ public Order complete(Boolean complete) {
* @return complete
**/
@ApiModelProperty(value = "")
public Boolean getComplete() {
public Boolean isComplete() {
return complete;
}

Expand Down

0 comments on commit fab49e8

Please sign in to comment.