-
-
Notifications
You must be signed in to change notification settings - Fork 6.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Java Jersey2: Make generated client code thread safe (#7605)
* fix issue-7453; make jersey 2 generated code thread safe by following the withHttpInfo pattern used by many other generated clients * fix issue-7453; make jersey 2 generated code thread safe by following the withHttpInfo pattern used by many other generated clients
- Loading branch information
1 parent
35ec8ca
commit cddcda0
Showing
12 changed files
with
545 additions
and
67 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
48 changes: 48 additions & 0 deletions
48
modules/swagger-codegen/src/main/resources/Java/libraries/jersey2/ApiResponse.mustache
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
{{>licenseInfo}} | ||
|
||
package {{invokerPackage}}; | ||
|
||
import java.util.List; | ||
import java.util.Map; | ||
|
||
/** | ||
* API response returned by API call. | ||
* | ||
* @param <T> The type of data that is deserialized from response body | ||
*/ | ||
public class ApiResponse<T> { | ||
private final int statusCode; | ||
private final Map<String, List<String>> headers; | ||
private final T data; | ||
/** | ||
* @param statusCode The status code of HTTP response | ||
* @param headers The headers of HTTP response | ||
*/ | ||
public ApiResponse(int statusCode, Map<String, List<String>> headers) { | ||
this(statusCode, headers, null); | ||
} | ||
|
||
/** | ||
* @param statusCode The status code of HTTP response | ||
* @param headers The headers of HTTP response | ||
* @param data The object deserialized from response bod | ||
*/ | ||
public ApiResponse(int statusCode, Map<String, List<String>> headers, T data) { | ||
this.statusCode = statusCode; | ||
this.headers = headers; | ||
this.data = data; | ||
} | ||
|
||
public int getStatusCode() { | ||
return statusCode; | ||
} | ||
|
||
public Map<String, List<String>> getHeaders() { | ||
return headers; | ||
} | ||
|
||
public T getData() { | ||
return data; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
59 changes: 59 additions & 0 deletions
59
samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/ApiResponse.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
/* | ||
* Swagger 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: \" \\ | ||
* | ||
* OpenAPI spec version: 1.0.0 | ||
* Contact: [email protected] | ||
* | ||
* NOTE: This class is auto generated by the swagger code generator program. | ||
* https://github.com/swagger-api/swagger-codegen.git | ||
* Do not edit the class manually. | ||
*/ | ||
|
||
|
||
package io.swagger.client; | ||
|
||
import java.util.List; | ||
import java.util.Map; | ||
|
||
/** | ||
* API response returned by API call. | ||
* | ||
* @param <T> The type of data that is deserialized from response body | ||
*/ | ||
public class ApiResponse<T> { | ||
private final int statusCode; | ||
private final Map<String, List<String>> headers; | ||
private final T data; | ||
|
||
/** | ||
* @param statusCode The status code of HTTP response | ||
* @param headers The headers of HTTP response | ||
*/ | ||
public ApiResponse(int statusCode, Map<String, List<String>> headers) { | ||
this(statusCode, headers, null); | ||
} | ||
|
||
/** | ||
* @param statusCode The status code of HTTP response | ||
* @param headers The headers of HTTP response | ||
* @param data The object deserialized from response bod | ||
*/ | ||
public ApiResponse(int statusCode, Map<String, List<String>> headers, T data) { | ||
this.statusCode = statusCode; | ||
this.headers = headers; | ||
this.data = data; | ||
} | ||
|
||
public int getStatusCode() { | ||
return statusCode; | ||
} | ||
|
||
public Map<String, List<String>> getHeaders() { | ||
return headers; | ||
} | ||
|
||
public T getData() { | ||
return data; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.