forked from loafle/openapi-generator-original
Update java client samples OAS2 (#140)
* Update java client examples * Rename artifactId in json config files * Add imports in api.mustache for play24 and play25
This commit is contained in:
@@ -18,7 +18,7 @@ public interface AnotherFakeApi extends ApiClient.Api {
|
||||
/**
|
||||
* To test special tags
|
||||
* To test special tags
|
||||
* @param body client model (required)
|
||||
* @param client client model (required)
|
||||
* @return Client
|
||||
*/
|
||||
@RequestLine("PATCH /another-fake/dummy")
|
||||
@@ -26,5 +26,5 @@ public interface AnotherFakeApi extends ApiClient.Api {
|
||||
"Content-Type: application/json",
|
||||
"Accept: application/json",
|
||||
})
|
||||
Client testSpecialTags(Client body);
|
||||
Client testSpecialTags(Client client);
|
||||
}
|
||||
|
||||
@@ -5,9 +5,11 @@ import io.swagger.client.EncodingUtils;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import io.swagger.client.model.Client;
|
||||
import java.io.File;
|
||||
import org.threeten.bp.LocalDate;
|
||||
import org.threeten.bp.OffsetDateTime;
|
||||
import io.swagger.client.model.OuterComposite;
|
||||
import io.swagger.client.model.User;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
@@ -22,28 +24,28 @@ public interface FakeApi extends ApiClient.Api {
|
||||
/**
|
||||
*
|
||||
* Test serialization of outer boolean types
|
||||
* @param body Input boolean as post body (optional)
|
||||
* @param booleanPostBody Input boolean as post body (optional)
|
||||
* @return Boolean
|
||||
*/
|
||||
@RequestLine("POST /fake/outer/boolean")
|
||||
@Headers({
|
||||
"Content-Type: application/json",
|
||||
"Accept: application/json",
|
||||
"Content-Type: */*",
|
||||
"Accept: */*",
|
||||
})
|
||||
Boolean fakeOuterBooleanSerialize(Boolean body);
|
||||
Boolean fakeOuterBooleanSerialize(Boolean booleanPostBody);
|
||||
|
||||
/**
|
||||
*
|
||||
* Test serialization of object with outer number type
|
||||
* @param body Input composite as post body (optional)
|
||||
* @param outerComposite Input composite as post body (optional)
|
||||
* @return OuterComposite
|
||||
*/
|
||||
@RequestLine("POST /fake/outer/composite")
|
||||
@Headers({
|
||||
"Content-Type: application/json",
|
||||
"Accept: application/json",
|
||||
"Content-Type: */*",
|
||||
"Accept: */*",
|
||||
})
|
||||
OuterComposite fakeOuterCompositeSerialize(OuterComposite body);
|
||||
OuterComposite fakeOuterCompositeSerialize(OuterComposite outerComposite);
|
||||
|
||||
/**
|
||||
*
|
||||
@@ -53,8 +55,8 @@ public interface FakeApi extends ApiClient.Api {
|
||||
*/
|
||||
@RequestLine("POST /fake/outer/number")
|
||||
@Headers({
|
||||
"Content-Type: application/json",
|
||||
"Accept: application/json",
|
||||
"Content-Type: */*",
|
||||
"Accept: */*",
|
||||
})
|
||||
BigDecimal fakeOuterNumberSerialize(BigDecimal body);
|
||||
|
||||
@@ -66,15 +68,61 @@ public interface FakeApi extends ApiClient.Api {
|
||||
*/
|
||||
@RequestLine("POST /fake/outer/string")
|
||||
@Headers({
|
||||
"Content-Type: application/json",
|
||||
"Accept: application/json",
|
||||
"Content-Type: */*",
|
||||
"Accept: */*",
|
||||
})
|
||||
String fakeOuterStringSerialize(String body);
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @param query (required)
|
||||
* @param user (required)
|
||||
*/
|
||||
@RequestLine("PUT /fake/body-with-query-params?query={query}")
|
||||
@Headers({
|
||||
"Content-Type: application/json",
|
||||
"Accept: application/json",
|
||||
})
|
||||
void testBodyWithQueryParams(@Param("query") String query, User user);
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* Note, this is equivalent to the other <code>testBodyWithQueryParams</code> method,
|
||||
* but with the query parameters collected into a single Map parameter. This
|
||||
* is convenient for services with optional query parameters, especially when
|
||||
* used with the {@link TestBodyWithQueryParamsQueryParams} class that allows for
|
||||
* building up this map in a fluent style.
|
||||
* @param user (required)
|
||||
* @param queryParams Map of query parameters as name-value pairs
|
||||
* <p>The following elements may be specified in the query map:</p>
|
||||
* <ul>
|
||||
* <li>query - (required)</li>
|
||||
* </ul>
|
||||
*/
|
||||
@RequestLine("PUT /fake/body-with-query-params?query={query}")
|
||||
@Headers({
|
||||
"Content-Type: application/json",
|
||||
"Accept: application/json",
|
||||
})
|
||||
void testBodyWithQueryParams(User user, @QueryMap(encoded=true) Map<String, Object> queryParams);
|
||||
|
||||
/**
|
||||
* A convenience class for generating query parameters for the
|
||||
* <code>testBodyWithQueryParams</code> method in a fluent style.
|
||||
*/
|
||||
public static class TestBodyWithQueryParamsQueryParams extends HashMap<String, Object> {
|
||||
public TestBodyWithQueryParamsQueryParams query(final String value) {
|
||||
put("query", EncodingUtils.encode(value));
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* To test \"client\" model
|
||||
* To test \"client\" model
|
||||
* @param body client model (required)
|
||||
* @param client client model (required)
|
||||
* @return Client
|
||||
*/
|
||||
@RequestLine("PATCH /fake")
|
||||
@@ -82,7 +130,7 @@ public interface FakeApi extends ApiClient.Api {
|
||||
"Content-Type: application/json",
|
||||
"Accept: application/json",
|
||||
})
|
||||
Client testClientModel(Client body);
|
||||
Client testClientModel(Client client);
|
||||
|
||||
/**
|
||||
* Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트
|
||||
@@ -104,32 +152,32 @@ public interface FakeApi extends ApiClient.Api {
|
||||
*/
|
||||
@RequestLine("POST /fake")
|
||||
@Headers({
|
||||
"Content-Type: application/xml; charset=utf-8",
|
||||
"Accept: application/xml; charset=utf-8,application/json; charset=utf-8",
|
||||
"Content-Type: application/x-www-form-urlencoded",
|
||||
"Accept: application/json",
|
||||
})
|
||||
void testEndpointParameters(@Param("number") BigDecimal number, @Param("_double") Double _double, @Param("patternWithoutDelimiter") String patternWithoutDelimiter, @Param("_byte") byte[] _byte, @Param("integer") Integer integer, @Param("int32") Integer int32, @Param("int64") Long int64, @Param("_float") Float _float, @Param("string") String string, @Param("binary") byte[] binary, @Param("date") LocalDate date, @Param("dateTime") OffsetDateTime dateTime, @Param("password") String password, @Param("paramCallback") String paramCallback);
|
||||
void testEndpointParameters(@Param("number") BigDecimal number, @Param("_double") Double _double, @Param("patternWithoutDelimiter") String patternWithoutDelimiter, @Param("_byte") byte[] _byte, @Param("integer") Integer integer, @Param("int32") Integer int32, @Param("int64") Long int64, @Param("_float") Float _float, @Param("string") String string, @Param("binary") File binary, @Param("date") LocalDate date, @Param("dateTime") OffsetDateTime dateTime, @Param("password") String password, @Param("paramCallback") String paramCallback);
|
||||
|
||||
/**
|
||||
* To test enum parameters
|
||||
* To test enum parameters
|
||||
* @param enumFormStringArray Form parameter enum test (string array) (optional)
|
||||
* @param enumFormString Form parameter enum test (string) (optional, default to -efg)
|
||||
* @param enumHeaderStringArray Header parameter enum test (string array) (optional)
|
||||
* @param enumHeaderString Header parameter enum test (string) (optional, default to -efg)
|
||||
* @param enumQueryStringArray Query parameter enum test (string array) (optional)
|
||||
* @param enumQueryString Query parameter enum test (string) (optional, default to -efg)
|
||||
* @param enumQueryInteger Query parameter enum test (double) (optional)
|
||||
* @param enumQueryDouble Query parameter enum test (double) (optional)
|
||||
* @param enumFormStringArray Form parameter enum test (string array) (optional)
|
||||
* @param enumFormString Form parameter enum test (string) (optional)
|
||||
*/
|
||||
@RequestLine("GET /fake?enum_query_string_array={enumQueryStringArray}&enum_query_string={enumQueryString}&enum_query_integer={enumQueryInteger}")
|
||||
@RequestLine("GET /fake?enum_query_string_array={enumQueryStringArray}&enum_query_string={enumQueryString}&enum_query_integer={enumQueryInteger}&enum_query_double={enumQueryDouble}")
|
||||
@Headers({
|
||||
"Content-Type: */*",
|
||||
"Accept: */*",
|
||||
"Content-Type: application/x-www-form-urlencoded",
|
||||
"Accept: application/json",
|
||||
"enum_header_string_array: {enumHeaderStringArray}",
|
||||
|
||||
"enum_header_string: {enumHeaderString}"
|
||||
})
|
||||
void testEnumParameters(@Param("enumFormStringArray") List<String> enumFormStringArray, @Param("enumFormString") String enumFormString, @Param("enumHeaderStringArray") List<String> enumHeaderStringArray, @Param("enumHeaderString") String enumHeaderString, @Param("enumQueryStringArray") List<String> enumQueryStringArray, @Param("enumQueryString") String enumQueryString, @Param("enumQueryInteger") Integer enumQueryInteger, @Param("enumQueryDouble") Double enumQueryDouble);
|
||||
void testEnumParameters(@Param("enumHeaderStringArray") List<String> enumHeaderStringArray, @Param("enumHeaderString") String enumHeaderString, @Param("enumQueryStringArray") List<String> enumQueryStringArray, @Param("enumQueryString") String enumQueryString, @Param("enumQueryInteger") Integer enumQueryInteger, @Param("enumQueryDouble") Double enumQueryDouble, @Param("enumFormStringArray") List<String> enumFormStringArray, @Param("enumFormString") String enumFormString);
|
||||
|
||||
/**
|
||||
* To test enum parameters
|
||||
@@ -139,28 +187,28 @@ public interface FakeApi extends ApiClient.Api {
|
||||
* is convenient for services with optional query parameters, especially when
|
||||
* used with the {@link TestEnumParametersQueryParams} class that allows for
|
||||
* building up this map in a fluent style.
|
||||
* @param enumFormStringArray Form parameter enum test (string array) (optional)
|
||||
* @param enumFormString Form parameter enum test (string) (optional, default to -efg)
|
||||
* @param enumHeaderStringArray Header parameter enum test (string array) (optional)
|
||||
* @param enumHeaderString Header parameter enum test (string) (optional, default to -efg)
|
||||
* @param enumQueryDouble Query parameter enum test (double) (optional)
|
||||
* @param enumFormStringArray Form parameter enum test (string array) (optional)
|
||||
* @param enumFormString Form parameter enum test (string) (optional)
|
||||
* @param queryParams Map of query parameters as name-value pairs
|
||||
* <p>The following elements may be specified in the query map:</p>
|
||||
* <ul>
|
||||
* <li>enumQueryStringArray - Query parameter enum test (string array) (optional)</li>
|
||||
* <li>enumQueryString - Query parameter enum test (string) (optional, default to -efg)</li>
|
||||
* <li>enumQueryInteger - Query parameter enum test (double) (optional)</li>
|
||||
* <li>enumQueryDouble - Query parameter enum test (double) (optional)</li>
|
||||
* </ul>
|
||||
*/
|
||||
@RequestLine("GET /fake?enum_query_string_array={enumQueryStringArray}&enum_query_string={enumQueryString}&enum_query_integer={enumQueryInteger}")
|
||||
@RequestLine("GET /fake?enum_query_string_array={enumQueryStringArray}&enum_query_string={enumQueryString}&enum_query_integer={enumQueryInteger}&enum_query_double={enumQueryDouble}")
|
||||
@Headers({
|
||||
"Content-Type: */*",
|
||||
"Accept: */*",
|
||||
"Content-Type: application/x-www-form-urlencoded",
|
||||
"Accept: application/json",
|
||||
"enum_header_string_array: {enumHeaderStringArray}",
|
||||
|
||||
"enum_header_string: {enumHeaderString}"
|
||||
})
|
||||
void testEnumParameters(@Param("enumFormStringArray") List<String> enumFormStringArray, @Param("enumFormString") String enumFormString, @Param("enumHeaderStringArray") List<String> enumHeaderStringArray, @Param("enumHeaderString") String enumHeaderString, @Param("enumQueryDouble") Double enumQueryDouble, @QueryMap(encoded=true) Map<String, Object> queryParams);
|
||||
void testEnumParameters(@Param("enumHeaderStringArray") List<String> enumHeaderStringArray, @Param("enumHeaderString") String enumHeaderString, @Param("enumFormStringArray") List<String> enumFormStringArray, @Param("enumFormString") String enumFormString, @QueryMap(encoded=true) Map<String, Object> queryParams);
|
||||
|
||||
/**
|
||||
* A convenience class for generating query parameters for the
|
||||
@@ -179,19 +227,23 @@ public interface FakeApi extends ApiClient.Api {
|
||||
put("enum_query_integer", EncodingUtils.encode(value));
|
||||
return this;
|
||||
}
|
||||
public TestEnumParametersQueryParams enumQueryDouble(final Double value) {
|
||||
put("enum_query_double", EncodingUtils.encode(value));
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* test inline additionalProperties
|
||||
*
|
||||
* @param param request body (required)
|
||||
* @param requestBody request body (required)
|
||||
*/
|
||||
@RequestLine("POST /fake/inline-additionalProperties")
|
||||
@Headers({
|
||||
"Content-Type: application/json",
|
||||
"Accept: application/json",
|
||||
})
|
||||
void testInlineAdditionalProperties(Object param);
|
||||
void testInlineAdditionalProperties(String requestBody);
|
||||
|
||||
/**
|
||||
* test json serialization of form data
|
||||
@@ -201,7 +253,7 @@ public interface FakeApi extends ApiClient.Api {
|
||||
*/
|
||||
@RequestLine("GET /fake/jsonFormData")
|
||||
@Headers({
|
||||
"Content-Type: application/json",
|
||||
"Content-Type: application/x-www-form-urlencoded",
|
||||
"Accept: application/json",
|
||||
})
|
||||
void testJsonFormData(@Param("param") String param, @Param("param2") String param2);
|
||||
|
||||
@@ -18,7 +18,7 @@ public interface FakeClassnameTags123Api extends ApiClient.Api {
|
||||
/**
|
||||
* To test class name in snake case
|
||||
* To test class name in snake case
|
||||
* @param body client model (required)
|
||||
* @param client client model (required)
|
||||
* @return Client
|
||||
*/
|
||||
@RequestLine("PATCH /fake_classname_test")
|
||||
@@ -26,5 +26,5 @@ public interface FakeClassnameTags123Api extends ApiClient.Api {
|
||||
"Content-Type: application/json",
|
||||
"Accept: application/json",
|
||||
})
|
||||
Client testClassname(Client body);
|
||||
Client testClassname(Client client);
|
||||
}
|
||||
|
||||
@@ -20,14 +20,14 @@ public interface PetApi extends ApiClient.Api {
|
||||
/**
|
||||
* Add a new pet to the store
|
||||
*
|
||||
* @param body Pet object that needs to be added to the store (required)
|
||||
* @param pet Pet object that needs to be added to the store (required)
|
||||
*/
|
||||
@RequestLine("POST /pet")
|
||||
@Headers({
|
||||
"Content-Type: application/json",
|
||||
"Accept: application/json",
|
||||
})
|
||||
void addPet(Pet body);
|
||||
void addPet(Pet pet);
|
||||
|
||||
/**
|
||||
* Deletes a pet
|
||||
@@ -145,14 +145,14 @@ public interface PetApi extends ApiClient.Api {
|
||||
/**
|
||||
* Update an existing pet
|
||||
*
|
||||
* @param body Pet object that needs to be added to the store (required)
|
||||
* @param pet Pet object that needs to be added to the store (required)
|
||||
*/
|
||||
@RequestLine("PUT /pet")
|
||||
@Headers({
|
||||
"Content-Type: application/json",
|
||||
"Accept: application/json",
|
||||
})
|
||||
void updatePet(Pet body);
|
||||
void updatePet(Pet pet);
|
||||
|
||||
/**
|
||||
* Updates a pet in the store with form data
|
||||
|
||||
@@ -52,13 +52,13 @@ public interface StoreApi extends ApiClient.Api {
|
||||
/**
|
||||
* Place an order for a pet
|
||||
*
|
||||
* @param body order placed for purchasing the pet (required)
|
||||
* @param order order placed for purchasing the pet (required)
|
||||
* @return Order
|
||||
*/
|
||||
@RequestLine("POST /store/order")
|
||||
@Headers({
|
||||
"Content-Type: application/json",
|
||||
"Content-Type: */*",
|
||||
"Accept: application/json",
|
||||
})
|
||||
Order placeOrder(Order body);
|
||||
Order placeOrder(Order order);
|
||||
}
|
||||
|
||||
@@ -18,38 +18,38 @@ public interface UserApi extends ApiClient.Api {
|
||||
/**
|
||||
* Create user
|
||||
* This can only be done by the logged in user.
|
||||
* @param body Created user object (required)
|
||||
* @param user Created user object (required)
|
||||
*/
|
||||
@RequestLine("POST /user")
|
||||
@Headers({
|
||||
"Content-Type: application/json",
|
||||
"Content-Type: */*",
|
||||
"Accept: application/json",
|
||||
})
|
||||
void createUser(User body);
|
||||
void createUser(User user);
|
||||
|
||||
/**
|
||||
* Creates list of users with given input array
|
||||
*
|
||||
* @param body List of user object (required)
|
||||
* @param user List of user object (required)
|
||||
*/
|
||||
@RequestLine("POST /user/createWithArray")
|
||||
@Headers({
|
||||
"Content-Type: application/json",
|
||||
"Content-Type: */*",
|
||||
"Accept: application/json",
|
||||
})
|
||||
void createUsersWithArrayInput(List<User> body);
|
||||
void createUsersWithArrayInput(List<User> user);
|
||||
|
||||
/**
|
||||
* Creates list of users with given input array
|
||||
*
|
||||
* @param body List of user object (required)
|
||||
* @param user List of user object (required)
|
||||
*/
|
||||
@RequestLine("POST /user/createWithList")
|
||||
@Headers({
|
||||
"Content-Type: application/json",
|
||||
"Content-Type: */*",
|
||||
"Accept: application/json",
|
||||
})
|
||||
void createUsersWithListInput(List<User> body);
|
||||
void createUsersWithListInput(List<User> user);
|
||||
|
||||
/**
|
||||
* Delete user
|
||||
@@ -138,12 +138,12 @@ public interface UserApi extends ApiClient.Api {
|
||||
* Updated user
|
||||
* This can only be done by the logged in user.
|
||||
* @param username name that need to be deleted (required)
|
||||
* @param body Updated user object (required)
|
||||
* @param user Updated user object (required)
|
||||
*/
|
||||
@RequestLine("PUT /user/{username}")
|
||||
@Headers({
|
||||
"Content-Type: application/json",
|
||||
"Content-Type: */*",
|
||||
"Accept: application/json",
|
||||
})
|
||||
void updateUser(@Param("username") String username, User body);
|
||||
void updateUser(@Param("username") String username, User user);
|
||||
}
|
||||
|
||||
@@ -67,6 +67,46 @@ public class EnumTest {
|
||||
@JsonProperty("enum_string")
|
||||
private EnumStringEnum enumString = null;
|
||||
|
||||
/**
|
||||
* Gets or Sets enumStringRequired
|
||||
*/
|
||||
public enum EnumStringRequiredEnum {
|
||||
UPPER("UPPER"),
|
||||
|
||||
LOWER("lower"),
|
||||
|
||||
EMPTY("");
|
||||
|
||||
private String value;
|
||||
|
||||
EnumStringRequiredEnum(String value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
@JsonValue
|
||||
public String getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return String.valueOf(value);
|
||||
}
|
||||
|
||||
@JsonCreator
|
||||
public static EnumStringRequiredEnum fromValue(String text) {
|
||||
for (EnumStringRequiredEnum b : EnumStringRequiredEnum.values()) {
|
||||
if (String.valueOf(b.value).equals(text)) {
|
||||
return b;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@JsonProperty("enum_string_required")
|
||||
private EnumStringRequiredEnum enumStringRequired = null;
|
||||
|
||||
/**
|
||||
* Gets or Sets enumInteger
|
||||
*/
|
||||
@@ -164,6 +204,24 @@ public class EnumTest {
|
||||
this.enumString = enumString;
|
||||
}
|
||||
|
||||
public EnumTest enumStringRequired(EnumStringRequiredEnum enumStringRequired) {
|
||||
this.enumStringRequired = enumStringRequired;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get enumStringRequired
|
||||
* @return enumStringRequired
|
||||
**/
|
||||
@ApiModelProperty(required = true, value = "")
|
||||
public EnumStringRequiredEnum getEnumStringRequired() {
|
||||
return enumStringRequired;
|
||||
}
|
||||
|
||||
public void setEnumStringRequired(EnumStringRequiredEnum enumStringRequired) {
|
||||
this.enumStringRequired = enumStringRequired;
|
||||
}
|
||||
|
||||
public EnumTest enumInteger(EnumIntegerEnum enumInteger) {
|
||||
this.enumInteger = enumInteger;
|
||||
return this;
|
||||
@@ -229,6 +287,7 @@ public class EnumTest {
|
||||
}
|
||||
EnumTest enumTest = (EnumTest) o;
|
||||
return Objects.equals(this.enumString, enumTest.enumString) &&
|
||||
Objects.equals(this.enumStringRequired, enumTest.enumStringRequired) &&
|
||||
Objects.equals(this.enumInteger, enumTest.enumInteger) &&
|
||||
Objects.equals(this.enumNumber, enumTest.enumNumber) &&
|
||||
Objects.equals(this.outerEnum, enumTest.outerEnum);
|
||||
@@ -236,7 +295,7 @@ public class EnumTest {
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(enumString, enumInteger, enumNumber, outerEnum);
|
||||
return Objects.hash(enumString, enumStringRequired, enumInteger, enumNumber, outerEnum);
|
||||
}
|
||||
|
||||
|
||||
@@ -246,6 +305,7 @@ public class EnumTest {
|
||||
sb.append("class EnumTest {\n");
|
||||
|
||||
sb.append(" enumString: ").append(toIndentedString(enumString)).append("\n");
|
||||
sb.append(" enumStringRequired: ").append(toIndentedString(enumStringRequired)).append("\n");
|
||||
sb.append(" enumInteger: ").append(toIndentedString(enumInteger)).append("\n");
|
||||
sb.append(" enumNumber: ").append(toIndentedString(enumNumber)).append("\n");
|
||||
sb.append(" outerEnum: ").append(toIndentedString(outerEnum)).append("\n");
|
||||
|
||||
@@ -20,6 +20,7 @@ import com.fasterxml.jackson.annotation.JsonCreator;
|
||||
import com.fasterxml.jackson.annotation.JsonValue;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import java.io.File;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.UUID;
|
||||
import org.threeten.bp.LocalDate;
|
||||
@@ -55,7 +56,7 @@ public class FormatTest {
|
||||
private byte[] _byte = null;
|
||||
|
||||
@JsonProperty("binary")
|
||||
private byte[] binary = null;
|
||||
private File binary = null;
|
||||
|
||||
@JsonProperty("date")
|
||||
private LocalDate date = null;
|
||||
@@ -223,7 +224,7 @@ public class FormatTest {
|
||||
this._byte = _byte;
|
||||
}
|
||||
|
||||
public FormatTest binary(byte[] binary) {
|
||||
public FormatTest binary(File binary) {
|
||||
this.binary = binary;
|
||||
return this;
|
||||
}
|
||||
@@ -233,11 +234,11 @@ public class FormatTest {
|
||||
* @return binary
|
||||
**/
|
||||
@ApiModelProperty(value = "")
|
||||
public byte[] getBinary() {
|
||||
public File getBinary() {
|
||||
return binary;
|
||||
}
|
||||
|
||||
public void setBinary(byte[] binary) {
|
||||
public void setBinary(File binary) {
|
||||
this.binary = binary;
|
||||
}
|
||||
|
||||
@@ -331,7 +332,7 @@ public class FormatTest {
|
||||
Objects.equals(this._double, formatTest._double) &&
|
||||
Objects.equals(this.string, formatTest.string) &&
|
||||
Arrays.equals(this._byte, formatTest._byte) &&
|
||||
Arrays.equals(this.binary, formatTest.binary) &&
|
||||
Objects.equals(this.binary, formatTest.binary) &&
|
||||
Objects.equals(this.date, formatTest.date) &&
|
||||
Objects.equals(this.dateTime, formatTest.dateTime) &&
|
||||
Objects.equals(this.uuid, formatTest.uuid) &&
|
||||
@@ -340,7 +341,7 @@ public class FormatTest {
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(integer, int32, int64, number, _float, _double, string, Arrays.hashCode(_byte), Arrays.hashCode(binary), date, dateTime, uuid, password);
|
||||
return Objects.hash(integer, int32, int64, number, _float, _double, string, Arrays.hashCode(_byte), binary, date, dateTime, uuid, password);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -78,9 +78,9 @@ public class Model200Response {
|
||||
if (o == null || getClass() != o.getClass()) {
|
||||
return false;
|
||||
}
|
||||
Model200Response _200Response = (Model200Response) o;
|
||||
return Objects.equals(this.name, _200Response.name) &&
|
||||
Objects.equals(this.propertyClass, _200Response.propertyClass);
|
||||
Model200Response _200response = (Model200Response) o;
|
||||
return Objects.equals(this.name, _200response.name) &&
|
||||
Objects.equals(this.propertyClass, _200response.propertyClass);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -37,7 +37,7 @@ public class Name {
|
||||
private String property = null;
|
||||
|
||||
@JsonProperty("123Number")
|
||||
private Integer _123Number = null;
|
||||
private Integer _123number = null;
|
||||
|
||||
public Name name(Integer name) {
|
||||
this.name = name;
|
||||
@@ -85,12 +85,12 @@ public class Name {
|
||||
}
|
||||
|
||||
/**
|
||||
* Get _123Number
|
||||
* @return _123Number
|
||||
* Get _123number
|
||||
* @return _123number
|
||||
**/
|
||||
@ApiModelProperty(value = "")
|
||||
public Integer get123Number() {
|
||||
return _123Number;
|
||||
public Integer get123number() {
|
||||
return _123number;
|
||||
}
|
||||
|
||||
|
||||
@@ -106,12 +106,12 @@ public class Name {
|
||||
return Objects.equals(this.name, name.name) &&
|
||||
Objects.equals(this.snakeCase, name.snakeCase) &&
|
||||
Objects.equals(this.property, name.property) &&
|
||||
Objects.equals(this._123Number, name._123Number);
|
||||
Objects.equals(this._123number, name._123number);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(name, snakeCase, property, _123Number);
|
||||
return Objects.hash(name, snakeCase, property, _123number);
|
||||
}
|
||||
|
||||
|
||||
@@ -123,7 +123,7 @@ public class Name {
|
||||
sb.append(" name: ").append(toIndentedString(name)).append("\n");
|
||||
sb.append(" snakeCase: ").append(toIndentedString(snakeCase)).append("\n");
|
||||
sb.append(" property: ").append(toIndentedString(property)).append("\n");
|
||||
sb.append(" _123Number: ").append(toIndentedString(_123Number)).append("\n");
|
||||
sb.append(" _123number: ").append(toIndentedString(_123number)).append("\n");
|
||||
sb.append("}");
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
@@ -0,0 +1,63 @@
|
||||
/*
|
||||
* 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: apiteam@swagger.io
|
||||
*
|
||||
* 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.model;
|
||||
|
||||
import java.util.Objects;
|
||||
import java.util.Arrays;
|
||||
|
||||
/**
|
||||
* OuterBoolean
|
||||
*/
|
||||
|
||||
public class OuterBoolean {
|
||||
|
||||
@Override
|
||||
public boolean equals(java.lang.Object o) {
|
||||
if (this == o) {
|
||||
return true;
|
||||
}
|
||||
if (o == null || getClass() != o.getClass()) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append("class OuterBoolean {\n");
|
||||
|
||||
sb.append("}");
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert the given object to string with each line indented by 4 spaces
|
||||
* (except the first line).
|
||||
*/
|
||||
private String toIndentedString(java.lang.Object o) {
|
||||
if (o == null) {
|
||||
return "null";
|
||||
}
|
||||
return o.toString().replace("\n", "\n ");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,63 @@
|
||||
/*
|
||||
* 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: apiteam@swagger.io
|
||||
*
|
||||
* 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.model;
|
||||
|
||||
import java.util.Objects;
|
||||
import java.util.Arrays;
|
||||
|
||||
/**
|
||||
* OuterNumber
|
||||
*/
|
||||
|
||||
public class OuterNumber {
|
||||
|
||||
@Override
|
||||
public boolean equals(java.lang.Object o) {
|
||||
if (this == o) {
|
||||
return true;
|
||||
}
|
||||
if (o == null || getClass() != o.getClass()) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append("class OuterNumber {\n");
|
||||
|
||||
sb.append("}");
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert the given object to string with each line indented by 4 spaces
|
||||
* (except the first line).
|
||||
*/
|
||||
private String toIndentedString(java.lang.Object o) {
|
||||
if (o == null) {
|
||||
return "null";
|
||||
}
|
||||
return o.toString().replace("\n", "\n ");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,63 @@
|
||||
/*
|
||||
* 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: apiteam@swagger.io
|
||||
*
|
||||
* 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.model;
|
||||
|
||||
import java.util.Objects;
|
||||
import java.util.Arrays;
|
||||
|
||||
/**
|
||||
* OuterString
|
||||
*/
|
||||
|
||||
public class OuterString {
|
||||
|
||||
@Override
|
||||
public boolean equals(java.lang.Object o) {
|
||||
if (this == o) {
|
||||
return true;
|
||||
}
|
||||
if (o == null || getClass() != o.getClass()) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append("class OuterString {\n");
|
||||
|
||||
sb.append("}");
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert the given object to string with each line indented by 4 spaces
|
||||
* (except the first line).
|
||||
*/
|
||||
private String toIndentedString(java.lang.Object o) {
|
||||
if (o == null) {
|
||||
return "null";
|
||||
}
|
||||
return o.toString().replace("\n", "\n ");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -27,24 +27,24 @@ import io.swagger.annotations.ApiModelProperty;
|
||||
|
||||
public class SpecialModelName {
|
||||
@JsonProperty("$special[property.name]")
|
||||
private Long specialPropertyName = null;
|
||||
private Long $specialPropertyName = null;
|
||||
|
||||
public SpecialModelName specialPropertyName(Long specialPropertyName) {
|
||||
this.specialPropertyName = specialPropertyName;
|
||||
public SpecialModelName $specialPropertyName(Long $specialPropertyName) {
|
||||
this.$specialPropertyName = $specialPropertyName;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get specialPropertyName
|
||||
* @return specialPropertyName
|
||||
* Get $specialPropertyName
|
||||
* @return $specialPropertyName
|
||||
**/
|
||||
@ApiModelProperty(value = "")
|
||||
public Long getSpecialPropertyName() {
|
||||
return specialPropertyName;
|
||||
public Long get$SpecialPropertyName() {
|
||||
return $specialPropertyName;
|
||||
}
|
||||
|
||||
public void setSpecialPropertyName(Long specialPropertyName) {
|
||||
this.specialPropertyName = specialPropertyName;
|
||||
public void set$SpecialPropertyName(Long $specialPropertyName) {
|
||||
this.$specialPropertyName = $specialPropertyName;
|
||||
}
|
||||
|
||||
|
||||
@@ -56,13 +56,13 @@ public class SpecialModelName {
|
||||
if (o == null || getClass() != o.getClass()) {
|
||||
return false;
|
||||
}
|
||||
SpecialModelName specialModelName = (SpecialModelName) o;
|
||||
return Objects.equals(this.specialPropertyName, specialModelName.specialPropertyName);
|
||||
SpecialModelName $specialModelName = (SpecialModelName) o;
|
||||
return Objects.equals(this.$specialPropertyName, $specialModelName.$specialPropertyName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(specialPropertyName);
|
||||
return Objects.hash($specialPropertyName);
|
||||
}
|
||||
|
||||
|
||||
@@ -71,7 +71,7 @@ public class SpecialModelName {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append("class SpecialModelName {\n");
|
||||
|
||||
sb.append(" specialPropertyName: ").append(toIndentedString(specialPropertyName)).append("\n");
|
||||
sb.append(" $specialPropertyName: ").append(toIndentedString($specialPropertyName)).append("\n");
|
||||
sb.append("}");
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
@@ -1,17 +0,0 @@
|
||||
package io.swagger;
|
||||
|
||||
import java.util.Random;
|
||||
import java.util.concurrent.atomic.AtomicLong;
|
||||
|
||||
public class TestUtils {
|
||||
private static final AtomicLong atomicId = createAtomicId();
|
||||
|
||||
public static long nextId() {
|
||||
return atomicId.getAndIncrement();
|
||||
}
|
||||
|
||||
private static AtomicLong createAtomicId() {
|
||||
int baseId = new Random(System.currentTimeMillis()).nextInt(1000000) + 20000;
|
||||
return new AtomicLong((long) baseId);
|
||||
}
|
||||
}
|
||||
@@ -1,32 +0,0 @@
|
||||
package io.swagger.client;
|
||||
|
||||
import org.junit.*;
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
public class StringUtilTest {
|
||||
@Test
|
||||
public void testContainsIgnoreCase() {
|
||||
assertTrue(StringUtil.containsIgnoreCase(new String[]{"abc"}, "abc"));
|
||||
assertTrue(StringUtil.containsIgnoreCase(new String[]{"abc"}, "ABC"));
|
||||
assertTrue(StringUtil.containsIgnoreCase(new String[]{"ABC"}, "abc"));
|
||||
assertTrue(StringUtil.containsIgnoreCase(new String[]{null, "abc"}, "ABC"));
|
||||
assertTrue(StringUtil.containsIgnoreCase(new String[]{null, "abc"}, null));
|
||||
|
||||
assertFalse(StringUtil.containsIgnoreCase(new String[]{"abc"}, "def"));
|
||||
assertFalse(StringUtil.containsIgnoreCase(new String[]{}, "ABC"));
|
||||
assertFalse(StringUtil.containsIgnoreCase(new String[]{}, null));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testJoin() {
|
||||
String[] array = {"aa", "bb", "cc"};
|
||||
assertEquals("aa,bb,cc", StringUtil.join(array, ","));
|
||||
assertEquals("aa, bb, cc", StringUtil.join(array, ", "));
|
||||
assertEquals("aabbcc", StringUtil.join(array, ""));
|
||||
assertEquals("aa bb cc", StringUtil.join(array, " "));
|
||||
assertEquals("aa\nbb\ncc", StringUtil.join(array, "\n"));
|
||||
|
||||
assertEquals("", StringUtil.join(new String[]{}, ","));
|
||||
assertEquals("abc", StringUtil.join(new String[]{"abc"}, ","));
|
||||
}
|
||||
}
|
||||
@@ -30,8 +30,8 @@ public class AnotherFakeApiTest {
|
||||
*/
|
||||
@Test
|
||||
public void testSpecialTagsTest() {
|
||||
Client body = null;
|
||||
// Client response = api.testSpecialTags(body);
|
||||
Client client = null;
|
||||
// Client response = api.testSpecialTags(client);
|
||||
|
||||
// TODO: test validations
|
||||
}
|
||||
|
||||
@@ -3,9 +3,11 @@ package io.swagger.client.api;
|
||||
import io.swagger.client.ApiClient;
|
||||
import java.math.BigDecimal;
|
||||
import io.swagger.client.model.Client;
|
||||
import java.io.File;
|
||||
import org.threeten.bp.LocalDate;
|
||||
import org.threeten.bp.OffsetDateTime;
|
||||
import io.swagger.client.model.OuterComposite;
|
||||
import io.swagger.client.model.User;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
@@ -34,8 +36,8 @@ public class FakeApiTest {
|
||||
*/
|
||||
@Test
|
||||
public void fakeOuterBooleanSerializeTest() {
|
||||
Boolean body = null;
|
||||
// Boolean response = api.fakeOuterBooleanSerialize(body);
|
||||
Boolean booleanPostBody = null;
|
||||
// Boolean response = api.fakeOuterBooleanSerialize(booleanPostBody);
|
||||
|
||||
// TODO: test validations
|
||||
}
|
||||
@@ -48,8 +50,8 @@ public class FakeApiTest {
|
||||
*/
|
||||
@Test
|
||||
public void fakeOuterCompositeSerializeTest() {
|
||||
OuterComposite body = null;
|
||||
// OuterComposite response = api.fakeOuterCompositeSerialize(body);
|
||||
OuterComposite outerComposite = null;
|
||||
// OuterComposite response = api.fakeOuterCompositeSerialize(outerComposite);
|
||||
|
||||
// TODO: test validations
|
||||
}
|
||||
@@ -83,6 +85,38 @@ public class FakeApiTest {
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
*
|
||||
*/
|
||||
@Test
|
||||
public void testBodyWithQueryParamsTest() {
|
||||
String query = null;
|
||||
User user = null;
|
||||
// api.testBodyWithQueryParams(query, user);
|
||||
|
||||
// TODO: test validations
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
* This tests the overload of the method that uses a Map for query parameters instead of
|
||||
* listing them out individually.
|
||||
*/
|
||||
@Test
|
||||
public void testBodyWithQueryParamsTestQueryMap() {
|
||||
User user = null;
|
||||
FakeApi.TestBodyWithQueryParamsQueryParams queryParams = new FakeApi.TestBodyWithQueryParamsQueryParams()
|
||||
.query(null);
|
||||
// api.testBodyWithQueryParams(user, queryParams);
|
||||
|
||||
// TODO: test validations
|
||||
}
|
||||
|
||||
/**
|
||||
* To test \"client\" model
|
||||
*
|
||||
@@ -90,8 +124,8 @@ public class FakeApiTest {
|
||||
*/
|
||||
@Test
|
||||
public void testClientModelTest() {
|
||||
Client body = null;
|
||||
// Client response = api.testClientModel(body);
|
||||
Client client = null;
|
||||
// Client response = api.testClientModel(client);
|
||||
|
||||
// TODO: test validations
|
||||
}
|
||||
@@ -113,7 +147,7 @@ public class FakeApiTest {
|
||||
Long int64 = null;
|
||||
Float _float = null;
|
||||
String string = null;
|
||||
byte[] binary = null;
|
||||
File binary = null;
|
||||
LocalDate date = null;
|
||||
OffsetDateTime dateTime = null;
|
||||
String password = null;
|
||||
@@ -131,15 +165,15 @@ public class FakeApiTest {
|
||||
*/
|
||||
@Test
|
||||
public void testEnumParametersTest() {
|
||||
List<String> enumFormStringArray = null;
|
||||
String enumFormString = null;
|
||||
List<String> enumHeaderStringArray = null;
|
||||
String enumHeaderString = null;
|
||||
List<String> enumQueryStringArray = null;
|
||||
String enumQueryString = null;
|
||||
Integer enumQueryInteger = null;
|
||||
Double enumQueryDouble = null;
|
||||
// api.testEnumParameters(enumFormStringArray, enumFormString, enumHeaderStringArray, enumHeaderString, enumQueryStringArray, enumQueryString, enumQueryInteger, enumQueryDouble);
|
||||
List<String> enumFormStringArray = null;
|
||||
String enumFormString = null;
|
||||
// api.testEnumParameters(enumHeaderStringArray, enumHeaderString, enumQueryStringArray, enumQueryString, enumQueryInteger, enumQueryDouble, enumFormStringArray, enumFormString);
|
||||
|
||||
// TODO: test validations
|
||||
}
|
||||
@@ -154,18 +188,47 @@ public class FakeApiTest {
|
||||
*/
|
||||
@Test
|
||||
public void testEnumParametersTestQueryMap() {
|
||||
List<String> enumFormStringArray = null;
|
||||
String enumFormString = null;
|
||||
List<String> enumHeaderStringArray = null;
|
||||
String enumHeaderString = null;
|
||||
Double enumQueryDouble = null;
|
||||
List<String> enumFormStringArray = null;
|
||||
String enumFormString = null;
|
||||
FakeApi.TestEnumParametersQueryParams queryParams = new FakeApi.TestEnumParametersQueryParams()
|
||||
.enumQueryStringArray(null)
|
||||
.enumQueryString(null)
|
||||
.enumQueryInteger(null);
|
||||
// api.testEnumParameters(enumFormStringArray, enumFormString, enumHeaderStringArray, enumHeaderString, enumQueryDouble, queryParams);
|
||||
.enumQueryInteger(null)
|
||||
.enumQueryDouble(null);
|
||||
// api.testEnumParameters(enumHeaderStringArray, enumHeaderString, enumFormStringArray, enumFormString, queryParams);
|
||||
|
||||
// TODO: test validations
|
||||
}
|
||||
|
||||
/**
|
||||
* test inline additionalProperties
|
||||
*
|
||||
*
|
||||
*/
|
||||
@Test
|
||||
public void testInlineAdditionalPropertiesTest() {
|
||||
String requestBody = null;
|
||||
// api.testInlineAdditionalProperties(requestBody);
|
||||
|
||||
// TODO: test validations
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* test json serialization of form data
|
||||
*
|
||||
*
|
||||
*/
|
||||
@Test
|
||||
public void testJsonFormDataTest() {
|
||||
String param = null;
|
||||
String param2 = null;
|
||||
// api.testJsonFormData(param, param2);
|
||||
|
||||
// TODO: test validations
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -26,14 +26,15 @@ public class FakeClassnameTags123ApiTest {
|
||||
/**
|
||||
* To test class name in snake case
|
||||
*
|
||||
*
|
||||
* To test class name in snake case
|
||||
*/
|
||||
@Test
|
||||
public void testClassnameTest() {
|
||||
Client body = null;
|
||||
// Client response = api.testClassname(body);
|
||||
Client client = null;
|
||||
// Client response = api.testClassname(client);
|
||||
|
||||
// TODO: test validations
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -1,251 +1,177 @@
|
||||
package io.swagger.client.api;
|
||||
|
||||
import io.swagger.TestUtils;
|
||||
|
||||
import io.swagger.client.ApiClient;
|
||||
import io.swagger.client.model.*;
|
||||
|
||||
import java.io.BufferedWriter;
|
||||
import java.io.File;
|
||||
import java.io.FileWriter;
|
||||
import io.swagger.client.model.ModelApiResponse;
|
||||
import io.swagger.client.model.Pet;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import okhttp3.mockwebserver.MockResponse;
|
||||
import okhttp3.mockwebserver.MockWebServer;
|
||||
import okhttp3.mockwebserver.RecordedRequest;
|
||||
import org.junit.*;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
/**
|
||||
* API tests for PetApi
|
||||
*/
|
||||
public class PetApiTest {
|
||||
ApiClient apiClient;
|
||||
PetApi api;
|
||||
MockWebServer localServer;
|
||||
ApiClient localClient;
|
||||
|
||||
private PetApi api;
|
||||
|
||||
@Before
|
||||
public void setup() {
|
||||
apiClient = new ApiClient();
|
||||
api = apiClient.buildClient(PetApi.class);
|
||||
localServer = new MockWebServer();
|
||||
localClient = new ApiClient();
|
||||
api = new ApiClient().buildClient(PetApi.class);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Add a new pet to the store
|
||||
*
|
||||
*
|
||||
*/
|
||||
@Test
|
||||
public void testApiClient() {
|
||||
// the default api client is used
|
||||
assertEquals("http://petstore.swagger.io:80/v2", apiClient.getBasePath());
|
||||
public void addPetTest() {
|
||||
Pet pet = null;
|
||||
// api.addPet(pet);
|
||||
|
||||
ApiClient newClient = new ApiClient();
|
||||
newClient.setBasePath("http://example.com");
|
||||
|
||||
assertEquals("http://example.com", newClient.getBasePath());
|
||||
// TODO: test validations
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Deletes a pet
|
||||
*
|
||||
*
|
||||
*/
|
||||
@Test
|
||||
public void testCreateAndGetPet() throws Exception {
|
||||
Pet pet = createRandomPet();
|
||||
api.addPet(pet);
|
||||
public void deletePetTest() {
|
||||
Long petId = null;
|
||||
String apiKey = null;
|
||||
// api.deletePet(petId, apiKey);
|
||||
|
||||
Pet fetched = api.getPetById(pet.getId());
|
||||
assertNotNull(fetched);
|
||||
assertEquals(pet.getId(), fetched.getId());
|
||||
assertNotNull(fetched.getCategory());
|
||||
assertEquals(fetched.getCategory().getName(), pet.getCategory().getName());
|
||||
// TODO: test validations
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Finds Pets by status
|
||||
*
|
||||
* Multiple status values can be provided with comma separated strings
|
||||
*/
|
||||
@Test
|
||||
public void testUpdatePet() throws Exception {
|
||||
Pet pet = createRandomPet();
|
||||
pet.setName("programmer");
|
||||
public void findPetsByStatusTest() {
|
||||
List<String> status = null;
|
||||
// List<Pet> response = api.findPetsByStatus(status);
|
||||
|
||||
api.updatePet(pet);
|
||||
|
||||
Pet fetched = api.getPetById(pet.getId());
|
||||
assertNotNull(fetched);
|
||||
assertEquals(pet.getId(), fetched.getId());
|
||||
assertNotNull(fetched.getCategory());
|
||||
assertEquals(fetched.getCategory().getName(), pet.getCategory().getName());
|
||||
// TODO: test validations
|
||||
}
|
||||
|
||||
/**
|
||||
* Finds Pets by status
|
||||
*
|
||||
* Multiple status values can be provided with comma separated strings
|
||||
*
|
||||
* This tests the overload of the method that uses a Map for query parameters instead of
|
||||
* listing them out individually.
|
||||
*/
|
||||
@Test
|
||||
public void testFindPetsByStatus() throws Exception {
|
||||
Pet pet = createRandomPet();
|
||||
pet.setName("programmer");
|
||||
pet.setStatus(Pet.StatusEnum.AVAILABLE);
|
||||
|
||||
api.updatePet(pet);
|
||||
|
||||
List<Pet> pets = api.findPetsByStatus(Collections.singletonList("available"));
|
||||
assertNotNull(pets);
|
||||
|
||||
boolean found = false;
|
||||
for (Pet fetched : pets) {
|
||||
if (fetched.getId().equals(pet.getId())) {
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
assertTrue(found);
|
||||
|
||||
public void findPetsByStatusTestQueryMap() {
|
||||
PetApi.FindPetsByStatusQueryParams queryParams = new PetApi.FindPetsByStatusQueryParams()
|
||||
.status(Arrays.asList(new String[]{"available"}));
|
||||
pets = api.findPetsByStatus(queryParams);
|
||||
assertNotNull(pets);
|
||||
.status(null);
|
||||
// List<Pet> response = api.findPetsByStatus(queryParams);
|
||||
|
||||
found = false;
|
||||
for (Pet fetched : pets) {
|
||||
if (fetched.getId().equals(pet.getId())) {
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
// TODO: test validations
|
||||
}
|
||||
|
||||
/**
|
||||
* Finds Pets by tags
|
||||
*
|
||||
* Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.
|
||||
*/
|
||||
@Test
|
||||
public void findPetsByTagsTest() {
|
||||
List<String> tags = null;
|
||||
// List<Pet> response = api.findPetsByTags(tags);
|
||||
|
||||
assertTrue(found);
|
||||
// TODO: test validations
|
||||
}
|
||||
|
||||
/**
|
||||
* Finds Pets by tags
|
||||
*
|
||||
* Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.
|
||||
*
|
||||
* This tests the overload of the method that uses a Map for query parameters instead of
|
||||
* listing them out individually.
|
||||
*/
|
||||
@Test
|
||||
public void testFindPetsByTags() throws Exception {
|
||||
Pet pet = createRandomPet();
|
||||
pet.setName("monster");
|
||||
pet.setStatus(Pet.StatusEnum.AVAILABLE);
|
||||
|
||||
List<Tag> tags = new ArrayList<>();
|
||||
Tag tag1 = new Tag();
|
||||
tag1.setName("friendly");
|
||||
tags.add(tag1);
|
||||
pet.setTags(tags);
|
||||
|
||||
api.updatePet(pet);
|
||||
|
||||
List<Pet> pets = api.findPetsByTags(Collections.singletonList("friendly"));
|
||||
assertNotNull(pets);
|
||||
|
||||
boolean found = false;
|
||||
for (Pet fetched : pets) {
|
||||
if (fetched.getId().equals(pet.getId())) {
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
assertTrue(found);
|
||||
|
||||
public void findPetsByTagsTestQueryMap() {
|
||||
PetApi.FindPetsByTagsQueryParams queryParams = new PetApi.FindPetsByTagsQueryParams()
|
||||
.tags(Arrays.asList(new String[]{"friendly"}));
|
||||
pets = api.findPetsByTags(queryParams);
|
||||
assertNotNull(pets);
|
||||
.tags(null);
|
||||
// List<Pet> response = api.findPetsByTags(queryParams);
|
||||
|
||||
found = false;
|
||||
for (Pet fetched : pets) {
|
||||
if (fetched.getId().equals(pet.getId())) {
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
assertTrue(found);
|
||||
// TODO: test validations
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Find pet by ID
|
||||
*
|
||||
* Returns a single pet
|
||||
*/
|
||||
@Test
|
||||
public void testUpdatePetWithForm() throws Exception {
|
||||
Pet pet = createRandomPet();
|
||||
pet.setName("frank");
|
||||
api.addPet(pet);
|
||||
public void getPetByIdTest() {
|
||||
Long petId = null;
|
||||
// Pet response = api.getPetById(petId);
|
||||
|
||||
Pet fetched = api.getPetById(pet.getId());
|
||||
|
||||
api.updatePetWithForm(fetched.getId(), "furt", null);
|
||||
Pet updated = api.getPetById(fetched.getId());
|
||||
|
||||
assertEquals(updated.getName(), "furt");
|
||||
// TODO: test validations
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Update an existing pet
|
||||
*
|
||||
*
|
||||
*/
|
||||
@Test
|
||||
public void testDeletePet() throws Exception {
|
||||
Pet pet = createRandomPet();
|
||||
api.addPet(pet);
|
||||
public void updatePetTest() {
|
||||
Pet pet = null;
|
||||
// api.updatePet(pet);
|
||||
|
||||
Pet fetched = api.getPetById(pet.getId());
|
||||
api.deletePet(fetched.getId(), null);
|
||||
|
||||
try {
|
||||
api.getPetById(fetched.getId());
|
||||
fail("expected an error");
|
||||
} catch (Exception e) {
|
||||
// assertEquals(404, e.getCode());
|
||||
}
|
||||
// TODO: test validations
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Updates a pet in the store with form data
|
||||
*
|
||||
*
|
||||
*/
|
||||
@Test
|
||||
public void testUploadFile() throws Exception {
|
||||
Pet pet = createRandomPet();
|
||||
api.addPet(pet);
|
||||
public void updatePetWithFormTest() {
|
||||
Long petId = null;
|
||||
String name = null;
|
||||
String status = null;
|
||||
// api.updatePetWithForm(petId, name, status);
|
||||
|
||||
File file = new File("hello.txt");
|
||||
BufferedWriter writer = new BufferedWriter(new FileWriter(file));
|
||||
writer.write("Hello world!");
|
||||
writer.close();
|
||||
|
||||
api.uploadFile(pet.getId(), "a test file", new File(file.getAbsolutePath()));
|
||||
// TODO: test validations
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* uploads an image
|
||||
*
|
||||
*
|
||||
*/
|
||||
@Test
|
||||
public void testEqualsAndHashCode() {
|
||||
Pet pet1 = new Pet();
|
||||
Pet pet2 = new Pet();
|
||||
assertTrue(pet1.equals(pet2));
|
||||
assertTrue(pet2.equals(pet1));
|
||||
assertTrue(pet1.hashCode() == pet2.hashCode());
|
||||
assertTrue(pet1.equals(pet1));
|
||||
assertTrue(pet1.hashCode() == pet1.hashCode());
|
||||
public void uploadFileTest() {
|
||||
Long petId = null;
|
||||
String additionalMetadata = null;
|
||||
File file = null;
|
||||
// ModelApiResponse response = api.uploadFile(petId, additionalMetadata, file);
|
||||
|
||||
pet2.setName("really-happy");
|
||||
pet2.setPhotoUrls(Arrays.asList("http://foo.bar.com/1", "http://foo.bar.com/2"));
|
||||
assertFalse(pet1.equals(pet2));
|
||||
assertFalse(pet2.equals(pet1));
|
||||
assertFalse(pet1.hashCode() == (pet2.hashCode()));
|
||||
assertTrue(pet2.equals(pet2));
|
||||
assertTrue(pet2.hashCode() == pet2.hashCode());
|
||||
|
||||
pet1.setName("really-happy");
|
||||
pet1.setPhotoUrls(Arrays.asList("http://foo.bar.com/1", "http://foo.bar.com/2"));
|
||||
assertTrue(pet1.equals(pet2));
|
||||
assertTrue(pet2.equals(pet1));
|
||||
assertTrue(pet1.hashCode() == pet2.hashCode());
|
||||
assertTrue(pet1.equals(pet1));
|
||||
assertTrue(pet1.hashCode() == pet1.hashCode());
|
||||
// TODO: test validations
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCSVDelimitedArray() throws Exception {
|
||||
localServer.enqueue(new MockResponse().setBody("[{\"id\":5,\"name\":\"rocky\"}]"));
|
||||
localServer.start();
|
||||
PetApi api = localClient.setBasePath(localServer.url("/").toString()).buildClient(PetApi.class);
|
||||
PetApi.FindPetsByTagsQueryParams queryParams = new PetApi.FindPetsByTagsQueryParams()
|
||||
.tags(Arrays.asList("friendly","energetic"));
|
||||
List<Pet> pets = api.findPetsByTags(queryParams);
|
||||
assertNotNull(pets);
|
||||
RecordedRequest request = localServer.takeRequest();
|
||||
assertThat(request.getPath()).contains("tags=friendly,energetic");
|
||||
localServer.shutdown();
|
||||
}
|
||||
|
||||
private Pet createRandomPet() {
|
||||
Pet pet = new Pet();
|
||||
pet.setId(TestUtils.nextId());
|
||||
pet.setName("gorilla");
|
||||
|
||||
Category category = new Category();
|
||||
category.setName("really-happy");
|
||||
|
||||
pet.setCategory(category);
|
||||
pet.setStatus(Pet.StatusEnum.AVAILABLE);
|
||||
List<String> photos = Arrays.asList("http://foo.bar.com/1", "http://foo.bar.com/2");
|
||||
pet.setPhotoUrls(photos);
|
||||
|
||||
return pet;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,82 +1,81 @@
|
||||
package io.swagger.client.api;
|
||||
|
||||
import feign.FeignException;
|
||||
|
||||
import io.swagger.TestUtils;
|
||||
|
||||
import io.swagger.client.ApiClient;
|
||||
import io.swagger.client.model.*;
|
||||
import io.swagger.client.model.Order;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.junit.*;
|
||||
import org.threeten.bp.OffsetDateTime;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
/**
|
||||
* API tests for StoreApi
|
||||
*/
|
||||
public class StoreApiTest {
|
||||
|
||||
private StoreApi api;
|
||||
|
||||
@Before
|
||||
public void setup() {
|
||||
ApiClient apiClient = new ApiClient();
|
||||
api = apiClient.buildClient(StoreApi.class);
|
||||
api = new ApiClient().buildClient(StoreApi.class);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Delete purchase order by ID
|
||||
*
|
||||
* For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors
|
||||
*/
|
||||
@Test
|
||||
public void testGetInventory() throws Exception {
|
||||
Map<String, Integer> inventory = api.getInventory();
|
||||
assertTrue(inventory.keySet().size() > 0);
|
||||
public void deleteOrderTest() {
|
||||
String orderId = null;
|
||||
// api.deleteOrder(orderId);
|
||||
|
||||
// TODO: test validations
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns pet inventories by status
|
||||
*
|
||||
* Returns a map of status codes to quantities
|
||||
*/
|
||||
@Test
|
||||
public void testPlaceOrder() throws Exception {
|
||||
Order order = createOrder();
|
||||
api.placeOrder(order);
|
||||
public void getInventoryTest() {
|
||||
// Map<String, Integer> response = api.getInventory();
|
||||
|
||||
Order fetched = api.getOrderById(order.getId());
|
||||
assertEquals(order.getId(), fetched.getId());
|
||||
assertEquals(order.getPetId(), fetched.getPetId());
|
||||
assertEquals(order.getQuantity(), fetched.getQuantity());
|
||||
assertTrue(order.getShipDate().isEqual(fetched.getShipDate()));
|
||||
// TODO: test validations
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Find purchase order by ID
|
||||
*
|
||||
* For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions
|
||||
*/
|
||||
@Test
|
||||
public void testDeleteOrder() throws Exception {
|
||||
Order order = createOrder();
|
||||
api.placeOrder(order);
|
||||
public void getOrderByIdTest() {
|
||||
Long orderId = null;
|
||||
// Order response = api.getOrderById(orderId);
|
||||
|
||||
Order fetched = api.getOrderById(order.getId());
|
||||
assertEquals(fetched.getId(), order.getId());
|
||||
|
||||
api.deleteOrder(order.getId().toString());
|
||||
|
||||
try {
|
||||
api.getOrderById(order.getId());
|
||||
fail("expected an error");
|
||||
} catch (FeignException e) {
|
||||
assertTrue(e.getMessage().startsWith("status 404 "));
|
||||
}
|
||||
// TODO: test validations
|
||||
}
|
||||
|
||||
private Order createOrder() {
|
||||
Order order = new Order();
|
||||
order.setPetId(200L);
|
||||
order.setQuantity(13);
|
||||
//Ensure 3 fractional digits because of a bug in the petstore server
|
||||
order.setShipDate(OffsetDateTime.now().withNano(123000000));
|
||||
order.setStatus(Order.StatusEnum.PLACED);
|
||||
order.setComplete(true);
|
||||
|
||||
/**
|
||||
* Place an order for a pet
|
||||
*
|
||||
*
|
||||
*/
|
||||
@Test
|
||||
public void placeOrderTest() {
|
||||
Order order = null;
|
||||
// Order response = api.placeOrder(order);
|
||||
|
||||
try {
|
||||
Field idField = Order.class.getDeclaredField("id");
|
||||
idField.setAccessible(true);
|
||||
idField.set(order, TestUtils.nextId());
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
||||
return order;
|
||||
// TODO: test validations
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -1,93 +1,156 @@
|
||||
package io.swagger.client.api;
|
||||
|
||||
import io.swagger.TestUtils;
|
||||
|
||||
import io.swagger.client.ApiClient;
|
||||
import io.swagger.client.model.*;
|
||||
import io.swagger.client.model.User;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
import org.junit.*;
|
||||
import static org.junit.Assert.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* API tests for UserApi
|
||||
*/
|
||||
public class UserApiTest {
|
||||
|
||||
private UserApi api;
|
||||
|
||||
@Before
|
||||
public void setup() {
|
||||
ApiClient apiClient = new ApiClient();
|
||||
api = apiClient.buildClient(UserApi.class);
|
||||
api = new ApiClient().buildClient(UserApi.class);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Create user
|
||||
*
|
||||
* This can only be done by the logged in user.
|
||||
*/
|
||||
@Test
|
||||
public void testCreateUser() throws Exception {
|
||||
User user = createUser();
|
||||
public void createUserTest() {
|
||||
User user = null;
|
||||
// api.createUser(user);
|
||||
|
||||
api.createUser(user);
|
||||
|
||||
User fetched = api.getUserByName(user.getUsername());
|
||||
assertEquals(user.getId(), fetched.getId());
|
||||
// TODO: test validations
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Creates list of users with given input array
|
||||
*
|
||||
*
|
||||
*/
|
||||
@Test
|
||||
public void testCreateUsersWithArray() throws Exception {
|
||||
User user1 = createUser();
|
||||
user1.setUsername("user" + user1.getId());
|
||||
User user2 = createUser();
|
||||
user2.setUsername("user" + user2.getId());
|
||||
public void createUsersWithArrayInputTest() {
|
||||
List<User> user = null;
|
||||
// api.createUsersWithArrayInput(user);
|
||||
|
||||
api.createUsersWithArrayInput(Arrays.asList(user1, user2));
|
||||
|
||||
User fetched = api.getUserByName(user1.getUsername());
|
||||
assertEquals(user1.getId(), fetched.getId());
|
||||
// TODO: test validations
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Creates list of users with given input array
|
||||
*
|
||||
*
|
||||
*/
|
||||
@Test
|
||||
public void testCreateUsersWithList() throws Exception {
|
||||
User user1 = createUser();
|
||||
user1.setUsername("user" + user1.getId());
|
||||
User user2 = createUser();
|
||||
user2.setUsername("user" + user2.getId());
|
||||
public void createUsersWithListInputTest() {
|
||||
List<User> user = null;
|
||||
// api.createUsersWithListInput(user);
|
||||
|
||||
api.createUsersWithListInput(Arrays.asList(user1, user2));
|
||||
|
||||
User fetched = api.getUserByName(user1.getUsername());
|
||||
assertEquals(user1.getId(), fetched.getId());
|
||||
// TODO: test validations
|
||||
}
|
||||
|
||||
// ignore for the time being, please refer to the following for more info:
|
||||
// https://github.com/swagger-api/swagger-codegen/issues/1660
|
||||
@Ignore @Test
|
||||
public void testLoginUser() throws Exception {
|
||||
User user = createUser();
|
||||
api.createUser(user);
|
||||
|
||||
/**
|
||||
* Delete user
|
||||
*
|
||||
* This can only be done by the logged in user.
|
||||
*/
|
||||
@Test
|
||||
public void deleteUserTest() {
|
||||
String username = null;
|
||||
// api.deleteUser(username);
|
||||
|
||||
String token = api.loginUser(user.getUsername(), user.getPassword());
|
||||
assertTrue(token.startsWith("logged in user session:"));
|
||||
// TODO: test validations
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get user by user name
|
||||
*
|
||||
*
|
||||
*/
|
||||
@Test
|
||||
public void getUserByNameTest() {
|
||||
String username = null;
|
||||
// User response = api.getUserByName(username);
|
||||
|
||||
// TODO: test validations
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Logs user into the system
|
||||
*
|
||||
*
|
||||
*/
|
||||
@Test
|
||||
public void loginUserTest() {
|
||||
String username = null;
|
||||
String password = null;
|
||||
// String response = api.loginUser(username, password);
|
||||
|
||||
// TODO: test validations
|
||||
}
|
||||
|
||||
/**
|
||||
* Logs user into the system
|
||||
*
|
||||
*
|
||||
*
|
||||
* This tests the overload of the method that uses a Map for query parameters instead of
|
||||
* listing them out individually.
|
||||
*/
|
||||
@Test
|
||||
public void loginUserTestQueryMap() {
|
||||
UserApi.LoginUserQueryParams queryParams = new UserApi.LoginUserQueryParams()
|
||||
.username(user.getUsername())
|
||||
.password(user.getPassword());
|
||||
token = api.loginUser(queryParams);
|
||||
assertTrue(token.startsWith("logged in user session:"));
|
||||
}
|
||||
.username(null)
|
||||
.password(null);
|
||||
// String response = api.loginUser(queryParams);
|
||||
|
||||
// TODO: test validations
|
||||
}
|
||||
|
||||
/**
|
||||
* Logs out current logged in user session
|
||||
*
|
||||
*
|
||||
*/
|
||||
@Test
|
||||
public void logoutUser() throws Exception {
|
||||
api.logoutUser();
|
||||
public void logoutUserTest() {
|
||||
// api.logoutUser();
|
||||
|
||||
// TODO: test validations
|
||||
}
|
||||
|
||||
private User createUser() {
|
||||
User user = new User();
|
||||
user.setId(TestUtils.nextId());
|
||||
user.setUsername("fred" + user.getId());
|
||||
user.setFirstName("Fred");
|
||||
user.setLastName("Meyer");
|
||||
user.setEmail("fred@fredmeyer.com");
|
||||
user.setPassword("xxXXxx");
|
||||
user.setPhone("408-867-5309");
|
||||
user.setUserStatus(123);
|
||||
|
||||
/**
|
||||
* Updated user
|
||||
*
|
||||
* This can only be done by the logged in user.
|
||||
*/
|
||||
@Test
|
||||
public void updateUserTest() {
|
||||
String username = null;
|
||||
User user = null;
|
||||
// api.updateUser(username, user);
|
||||
|
||||
return user;
|
||||
// TODO: test validations
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user