[Java][retrofit2] Fix for Issue #7446 (#7659)

* [Java][retrofit2]  Fix for issue #7446:  file upload sets filename as baseName instead of a dynamic filename. The solution is to use  okhttp3.MultipartBody.Part instead of RequestBody in formParams template.

* Changes corresponding to review comments

* Petstore Samples

* Fixed tests
This commit is contained in:
Adrien CABARBAYE 2018-02-22 13:45:19 +00:00 committed by William Cheng
parent b4827beba4
commit d4543a99e3
73 changed files with 130 additions and 115 deletions

View File

@ -20,6 +20,7 @@ import retrofit2.http.*;
import okhttp3.RequestBody;
import okhttp3.ResponseBody;
import okhttp3.MultipartBody;
{{#imports}}import {{import}};
{{/imports}}

View File

@ -1 +1 @@
{{#isFormParam}}{{#notFile}}{{#isMultipart}}@retrofit2.http.Part{{/isMultipart}}{{^isMultipart}}@retrofit2.http.Field{{/isMultipart}}("{{baseName}}") {{{dataType}}} {{paramName}}{{/notFile}}{{#isFile}}{{#isMultipart}}@retrofit2.http.Part{{/isMultipart}}{{^isMultipart}}@retrofit2.http.Field{{/isMultipart}}{{#usePlayWS}} okhttp3.MultipartBody.Part {{/usePlayWS}}{{^usePlayWS}}("{{baseName}}\"; filename=\"{{baseName}}") RequestBody {{/usePlayWS}}{{paramName}}{{/isFile}}{{/isFormParam}}
{{#isFormParam}}{{#notFile}}{{#isMultipart}}@retrofit2.http.Part{{/isMultipart}}{{^isMultipart}}@retrofit2.http.Field{{/isMultipart}}("{{baseName}}") {{{dataType}}} {{paramName}}{{/notFile}}{{#isFile}}{{#isMultipart}}@retrofit2.http.Part{{/isMultipart}}{{^isMultipart}}@retrofit2.http.Field{{/isMultipart}} MultipartBody.Part {{paramName}}{{/isFile}}{{/isFormParam}}

View File

@ -206,7 +206,7 @@ Get user by user name
UserApi apiInstance = new UserApi();
String username = "username_example"; // String | The name that needs to be fetched. Use user1 for testing.
String username = "username_example"; // String | The name that needs to be fetched. Use user1 for testing.
try {
User result = apiInstance.getUserByName(username);
System.out.println(result);
@ -220,7 +220,7 @@ try {
Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
**username** | **String**| The name that needs to be fetched. Use user1 for testing. |
**username** | **String**| The name that needs to be fetched. Use user1 for testing. |
### Return type

View File

@ -120,7 +120,7 @@ public interface PetApi {
@retrofit2.http.Multipart
@POST("pet/{petId}/uploadImage")
F.Promise<Response<ModelApiResponse>> uploadFile(
@retrofit2.http.Path("petId") Long petId, @retrofit2.http.Part("additionalMetadata") String additionalMetadata, @retrofit2.http.Part okhttp3.MultipartBody.Part file
@retrofit2.http.Path("petId") Long petId, @retrofit2.http.Part("additionalMetadata") String additionalMetadata, @retrofit2.http.Part MultipartBody.Part file
);
}

View File

@ -67,7 +67,7 @@ public interface UserApi {
/**
* Get user by user name
*
* @param username The name that needs to be fetched. Use user1 for testing. (required)
* @param username The name that needs to be fetched. Use user1 for testing. (required)
* @return Call&lt;User&gt;
*/
@GET("user/{username}")

View File

@ -1 +1 @@
2.3.1-SNAPSHOT
2.4.0-SNAPSHOT

View File

@ -98,7 +98,7 @@ ext {
retrofit_version = "2.3.0"
jackson_version = "2.7.8"
play_version = "2.5.14"
swagger_annotations_version = "1.5.15"
swagger_annotations_version = "1.5.17"
junit_version = "4.12"
threetenbp_version = "1.3.5"
json_fire_version = "1.8.0"

View File

@ -16,7 +16,7 @@ lazy val root = (project in file(".")).
"com.fasterxml.jackson.core" % "jackson-annotations" % "2.7.8" % "compile",
"com.fasterxml.jackson.core" % "jackson-databind" % "2.7.8" % "compile",
"com.squareup.retrofit2" % "converter-jackson" % "2.3.0" % "compile",
"io.swagger" % "swagger-annotations" % "1.5.15" % "compile",
"io.swagger" % "swagger-annotations" % "1.5.17" % "compile",
"org.apache.oltu.oauth2" % "org.apache.oltu.oauth2.client" % "1.0.1" % "compile",
"org.threeten" % "threetenbp" % "1.3.5" % "compile",
"io.gsonfire" % "gson-fire" % "1.8.0" % "compile",

View File

@ -242,7 +242,7 @@ No authorization required
<a name="testEndpointParameters"></a>
# **testEndpointParameters**
> Void testEndpointParameters(number, _double, patternWithoutDelimiter, _byte, integer, int32, int64, _float, string, binary, date, dateTime, password, paramCallback)
> testEndpointParameters(number, _double, patternWithoutDelimiter, _byte, integer, int32, int64, _float, string, binary, date, dateTime, password, paramCallback)
Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트
@ -280,8 +280,7 @@ OffsetDateTime dateTime = new OffsetDateTime(); // OffsetDateTime | None
String password = "password_example"; // String | None
String paramCallback = "paramCallback_example"; // String | None
try {
Void result = apiInstance.testEndpointParameters(number, _double, patternWithoutDelimiter, _byte, integer, int32, int64, _float, string, binary, date, dateTime, password, paramCallback);
System.out.println(result);
apiInstance.testEndpointParameters(number, _double, patternWithoutDelimiter, _byte, integer, int32, int64, _float, string, binary, date, dateTime, password, paramCallback);
} catch (ApiException e) {
System.err.println("Exception when calling FakeApi#testEndpointParameters");
e.printStackTrace();
@ -309,7 +308,7 @@ Name | Type | Description | Notes
### Return type
[**Void**](.md)
null (empty response body)
### Authorization
@ -322,7 +321,7 @@ Name | Type | Description | Notes
<a name="testEnumParameters"></a>
# **testEnumParameters**
> Void testEnumParameters(enumFormStringArray, enumFormString, enumHeaderStringArray, enumHeaderString, enumQueryStringArray, enumQueryString, enumQueryInteger, enumQueryDouble)
> testEnumParameters(enumFormStringArray, enumFormString, enumHeaderStringArray, enumHeaderString, enumQueryStringArray, enumQueryString, enumQueryInteger, enumQueryDouble)
To test enum parameters
@ -345,8 +344,7 @@ String enumQueryString = "-efg"; // String | Query parameter enum test (string)
Integer enumQueryInteger = 56; // Integer | Query parameter enum test (double)
Double enumQueryDouble = 3.4D; // Double | Query parameter enum test (double)
try {
Void result = apiInstance.testEnumParameters(enumFormStringArray, enumFormString, enumHeaderStringArray, enumHeaderString, enumQueryStringArray, enumQueryString, enumQueryInteger, enumQueryDouble);
System.out.println(result);
apiInstance.testEnumParameters(enumFormStringArray, enumFormString, enumHeaderStringArray, enumHeaderString, enumQueryStringArray, enumQueryString, enumQueryInteger, enumQueryDouble);
} catch (ApiException e) {
System.err.println("Exception when calling FakeApi#testEnumParameters");
e.printStackTrace();
@ -368,7 +366,7 @@ Name | Type | Description | Notes
### Return type
[**Void**](.md)
null (empty response body)
### Authorization
@ -381,7 +379,7 @@ No authorization required
<a name="testInlineAdditionalProperties"></a>
# **testInlineAdditionalProperties**
> Void testInlineAdditionalProperties(param)
> testInlineAdditionalProperties(param)
test inline additionalProperties
@ -397,8 +395,7 @@ test inline additionalProperties
FakeApi apiInstance = new FakeApi();
Object param = null; // Object | request body
try {
Void result = apiInstance.testInlineAdditionalProperties(param);
System.out.println(result);
apiInstance.testInlineAdditionalProperties(param);
} catch (ApiException e) {
System.err.println("Exception when calling FakeApi#testInlineAdditionalProperties");
e.printStackTrace();
@ -413,7 +410,7 @@ Name | Type | Description | Notes
### Return type
[**Void**](.md)
null (empty response body)
### Authorization
@ -426,7 +423,7 @@ No authorization required
<a name="testJsonFormData"></a>
# **testJsonFormData**
> Void testJsonFormData(param, param2)
> testJsonFormData(param, param2)
test json serialization of form data
@ -443,8 +440,7 @@ FakeApi apiInstance = new FakeApi();
String param = "param_example"; // String | field1
String param2 = "param2_example"; // String | field2
try {
Void result = apiInstance.testJsonFormData(param, param2);
System.out.println(result);
apiInstance.testJsonFormData(param, param2);
} catch (ApiException e) {
System.err.println("Exception when calling FakeApi#testJsonFormData");
e.printStackTrace();
@ -460,7 +456,7 @@ Name | Type | Description | Notes
### Return type
[**Void**](.md)
null (empty response body)
### Authorization

View File

@ -16,7 +16,7 @@ Method | HTTP request | Description
<a name="addPet"></a>
# **addPet**
> Void addPet(body)
> addPet(body)
Add a new pet to the store
@ -40,8 +40,7 @@ petstore_auth.setAccessToken("YOUR ACCESS TOKEN");
PetApi apiInstance = new PetApi();
Pet body = new Pet(); // Pet | Pet object that needs to be added to the store
try {
Void result = apiInstance.addPet(body);
System.out.println(result);
apiInstance.addPet(body);
} catch (ApiException e) {
System.err.println("Exception when calling PetApi#addPet");
e.printStackTrace();
@ -56,7 +55,7 @@ Name | Type | Description | Notes
### Return type
[**Void**](.md)
null (empty response body)
### Authorization
@ -69,7 +68,7 @@ Name | Type | Description | Notes
<a name="deletePet"></a>
# **deletePet**
> Void deletePet(petId, apiKey)
> deletePet(petId, apiKey)
Deletes a pet
@ -94,8 +93,7 @@ PetApi apiInstance = new PetApi();
Long petId = 789L; // Long | Pet id to delete
String apiKey = "apiKey_example"; // String |
try {
Void result = apiInstance.deletePet(petId, apiKey);
System.out.println(result);
apiInstance.deletePet(petId, apiKey);
} catch (ApiException e) {
System.err.println("Exception when calling PetApi#deletePet");
e.printStackTrace();
@ -111,7 +109,7 @@ Name | Type | Description | Notes
### Return type
[**Void**](.md)
null (empty response body)
### Authorization
@ -285,7 +283,7 @@ Name | Type | Description | Notes
<a name="updatePet"></a>
# **updatePet**
> Void updatePet(body)
> updatePet(body)
Update an existing pet
@ -309,8 +307,7 @@ petstore_auth.setAccessToken("YOUR ACCESS TOKEN");
PetApi apiInstance = new PetApi();
Pet body = new Pet(); // Pet | Pet object that needs to be added to the store
try {
Void result = apiInstance.updatePet(body);
System.out.println(result);
apiInstance.updatePet(body);
} catch (ApiException e) {
System.err.println("Exception when calling PetApi#updatePet");
e.printStackTrace();
@ -325,7 +322,7 @@ Name | Type | Description | Notes
### Return type
[**Void**](.md)
null (empty response body)
### Authorization
@ -338,7 +335,7 @@ Name | Type | Description | Notes
<a name="updatePetWithForm"></a>
# **updatePetWithForm**
> Void updatePetWithForm(petId, name, status)
> updatePetWithForm(petId, name, status)
Updates a pet in the store with form data
@ -364,8 +361,7 @@ Long petId = 789L; // Long | ID of pet that needs to be updated
String name = "name_example"; // String | Updated name of the pet
String status = "status_example"; // String | Updated status of the pet
try {
Void result = apiInstance.updatePetWithForm(petId, name, status);
System.out.println(result);
apiInstance.updatePetWithForm(petId, name, status);
} catch (ApiException e) {
System.err.println("Exception when calling PetApi#updatePetWithForm");
e.printStackTrace();
@ -382,7 +378,7 @@ Name | Type | Description | Notes
### Return type
[**Void**](.md)
null (empty response body)
### Authorization

View File

@ -12,7 +12,7 @@ Method | HTTP request | Description
<a name="deleteOrder"></a>
# **deleteOrder**
> Void deleteOrder(orderId)
> deleteOrder(orderId)
Delete purchase order by ID
@ -28,8 +28,7 @@ For valid response try integer IDs with value &lt; 1000. Anything above 1000 or
StoreApi apiInstance = new StoreApi();
String orderId = "orderId_example"; // String | ID of the order that needs to be deleted
try {
Void result = apiInstance.deleteOrder(orderId);
System.out.println(result);
apiInstance.deleteOrder(orderId);
} catch (ApiException e) {
System.err.println("Exception when calling StoreApi#deleteOrder");
e.printStackTrace();
@ -44,7 +43,7 @@ Name | Type | Description | Notes
### Return type
[**Void**](.md)
null (empty response body)
### Authorization

View File

@ -16,7 +16,7 @@ Method | HTTP request | Description
<a name="createUser"></a>
# **createUser**
> Void createUser(body)
> createUser(body)
Create user
@ -32,8 +32,7 @@ This can only be done by the logged in user.
UserApi apiInstance = new UserApi();
User body = new User(); // User | Created user object
try {
Void result = apiInstance.createUser(body);
System.out.println(result);
apiInstance.createUser(body);
} catch (ApiException e) {
System.err.println("Exception when calling UserApi#createUser");
e.printStackTrace();
@ -48,7 +47,7 @@ Name | Type | Description | Notes
### Return type
[**Void**](.md)
null (empty response body)
### Authorization
@ -61,7 +60,7 @@ No authorization required
<a name="createUsersWithArrayInput"></a>
# **createUsersWithArrayInput**
> Void createUsersWithArrayInput(body)
> createUsersWithArrayInput(body)
Creates list of users with given input array
@ -77,8 +76,7 @@ Creates list of users with given input array
UserApi apiInstance = new UserApi();
List<User> body = Arrays.asList(new User()); // List<User> | List of user object
try {
Void result = apiInstance.createUsersWithArrayInput(body);
System.out.println(result);
apiInstance.createUsersWithArrayInput(body);
} catch (ApiException e) {
System.err.println("Exception when calling UserApi#createUsersWithArrayInput");
e.printStackTrace();
@ -93,7 +91,7 @@ Name | Type | Description | Notes
### Return type
[**Void**](.md)
null (empty response body)
### Authorization
@ -106,7 +104,7 @@ No authorization required
<a name="createUsersWithListInput"></a>
# **createUsersWithListInput**
> Void createUsersWithListInput(body)
> createUsersWithListInput(body)
Creates list of users with given input array
@ -122,8 +120,7 @@ Creates list of users with given input array
UserApi apiInstance = new UserApi();
List<User> body = Arrays.asList(new User()); // List<User> | List of user object
try {
Void result = apiInstance.createUsersWithListInput(body);
System.out.println(result);
apiInstance.createUsersWithListInput(body);
} catch (ApiException e) {
System.err.println("Exception when calling UserApi#createUsersWithListInput");
e.printStackTrace();
@ -138,7 +135,7 @@ Name | Type | Description | Notes
### Return type
[**Void**](.md)
null (empty response body)
### Authorization
@ -151,7 +148,7 @@ No authorization required
<a name="deleteUser"></a>
# **deleteUser**
> Void deleteUser(username)
> deleteUser(username)
Delete user
@ -167,8 +164,7 @@ This can only be done by the logged in user.
UserApi apiInstance = new UserApi();
String username = "username_example"; // String | The name that needs to be deleted
try {
Void result = apiInstance.deleteUser(username);
System.out.println(result);
apiInstance.deleteUser(username);
} catch (ApiException e) {
System.err.println("Exception when calling UserApi#deleteUser");
e.printStackTrace();
@ -183,7 +179,7 @@ Name | Type | Description | Notes
### Return type
[**Void**](.md)
null (empty response body)
### Authorization
@ -210,7 +206,7 @@ Get user by user name
UserApi apiInstance = new UserApi();
String username = "username_example"; // String | The name that needs to be fetched. Use user1 for testing.
String username = "username_example"; // String | The name that needs to be fetched. Use user1 for testing.
try {
User result = apiInstance.getUserByName(username);
System.out.println(result);
@ -224,7 +220,7 @@ try {
Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
**username** | **String**| The name that needs to be fetched. Use user1 for testing. |
**username** | **String**| The name that needs to be fetched. Use user1 for testing. |
### Return type
@ -288,7 +284,7 @@ No authorization required
<a name="logoutUser"></a>
# **logoutUser**
> Void logoutUser()
> logoutUser()
Logs out current logged in user session
@ -303,8 +299,7 @@ Logs out current logged in user session
UserApi apiInstance = new UserApi();
try {
Void result = apiInstance.logoutUser();
System.out.println(result);
apiInstance.logoutUser();
} catch (ApiException e) {
System.err.println("Exception when calling UserApi#logoutUser");
e.printStackTrace();
@ -316,7 +311,7 @@ This endpoint does not need any parameter.
### Return type
[**Void**](.md)
null (empty response body)
### Authorization
@ -329,7 +324,7 @@ No authorization required
<a name="updateUser"></a>
# **updateUser**
> Void updateUser(username, body)
> updateUser(username, body)
Updated user
@ -346,8 +341,7 @@ UserApi apiInstance = new UserApi();
String username = "username_example"; // String | name that need to be deleted
User body = new User(); // User | Updated user object
try {
Void result = apiInstance.updateUser(username, body);
System.out.println(result);
apiInstance.updateUser(username, body);
} catch (ApiException e) {
System.err.println("Exception when calling UserApi#updateUser");
e.printStackTrace();
@ -363,7 +357,7 @@ Name | Type | Description | Notes
### Return type
[**Void**](.md)
null (empty response body)
### Authorization

View File

@ -208,7 +208,6 @@
<artifactId>converter-scalars</artifactId>
<version>${retrofit-version}</version>
</dependency>
<dependency>
<groupId>org.apache.oltu.oauth2</groupId>
<artifactId>org.apache.oltu.oauth2.client</artifactId>

View File

@ -1,8 +0,0 @@
/*___Generated_by_IDEA___*/
package io.swagger.client;
/* This stub is only used by the IDE. It is NOT the BuildConfig class actually packed into the APK */
public final class BuildConfig {
public final static boolean DEBUG = Boolean.parseBoolean(null);
}

View File

@ -1,7 +0,0 @@
/*___Generated_by_IDEA___*/
package io.swagger.client;
/* This stub is only used by the IDE. It is NOT the Manifest class actually packed into the APK */
public final class Manifest {
}

View File

@ -1,7 +0,0 @@
/*___Generated_by_IDEA___*/
package io.swagger.client;
/* This stub is only used by the IDE. It is NOT the R class actually packed into the APK */
public final class R {
}

View File

@ -120,7 +120,7 @@ public interface PetApi {
@retrofit2.http.Multipart
@POST("pet/{petId}/uploadImage")
CompletionStage<Response<ModelApiResponse>> uploadFile(
@retrofit2.http.Path("petId") Long petId, @retrofit2.http.Part("additionalMetadata") String additionalMetadata, @retrofit2.http.Part okhttp3.MultipartBody.Part file
@retrofit2.http.Path("petId") Long petId, @retrofit2.http.Part("additionalMetadata") String additionalMetadata, @retrofit2.http.Part MultipartBody.Part file
);
}

View File

@ -67,7 +67,7 @@ public interface UserApi {
/**
* Get user by user name
*
* @param username The name that needs to be fetched. Use user1 for testing. (required)
* @param username The name that needs to be fetched. Use user1 for testing. (required)
* @return Call&lt;User&gt;
*/
@GET("user/{username}")

View File

@ -14,6 +14,7 @@
package io.swagger.client.model;
import java.util.Objects;
import java.util.Arrays;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonValue;

View File

@ -14,6 +14,7 @@
package io.swagger.client.model;
import java.util.Objects;
import java.util.Arrays;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonSubTypes;

View File

@ -14,6 +14,7 @@
package io.swagger.client.model;
import java.util.Objects;
import java.util.Arrays;
import io.swagger.client.model.Animal;
import java.util.ArrayList;
import java.util.List;

View File

@ -14,6 +14,7 @@
package io.swagger.client.model;
import java.util.Objects;
import java.util.Arrays;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonValue;

View File

@ -14,6 +14,7 @@
package io.swagger.client.model;
import java.util.Objects;
import java.util.Arrays;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonValue;

View File

@ -14,6 +14,7 @@
package io.swagger.client.model;
import java.util.Objects;
import java.util.Arrays;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonValue;

View File

@ -14,6 +14,7 @@
package io.swagger.client.model;
import java.util.Objects;
import java.util.Arrays;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonValue;

View File

@ -14,6 +14,7 @@
package io.swagger.client.model;
import java.util.Objects;
import java.util.Arrays;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonValue;

View File

@ -14,6 +14,7 @@
package io.swagger.client.model;
import java.util.Objects;
import java.util.Arrays;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonValue;

View File

@ -14,6 +14,7 @@
package io.swagger.client.model;
import java.util.Objects;
import java.util.Arrays;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonValue;

View File

@ -14,6 +14,7 @@
package io.swagger.client.model;
import java.util.Objects;
import java.util.Arrays;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonValue;

View File

@ -14,6 +14,7 @@
package io.swagger.client.model;
import java.util.Objects;
import java.util.Arrays;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonValue;

View File

@ -14,6 +14,7 @@
package io.swagger.client.model;
import java.util.Objects;
import java.util.Arrays;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonValue;

View File

@ -14,6 +14,7 @@
package io.swagger.client.model;
import java.util.Objects;
import java.util.Arrays;
import javax.validation.constraints.*;
import javax.validation.Valid;

View File

@ -14,6 +14,7 @@
package io.swagger.client.model;
import java.util.Objects;
import java.util.Arrays;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonValue;

View File

@ -14,6 +14,7 @@
package io.swagger.client.model;
import java.util.Objects;
import java.util.Arrays;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonValue;
@ -339,8 +340,8 @@ public class FormatTest {
Objects.equals(this._float, formatTest._float) &&
Objects.equals(this._double, formatTest._double) &&
Objects.equals(this.string, formatTest.string) &&
Objects.equals(this._byte, formatTest._byte) &&
Objects.equals(this.binary, formatTest.binary) &&
Arrays.equals(this._byte, formatTest._byte) &&
Arrays.equals(this.binary, formatTest.binary) &&
Objects.equals(this.date, formatTest.date) &&
Objects.equals(this.dateTime, formatTest.dateTime) &&
Objects.equals(this.uuid, formatTest.uuid) &&
@ -349,7 +350,7 @@ public class FormatTest {
@Override
public int hashCode() {
return Objects.hash(integer, int32, int64, number, _float, _double, string, _byte, binary, date, dateTime, uuid, password);
return Objects.hash(integer, int32, int64, number, _float, _double, string, Arrays.hashCode(_byte), Arrays.hashCode(binary), date, dateTime, uuid, password);
}

View File

@ -14,6 +14,7 @@
package io.swagger.client.model;
import java.util.Objects;
import java.util.Arrays;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonValue;

View File

@ -14,6 +14,7 @@
package io.swagger.client.model;
import java.util.Objects;
import java.util.Arrays;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonValue;

View File

@ -14,6 +14,7 @@
package io.swagger.client.model;
import java.util.Objects;
import java.util.Arrays;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonValue;

View File

@ -14,6 +14,7 @@
package io.swagger.client.model;
import java.util.Objects;
import java.util.Arrays;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonValue;

View File

@ -14,6 +14,7 @@
package io.swagger.client.model;
import java.util.Objects;
import java.util.Arrays;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonValue;

View File

@ -14,6 +14,7 @@
package io.swagger.client.model;
import java.util.Objects;
import java.util.Arrays;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonValue;

View File

@ -14,6 +14,7 @@
package io.swagger.client.model;
import java.util.Objects;
import java.util.Arrays;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonValue;

View File

@ -14,6 +14,7 @@
package io.swagger.client.model;
import java.util.Objects;
import java.util.Arrays;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonValue;

View File

@ -14,6 +14,7 @@
package io.swagger.client.model;
import java.util.Objects;
import java.util.Arrays;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonValue;

View File

@ -14,6 +14,7 @@
package io.swagger.client.model;
import java.util.Objects;
import java.util.Arrays;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonValue;

View File

@ -14,6 +14,7 @@
package io.swagger.client.model;
import java.util.Objects;
import java.util.Arrays;
import javax.validation.constraints.*;
import javax.validation.Valid;

View File

@ -14,6 +14,7 @@
package io.swagger.client.model;
import java.util.Objects;
import java.util.Arrays;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonValue;

View File

@ -14,6 +14,7 @@
package io.swagger.client.model;
import java.util.Objects;
import java.util.Arrays;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonValue;

View File

@ -14,6 +14,7 @@
package io.swagger.client.model;
import java.util.Objects;
import java.util.Arrays;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonValue;

View File

@ -14,6 +14,7 @@
package io.swagger.client.model;
import java.util.Objects;
import java.util.Arrays;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonValue;

View File

@ -14,6 +14,7 @@
package io.swagger.client.model;
import java.util.Objects;
import java.util.Arrays;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonValue;

View File

@ -206,7 +206,7 @@ Get user by user name
UserApi apiInstance = new UserApi();
String username = "username_example"; // String | The name that needs to be fetched. Use user1 for testing.
String username = "username_example"; // String | The name that needs to be fetched. Use user1 for testing.
try {
User result = apiInstance.getUserByName(username);
System.out.println(result);
@ -220,7 +220,7 @@ try {
Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
**username** | **String**| The name that needs to be fetched. Use user1 for testing. |
**username** | **String**| The name that needs to be fetched. Use user1 for testing. |
### Return type

View File

@ -7,6 +7,7 @@ import retrofit2.http.*;
import okhttp3.RequestBody;
import okhttp3.ResponseBody;
import okhttp3.MultipartBody;
import io.swagger.client.model.Client;

View File

@ -7,6 +7,7 @@ import retrofit2.http.*;
import okhttp3.RequestBody;
import okhttp3.ResponseBody;
import okhttp3.MultipartBody;
import java.math.BigDecimal;
import io.swagger.client.model.Client;

View File

@ -7,6 +7,7 @@ import retrofit2.http.*;
import okhttp3.RequestBody;
import okhttp3.ResponseBody;
import okhttp3.MultipartBody;
import io.swagger.client.model.Client;

View File

@ -7,6 +7,7 @@ import retrofit2.http.*;
import okhttp3.RequestBody;
import okhttp3.ResponseBody;
import okhttp3.MultipartBody;
import java.io.File;
import io.swagger.client.model.ModelApiResponse;
@ -118,7 +119,7 @@ public interface PetApi {
@retrofit2.http.Multipart
@POST("pet/{petId}/uploadImage")
Call<ModelApiResponse> uploadFile(
@retrofit2.http.Path("petId") Long petId, @retrofit2.http.Part("additionalMetadata") String additionalMetadata, @retrofit2.http.Part("file\"; filename=\"file") RequestBody file
@retrofit2.http.Path("petId") Long petId, @retrofit2.http.Part("additionalMetadata") String additionalMetadata, @retrofit2.http.Part MultipartBody.Part file
);
}

View File

@ -7,6 +7,7 @@ import retrofit2.http.*;
import okhttp3.RequestBody;
import okhttp3.ResponseBody;
import okhttp3.MultipartBody;
import io.swagger.client.model.Order;

View File

@ -7,6 +7,7 @@ import retrofit2.http.*;
import okhttp3.RequestBody;
import okhttp3.ResponseBody;
import okhttp3.MultipartBody;
import io.swagger.client.model.User;
@ -63,7 +64,7 @@ public interface UserApi {
/**
* Get user by user name
*
* @param username The name that needs to be fetched. Use user1 for testing. (required)
* @param username The name that needs to be fetched. Use user1 for testing. (required)
* @return Call&lt;User&gt;
*/
@GET("user/{username}")

View File

@ -19,6 +19,7 @@ import retrofit2.Response;
import okhttp3.MediaType;
import okhttp3.RequestBody;
import okhttp3.MultipartBody;
import static org.junit.Assert.*;
@ -139,9 +140,9 @@ public class PetApiTest {
File file = new File("hello.txt");
BufferedWriter writer = new BufferedWriter(new FileWriter(file));
writer.write("Hello world!");
writer.close();
api.uploadFile(pet.getId(), null, RequestBody.create(MediaType.parse("text/plain"), file)).execute();
writer.close();
final RequestBody body = RequestBody.create(MediaType.parse("text/plain"), file);
api.uploadFile(pet.getId(), null, MultipartBody.Part.createFormData("datafile", file.getName(), body)).execute();
}
@Test

View File

@ -206,7 +206,7 @@ Get user by user name
UserApi apiInstance = new UserApi();
String username = "username_example"; // String | The name that needs to be fetched. Use user1 for testing.
String username = "username_example"; // String | The name that needs to be fetched. Use user1 for testing.
try {
User result = apiInstance.getUserByName(username);
System.out.println(result);
@ -220,7 +220,7 @@ try {
Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
**username** | **String**| The name that needs to be fetched. Use user1 for testing. |
**username** | **String**| The name that needs to be fetched. Use user1 for testing. |
### Return type

View File

@ -7,6 +7,7 @@ import retrofit2.http.*;
import okhttp3.RequestBody;
import okhttp3.ResponseBody;
import okhttp3.MultipartBody;
import io.swagger.client.model.Client;

View File

@ -7,6 +7,7 @@ import retrofit2.http.*;
import okhttp3.RequestBody;
import okhttp3.ResponseBody;
import okhttp3.MultipartBody;
import java.math.BigDecimal;
import io.swagger.client.model.Client;

View File

@ -7,6 +7,7 @@ import retrofit2.http.*;
import okhttp3.RequestBody;
import okhttp3.ResponseBody;
import okhttp3.MultipartBody;
import io.swagger.client.model.Client;

View File

@ -7,6 +7,7 @@ import retrofit2.http.*;
import okhttp3.RequestBody;
import okhttp3.ResponseBody;
import okhttp3.MultipartBody;
import java.io.File;
import io.swagger.client.model.ModelApiResponse;
@ -118,7 +119,7 @@ public interface PetApi {
@retrofit2.http.Multipart
@POST("pet/{petId}/uploadImage")
Observable<ModelApiResponse> uploadFile(
@retrofit2.http.Path("petId") Long petId, @retrofit2.http.Part("additionalMetadata") String additionalMetadata, @retrofit2.http.Part("file\"; filename=\"file") RequestBody file
@retrofit2.http.Path("petId") Long petId, @retrofit2.http.Part("additionalMetadata") String additionalMetadata, @retrofit2.http.Part MultipartBody.Part file
);
}

View File

@ -7,6 +7,7 @@ import retrofit2.http.*;
import okhttp3.RequestBody;
import okhttp3.ResponseBody;
import okhttp3.MultipartBody;
import io.swagger.client.model.Order;

View File

@ -7,6 +7,7 @@ import retrofit2.http.*;
import okhttp3.RequestBody;
import okhttp3.ResponseBody;
import okhttp3.MultipartBody;
import io.swagger.client.model.User;
@ -63,7 +64,7 @@ public interface UserApi {
/**
* Get user by user name
*
* @param username The name that needs to be fetched. Use user1 for testing. (required)
* @param username The name that needs to be fetched. Use user1 for testing. (required)
* @return Observable&lt;User&gt;
*/
@GET("user/{username}")

View File

@ -14,6 +14,7 @@ import java.util.List;
import org.junit.*;
import okhttp3.MediaType;
import okhttp3.MultipartBody;
import okhttp3.RequestBody;
import static org.junit.Assert.*;
@ -200,8 +201,8 @@ public class PetApiTest {
Pet pet = createRandomPet();
api.addPet(pet).subscribe(SkeletonSubscriber.failTestOnError());
RequestBody body = RequestBody.create(MediaType.parse("text/plain"), file);
api.uploadFile(pet.getId(), "a test file", body).subscribe(new SkeletonSubscriber<ModelApiResponse>() {
final RequestBody body = RequestBody.create(MediaType.parse("text/plain"), file);
api.uploadFile(pet.getId(), "a test file", MultipartBody.Part.createFormData("datafile", file.getName(), body)).subscribe(new SkeletonSubscriber<ModelApiResponse>() {
@Override
public void onError(Throwable e) {
// this also yields a 400 for other tests, so I guess it's okay...

View File

@ -206,7 +206,7 @@ Get user by user name
UserApi apiInstance = new UserApi();
String username = "username_example"; // String | The name that needs to be fetched. Use user1 for testing.
String username = "username_example"; // String | The name that needs to be fetched. Use user1 for testing.
try {
User result = apiInstance.getUserByName(username);
System.out.println(result);
@ -220,7 +220,7 @@ try {
Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
**username** | **String**| The name that needs to be fetched. Use user1 for testing. |
**username** | **String**| The name that needs to be fetched. Use user1 for testing. |
### Return type

View File

@ -8,6 +8,7 @@ import retrofit2.http.*;
import okhttp3.RequestBody;
import okhttp3.ResponseBody;
import okhttp3.MultipartBody;
import io.swagger.client.model.Client;

View File

@ -8,6 +8,7 @@ import retrofit2.http.*;
import okhttp3.RequestBody;
import okhttp3.ResponseBody;
import okhttp3.MultipartBody;
import java.math.BigDecimal;
import io.swagger.client.model.Client;

View File

@ -8,6 +8,7 @@ import retrofit2.http.*;
import okhttp3.RequestBody;
import okhttp3.ResponseBody;
import okhttp3.MultipartBody;
import io.swagger.client.model.Client;

View File

@ -8,6 +8,7 @@ import retrofit2.http.*;
import okhttp3.RequestBody;
import okhttp3.ResponseBody;
import okhttp3.MultipartBody;
import java.io.File;
import io.swagger.client.model.ModelApiResponse;
@ -119,7 +120,7 @@ public interface PetApi {
@retrofit2.http.Multipart
@POST("pet/{petId}/uploadImage")
Observable<ModelApiResponse> uploadFile(
@retrofit2.http.Path("petId") Long petId, @retrofit2.http.Part("additionalMetadata") String additionalMetadata, @retrofit2.http.Part("file\"; filename=\"file") RequestBody file
@retrofit2.http.Path("petId") Long petId, @retrofit2.http.Part("additionalMetadata") String additionalMetadata, @retrofit2.http.Part MultipartBody.Part file
);
}

View File

@ -8,6 +8,7 @@ import retrofit2.http.*;
import okhttp3.RequestBody;
import okhttp3.ResponseBody;
import okhttp3.MultipartBody;
import io.swagger.client.model.Order;

View File

@ -8,6 +8,7 @@ import retrofit2.http.*;
import okhttp3.RequestBody;
import okhttp3.ResponseBody;
import okhttp3.MultipartBody;
import io.swagger.client.model.User;
@ -64,7 +65,7 @@ public interface UserApi {
/**
* Get user by user name
*
* @param username The name that needs to be fetched. Use user1 for testing. (required)
* @param username The name that needs to be fetched. Use user1 for testing. (required)
* @return Observable&lt;User&gt;
*/
@GET("user/{username}")