diff --git a/bin/java-petstore-jersey2.sh b/bin/java-petstore-jersey2.sh
index a715e7ff545..335652f79bb 100755
--- a/bin/java-petstore-jersey2.sh
+++ b/bin/java-petstore-jersey2.sh
@@ -26,6 +26,9 @@ fi
# if you've executed sbt assembly previously it will use that instead.
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
-ags="$@ generate -i modules/swagger-codegen/src/test/resources/2_0/petstore-with-fake-endpoints-models-for-testing.yaml -l java -c bin/java-petstore-jersey2.json -o samples/client/petstore/java/jersey2"
+ags="$@ generate -i modules/swagger-codegen/src/test/resources/2_0/petstore-with-fake-endpoints-models-for-testing.yaml -l java -c bin/java-petstore-jersey2.json -o samples/client/petstore/java/jersey2 -DdateLibrary=joda,hideGenerationTimestamp=true"
+echo "Removing files and folders under samples/client/petstore/java/jersey2/src/main"
+rm -rf samples/client/petstore/java/jersey2/src/main
+find samples/client/petstore/java/jersey2 -maxdepth 1 -type f ! -name "README.md" -exec rm {} +
java $JAVA_OPTS -jar $executable $ags
diff --git a/bin/java-petstore.sh b/bin/java-petstore.sh
index ed80c841df6..b2773945ea2 100755
--- a/bin/java-petstore.sh
+++ b/bin/java-petstore.sh
@@ -26,6 +26,9 @@ fi
# if you've executed sbt assembly previously it will use that instead.
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
-ags="$@ generate -i modules/swagger-codegen/src/test/resources/2_0/petstore-with-fake-endpoints-models-for-testing.yaml -l java -o samples/client/petstore/java/default -DhideGenerationTimestamp=true"
+ags="$@ generate -i modules/swagger-codegen/src/test/resources/2_0/petstore-with-fake-endpoints-models-for-testing.yaml -l java -o samples/client/petstore/java/default -DdateLibrary=joda,hideGenerationTimestamp=true"
+echo "Removing files and folders under samples/client/petstore/java/default/src/main"
+rm -rf samples/client/petstore/java/default/src/main
+find samples/client/petstore/java/default -maxdepth 1 -type f ! -name "README.md" -exec rm {} +
java $JAVA_OPTS -jar $executable $ags
diff --git a/bin/windows/java-petstore.bat b/bin/windows/java-petstore.bat
index 18544cbad36..02a81e1adbf 100755
--- a/bin/windows/java-petstore.bat
+++ b/bin/windows/java-petstore.bat
@@ -5,6 +5,6 @@ If Not Exist %executable% (
)
set JAVA_OPTS=%JAVA_OPTS% -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties
-set ags=generate -t modules\swagger-codegen\src\main\resources\java -i modules\swagger-codegen\src\test\resources\2_0\petstore.json -l java -o samples\client\petstore\java
+set ags=generate -t modules\swagger-codegen\src\main\resources\java -i modules\swagger-codegen\src\test\resources\2_0\petstore.json -l java -o samples\client\petstore\java -DdateLibrary=joda,hideGenerationTimestamp=true
java %JAVA_OPTS% -jar %executable% %ags%
diff --git a/samples/client/petstore/java/default/.swagger-codegen-ignore b/samples/client/petstore/java/default/.swagger-codegen-ignore
new file mode 100644
index 00000000000..19d3377182e
--- /dev/null
+++ b/samples/client/petstore/java/default/.swagger-codegen-ignore
@@ -0,0 +1,23 @@
+# Swagger Codegen Ignore
+# Generated by swagger-codegen https://github.com/swagger-api/swagger-codegen
+
+# Use this file to prevent files from being overwritten by the generator.
+# The patterns follow closely to .gitignore or .dockerignore.
+
+# As an example, the C# client generator defines ApiClient.cs.
+# You can make changes and tell Swagger Codgen to ignore just this file by uncommenting the following line:
+#ApiClient.cs
+
+# You can match any string of characters against a directory, file or extension with a single asterisk (*):
+#foo/*/qux
+# The above matches foo/bar/qux and foo/baz/qux, but not foo/bar/baz/qux
+
+# You can recursively match patterns against a directory, file or extension with a double asterisk (**):
+#foo/**/qux
+# Thsi matches foo/bar/qux, foo/baz/qux, and foo/bar/baz/qux
+
+# You can also negate patterns with an exclamation (!).
+# For example, you can ignore all files in a docs folder with the file extension .md:
+#docs/*.md
+# Then explicitly reverse the ignore rule for a single file:
+#!docs/README.md
diff --git a/samples/client/petstore/java/default/LICENSE b/samples/client/petstore/java/default/LICENSE
new file mode 100644
index 00000000000..8dada3edaf5
--- /dev/null
+++ b/samples/client/petstore/java/default/LICENSE
@@ -0,0 +1,201 @@
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
+
+ APPENDIX: How to apply the Apache License to your work.
+
+ To apply the Apache License to your work, attach the following
+ boilerplate notice, with the fields enclosed by brackets "{}"
+ replaced with your own identifying information. (Don't include
+ the brackets!) The text should be enclosed in the appropriate
+ comment syntax for the file format. We also recommend that a
+ file or class name and description of purpose be included on the
+ same "printed page" as the copyright notice for easier
+ identification within third-party archives.
+
+ Copyright {yyyy} {name of copyright owner}
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
diff --git a/samples/client/petstore/java/default/docs/AdditionalPropertiesClass.md b/samples/client/petstore/java/default/docs/AdditionalPropertiesClass.md
new file mode 100644
index 00000000000..0437c4dd8cc
--- /dev/null
+++ b/samples/client/petstore/java/default/docs/AdditionalPropertiesClass.md
@@ -0,0 +1,11 @@
+
+# AdditionalPropertiesClass
+
+## Properties
+Name | Type | Description | Notes
+------------ | ------------- | ------------- | -------------
+**mapProperty** | **Map<String, String>** | | [optional]
+**mapOfMapProperty** | [**Map<String, Map<String, String>>**](Map.md) | | [optional]
+
+
+
diff --git a/samples/client/petstore/java/default/docs/Animal.md b/samples/client/petstore/java/default/docs/Animal.md
index 3ecb7f991f3..b3f325c3524 100644
--- a/samples/client/petstore/java/default/docs/Animal.md
+++ b/samples/client/petstore/java/default/docs/Animal.md
@@ -5,6 +5,7 @@
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**className** | **String** | |
+**color** | **String** | | [optional]
diff --git a/samples/client/petstore/java/default/docs/ArrayTest.md b/samples/client/petstore/java/default/docs/ArrayTest.md
new file mode 100644
index 00000000000..9feee16427f
--- /dev/null
+++ b/samples/client/petstore/java/default/docs/ArrayTest.md
@@ -0,0 +1,12 @@
+
+# ArrayTest
+
+## Properties
+Name | Type | Description | Notes
+------------ | ------------- | ------------- | -------------
+**arrayOfString** | **List<String>** | | [optional]
+**arrayArrayOfInteger** | [**List<List<Long>>**](List.md) | | [optional]
+**arrayArrayOfModel** | [**List<List<ReadOnlyFirst>>**](List.md) | | [optional]
+
+
+
diff --git a/samples/client/petstore/java/default/docs/Cat.md b/samples/client/petstore/java/default/docs/Cat.md
index 373af540c41..be6e56fa8ce 100644
--- a/samples/client/petstore/java/default/docs/Cat.md
+++ b/samples/client/petstore/java/default/docs/Cat.md
@@ -5,6 +5,7 @@
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**className** | **String** | |
+**color** | **String** | | [optional]
**declawed** | **Boolean** | | [optional]
diff --git a/samples/client/petstore/java/default/docs/Dog.md b/samples/client/petstore/java/default/docs/Dog.md
index a1d638d3bad..71a7dbe809e 100644
--- a/samples/client/petstore/java/default/docs/Dog.md
+++ b/samples/client/petstore/java/default/docs/Dog.md
@@ -5,6 +5,7 @@
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**className** | **String** | |
+**color** | **String** | | [optional]
**breed** | **String** | | [optional]
diff --git a/samples/client/petstore/java/default/docs/FakeApi.md b/samples/client/petstore/java/default/docs/FakeApi.md
index b4e5f34974a..0c1f55a0902 100644
--- a/samples/client/petstore/java/default/docs/FakeApi.md
+++ b/samples/client/petstore/java/default/docs/FakeApi.md
@@ -32,8 +32,8 @@ Integer int32 = 56; // Integer | None
Long int64 = 789L; // Long | None
Float _float = 3.4F; // Float | None
byte[] binary = B; // byte[] | None
-Date date = new Date(); // Date | None
-Date dateTime = new Date(); // Date | None
+LocalDate date = new LocalDate(); // LocalDate | None
+DateTime dateTime = new DateTime(); // DateTime | None
String password = "password_example"; // String | None
try {
apiInstance.testEndpointParameters(number, _double, string, _byte, integer, int32, int64, _float, binary, date, dateTime, password);
@@ -56,8 +56,8 @@ Name | Type | Description | Notes
**int64** | **Long**| None | [optional]
**_float** | **Float**| None | [optional]
**binary** | **byte[]**| None | [optional]
- **date** | **Date**| None | [optional]
- **dateTime** | **Date**| None | [optional]
+ **date** | **LocalDate**| None | [optional]
+ **dateTime** | **DateTime**| None | [optional]
**password** | **String**| None | [optional]
### Return type
@@ -70,6 +70,6 @@ No authorization required
### HTTP request headers
- - **Content-Type**: Not defined
- - **Accept**: application/xml, application/json
+ - **Content-Type**: application/xml; charset=utf-8, application/json; charset=utf-8
+ - **Accept**: application/xml; charset=utf-8, application/json; charset=utf-8
diff --git a/samples/client/petstore/java/default/docs/FormatTest.md b/samples/client/petstore/java/default/docs/FormatTest.md
index dc2b559dad2..44de7d9511a 100644
--- a/samples/client/petstore/java/default/docs/FormatTest.md
+++ b/samples/client/petstore/java/default/docs/FormatTest.md
@@ -13,8 +13,8 @@ Name | Type | Description | Notes
**string** | **String** | | [optional]
**_byte** | **byte[]** | |
**binary** | **byte[]** | | [optional]
-**date** | [**Date**](Date.md) | |
-**dateTime** | [**Date**](Date.md) | | [optional]
+**date** | [**LocalDate**](LocalDate.md) | |
+**dateTime** | [**DateTime**](DateTime.md) | | [optional]
**uuid** | **String** | | [optional]
**password** | **String** | |
diff --git a/samples/client/petstore/java/default/docs/MixedPropertiesAndAdditionalPropertiesClass.md b/samples/client/petstore/java/default/docs/MixedPropertiesAndAdditionalPropertiesClass.md
new file mode 100644
index 00000000000..e3487bcc501
--- /dev/null
+++ b/samples/client/petstore/java/default/docs/MixedPropertiesAndAdditionalPropertiesClass.md
@@ -0,0 +1,12 @@
+
+# MixedPropertiesAndAdditionalPropertiesClass
+
+## Properties
+Name | Type | Description | Notes
+------------ | ------------- | ------------- | -------------
+**uuid** | **String** | | [optional]
+**dateTime** | [**DateTime**](DateTime.md) | | [optional]
+**map** | [**Map<String, Animal>**](Animal.md) | | [optional]
+
+
+
diff --git a/samples/client/petstore/java/default/docs/Name.md b/samples/client/petstore/java/default/docs/Name.md
index 5390a15e9cd..ce2fb4dee50 100644
--- a/samples/client/petstore/java/default/docs/Name.md
+++ b/samples/client/petstore/java/default/docs/Name.md
@@ -7,6 +7,7 @@ Name | Type | Description | Notes
**name** | **Integer** | |
**snakeCase** | **Integer** | | [optional]
**property** | **String** | | [optional]
+**_123Number** | **Integer** | | [optional]
diff --git a/samples/client/petstore/java/default/docs/Order.md b/samples/client/petstore/java/default/docs/Order.md
index 29ca3ddbc6b..a1089f5384e 100644
--- a/samples/client/petstore/java/default/docs/Order.md
+++ b/samples/client/petstore/java/default/docs/Order.md
@@ -7,7 +7,7 @@ Name | Type | Description | Notes
**id** | **Long** | | [optional]
**petId** | **Long** | | [optional]
**quantity** | **Integer** | | [optional]
-**shipDate** | [**Date**](Date.md) | | [optional]
+**shipDate** | [**DateTime**](DateTime.md) | | [optional]
**status** | [**StatusEnum**](#StatusEnum) | Order Status | [optional]
**complete** | **Boolean** | | [optional]
diff --git a/samples/client/petstore/java/default/docs/ReadOnlyFirst.md b/samples/client/petstore/java/default/docs/ReadOnlyFirst.md
new file mode 100644
index 00000000000..426b7cde95a
--- /dev/null
+++ b/samples/client/petstore/java/default/docs/ReadOnlyFirst.md
@@ -0,0 +1,11 @@
+
+# ReadOnlyFirst
+
+## Properties
+Name | Type | Description | Notes
+------------ | ------------- | ------------- | -------------
+**bar** | **String** | | [optional]
+**baz** | **String** | | [optional]
+
+
+
diff --git a/samples/client/petstore/java/default/gradlew b/samples/client/petstore/java/default/gradlew
old mode 100755
new mode 100644
diff --git a/samples/client/petstore/java/default/petstore_profiling.output b/samples/client/petstore/java/default/petstore_profiling.output
deleted file mode 100644
index 21562548765..00000000000
--- a/samples/client/petstore/java/default/petstore_profiling.output
+++ /dev/null
@@ -1,23 +0,0 @@
-# To run the profiling:
-# mvn compile test-compile exec:java -Dexec.classpathScope=test -Dexec.mainClass="io.swagger.PetstoreProfiling"
-
-0: ADD PET => 0.987609128
-0: GET PET => 0.450873167
-0: UPDATE PET => 0.447611998
-0: DELETE PET => 0.397707664
-1: ADD PET => 0.395333121
-1: GET PET => 0.381760136
-1: UPDATE PET => 0.395245221
-1: DELETE PET => 0.384854324
-2: ADD PET => 0.400336227
-2: GET PET => 0.378959921
-2: UPDATE PET => 0.397619284
-2: DELETE PET => 0.383307393
-3: ADD PET => 0.385764805
-3: GET PET => 0.40218304
-3: UPDATE PET => 0.387887511
-3: DELETE PET => 0.398063489
-4: ADD PET => 0.384757488
-4: GET PET => 0.398719713
-4: UPDATE PET => 0.383319052
-4: DELETE PET => 0.408516644
diff --git a/samples/client/petstore/java/default/pom.xml b/samples/client/petstore/java/default/pom.xml
index 2ea4060bc3a..0b24e120100 100644
--- a/samples/client/petstore/java/default/pom.xml
+++ b/samples/client/petstore/java/default/pom.xml
@@ -97,8 +97,8 @@
maven-compiler-plugin
2.3.2
- 1.6
- 1.6
+ 1.7
+ 1.7
diff --git a/samples/client/petstore/java/default/src/main/java/io/swagger/client/ApiClient.java b/samples/client/petstore/java/default/src/main/java/io/swagger/client/ApiClient.java
index 50c0e8db641..0d7898329d0 100644
--- a/samples/client/petstore/java/default/src/main/java/io/swagger/client/ApiClient.java
+++ b/samples/client/petstore/java/default/src/main/java/io/swagger/client/ApiClient.java
@@ -41,7 +41,7 @@ import io.swagger.client.auth.HttpBasicAuth;
import io.swagger.client.auth.ApiKeyAuth;
import io.swagger.client.auth.OAuth;
-@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-03-17T15:55:38.841+08:00")
+
public class ApiClient {
private Map defaultHeaderMap = new HashMap();
private String basePath = "http://petstore.swagger.io/v2";
@@ -75,13 +75,8 @@ public class ApiClient {
// Setup authentications (key: authentication name, value: authentication).
authentications = new HashMap();
- authentications.put("petstore_auth", new OAuth());
- authentications.put("test_api_client_id", new ApiKeyAuth("header", "x-test_api_client_id"));
- authentications.put("test_api_client_secret", new ApiKeyAuth("header", "x-test_api_client_secret"));
authentications.put("api_key", new ApiKeyAuth("header", "api_key"));
- authentications.put("test_http_basic", new HttpBasicAuth());
- authentications.put("test_api_key_query", new ApiKeyAuth("query", "test_api_key_query"));
- authentications.put("test_api_key_header", new ApiKeyAuth("header", "test_api_key_header"));
+ authentications.put("petstore_auth", new OAuth());
// Prevent the authentications from being modified.
authentications = Collections.unmodifiableMap(authentications);
diff --git a/samples/client/petstore/java/default/src/main/java/io/swagger/client/ApiException.java b/samples/client/petstore/java/default/src/main/java/io/swagger/client/ApiException.java
index 27395e86ba9..600bb507f09 100644
--- a/samples/client/petstore/java/default/src/main/java/io/swagger/client/ApiException.java
+++ b/samples/client/petstore/java/default/src/main/java/io/swagger/client/ApiException.java
@@ -1,3 +1,28 @@
+/**
+ * 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.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
package io.swagger.client;
import java.util.Map;
@@ -5,65 +30,74 @@ import java.util.List;
public class ApiException extends Exception {
- private int code = 0;
- private Map> responseHeaders = null;
- private String responseBody = null;
+ private int code = 0;
+ private Map> responseHeaders = null;
+ private String responseBody = null;
- public ApiException() {}
+ public ApiException() {}
- public ApiException(Throwable throwable) {
- super(throwable);
- }
+ public ApiException(Throwable throwable) {
+ super(throwable);
+ }
- public ApiException(String message) {
- super(message);
- }
+ public ApiException(String message) {
+ super(message);
+ }
- public ApiException(String message, Throwable throwable, int code, Map> responseHeaders, String responseBody) {
- super(message, throwable);
- this.code = code;
- this.responseHeaders = responseHeaders;
- this.responseBody = responseBody;
- }
+ public ApiException(String message, Throwable throwable, int code, Map> responseHeaders, String responseBody) {
+ super(message, throwable);
+ this.code = code;
+ this.responseHeaders = responseHeaders;
+ this.responseBody = responseBody;
+ }
- public ApiException(String message, int code, Map> responseHeaders, String responseBody) {
- this(message, (Throwable) null, code, responseHeaders, responseBody);
- }
+ public ApiException(String message, int code, Map> responseHeaders, String responseBody) {
+ this(message, (Throwable) null, code, responseHeaders, responseBody);
+ }
- public ApiException(String message, Throwable throwable, int code, Map> responseHeaders) {
- this(message, throwable, code, responseHeaders, null);
- }
+ public ApiException(String message, Throwable throwable, int code, Map> responseHeaders) {
+ this(message, throwable, code, responseHeaders, null);
+ }
- public ApiException(int code, Map> responseHeaders, String responseBody) {
- this((String) null, (Throwable) null, code, responseHeaders, responseBody);
- }
+ public ApiException(int code, Map> responseHeaders, String responseBody) {
+ this((String) null, (Throwable) null, code, responseHeaders, responseBody);
+ }
- public ApiException(int code, String message) {
- super(message);
- this.code = code;
- }
+ public ApiException(int code, String message) {
+ super(message);
+ this.code = code;
+ }
- public ApiException(int code, String message, Map> responseHeaders, String responseBody) {
- this(code, message);
- this.responseHeaders = responseHeaders;
- this.responseBody = responseBody;
- }
+ public ApiException(int code, String message, Map> responseHeaders, String responseBody) {
+ this(code, message);
+ this.responseHeaders = responseHeaders;
+ this.responseBody = responseBody;
+ }
- public int getCode() {
- return code;
- }
+ /**
+ * Get the HTTP status code.
+ *
+ * @return HTTP status code
+ */
+ public int getCode() {
+ return code;
+ }
- /**
- * Get the HTTP response headers.
- */
- public Map> getResponseHeaders() {
- return responseHeaders;
- }
+ /**
+ * Get the HTTP response headers.
+ *
+ * @return A map of list of string
+ */
+ public Map> getResponseHeaders() {
+ return responseHeaders;
+ }
- /**
- * Get the HTTP response body.
- */
- public String getResponseBody() {
- return responseBody;
- }
+ /**
+ * Get the HTTP response body.
+ *
+ * @return Response body in the form of string
+ */
+ public String getResponseBody() {
+ return responseBody;
+ }
}
diff --git a/samples/client/petstore/java/default/src/main/java/io/swagger/client/Configuration.java b/samples/client/petstore/java/default/src/main/java/io/swagger/client/Configuration.java
index 19b0ebeae4e..cbdadd6262d 100644
--- a/samples/client/petstore/java/default/src/main/java/io/swagger/client/Configuration.java
+++ b/samples/client/petstore/java/default/src/main/java/io/swagger/client/Configuration.java
@@ -1,22 +1,51 @@
+/**
+ * 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.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
package io.swagger.client;
public class Configuration {
- private static ApiClient defaultApiClient = new ApiClient();
+ private static ApiClient defaultApiClient = new ApiClient();
- /**
- * Get the default API client, which would be used when creating API
- * instances without providing an API client.
- */
- public static ApiClient getDefaultApiClient() {
- return defaultApiClient;
- }
+ /**
+ * Get the default API client, which would be used when creating API
+ * instances without providing an API client.
+ *
+ * @return Default API client
+ */
+ public static ApiClient getDefaultApiClient() {
+ return defaultApiClient;
+ }
- /**
- * Set the default API client, which would be used when creating API
- * instances without providing an API client.
- */
- public static void setDefaultApiClient(ApiClient apiClient) {
- defaultApiClient = apiClient;
- }
+ /**
+ * Set the default API client, which would be used when creating API
+ * instances without providing an API client.
+ *
+ * @param apiClient API client
+ */
+ public static void setDefaultApiClient(ApiClient apiClient) {
+ defaultApiClient = apiClient;
+ }
}
diff --git a/samples/client/petstore/java/default/src/main/java/io/swagger/client/Pair.java b/samples/client/petstore/java/default/src/main/java/io/swagger/client/Pair.java
index d8d32210b10..4b44c415812 100644
--- a/samples/client/petstore/java/default/src/main/java/io/swagger/client/Pair.java
+++ b/samples/client/petstore/java/default/src/main/java/io/swagger/client/Pair.java
@@ -1,3 +1,28 @@
+/**
+ * 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.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
package io.swagger.client;
diff --git a/samples/client/petstore/java/default/src/main/java/io/swagger/client/StringUtil.java b/samples/client/petstore/java/default/src/main/java/io/swagger/client/StringUtil.java
index 1383dd0decb..03c6c81e434 100644
--- a/samples/client/petstore/java/default/src/main/java/io/swagger/client/StringUtil.java
+++ b/samples/client/petstore/java/default/src/main/java/io/swagger/client/StringUtil.java
@@ -1,3 +1,28 @@
+/**
+ * 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.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
package io.swagger.client;
diff --git a/samples/client/petstore/java/default/src/main/java/io/swagger/client/api/FakeApi.java b/samples/client/petstore/java/default/src/main/java/io/swagger/client/api/FakeApi.java
index 40ee5e2774f..18ec9428c16 100644
--- a/samples/client/petstore/java/default/src/main/java/io/swagger/client/api/FakeApi.java
+++ b/samples/client/petstore/java/default/src/main/java/io/swagger/client/api/FakeApi.java
@@ -8,7 +8,8 @@ import io.swagger.client.Configuration;
import io.swagger.client.model.*;
import io.swagger.client.Pair;
-import java.util.Date;
+import org.joda.time.LocalDate;
+import org.joda.time.DateTime;
import java.math.BigDecimal;
@@ -54,7 +55,7 @@ public class FakeApi {
* @param password None (optional)
* @throws ApiException if fails to make API call
*/
- public void testEndpointParameters(BigDecimal number, Double _double, String string, byte[] _byte, Integer integer, Integer int32, Long int64, Float _float, byte[] binary, Date date, Date dateTime, String password) throws ApiException {
+ public void testEndpointParameters(BigDecimal number, Double _double, String string, byte[] _byte, Integer integer, Integer int32, Long int64, Float _float, byte[] binary, LocalDate date, DateTime dateTime, String password) throws ApiException {
Object localVarPostBody = null;
// verify the required parameter 'number' is set
@@ -113,12 +114,12 @@ if (password != null)
localVarFormParams.put("password", password);
final String[] localVarAccepts = {
- "application/xml", "application/json"
+ "application/xml; charset=utf-8", "application/json; charset=utf-8"
};
final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts);
final String[] localVarContentTypes = {
-
+ "application/xml; charset=utf-8", "application/json; charset=utf-8"
};
final String localVarContentType = apiClient.selectHeaderContentType(localVarContentTypes);
diff --git a/samples/client/petstore/java/default/src/main/java/io/swagger/client/auth/ApiKeyAuth.java b/samples/client/petstore/java/default/src/main/java/io/swagger/client/auth/ApiKeyAuth.java
index 6882dbc41c0..6ba15566b60 100644
--- a/samples/client/petstore/java/default/src/main/java/io/swagger/client/auth/ApiKeyAuth.java
+++ b/samples/client/petstore/java/default/src/main/java/io/swagger/client/auth/ApiKeyAuth.java
@@ -1,3 +1,28 @@
+/**
+ * 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.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
package io.swagger.client.auth;
import io.swagger.client.Pair;
diff --git a/samples/client/petstore/java/default/src/main/java/io/swagger/client/auth/Authentication.java b/samples/client/petstore/java/default/src/main/java/io/swagger/client/auth/Authentication.java
index 98b1a6900b9..a063a6998b5 100644
--- a/samples/client/petstore/java/default/src/main/java/io/swagger/client/auth/Authentication.java
+++ b/samples/client/petstore/java/default/src/main/java/io/swagger/client/auth/Authentication.java
@@ -1,3 +1,28 @@
+/**
+ * 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.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
package io.swagger.client.auth;
import io.swagger.client.Pair;
@@ -6,6 +31,11 @@ import java.util.Map;
import java.util.List;
public interface Authentication {
- /** Apply authentication settings to header and query params. */
- void applyToParams(List queryParams, Map headerParams);
+ /**
+ * Apply authentication settings to header and query params.
+ *
+ * @param queryParams List of query parameters
+ * @param headerParams Map of header parameters
+ */
+ void applyToParams(List queryParams, Map headerParams);
}
diff --git a/samples/client/petstore/java/default/src/main/java/io/swagger/client/auth/HttpBasicAuth.java b/samples/client/petstore/java/default/src/main/java/io/swagger/client/auth/HttpBasicAuth.java
index 64f2c887377..5895370e4d4 100644
--- a/samples/client/petstore/java/default/src/main/java/io/swagger/client/auth/HttpBasicAuth.java
+++ b/samples/client/petstore/java/default/src/main/java/io/swagger/client/auth/HttpBasicAuth.java
@@ -1,3 +1,28 @@
+/**
+ * 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.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
package io.swagger.client.auth;
import io.swagger.client.Pair;
diff --git a/samples/client/petstore/java/default/src/main/java/io/swagger/client/auth/OAuth.java b/samples/client/petstore/java/default/src/main/java/io/swagger/client/auth/OAuth.java
index 76d2917f24e..8802ebc92c8 100644
--- a/samples/client/petstore/java/default/src/main/java/io/swagger/client/auth/OAuth.java
+++ b/samples/client/petstore/java/default/src/main/java/io/swagger/client/auth/OAuth.java
@@ -1,3 +1,28 @@
+/**
+ * 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.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
package io.swagger.client.auth;
import io.swagger.client.Pair;
diff --git a/samples/client/petstore/java/default/src/main/java/io/swagger/client/auth/OAuthFlow.java b/samples/client/petstore/java/default/src/main/java/io/swagger/client/auth/OAuthFlow.java
index 597ec99b48b..ec1f942b0f2 100644
--- a/samples/client/petstore/java/default/src/main/java/io/swagger/client/auth/OAuthFlow.java
+++ b/samples/client/petstore/java/default/src/main/java/io/swagger/client/auth/OAuthFlow.java
@@ -1,5 +1,30 @@
+/**
+ * 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.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
package io.swagger.client.auth;
public enum OAuthFlow {
accessCode, implicit, password, application
-}
\ No newline at end of file
+}
diff --git a/samples/client/petstore/java/default/src/main/java/io/swagger/client/model/AdditionalPropertiesClass.java b/samples/client/petstore/java/default/src/main/java/io/swagger/client/model/AdditionalPropertiesClass.java
new file mode 100644
index 00000000000..ccaba7709c4
--- /dev/null
+++ b/samples/client/petstore/java/default/src/main/java/io/swagger/client/model/AdditionalPropertiesClass.java
@@ -0,0 +1,97 @@
+package io.swagger.client.model;
+
+import com.fasterxml.jackson.annotation.JsonValue;
+import java.util.Objects;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+
+/**
+ * AdditionalPropertiesClass
+ */
+
+public class AdditionalPropertiesClass {
+
+ private Map mapProperty = new HashMap();
+ private Map> mapOfMapProperty = new HashMap>();
+
+
+ /**
+ **/
+ public AdditionalPropertiesClass mapProperty(Map mapProperty) {
+ this.mapProperty = mapProperty;
+ return this;
+ }
+
+ @ApiModelProperty(example = "null", value = "")
+ @JsonProperty("map_property")
+ public Map getMapProperty() {
+ return mapProperty;
+ }
+ public void setMapProperty(Map mapProperty) {
+ this.mapProperty = mapProperty;
+ }
+
+
+ /**
+ **/
+ public AdditionalPropertiesClass mapOfMapProperty(Map> mapOfMapProperty) {
+ this.mapOfMapProperty = mapOfMapProperty;
+ return this;
+ }
+
+ @ApiModelProperty(example = "null", value = "")
+ @JsonProperty("map_of_map_property")
+ public Map> getMapOfMapProperty() {
+ return mapOfMapProperty;
+ }
+ public void setMapOfMapProperty(Map> mapOfMapProperty) {
+ this.mapOfMapProperty = mapOfMapProperty;
+ }
+
+
+ @Override
+ public boolean equals(java.lang.Object o) {
+ if (this == o) {
+ return true;
+ }
+ if (o == null || getClass() != o.getClass()) {
+ return false;
+ }
+ AdditionalPropertiesClass additionalPropertiesClass = (AdditionalPropertiesClass) o;
+ return Objects.equals(this.mapProperty, additionalPropertiesClass.mapProperty) &&
+ Objects.equals(this.mapOfMapProperty, additionalPropertiesClass.mapOfMapProperty);
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(mapProperty, mapOfMapProperty);
+ }
+
+ @Override
+ public String toString() {
+ StringBuilder sb = new StringBuilder();
+ sb.append("class AdditionalPropertiesClass {\n");
+
+ sb.append(" mapProperty: ").append(toIndentedString(mapProperty)).append("\n");
+ sb.append(" mapOfMapProperty: ").append(toIndentedString(mapOfMapProperty)).append("\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 ");
+ }
+}
+
diff --git a/samples/client/petstore/java/default/src/main/java/io/swagger/client/model/Animal.java b/samples/client/petstore/java/default/src/main/java/io/swagger/client/model/Animal.java
index 365f0110b78..25c7d3e421c 100644
--- a/samples/client/petstore/java/default/src/main/java/io/swagger/client/model/Animal.java
+++ b/samples/client/petstore/java/default/src/main/java/io/swagger/client/model/Animal.java
@@ -14,6 +14,7 @@ import io.swagger.annotations.ApiModelProperty;
public class Animal {
private String className = null;
+ private String color = "red";
/**
@@ -33,6 +34,23 @@ public class Animal {
}
+ /**
+ **/
+ public Animal color(String color) {
+ this.color = color;
+ return this;
+ }
+
+ @ApiModelProperty(example = "null", value = "")
+ @JsonProperty("color")
+ public String getColor() {
+ return color;
+ }
+ public void setColor(String color) {
+ this.color = color;
+ }
+
+
@Override
public boolean equals(java.lang.Object o) {
if (this == o) {
@@ -42,12 +60,13 @@ public class Animal {
return false;
}
Animal animal = (Animal) o;
- return Objects.equals(this.className, animal.className);
+ return Objects.equals(this.className, animal.className) &&
+ Objects.equals(this.color, animal.color);
}
@Override
public int hashCode() {
- return Objects.hash(className);
+ return Objects.hash(className, color);
}
@Override
@@ -56,6 +75,7 @@ public class Animal {
sb.append("class Animal {\n");
sb.append(" className: ").append(toIndentedString(className)).append("\n");
+ sb.append(" color: ").append(toIndentedString(color)).append("\n");
sb.append("}");
return sb.toString();
}
diff --git a/samples/client/petstore/java/default/src/main/java/io/swagger/client/model/ArrayTest.java b/samples/client/petstore/java/default/src/main/java/io/swagger/client/model/ArrayTest.java
new file mode 100644
index 00000000000..6c1eb23d8d0
--- /dev/null
+++ b/samples/client/petstore/java/default/src/main/java/io/swagger/client/model/ArrayTest.java
@@ -0,0 +1,116 @@
+package io.swagger.client.model;
+
+import com.fasterxml.jackson.annotation.JsonValue;
+import java.util.Objects;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import java.util.ArrayList;
+import java.util.List;
+
+
+/**
+ * ArrayTest
+ */
+
+public class ArrayTest {
+
+ private List arrayOfString = new ArrayList();
+ private List> arrayArrayOfInteger = new ArrayList>();
+ private List> arrayArrayOfModel = new ArrayList>();
+
+
+ /**
+ **/
+ public ArrayTest arrayOfString(List arrayOfString) {
+ this.arrayOfString = arrayOfString;
+ return this;
+ }
+
+ @ApiModelProperty(example = "null", value = "")
+ @JsonProperty("array_of_string")
+ public List getArrayOfString() {
+ return arrayOfString;
+ }
+ public void setArrayOfString(List arrayOfString) {
+ this.arrayOfString = arrayOfString;
+ }
+
+
+ /**
+ **/
+ public ArrayTest arrayArrayOfInteger(List> arrayArrayOfInteger) {
+ this.arrayArrayOfInteger = arrayArrayOfInteger;
+ return this;
+ }
+
+ @ApiModelProperty(example = "null", value = "")
+ @JsonProperty("array_array_of_integer")
+ public List> getArrayArrayOfInteger() {
+ return arrayArrayOfInteger;
+ }
+ public void setArrayArrayOfInteger(List> arrayArrayOfInteger) {
+ this.arrayArrayOfInteger = arrayArrayOfInteger;
+ }
+
+
+ /**
+ **/
+ public ArrayTest arrayArrayOfModel(List> arrayArrayOfModel) {
+ this.arrayArrayOfModel = arrayArrayOfModel;
+ return this;
+ }
+
+ @ApiModelProperty(example = "null", value = "")
+ @JsonProperty("array_array_of_model")
+ public List> getArrayArrayOfModel() {
+ return arrayArrayOfModel;
+ }
+ public void setArrayArrayOfModel(List> arrayArrayOfModel) {
+ this.arrayArrayOfModel = arrayArrayOfModel;
+ }
+
+
+ @Override
+ public boolean equals(java.lang.Object o) {
+ if (this == o) {
+ return true;
+ }
+ if (o == null || getClass() != o.getClass()) {
+ return false;
+ }
+ ArrayTest arrayTest = (ArrayTest) o;
+ return Objects.equals(this.arrayOfString, arrayTest.arrayOfString) &&
+ Objects.equals(this.arrayArrayOfInteger, arrayTest.arrayArrayOfInteger) &&
+ Objects.equals(this.arrayArrayOfModel, arrayTest.arrayArrayOfModel);
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(arrayOfString, arrayArrayOfInteger, arrayArrayOfModel);
+ }
+
+ @Override
+ public String toString() {
+ StringBuilder sb = new StringBuilder();
+ sb.append("class ArrayTest {\n");
+
+ sb.append(" arrayOfString: ").append(toIndentedString(arrayOfString)).append("\n");
+ sb.append(" arrayArrayOfInteger: ").append(toIndentedString(arrayArrayOfInteger)).append("\n");
+ sb.append(" arrayArrayOfModel: ").append(toIndentedString(arrayArrayOfModel)).append("\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 ");
+ }
+}
+
diff --git a/samples/client/petstore/java/default/src/main/java/io/swagger/client/model/Cat.java b/samples/client/petstore/java/default/src/main/java/io/swagger/client/model/Cat.java
index 21c54aff204..5ef9e23bd96 100644
--- a/samples/client/petstore/java/default/src/main/java/io/swagger/client/model/Cat.java
+++ b/samples/client/petstore/java/default/src/main/java/io/swagger/client/model/Cat.java
@@ -15,6 +15,7 @@ import io.swagger.client.model.Animal;
public class Cat extends Animal {
private String className = null;
+ private String color = "red";
private Boolean declawed = null;
@@ -35,6 +36,23 @@ public class Cat extends Animal {
}
+ /**
+ **/
+ public Cat color(String color) {
+ this.color = color;
+ return this;
+ }
+
+ @ApiModelProperty(example = "null", value = "")
+ @JsonProperty("color")
+ public String getColor() {
+ return color;
+ }
+ public void setColor(String color) {
+ this.color = color;
+ }
+
+
/**
**/
public Cat declawed(Boolean declawed) {
@@ -62,13 +80,14 @@ public class Cat extends Animal {
}
Cat cat = (Cat) o;
return Objects.equals(this.className, cat.className) &&
+ Objects.equals(this.color, cat.color) &&
Objects.equals(this.declawed, cat.declawed) &&
super.equals(o);
}
@Override
public int hashCode() {
- return Objects.hash(className, declawed, super.hashCode());
+ return Objects.hash(className, color, declawed, super.hashCode());
}
@Override
@@ -77,6 +96,7 @@ public class Cat extends Animal {
sb.append("class Cat {\n");
sb.append(" ").append(toIndentedString(super.toString())).append("\n");
sb.append(" className: ").append(toIndentedString(className)).append("\n");
+ sb.append(" color: ").append(toIndentedString(color)).append("\n");
sb.append(" declawed: ").append(toIndentedString(declawed)).append("\n");
sb.append("}");
return sb.toString();
diff --git a/samples/client/petstore/java/default/src/main/java/io/swagger/client/model/Dog.java b/samples/client/petstore/java/default/src/main/java/io/swagger/client/model/Dog.java
index ed5581058c6..4b3cc947cc5 100644
--- a/samples/client/petstore/java/default/src/main/java/io/swagger/client/model/Dog.java
+++ b/samples/client/petstore/java/default/src/main/java/io/swagger/client/model/Dog.java
@@ -15,6 +15,7 @@ import io.swagger.client.model.Animal;
public class Dog extends Animal {
private String className = null;
+ private String color = "red";
private String breed = null;
@@ -35,6 +36,23 @@ public class Dog extends Animal {
}
+ /**
+ **/
+ public Dog color(String color) {
+ this.color = color;
+ return this;
+ }
+
+ @ApiModelProperty(example = "null", value = "")
+ @JsonProperty("color")
+ public String getColor() {
+ return color;
+ }
+ public void setColor(String color) {
+ this.color = color;
+ }
+
+
/**
**/
public Dog breed(String breed) {
@@ -62,13 +80,14 @@ public class Dog extends Animal {
}
Dog dog = (Dog) o;
return Objects.equals(this.className, dog.className) &&
+ Objects.equals(this.color, dog.color) &&
Objects.equals(this.breed, dog.breed) &&
super.equals(o);
}
@Override
public int hashCode() {
- return Objects.hash(className, breed, super.hashCode());
+ return Objects.hash(className, color, breed, super.hashCode());
}
@Override
@@ -77,6 +96,7 @@ public class Dog extends Animal {
sb.append("class Dog {\n");
sb.append(" ").append(toIndentedString(super.toString())).append("\n");
sb.append(" className: ").append(toIndentedString(className)).append("\n");
+ sb.append(" color: ").append(toIndentedString(color)).append("\n");
sb.append(" breed: ").append(toIndentedString(breed)).append("\n");
sb.append("}");
return sb.toString();
diff --git a/samples/client/petstore/java/default/src/main/java/io/swagger/client/model/FormatTest.java b/samples/client/petstore/java/default/src/main/java/io/swagger/client/model/FormatTest.java
index c01974880ae..79376150017 100644
--- a/samples/client/petstore/java/default/src/main/java/io/swagger/client/model/FormatTest.java
+++ b/samples/client/petstore/java/default/src/main/java/io/swagger/client/model/FormatTest.java
@@ -6,7 +6,8 @@ import com.fasterxml.jackson.annotation.JsonProperty;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import java.math.BigDecimal;
-import java.util.Date;
+import org.joda.time.DateTime;
+import org.joda.time.LocalDate;
/**
@@ -24,8 +25,8 @@ public class FormatTest {
private String string = null;
private byte[] _byte = null;
private byte[] binary = null;
- private Date date = null;
- private Date dateTime = null;
+ private LocalDate date = null;
+ private DateTime dateTime = null;
private String uuid = null;
private String password = null;
@@ -195,34 +196,34 @@ public class FormatTest {
/**
**/
- public FormatTest date(Date date) {
+ public FormatTest date(LocalDate date) {
this.date = date;
return this;
}
@ApiModelProperty(example = "null", required = true, value = "")
@JsonProperty("date")
- public Date getDate() {
+ public LocalDate getDate() {
return date;
}
- public void setDate(Date date) {
+ public void setDate(LocalDate date) {
this.date = date;
}
/**
**/
- public FormatTest dateTime(Date dateTime) {
+ public FormatTest dateTime(DateTime dateTime) {
this.dateTime = dateTime;
return this;
}
@ApiModelProperty(example = "null", value = "")
@JsonProperty("dateTime")
- public Date getDateTime() {
+ public DateTime getDateTime() {
return dateTime;
}
- public void setDateTime(Date dateTime) {
+ public void setDateTime(DateTime dateTime) {
this.dateTime = dateTime;
}
diff --git a/samples/client/petstore/java/default/src/main/java/io/swagger/client/model/MixedPropertiesAndAdditionalPropertiesClass.java b/samples/client/petstore/java/default/src/main/java/io/swagger/client/model/MixedPropertiesAndAdditionalPropertiesClass.java
new file mode 100644
index 00000000000..2f0972bf41e
--- /dev/null
+++ b/samples/client/petstore/java/default/src/main/java/io/swagger/client/model/MixedPropertiesAndAdditionalPropertiesClass.java
@@ -0,0 +1,119 @@
+package io.swagger.client.model;
+
+import com.fasterxml.jackson.annotation.JsonValue;
+import java.util.Objects;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import io.swagger.client.model.Animal;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import org.joda.time.DateTime;
+
+
+/**
+ * MixedPropertiesAndAdditionalPropertiesClass
+ */
+
+public class MixedPropertiesAndAdditionalPropertiesClass {
+
+ private String uuid = null;
+ private DateTime dateTime = null;
+ private Map map = new HashMap();
+
+
+ /**
+ **/
+ public MixedPropertiesAndAdditionalPropertiesClass uuid(String uuid) {
+ this.uuid = uuid;
+ return this;
+ }
+
+ @ApiModelProperty(example = "null", value = "")
+ @JsonProperty("uuid")
+ public String getUuid() {
+ return uuid;
+ }
+ public void setUuid(String uuid) {
+ this.uuid = uuid;
+ }
+
+
+ /**
+ **/
+ public MixedPropertiesAndAdditionalPropertiesClass dateTime(DateTime dateTime) {
+ this.dateTime = dateTime;
+ return this;
+ }
+
+ @ApiModelProperty(example = "null", value = "")
+ @JsonProperty("dateTime")
+ public DateTime getDateTime() {
+ return dateTime;
+ }
+ public void setDateTime(DateTime dateTime) {
+ this.dateTime = dateTime;
+ }
+
+
+ /**
+ **/
+ public MixedPropertiesAndAdditionalPropertiesClass map(Map map) {
+ this.map = map;
+ return this;
+ }
+
+ @ApiModelProperty(example = "null", value = "")
+ @JsonProperty("map")
+ public Map getMap() {
+ return map;
+ }
+ public void setMap(Map map) {
+ this.map = map;
+ }
+
+
+ @Override
+ public boolean equals(java.lang.Object o) {
+ if (this == o) {
+ return true;
+ }
+ if (o == null || getClass() != o.getClass()) {
+ return false;
+ }
+ MixedPropertiesAndAdditionalPropertiesClass mixedPropertiesAndAdditionalPropertiesClass = (MixedPropertiesAndAdditionalPropertiesClass) o;
+ return Objects.equals(this.uuid, mixedPropertiesAndAdditionalPropertiesClass.uuid) &&
+ Objects.equals(this.dateTime, mixedPropertiesAndAdditionalPropertiesClass.dateTime) &&
+ Objects.equals(this.map, mixedPropertiesAndAdditionalPropertiesClass.map);
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(uuid, dateTime, map);
+ }
+
+ @Override
+ public String toString() {
+ StringBuilder sb = new StringBuilder();
+ sb.append("class MixedPropertiesAndAdditionalPropertiesClass {\n");
+
+ sb.append(" uuid: ").append(toIndentedString(uuid)).append("\n");
+ sb.append(" dateTime: ").append(toIndentedString(dateTime)).append("\n");
+ sb.append(" map: ").append(toIndentedString(map)).append("\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 ");
+ }
+}
+
diff --git a/samples/client/petstore/java/default/src/main/java/io/swagger/client/model/Name.java b/samples/client/petstore/java/default/src/main/java/io/swagger/client/model/Name.java
index 60b26b55658..1ba2cc5e4a3 100644
--- a/samples/client/petstore/java/default/src/main/java/io/swagger/client/model/Name.java
+++ b/samples/client/petstore/java/default/src/main/java/io/swagger/client/model/Name.java
@@ -17,6 +17,7 @@ public class Name {
private Integer name = null;
private Integer snakeCase = null;
private String property = null;
+ private Integer _123Number = null;
/**
@@ -60,6 +61,13 @@ public class Name {
}
+ @ApiModelProperty(example = "null", value = "")
+ @JsonProperty("123Number")
+ public Integer get123Number() {
+ return _123Number;
+ }
+
+
@Override
public boolean equals(java.lang.Object o) {
if (this == o) {
@@ -71,12 +79,13 @@ public class Name {
Name name = (Name) o;
return Objects.equals(this.name, name.name) &&
Objects.equals(this.snakeCase, name.snakeCase) &&
- Objects.equals(this.property, name.property);
+ Objects.equals(this.property, name.property) &&
+ Objects.equals(this._123Number, name._123Number);
}
@Override
public int hashCode() {
- return Objects.hash(name, snakeCase, property);
+ return Objects.hash(name, snakeCase, property, _123Number);
}
@Override
@@ -87,6 +96,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("}");
return sb.toString();
}
diff --git a/samples/client/petstore/java/default/src/main/java/io/swagger/client/model/Order.java b/samples/client/petstore/java/default/src/main/java/io/swagger/client/model/Order.java
index ed5739592a3..cec651e73a6 100644
--- a/samples/client/petstore/java/default/src/main/java/io/swagger/client/model/Order.java
+++ b/samples/client/petstore/java/default/src/main/java/io/swagger/client/model/Order.java
@@ -6,7 +6,7 @@ import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonValue;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
-import java.util.Date;
+import org.joda.time.DateTime;
/**
@@ -18,7 +18,7 @@ public class Order {
private Long id = null;
private Long petId = null;
private Integer quantity = null;
- private Date shipDate = null;
+ private DateTime shipDate = null;
/**
* Order Status
@@ -98,17 +98,17 @@ public class Order {
/**
**/
- public Order shipDate(Date shipDate) {
+ public Order shipDate(DateTime shipDate) {
this.shipDate = shipDate;
return this;
}
@ApiModelProperty(example = "null", value = "")
@JsonProperty("shipDate")
- public Date getShipDate() {
+ public DateTime getShipDate() {
return shipDate;
}
- public void setShipDate(Date shipDate) {
+ public void setShipDate(DateTime shipDate) {
this.shipDate = shipDate;
}
diff --git a/samples/client/petstore/java/default/src/main/java/io/swagger/client/model/ReadOnlyFirst.java b/samples/client/petstore/java/default/src/main/java/io/swagger/client/model/ReadOnlyFirst.java
new file mode 100644
index 00000000000..fdc3587df0e
--- /dev/null
+++ b/samples/client/petstore/java/default/src/main/java/io/swagger/client/model/ReadOnlyFirst.java
@@ -0,0 +1,84 @@
+package io.swagger.client.model;
+
+import com.fasterxml.jackson.annotation.JsonValue;
+import java.util.Objects;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+
+
+/**
+ * ReadOnlyFirst
+ */
+
+public class ReadOnlyFirst {
+
+ private String bar = null;
+ private String baz = null;
+
+
+ @ApiModelProperty(example = "null", value = "")
+ @JsonProperty("bar")
+ public String getBar() {
+ return bar;
+ }
+
+
+ /**
+ **/
+ public ReadOnlyFirst baz(String baz) {
+ this.baz = baz;
+ return this;
+ }
+
+ @ApiModelProperty(example = "null", value = "")
+ @JsonProperty("baz")
+ public String getBaz() {
+ return baz;
+ }
+ public void setBaz(String baz) {
+ this.baz = baz;
+ }
+
+
+ @Override
+ public boolean equals(java.lang.Object o) {
+ if (this == o) {
+ return true;
+ }
+ if (o == null || getClass() != o.getClass()) {
+ return false;
+ }
+ ReadOnlyFirst readOnlyFirst = (ReadOnlyFirst) o;
+ return Objects.equals(this.bar, readOnlyFirst.bar) &&
+ Objects.equals(this.baz, readOnlyFirst.baz);
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(bar, baz);
+ }
+
+ @Override
+ public String toString() {
+ StringBuilder sb = new StringBuilder();
+ sb.append("class ReadOnlyFirst {\n");
+
+ sb.append(" bar: ").append(toIndentedString(bar)).append("\n");
+ sb.append(" baz: ").append(toIndentedString(baz)).append("\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 ");
+ }
+}
+
diff --git a/samples/client/petstore/java/default/src/test/java/io/swagger/client/ApiClientTest.java b/samples/client/petstore/java/default/src/test/java/io/swagger/client/ApiClientTest.java
index 47f004c283b..19b55257d0c 100644
--- a/samples/client/petstore/java/default/src/test/java/io/swagger/client/ApiClientTest.java
+++ b/samples/client/petstore/java/default/src/test/java/io/swagger/client/ApiClientTest.java
@@ -111,6 +111,7 @@ public class ApiClientTest {
}
}
+ @Ignore("There is no more basic auth in petstore security definitions")
@Test
public void testSetUsernameAndPassword() {
HttpBasicAuth auth = null;
diff --git a/samples/client/petstore/java/default/src/test/java/io/swagger/client/api/PetApiTest.java b/samples/client/petstore/java/default/src/test/java/io/swagger/client/api/PetApiTest.java
index c25e0d8bfa2..e75a9c7e7da 100644
--- a/samples/client/petstore/java/default/src/test/java/io/swagger/client/api/PetApiTest.java
+++ b/samples/client/petstore/java/default/src/test/java/io/swagger/client/api/PetApiTest.java
@@ -1,155 +1,306 @@
package io.swagger.client.api;
-import io.swagger.client.ApiException;
-import io.swagger.client.model.Pet;
-import io.swagger.client.model.ModelApiResponse;
-import java.io.File;
-import org.junit.Test;
+import com.fasterxml.jackson.annotation.*;
+import com.fasterxml.jackson.databind.*;
+import com.fasterxml.jackson.datatype.joda.*;
+import io.swagger.TestUtils;
+
+import io.swagger.client.*;
+import io.swagger.client.api.*;
+import io.swagger.client.auth.*;
+import io.swagger.client.model.*;
+
+import java.io.BufferedWriter;
+import java.io.File;
+import java.io.FileWriter;
import java.util.ArrayList;
-import java.util.HashMap;
+import java.util.Arrays;
import java.util.List;
import java.util.Map;
-/**
- * API tests for PetApi
- */
+import org.junit.*;
+import static org.junit.Assert.*;
+
public class PetApiTest {
+ private PetApi api;
+ private ObjectMapper mapper;
- private final PetApi api = new PetApi();
-
-
- /**
- * Add a new pet to the store
- *
- *
- *
- * @throws ApiException
- * if the Api call fails
- */
- @Test
- public void addPetTest() throws ApiException {
- Pet body = null;
- // api.addPet(body);
-
- // TODO: test validations
+ @Before
+ public void setup() {
+ api = new PetApi();
+ // setup authentication
+ ApiKeyAuth apiKeyAuth = (ApiKeyAuth) api.getApiClient().getAuthentication("api_key");
+ apiKeyAuth.setApiKey("special-key");
}
-
- /**
- * Deletes a pet
- *
- *
- *
- * @throws ApiException
- * if the Api call fails
- */
- @Test
- public void deletePetTest() throws ApiException {
- Long petId = null;
- String apiKey = null;
- // api.deletePet(petId, apiKey);
- // TODO: test validations
- }
-
- /**
- * Finds Pets by status
- *
- * Multiple status values can be provided with comma separated strings
- *
- * @throws ApiException
- * if the Api call fails
- */
@Test
- public void findPetsByStatusTest() throws ApiException {
- List status = null;
- // List response = api.findPetsByStatus(status);
+ public void testApiClient() {
+ // the default api client is used
+ assertEquals(Configuration.getDefaultApiClient(), api.getApiClient());
+ assertNotNull(api.getApiClient());
+ assertEquals("http://petstore.swagger.io/v2", api.getApiClient().getBasePath());
+ assertFalse(api.getApiClient().isDebugging());
- // TODO: test validations
+ ApiClient oldClient = api.getApiClient();
+
+ ApiClient newClient = new ApiClient();
+ newClient.setBasePath("http://example.com");
+ newClient.setDebugging(true);
+
+ // set api client via constructor
+ api = new PetApi(newClient);
+ assertNotNull(api.getApiClient());
+ assertEquals("http://example.com", api.getApiClient().getBasePath());
+ assertTrue(api.getApiClient().isDebugging());
+
+ // set api client via setter method
+ api.setApiClient(oldClient);
+ assertNotNull(api.getApiClient());
+ assertEquals("http://petstore.swagger.io/v2", api.getApiClient().getBasePath());
+ assertFalse(api.getApiClient().isDebugging());
}
-
- /**
- * Finds Pets by tags
- *
- * Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.
- *
- * @throws ApiException
- * if the Api call fails
- */
+
@Test
- public void findPetsByTagsTest() throws ApiException {
- List tags = null;
- // List response = api.findPetsByTags(tags);
+ public void testCreateAndGetPet() throws Exception {
+ Pet pet = createRandomPet();
+ api.addPet(pet);
- // TODO: test validations
+ Pet fetched = api.getPetById(pet.getId());
+ assertNotNull(fetched);
+ assertEquals(pet.getId(), fetched.getId());
+ assertNotNull(fetched.getCategory());
+ assertEquals(fetched.getCategory().getName(), pet.getCategory().getName());
}
-
- /**
- * Find pet by ID
- *
- * Returns a single pet
- *
- * @throws ApiException
- * if the Api call fails
- */
+
+ /*
@Test
- public void getPetByIdTest() throws ApiException {
- Long petId = null;
- // Pet response = api.getPetById(petId);
+ public void testCreateAndGetPetWithByteArray() throws Exception {
+ Pet pet = createRandomPet();
+ byte[] bytes = serializeJson(pet).getBytes();
+ api.addPetUsingByteArray(bytes);
- // TODO: test validations
+ byte[] fetchedBytes = api.petPetIdtestingByteArraytrueGet(pet.getId());
+ Pet fetched = deserializeJson(new String(fetchedBytes), Pet.class);
+ assertNotNull(fetched);
+ assertEquals(pet.getId(), fetched.getId());
+ assertNotNull(fetched.getCategory());
+ assertEquals(fetched.getCategory().getName(), pet.getCategory().getName());
}
-
- /**
- * Update an existing pet
- *
- *
- *
- * @throws ApiException
- * if the Api call fails
- */
+
@Test
- public void updatePetTest() throws ApiException {
- Pet body = null;
- // api.updatePet(body);
+ public void testGetPetByIdInObject() throws Exception {
+ Pet pet = new Pet();
+ pet.setId(TestUtils.nextId());
+ pet.setName("pet " + pet.getId());
- // TODO: test validations
+ Category category = new Category();
+ category.setId(TestUtils.nextId());
+ category.setName("category " + category.getId());
+ pet.setCategory(category);
+
+ pet.setStatus(Pet.StatusEnum.PENDING);
+ List photos = Arrays.asList(new String[]{"http://foo.bar.com/1"});
+ pet.setPhotoUrls(photos);
+
+ api.addPet(pet);
+
+ InlineResponse200 fetched = api.getPetByIdInObject(pet.getId());
+ assertEquals(pet.getId(), fetched.getId());
+ assertEquals(pet.getName(), fetched.getName());
+
+ Object categoryObj = fetched.getCategory();
+ assertNotNull(categoryObj);
+ assertTrue(categoryObj instanceof Map);
+
+ Map categoryMap = (Map) categoryObj;
+ Object categoryIdObj = categoryMap.get("id");
+ assertTrue(categoryIdObj instanceof Integer);
+ Integer categoryIdInt = (Integer) categoryIdObj;
+ assertEquals(category.getId(), Long.valueOf(categoryIdInt));
+ assertEquals(category.getName(), categoryMap.get("name"));
}
-
- /**
- * Updates a pet in the store with form data
- *
- *
- *
- * @throws ApiException
- * if the Api call fails
- */
+ */
+
@Test
- public void updatePetWithFormTest() throws ApiException {
- Long petId = null;
- String name = null;
- String status = null;
- // api.updatePetWithForm(petId, name, status);
+ public void testUpdatePet() throws Exception {
+ Pet pet = createRandomPet();
+ pet.setName("programmer");
- // TODO: test validations
+ 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());
}
-
- /**
- * uploads an image
- *
- *
- *
- * @throws ApiException
- * if the Api call fails
- */
+
@Test
- public void uploadFileTest() throws ApiException {
- Long petId = null;
- String additionalMetadata = null;
- File file = null;
- // ModelApiResponse response = api.uploadFile(petId, additionalMetadata, file);
+ public void testFindPetsByStatus() throws Exception {
+ Pet pet = createRandomPet();
+ pet.setName("programmer");
+ pet.setStatus(Pet.StatusEnum.AVAILABLE);
- // TODO: test validations
+ api.updatePet(pet);
+
+ List pets = api.findPetsByStatus(Arrays.asList(new String[]{"available"}));
+ assertNotNull(pets);
+
+ boolean found = false;
+ for (Pet fetched : pets) {
+ if (fetched.getId().equals(pet.getId())) {
+ found = true;
+ break;
+ }
+ }
+
+ assertTrue(found);
+ }
+
+ @Test
+ public void testFindPetsByTags() throws Exception {
+ Pet pet = createRandomPet();
+ pet.setName("monster");
+ pet.setStatus(Pet.StatusEnum.AVAILABLE);
+
+ List tags = new ArrayList();
+ Tag tag1 = new Tag();
+ tag1.setName("friendly");
+ tags.add(tag1);
+ pet.setTags(tags);
+
+ api.updatePet(pet);
+
+ List pets = api.findPetsByTags(Arrays.asList(new String[]{"friendly"}));
+ assertNotNull(pets);
+
+ boolean found = false;
+ for (Pet fetched : pets) {
+ if (fetched.getId().equals(pet.getId())) {
+ found = true;
+ break;
+ }
+ }
+ assertTrue(found);
+ }
+
+ @Test
+ public void testUpdatePetWithForm() throws Exception {
+ Pet pet = createRandomPet();
+ pet.setName("frank");
+ api.addPet(pet);
+
+ Pet fetched = api.getPetById(pet.getId());
+
+ api.updatePetWithForm(fetched.getId(), "furt", null);
+ Pet updated = api.getPetById(fetched.getId());
+
+ assertEquals(updated.getName(), "furt");
+ }
+
+ @Test
+ public void testDeletePet() throws Exception {
+ Pet pet = createRandomPet();
+ api.addPet(pet);
+
+ Pet fetched = api.getPetById(pet.getId());
+ api.deletePet(fetched.getId(), null);
+
+ try {
+ fetched = api.getPetById(fetched.getId());
+ fail("expected an error");
+ } catch (ApiException e) {
+ assertEquals(404, e.getCode());
+ }
+ }
+
+ @Test
+ public void testUploadFile() throws Exception {
+ Pet pet = createRandomPet();
+ api.addPet(pet);
+
+ 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()));
+ }
+
+ @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());
+
+ pet2.setName("really-happy");
+ pet2.setPhotoUrls(Arrays.asList(new String[]{"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(new String[]{"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());
+ }
+
+ 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 photos = Arrays.asList(new String[]{"http://foo.bar.com/1", "http://foo.bar.com/2"});
+ pet.setPhotoUrls(photos);
+
+ return pet;
+ }
+
+ private String serializeJson(Object o) {
+ if (mapper == null) {
+ mapper = createObjectMapper();
+ }
+ try {
+ return mapper.writeValueAsString(o);
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ private T deserializeJson(String json, Class klass) {
+ if (mapper == null) {
+ mapper = createObjectMapper();
+ }
+ try {
+ return mapper.readValue(json, klass);
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ private ObjectMapper createObjectMapper() {
+ ObjectMapper mapper = new ObjectMapper();
+ mapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
+ mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
+ mapper.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS);
+ mapper.enable(SerializationFeature.WRITE_ENUMS_USING_TO_STRING);
+ mapper.enable(DeserializationFeature.READ_ENUMS_USING_TO_STRING);
+ mapper.registerModule(new JodaModule());
+ return mapper;
}
-
}
diff --git a/samples/client/petstore/java/default/src/test/java/io/swagger/client/api/StoreApiTest.java b/samples/client/petstore/java/default/src/test/java/io/swagger/client/api/StoreApiTest.java
index 31abbbeae4e..51779f265f0 100644
--- a/samples/client/petstore/java/default/src/test/java/io/swagger/client/api/StoreApiTest.java
+++ b/samples/client/petstore/java/default/src/test/java/io/swagger/client/api/StoreApiTest.java
@@ -1,83 +1,103 @@
package io.swagger.client.api;
+import io.swagger.TestUtils;
+
import io.swagger.client.ApiException;
-import io.swagger.client.model.Order;
-import org.junit.Test;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
+import io.swagger.client.*;
+import io.swagger.client.api.*;
+import io.swagger.client.auth.*;
+import io.swagger.client.model.*;
+
+import java.lang.reflect.Field;
import java.util.Map;
+import java.text.SimpleDateFormat;
+
+import org.joda.time.DateTime;
+import org.joda.time.DateTimeZone;
+import org.junit.*;
+import static org.junit.Assert.*;
-/**
- * API tests for StoreApi
- */
public class StoreApiTest {
+ StoreApi api = null;
- private final StoreApi api = new StoreApi();
-
-
- /**
- * Delete purchase order by ID
- *
- * For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors
- *
- * @throws ApiException
- * if the Api call fails
- */
- @Test
- public void deleteOrderTest() throws ApiException {
- String orderId = null;
- // api.deleteOrder(orderId);
-
- // TODO: test validations
+ @Before
+ public void setup() {
+ api = new StoreApi();
+ // setup authentication
+ ApiKeyAuth apiKeyAuth = (ApiKeyAuth) api.getApiClient().getAuthentication("api_key");
+ apiKeyAuth.setApiKey("special-key");
+ // set custom date format that is used by the petstore server
+ api.getApiClient().setDateFormat(new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSZ"));
}
-
- /**
- * Returns pet inventories by status
- *
- * Returns a map of status codes to quantities
- *
- * @throws ApiException
- * if the Api call fails
- */
- @Test
- public void getInventoryTest() throws ApiException {
- // Map response = api.getInventory();
- // TODO: test validations
- }
-
- /**
- * Find purchase order by ID
- *
- * For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions
- *
- * @throws ApiException
- * if the Api call fails
- */
@Test
- public void getOrderByIdTest() throws ApiException {
- Long orderId = null;
- // Order response = api.getOrderById(orderId);
-
- // TODO: test validations
+ public void testGetInventory() throws Exception {
+ Map inventory = api.getInventory();
+ assertTrue(inventory.keySet().size() > 0);
}
-
- /**
- * Place an order for a pet
- *
- *
- *
- * @throws ApiException
- * if the Api call fails
- */
+
+ /*
@Test
- public void placeOrderTest() throws ApiException {
- Order body = null;
- // Order response = api.placeOrder(body);
+ public void testGetInventoryInObject() throws Exception {
+ Object inventoryObj = api.getInventoryInObject();
+ assertTrue(inventoryObj instanceof Map);
- // TODO: test validations
+ Map inventoryMap = (Map) inventoryObj;
+ assertTrue(inventoryMap.keySet().size() > 0);
+
+ Map.Entry firstEntry = (Map.Entry) inventoryMap.entrySet().iterator().next();
+ assertTrue(firstEntry.getKey() instanceof String);
+ assertTrue(firstEntry.getValue() instanceof Integer);
+ }
+ */
+
+ @Test
+ public void testPlaceOrder() throws Exception {
+ Order order = createOrder();
+ api.placeOrder(order);
+
+ Order fetched = api.getOrderById(order.getId());
+ assertEquals(order.getId(), fetched.getId());
+ assertEquals(order.getPetId(), fetched.getPetId());
+ assertEquals(order.getQuantity(), fetched.getQuantity());
+ assertEquals(order.getShipDate().withZone(DateTimeZone.UTC), fetched.getShipDate().withZone(DateTimeZone.UTC));
+ }
+
+ @Test
+ public void testDeleteOrder() throws Exception {
+ Order order = createOrder();
+ api.placeOrder(order);
+
+ Order fetched = api.getOrderById(order.getId());
+ assertEquals(fetched.getId(), order.getId());
+
+ api.deleteOrder(String.valueOf(order.getId()));
+
+ try {
+ api.getOrderById(order.getId());
+ // fail("expected an error");
+ } catch (ApiException e) {
+ // ok
+ }
+ }
+
+ private Order createOrder() {
+ Order order = new Order();
+ order.setPetId(new Long(200));
+ order.setQuantity(new Integer(13));
+ order.setShipDate(DateTime.now());
+ order.setStatus(Order.StatusEnum.PLACED);
+ order.setComplete(true);
+
+ try {
+ Field idField = Order.class.getDeclaredField("id");
+ idField.setAccessible(true);
+ idField.set(order, TestUtils.nextId());
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+
+ return order;
}
-
}
diff --git a/samples/client/petstore/java/default/src/test/java/io/swagger/client/api/UserApiTest.java b/samples/client/petstore/java/default/src/test/java/io/swagger/client/api/UserApiTest.java
index 7e96762ff4e..c7fb92d2552 100644
--- a/samples/client/petstore/java/default/src/test/java/io/swagger/client/api/UserApiTest.java
+++ b/samples/client/petstore/java/default/src/test/java/io/swagger/client/api/UserApiTest.java
@@ -1,149 +1,88 @@
package io.swagger.client.api;
-import io.swagger.client.ApiException;
-import io.swagger.client.model.User;
-import org.junit.Test;
+import io.swagger.TestUtils;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
+import io.swagger.client.api.*;
+import io.swagger.client.auth.*;
+import io.swagger.client.model.*;
+
+import java.util.Arrays;
+
+import org.junit.*;
+import static org.junit.Assert.*;
-/**
- * API tests for UserApi
- */
public class UserApiTest {
+ UserApi api = null;
- private final UserApi api = new UserApi();
-
-
- /**
- * Create user
- *
- * This can only be done by the logged in user.
- *
- * @throws ApiException
- * if the Api call fails
- */
- @Test
- public void createUserTest() throws ApiException {
- User body = null;
- // api.createUser(body);
-
- // TODO: test validations
+ @Before
+ public void setup() {
+ api = new UserApi();
+ // setup authentication
+ ApiKeyAuth apiKeyAuth = (ApiKeyAuth) api.getApiClient().getAuthentication("api_key");
+ apiKeyAuth.setApiKey("special-key");
}
-
- /**
- * Creates list of users with given input array
- *
- *
- *
- * @throws ApiException
- * if the Api call fails
- */
- @Test
- public void createUsersWithArrayInputTest() throws ApiException {
- List body = null;
- // api.createUsersWithArrayInput(body);
- // TODO: test validations
- }
-
- /**
- * Creates list of users with given input array
- *
- *
- *
- * @throws ApiException
- * if the Api call fails
- */
@Test
- public void createUsersWithListInputTest() throws ApiException {
- List body = null;
- // api.createUsersWithListInput(body);
+ public void testCreateUser() throws Exception {
+ User user = createUser();
- // TODO: test validations
+ api.createUser(user);
+
+ User fetched = api.getUserByName(user.getUsername());
+ assertEquals(user.getId(), fetched.getId());
}
-
- /**
- * Delete user
- *
- * This can only be done by the logged in user.
- *
- * @throws ApiException
- * if the Api call fails
- */
+
@Test
- public void deleteUserTest() throws ApiException {
- String username = null;
- // api.deleteUser(username);
+ public void testCreateUsersWithArray() throws Exception {
+ User user1 = createUser();
+ user1.setUsername("user" + user1.getId());
+ User user2 = createUser();
+ user2.setUsername("user" + user2.getId());
- // TODO: test validations
+ api.createUsersWithArrayInput(Arrays.asList(new User[]{user1, user2}));
+
+ User fetched = api.getUserByName(user1.getUsername());
+ assertEquals(user1.getId(), fetched.getId());
}
-
- /**
- * Get user by user name
- *
- *
- *
- * @throws ApiException
- * if the Api call fails
- */
+
@Test
- public void getUserByNameTest() throws ApiException {
- String username = null;
- // User response = api.getUserByName(username);
+ public void testCreateUsersWithList() throws Exception {
+ User user1 = createUser();
+ user1.setUsername("user" + user1.getId());
+ User user2 = createUser();
+ user2.setUsername("user" + user2.getId());
- // TODO: test validations
+ api.createUsersWithListInput(Arrays.asList(new User[]{user1, user2}));
+
+ User fetched = api.getUserByName(user1.getUsername());
+ assertEquals(user1.getId(), fetched.getId());
}
-
- /**
- * Logs user into the system
- *
- *
- *
- * @throws ApiException
- * if the Api call fails
- */
+
@Test
- public void loginUserTest() throws ApiException {
- String username = null;
- String password = null;
- // String response = api.loginUser(username, password);
+ public void testLoginUser() throws Exception {
+ User user = createUser();
+ api.createUser(user);
- // TODO: test validations
+ String token = api.loginUser(user.getUsername(), user.getPassword());
+ assertTrue(token.startsWith("logged in user session:"));
}
-
- /**
- * Logs out current logged in user session
- *
- *
- *
- * @throws ApiException
- * if the Api call fails
- */
+
@Test
- public void logoutUserTest() throws ApiException {
- // api.logoutUser();
-
- // TODO: test validations
+ public void logoutUser() throws Exception {
+ api.logoutUser();
}
-
- /**
- * Updated user
- *
- * This can only be done by the logged in user.
- *
- * @throws ApiException
- * if the Api call fails
- */
- @Test
- public void updateUserTest() throws ApiException {
- String username = null;
- User body = null;
- // api.updateUser(username, body);
- // 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);
+
+ return user;
}
-
}
diff --git a/samples/client/petstore/java/default/src/test/java/io/swagger/petstore/test/PetApiTest.java b/samples/client/petstore/java/default/src/test/java/io/swagger/petstore/test/PetApiTest.java
deleted file mode 100644
index 9e927a69ba2..00000000000
--- a/samples/client/petstore/java/default/src/test/java/io/swagger/petstore/test/PetApiTest.java
+++ /dev/null
@@ -1,306 +0,0 @@
-package io.swagger.petstore.test;
-
-import com.fasterxml.jackson.annotation.*;
-import com.fasterxml.jackson.databind.*;
-import com.fasterxml.jackson.datatype.joda.*;
-
-import io.swagger.TestUtils;
-
-import io.swagger.client.*;
-import io.swagger.client.api.*;
-import io.swagger.client.auth.*;
-import io.swagger.client.model.*;
-
-import java.io.BufferedWriter;
-import java.io.File;
-import java.io.FileWriter;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
-import java.util.Map;
-
-import org.junit.*;
-import static org.junit.Assert.*;
-
-public class PetApiTest {
- private PetApi api;
- private ObjectMapper mapper;
-
- @Before
- public void setup() {
- api = new PetApi();
- // setup authentication
- ApiKeyAuth apiKeyAuth = (ApiKeyAuth) api.getApiClient().getAuthentication("api_key");
- apiKeyAuth.setApiKey("special-key");
- }
-
- @Test
- public void testApiClient() {
- // the default api client is used
- assertEquals(Configuration.getDefaultApiClient(), api.getApiClient());
- assertNotNull(api.getApiClient());
- assertEquals("http://petstore.swagger.io/v2", api.getApiClient().getBasePath());
- assertFalse(api.getApiClient().isDebugging());
-
- ApiClient oldClient = api.getApiClient();
-
- ApiClient newClient = new ApiClient();
- newClient.setBasePath("http://example.com");
- newClient.setDebugging(true);
-
- // set api client via constructor
- api = new PetApi(newClient);
- assertNotNull(api.getApiClient());
- assertEquals("http://example.com", api.getApiClient().getBasePath());
- assertTrue(api.getApiClient().isDebugging());
-
- // set api client via setter method
- api.setApiClient(oldClient);
- assertNotNull(api.getApiClient());
- assertEquals("http://petstore.swagger.io/v2", api.getApiClient().getBasePath());
- assertFalse(api.getApiClient().isDebugging());
- }
-
- @Test
- public void testCreateAndGetPet() throws Exception {
- Pet pet = createRandomPet();
- api.addPet(pet);
-
- Pet fetched = api.getPetById(pet.getId());
- assertNotNull(fetched);
- assertEquals(pet.getId(), fetched.getId());
- assertNotNull(fetched.getCategory());
- assertEquals(fetched.getCategory().getName(), pet.getCategory().getName());
- }
-
- /*
- @Test
- public void testCreateAndGetPetWithByteArray() throws Exception {
- Pet pet = createRandomPet();
- byte[] bytes = serializeJson(pet).getBytes();
- api.addPetUsingByteArray(bytes);
-
- byte[] fetchedBytes = api.petPetIdtestingByteArraytrueGet(pet.getId());
- Pet fetched = deserializeJson(new String(fetchedBytes), Pet.class);
- assertNotNull(fetched);
- assertEquals(pet.getId(), fetched.getId());
- assertNotNull(fetched.getCategory());
- assertEquals(fetched.getCategory().getName(), pet.getCategory().getName());
- }
-
- @Test
- public void testGetPetByIdInObject() throws Exception {
- Pet pet = new Pet();
- pet.setId(TestUtils.nextId());
- pet.setName("pet " + pet.getId());
-
- Category category = new Category();
- category.setId(TestUtils.nextId());
- category.setName("category " + category.getId());
- pet.setCategory(category);
-
- pet.setStatus(Pet.StatusEnum.PENDING);
- List photos = Arrays.asList(new String[]{"http://foo.bar.com/1"});
- pet.setPhotoUrls(photos);
-
- api.addPet(pet);
-
- InlineResponse200 fetched = api.getPetByIdInObject(pet.getId());
- assertEquals(pet.getId(), fetched.getId());
- assertEquals(pet.getName(), fetched.getName());
-
- Object categoryObj = fetched.getCategory();
- assertNotNull(categoryObj);
- assertTrue(categoryObj instanceof Map);
-
- Map categoryMap = (Map) categoryObj;
- Object categoryIdObj = categoryMap.get("id");
- assertTrue(categoryIdObj instanceof Integer);
- Integer categoryIdInt = (Integer) categoryIdObj;
- assertEquals(category.getId(), Long.valueOf(categoryIdInt));
- assertEquals(category.getName(), categoryMap.get("name"));
- }
- */
-
- @Test
- public void testUpdatePet() throws Exception {
- Pet pet = createRandomPet();
- pet.setName("programmer");
-
- 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());
- }
-
- @Test
- public void testFindPetsByStatus() throws Exception {
- Pet pet = createRandomPet();
- pet.setName("programmer");
- pet.setStatus(Pet.StatusEnum.AVAILABLE);
-
- api.updatePet(pet);
-
- List pets = api.findPetsByStatus(Arrays.asList(new String[]{"available"}));
- assertNotNull(pets);
-
- boolean found = false;
- for (Pet fetched : pets) {
- if (fetched.getId().equals(pet.getId())) {
- found = true;
- break;
- }
- }
-
- assertTrue(found);
- }
-
- @Test
- public void testFindPetsByTags() throws Exception {
- Pet pet = createRandomPet();
- pet.setName("monster");
- pet.setStatus(Pet.StatusEnum.AVAILABLE);
-
- List tags = new ArrayList();
- Tag tag1 = new Tag();
- tag1.setName("friendly");
- tags.add(tag1);
- pet.setTags(tags);
-
- api.updatePet(pet);
-
- List pets = api.findPetsByTags(Arrays.asList(new String[]{"friendly"}));
- assertNotNull(pets);
-
- boolean found = false;
- for (Pet fetched : pets) {
- if (fetched.getId().equals(pet.getId())) {
- found = true;
- break;
- }
- }
- assertTrue(found);
- }
-
- @Test
- public void testUpdatePetWithForm() throws Exception {
- Pet pet = createRandomPet();
- pet.setName("frank");
- api.addPet(pet);
-
- Pet fetched = api.getPetById(pet.getId());
-
- api.updatePetWithForm(fetched.getId(), "furt", null);
- Pet updated = api.getPetById(fetched.getId());
-
- assertEquals(updated.getName(), "furt");
- }
-
- @Test
- public void testDeletePet() throws Exception {
- Pet pet = createRandomPet();
- api.addPet(pet);
-
- Pet fetched = api.getPetById(pet.getId());
- api.deletePet(fetched.getId(), null);
-
- try {
- fetched = api.getPetById(fetched.getId());
- fail("expected an error");
- } catch (ApiException e) {
- assertEquals(404, e.getCode());
- }
- }
-
- @Test
- public void testUploadFile() throws Exception {
- Pet pet = createRandomPet();
- api.addPet(pet);
-
- 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()));
- }
-
- @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());
-
- pet2.setName("really-happy");
- pet2.setPhotoUrls(Arrays.asList(new String[]{"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(new String[]{"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());
- }
-
- 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 photos = Arrays.asList(new String[]{"http://foo.bar.com/1", "http://foo.bar.com/2"});
- pet.setPhotoUrls(photos);
-
- return pet;
- }
-
- private String serializeJson(Object o) {
- if (mapper == null) {
- mapper = createObjectMapper();
- }
- try {
- return mapper.writeValueAsString(o);
- } catch (Exception e) {
- throw new RuntimeException(e);
- }
- }
-
- private T deserializeJson(String json, Class klass) {
- if (mapper == null) {
- mapper = createObjectMapper();
- }
- try {
- return mapper.readValue(json, klass);
- } catch (Exception e) {
- throw new RuntimeException(e);
- }
- }
-
- private ObjectMapper createObjectMapper() {
- ObjectMapper mapper = new ObjectMapper();
- mapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
- mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
- mapper.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS);
- mapper.enable(SerializationFeature.WRITE_ENUMS_USING_TO_STRING);
- mapper.enable(DeserializationFeature.READ_ENUMS_USING_TO_STRING);
- mapper.registerModule(new JodaModule());
- return mapper;
- }
-}
diff --git a/samples/client/petstore/java/default/src/test/java/io/swagger/petstore/test/StoreApiTest.java b/samples/client/petstore/java/default/src/test/java/io/swagger/petstore/test/StoreApiTest.java
deleted file mode 100644
index 4b33d380f14..00000000000
--- a/samples/client/petstore/java/default/src/test/java/io/swagger/petstore/test/StoreApiTest.java
+++ /dev/null
@@ -1,100 +0,0 @@
-package io.swagger.petstore.test;
-
-import io.swagger.TestUtils;
-
-import io.swagger.client.ApiException;
-
-import io.swagger.client.*;
-import io.swagger.client.api.*;
-import io.swagger.client.auth.*;
-import io.swagger.client.model.*;
-
-import java.lang.reflect.Field;
-import java.util.Map;
-import java.text.SimpleDateFormat;
-
-import org.junit.*;
-import static org.junit.Assert.*;
-
-public class StoreApiTest {
- StoreApi api = null;
-
- @Before
- public void setup() {
- api = new StoreApi();
- // setup authentication
- ApiKeyAuth apiKeyAuth = (ApiKeyAuth) api.getApiClient().getAuthentication("api_key");
- apiKeyAuth.setApiKey("special-key");
- // set custom date format that is used by the petstore server
- api.getApiClient().setDateFormat(new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSZ"));
- }
-
- @Test
- public void testGetInventory() throws Exception {
- Map inventory = api.getInventory();
- assertTrue(inventory.keySet().size() > 0);
- }
-
- /*
- @Test
- public void testGetInventoryInObject() throws Exception {
- Object inventoryObj = api.getInventoryInObject();
- assertTrue(inventoryObj instanceof Map);
-
- Map inventoryMap = (Map) inventoryObj;
- assertTrue(inventoryMap.keySet().size() > 0);
-
- Map.Entry firstEntry = (Map.Entry) inventoryMap.entrySet().iterator().next();
- assertTrue(firstEntry.getKey() instanceof String);
- assertTrue(firstEntry.getValue() instanceof Integer);
- }
- */
-
- @Test
- public void testPlaceOrder() throws Exception {
- Order order = createOrder();
- api.placeOrder(order);
-
- Order fetched = api.getOrderById(order.getId());
- assertEquals(order.getId(), fetched.getId());
- assertEquals(order.getPetId(), fetched.getPetId());
- assertEquals(order.getQuantity(), fetched.getQuantity());
- }
-
- @Test
- public void testDeleteOrder() throws Exception {
- Order order = createOrder();
- api.placeOrder(order);
-
- Order fetched = api.getOrderById(order.getId());
- assertEquals(fetched.getId(), order.getId());
-
- api.deleteOrder(String.valueOf(order.getId()));
-
- try {
- api.getOrderById(order.getId());
- // fail("expected an error");
- } catch (ApiException e) {
- // ok
- }
- }
-
- private Order createOrder() {
- Order order = new Order();
- order.setPetId(new Long(200));
- order.setQuantity(new Integer(13));
- order.setShipDate(new java.util.Date());
- order.setStatus(Order.StatusEnum.PLACED);
- order.setComplete(true);
-
- try {
- Field idField = Order.class.getDeclaredField("id");
- idField.setAccessible(true);
- idField.set(order, TestUtils.nextId());
- } catch (Exception e) {
- throw new RuntimeException(e);
- }
-
- return order;
- }
-}
diff --git a/samples/client/petstore/java/default/src/test/java/io/swagger/petstore/test/UserApiTest.java b/samples/client/petstore/java/default/src/test/java/io/swagger/petstore/test/UserApiTest.java
deleted file mode 100644
index 195e5c1e861..00000000000
--- a/samples/client/petstore/java/default/src/test/java/io/swagger/petstore/test/UserApiTest.java
+++ /dev/null
@@ -1,88 +0,0 @@
-package io.swagger.petstore.test;
-
-import io.swagger.TestUtils;
-
-import io.swagger.client.api.*;
-import io.swagger.client.auth.*;
-import io.swagger.client.model.*;
-
-import java.util.Arrays;
-
-import org.junit.*;
-import static org.junit.Assert.*;
-
-public class UserApiTest {
- UserApi api = null;
-
- @Before
- public void setup() {
- api = new UserApi();
- // setup authentication
- ApiKeyAuth apiKeyAuth = (ApiKeyAuth) api.getApiClient().getAuthentication("api_key");
- apiKeyAuth.setApiKey("special-key");
- }
-
- @Test
- public void testCreateUser() throws Exception {
- User user = createUser();
-
- api.createUser(user);
-
- User fetched = api.getUserByName(user.getUsername());
- assertEquals(user.getId(), fetched.getId());
- }
-
- @Test
- public void testCreateUsersWithArray() throws Exception {
- User user1 = createUser();
- user1.setUsername("user" + user1.getId());
- User user2 = createUser();
- user2.setUsername("user" + user2.getId());
-
- api.createUsersWithArrayInput(Arrays.asList(new User[]{user1, user2}));
-
- User fetched = api.getUserByName(user1.getUsername());
- assertEquals(user1.getId(), fetched.getId());
- }
-
- @Test
- public void testCreateUsersWithList() throws Exception {
- User user1 = createUser();
- user1.setUsername("user" + user1.getId());
- User user2 = createUser();
- user2.setUsername("user" + user2.getId());
-
- api.createUsersWithListInput(Arrays.asList(new User[]{user1, user2}));
-
- User fetched = api.getUserByName(user1.getUsername());
- assertEquals(user1.getId(), fetched.getId());
- }
-
- @Test
- public void testLoginUser() throws Exception {
- User user = createUser();
- api.createUser(user);
-
- String token = api.loginUser(user.getUsername(), user.getPassword());
- assertTrue(token.startsWith("logged in user session:"));
- }
-
- @Test
- public void logoutUser() throws Exception {
- api.logoutUser();
- }
-
- 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);
-
- return user;
- }
-}
diff --git a/samples/client/petstore/java/jersey2/build.gradle b/samples/client/petstore/java/jersey2/build.gradle
index 9c98d11c4cd..6574f746d05 100644
--- a/samples/client/petstore/java/jersey2/build.gradle
+++ b/samples/client/petstore/java/jersey2/build.gradle
@@ -94,7 +94,7 @@ if(hasProperty('target') && target == 'android') {
}
ext {
- swagger_annotations_version = "1.5.0"
+ swagger_annotations_version = "1.5.8"
jackson_version = "2.7.0"
jersey_version = "2.22.2"
jodatime_version = "2.9.3"
diff --git a/samples/client/petstore/java/jersey2/docs/FakeApi.md b/samples/client/petstore/java/jersey2/docs/FakeApi.md
index 8e15d4d1f69..0c1f55a0902 100644
--- a/samples/client/petstore/java/jersey2/docs/FakeApi.md
+++ b/samples/client/petstore/java/jersey2/docs/FakeApi.md
@@ -32,8 +32,8 @@ Integer int32 = 56; // Integer | None
Long int64 = 789L; // Long | None
Float _float = 3.4F; // Float | None
byte[] binary = B; // byte[] | None
-Date date = new Date(); // Date | None
-Date dateTime = new Date(); // Date | None
+LocalDate date = new LocalDate(); // LocalDate | None
+DateTime dateTime = new DateTime(); // DateTime | None
String password = "password_example"; // String | None
try {
apiInstance.testEndpointParameters(number, _double, string, _byte, integer, int32, int64, _float, binary, date, dateTime, password);
@@ -56,8 +56,8 @@ Name | Type | Description | Notes
**int64** | **Long**| None | [optional]
**_float** | **Float**| None | [optional]
**binary** | **byte[]**| None | [optional]
- **date** | **Date**| None | [optional]
- **dateTime** | **Date**| None | [optional]
+ **date** | **LocalDate**| None | [optional]
+ **dateTime** | **DateTime**| None | [optional]
**password** | **String**| None | [optional]
### Return type
diff --git a/samples/client/petstore/java/jersey2/docs/FormatTest.md b/samples/client/petstore/java/jersey2/docs/FormatTest.md
index dc2b559dad2..44de7d9511a 100644
--- a/samples/client/petstore/java/jersey2/docs/FormatTest.md
+++ b/samples/client/petstore/java/jersey2/docs/FormatTest.md
@@ -13,8 +13,8 @@ Name | Type | Description | Notes
**string** | **String** | | [optional]
**_byte** | **byte[]** | |
**binary** | **byte[]** | | [optional]
-**date** | [**Date**](Date.md) | |
-**dateTime** | [**Date**](Date.md) | | [optional]
+**date** | [**LocalDate**](LocalDate.md) | |
+**dateTime** | [**DateTime**](DateTime.md) | | [optional]
**uuid** | **String** | | [optional]
**password** | **String** | |
diff --git a/samples/client/petstore/java/jersey2/docs/MixedPropertiesAndAdditionalPropertiesClass.md b/samples/client/petstore/java/jersey2/docs/MixedPropertiesAndAdditionalPropertiesClass.md
index 00cc10ca9b3..e3487bcc501 100644
--- a/samples/client/petstore/java/jersey2/docs/MixedPropertiesAndAdditionalPropertiesClass.md
+++ b/samples/client/petstore/java/jersey2/docs/MixedPropertiesAndAdditionalPropertiesClass.md
@@ -5,7 +5,7 @@
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**uuid** | **String** | | [optional]
-**dateTime** | [**Date**](Date.md) | | [optional]
+**dateTime** | [**DateTime**](DateTime.md) | | [optional]
**map** | [**Map<String, Animal>**](Animal.md) | | [optional]
diff --git a/samples/client/petstore/java/jersey2/docs/Order.md b/samples/client/petstore/java/jersey2/docs/Order.md
index 29ca3ddbc6b..a1089f5384e 100644
--- a/samples/client/petstore/java/jersey2/docs/Order.md
+++ b/samples/client/petstore/java/jersey2/docs/Order.md
@@ -7,7 +7,7 @@ Name | Type | Description | Notes
**id** | **Long** | | [optional]
**petId** | **Long** | | [optional]
**quantity** | **Integer** | | [optional]
-**shipDate** | [**Date**](Date.md) | | [optional]
+**shipDate** | [**DateTime**](DateTime.md) | | [optional]
**status** | [**StatusEnum**](#StatusEnum) | Order Status | [optional]
**complete** | **Boolean** | | [optional]
diff --git a/samples/client/petstore/java/jersey2/gradlew b/samples/client/petstore/java/jersey2/gradlew
old mode 100755
new mode 100644
diff --git a/samples/client/petstore/java/jersey2/hello.txt b/samples/client/petstore/java/jersey2/hello.txt
deleted file mode 100644
index 6769dd60bdf..00000000000
--- a/samples/client/petstore/java/jersey2/hello.txt
+++ /dev/null
@@ -1 +0,0 @@
-Hello world!
\ No newline at end of file
diff --git a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/ApiClient.java b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/ApiClient.java
index bc43cfe670e..a2607bfd516 100644
--- a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/ApiClient.java
+++ b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/ApiClient.java
@@ -48,7 +48,7 @@ import io.swagger.client.auth.HttpBasicAuth;
import io.swagger.client.auth.ApiKeyAuth;
import io.swagger.client.auth.OAuth;
-@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-03-17T17:22:31.147+08:00")
+
public class ApiClient {
private Map defaultHeaderMap = new HashMap();
private String basePath = "http://petstore.swagger.io/v2";
@@ -84,13 +84,8 @@ public class ApiClient {
// Setup authentications (key: authentication name, value: authentication).
authentications = new HashMap();
- authentications.put("petstore_auth", new OAuth());
- authentications.put("test_api_client_id", new ApiKeyAuth("header", "x-test_api_client_id"));
- authentications.put("test_api_client_secret", new ApiKeyAuth("header", "x-test_api_client_secret"));
authentications.put("api_key", new ApiKeyAuth("header", "api_key"));
- authentications.put("test_http_basic", new HttpBasicAuth());
- authentications.put("test_api_key_query", new ApiKeyAuth("query", "test_api_key_query"));
- authentications.put("test_api_key_header", new ApiKeyAuth("header", "test_api_key_header"));
+ authentications.put("petstore_auth", new OAuth());
// Prevent the authentications from being modified.
authentications = Collections.unmodifiableMap(authentications);
}
diff --git a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/ApiException.java b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/ApiException.java
index 00a3321d474..600bb507f09 100644
--- a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/ApiException.java
+++ b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/ApiException.java
@@ -1,69 +1,103 @@
+/**
+ * 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.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
package io.swagger.client;
import java.util.Map;
import java.util.List;
-@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-06-03T00:41:43.242+08:00")
+
public class ApiException extends Exception {
- private int code = 0;
- private Map> responseHeaders = null;
- private String responseBody = null;
+ private int code = 0;
+ private Map> responseHeaders = null;
+ private String responseBody = null;
- public ApiException() {}
+ public ApiException() {}
- public ApiException(Throwable throwable) {
- super(throwable);
- }
+ public ApiException(Throwable throwable) {
+ super(throwable);
+ }
- public ApiException(String message) {
- super(message);
- }
+ public ApiException(String message) {
+ super(message);
+ }
- public ApiException(String message, Throwable throwable, int code, Map> responseHeaders, String responseBody) {
- super(message, throwable);
- this.code = code;
- this.responseHeaders = responseHeaders;
- this.responseBody = responseBody;
- }
+ public ApiException(String message, Throwable throwable, int code, Map> responseHeaders, String responseBody) {
+ super(message, throwable);
+ this.code = code;
+ this.responseHeaders = responseHeaders;
+ this.responseBody = responseBody;
+ }
- public ApiException(String message, int code, Map> responseHeaders, String responseBody) {
- this(message, (Throwable) null, code, responseHeaders, responseBody);
- }
+ public ApiException(String message, int code, Map> responseHeaders, String responseBody) {
+ this(message, (Throwable) null, code, responseHeaders, responseBody);
+ }
- public ApiException(String message, Throwable throwable, int code, Map> responseHeaders) {
- this(message, throwable, code, responseHeaders, null);
- }
+ public ApiException(String message, Throwable throwable, int code, Map> responseHeaders) {
+ this(message, throwable, code, responseHeaders, null);
+ }
- public ApiException(int code, Map> responseHeaders, String responseBody) {
- this((String) null, (Throwable) null, code, responseHeaders, responseBody);
- }
+ public ApiException(int code, Map> responseHeaders, String responseBody) {
+ this((String) null, (Throwable) null, code, responseHeaders, responseBody);
+ }
- public ApiException(int code, String message) {
- super(message);
- this.code = code;
- }
+ public ApiException(int code, String message) {
+ super(message);
+ this.code = code;
+ }
- public ApiException(int code, String message, Map> responseHeaders, String responseBody) {
- this(code, message);
- this.responseHeaders = responseHeaders;
- this.responseBody = responseBody;
- }
+ public ApiException(int code, String message, Map> responseHeaders, String responseBody) {
+ this(code, message);
+ this.responseHeaders = responseHeaders;
+ this.responseBody = responseBody;
+ }
- public int getCode() {
- return code;
- }
+ /**
+ * Get the HTTP status code.
+ *
+ * @return HTTP status code
+ */
+ public int getCode() {
+ return code;
+ }
- /**
- * Get the HTTP response headers.
- */
- public Map> getResponseHeaders() {
- return responseHeaders;
- }
+ /**
+ * Get the HTTP response headers.
+ *
+ * @return A map of list of string
+ */
+ public Map> getResponseHeaders() {
+ return responseHeaders;
+ }
- /**
- * Get the HTTP response body.
- */
- public String getResponseBody() {
- return responseBody;
- }
+ /**
+ * Get the HTTP response body.
+ *
+ * @return Response body in the form of string
+ */
+ public String getResponseBody() {
+ return responseBody;
+ }
}
diff --git a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/Configuration.java b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/Configuration.java
index bbfa1a1c4ee..cbdadd6262d 100644
--- a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/Configuration.java
+++ b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/Configuration.java
@@ -1,22 +1,51 @@
+/**
+ * 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.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
package io.swagger.client;
-@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-06-03T00:41:43.242+08:00")
+
public class Configuration {
- private static ApiClient defaultApiClient = new ApiClient();
+ private static ApiClient defaultApiClient = new ApiClient();
- /**
- * Get the default API client, which would be used when creating API
- * instances without providing an API client.
- */
- public static ApiClient getDefaultApiClient() {
- return defaultApiClient;
- }
+ /**
+ * Get the default API client, which would be used when creating API
+ * instances without providing an API client.
+ *
+ * @return Default API client
+ */
+ public static ApiClient getDefaultApiClient() {
+ return defaultApiClient;
+ }
- /**
- * Set the default API client, which would be used when creating API
- * instances without providing an API client.
- */
- public static void setDefaultApiClient(ApiClient apiClient) {
- defaultApiClient = apiClient;
- }
+ /**
+ * Set the default API client, which would be used when creating API
+ * instances without providing an API client.
+ *
+ * @param apiClient API client
+ */
+ public static void setDefaultApiClient(ApiClient apiClient) {
+ defaultApiClient = apiClient;
+ }
}
diff --git a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/JSON.java b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/JSON.java
index f38b16d55ad..d6f725b2caa 100644
--- a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/JSON.java
+++ b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/JSON.java
@@ -8,7 +8,7 @@ import java.text.DateFormat;
import javax.ws.rs.ext.ContextResolver;
-@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-06-03T00:41:43.242+08:00")
+
public class JSON implements ContextResolver {
private ObjectMapper mapper;
diff --git a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/Pair.java b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/Pair.java
index 863136c9ef6..4b44c415812 100644
--- a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/Pair.java
+++ b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/Pair.java
@@ -1,6 +1,31 @@
+/**
+ * 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.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
package io.swagger.client;
-@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-06-03T00:41:43.242+08:00")
+
public class Pair {
private String name = "";
private String value = "";
diff --git a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/StringUtil.java b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/StringUtil.java
index 9bd7767e8a2..03c6c81e434 100644
--- a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/StringUtil.java
+++ b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/StringUtil.java
@@ -1,6 +1,31 @@
+/**
+ * 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.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
package io.swagger.client;
-@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-06-03T00:41:43.242+08:00")
+
public class StringUtil {
/**
* Check if the given array contains the given value (with case-insensitive comparison).
diff --git a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/api/FakeApi.java b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/api/FakeApi.java
index e120b12d42c..b8b499c4dee 100644
--- a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/api/FakeApi.java
+++ b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/api/FakeApi.java
@@ -7,15 +7,16 @@ import io.swagger.client.Pair;
import javax.ws.rs.core.GenericType;
+import org.joda.time.LocalDate;
+import org.joda.time.DateTime;
import java.math.BigDecimal;
-import java.util.Date;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
-@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-06-03T00:41:43.242+08:00")
+
public class FakeApi {
private ApiClient apiClient;
@@ -52,7 +53,7 @@ public class FakeApi {
* @param password None (optional)
* @throws ApiException if fails to make API call
*/
- public void testEndpointParameters(BigDecimal number, Double _double, String string, byte[] _byte, Integer integer, Integer int32, Long int64, Float _float, byte[] binary, Date date, Date dateTime, String password) throws ApiException {
+ public void testEndpointParameters(BigDecimal number, Double _double, String string, byte[] _byte, Integer integer, Integer int32, Long int64, Float _float, byte[] binary, LocalDate date, DateTime dateTime, String password) throws ApiException {
Object localVarPostBody = null;
// verify the required parameter 'number' is set
diff --git a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/api/PetApi.java b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/api/PetApi.java
index f09defffe3c..ab85c4ac394 100644
--- a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/api/PetApi.java
+++ b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/api/PetApi.java
@@ -8,15 +8,15 @@ import io.swagger.client.Pair;
import javax.ws.rs.core.GenericType;
import io.swagger.client.model.Pet;
-import io.swagger.client.model.ModelApiResponse;
import java.io.File;
+import io.swagger.client.model.ModelApiResponse;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
-@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-06-03T00:41:43.242+08:00")
+
public class PetApi {
private ApiClient apiClient;
diff --git a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/api/StoreApi.java b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/api/StoreApi.java
index 36336fe8c0b..c0c9a166ad7 100644
--- a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/api/StoreApi.java
+++ b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/api/StoreApi.java
@@ -14,7 +14,7 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
-@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-06-03T00:41:43.242+08:00")
+
public class StoreApi {
private ApiClient apiClient;
diff --git a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/api/UserApi.java b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/api/UserApi.java
index 42e08132830..7602f4e2ba9 100644
--- a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/api/UserApi.java
+++ b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/api/UserApi.java
@@ -14,7 +14,7 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
-@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-06-03T00:41:43.242+08:00")
+
public class UserApi {
private ApiClient apiClient;
diff --git a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/auth/ApiKeyAuth.java b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/auth/ApiKeyAuth.java
index 6d5c20361ef..6ba15566b60 100644
--- a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/auth/ApiKeyAuth.java
+++ b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/auth/ApiKeyAuth.java
@@ -1,3 +1,28 @@
+/**
+ * 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.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
package io.swagger.client.auth;
import io.swagger.client.Pair;
@@ -5,7 +30,7 @@ import io.swagger.client.Pair;
import java.util.Map;
import java.util.List;
-@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-06-03T00:41:43.242+08:00")
+
public class ApiKeyAuth implements Authentication {
private final String location;
private final String paramName;
diff --git a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/auth/Authentication.java b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/auth/Authentication.java
index 98b1a6900b9..a063a6998b5 100644
--- a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/auth/Authentication.java
+++ b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/auth/Authentication.java
@@ -1,3 +1,28 @@
+/**
+ * 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.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
package io.swagger.client.auth;
import io.swagger.client.Pair;
@@ -6,6 +31,11 @@ import java.util.Map;
import java.util.List;
public interface Authentication {
- /** Apply authentication settings to header and query params. */
- void applyToParams(List queryParams, Map headerParams);
+ /**
+ * Apply authentication settings to header and query params.
+ *
+ * @param queryParams List of query parameters
+ * @param headerParams Map of header parameters
+ */
+ void applyToParams(List queryParams, Map headerParams);
}
diff --git a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/auth/HttpBasicAuth.java b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/auth/HttpBasicAuth.java
index 8bc5686d3c1..5895370e4d4 100644
--- a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/auth/HttpBasicAuth.java
+++ b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/auth/HttpBasicAuth.java
@@ -1,3 +1,28 @@
+/**
+ * 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.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
package io.swagger.client.auth;
import io.swagger.client.Pair;
@@ -9,7 +34,7 @@ import java.util.List;
import java.io.UnsupportedEncodingException;
-@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-06-03T00:41:43.242+08:00")
+
public class HttpBasicAuth implements Authentication {
private String username;
private String password;
diff --git a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/auth/OAuth.java b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/auth/OAuth.java
index 140ee3d63c9..8802ebc92c8 100644
--- a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/auth/OAuth.java
+++ b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/auth/OAuth.java
@@ -1,3 +1,28 @@
+/**
+ * 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.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
package io.swagger.client.auth;
import io.swagger.client.Pair;
@@ -5,7 +30,7 @@ import io.swagger.client.Pair;
import java.util.Map;
import java.util.List;
-@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-06-03T00:41:43.242+08:00")
+
public class OAuth implements Authentication {
private String accessToken;
diff --git a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/auth/OAuthFlow.java b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/auth/OAuthFlow.java
index 597ec99b48b..ec1f942b0f2 100644
--- a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/auth/OAuthFlow.java
+++ b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/auth/OAuthFlow.java
@@ -1,5 +1,30 @@
+/**
+ * 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.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
package io.swagger.client.auth;
public enum OAuthFlow {
accessCode, implicit, password, application
-}
\ No newline at end of file
+}
diff --git a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/AdditionalPropertiesClass.java b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/AdditionalPropertiesClass.java
index 4c9d7b51a02..ccaba7709c4 100644
--- a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/AdditionalPropertiesClass.java
+++ b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/AdditionalPropertiesClass.java
@@ -13,7 +13,7 @@ import java.util.Map;
/**
* AdditionalPropertiesClass
*/
-@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-06-03T00:41:43.242+08:00")
+
public class AdditionalPropertiesClass {
private Map mapProperty = new HashMap();
diff --git a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/Animal.java b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/Animal.java
index 3506eb25298..25c7d3e421c 100644
--- a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/Animal.java
+++ b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/Animal.java
@@ -10,7 +10,7 @@ import io.swagger.annotations.ApiModelProperty;
/**
* Animal
*/
-@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-06-03T00:41:43.242+08:00")
+
public class Animal {
private String className = null;
diff --git a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/AnimalFarm.java b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/AnimalFarm.java
index e035fb41d85..647e3a893e1 100644
--- a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/AnimalFarm.java
+++ b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/AnimalFarm.java
@@ -10,7 +10,7 @@ import java.util.List;
/**
* AnimalFarm
*/
-@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-06-03T00:41:43.242+08:00")
+
public class AnimalFarm extends ArrayList {
diff --git a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/ArrayTest.java b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/ArrayTest.java
index 7b4d2bb3cc3..6c1eb23d8d0 100644
--- a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/ArrayTest.java
+++ b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/ArrayTest.java
@@ -12,7 +12,7 @@ import java.util.List;
/**
* ArrayTest
*/
-@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-06-03T00:41:43.242+08:00")
+
public class ArrayTest {
private List arrayOfString = new ArrayList();
diff --git a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/Cat.java b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/Cat.java
index 19d57357959..5ef9e23bd96 100644
--- a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/Cat.java
+++ b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/Cat.java
@@ -11,7 +11,7 @@ import io.swagger.client.model.Animal;
/**
* Cat
*/
-@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-06-03T00:41:43.242+08:00")
+
public class Cat extends Animal {
private String className = null;
diff --git a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/Category.java b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/Category.java
index 5f8edb7f80f..c6cb703a89e 100644
--- a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/Category.java
+++ b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/Category.java
@@ -10,7 +10,7 @@ import io.swagger.annotations.ApiModelProperty;
/**
* Category
*/
-@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-06-03T00:41:43.242+08:00")
+
public class Category {
private Long id = null;
diff --git a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/Dog.java b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/Dog.java
index 2c01fa4f1a1..4b3cc947cc5 100644
--- a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/Dog.java
+++ b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/Dog.java
@@ -11,7 +11,7 @@ import io.swagger.client.model.Animal;
/**
* Dog
*/
-@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-06-03T00:41:43.242+08:00")
+
public class Dog extends Animal {
private String className = null;
diff --git a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/EnumTest.java b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/EnumTest.java
index 08d5c3d617a..1c8657fd3ec 100644
--- a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/EnumTest.java
+++ b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/EnumTest.java
@@ -11,7 +11,7 @@ import io.swagger.annotations.ApiModelProperty;
/**
* EnumTest
*/
-@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-06-03T00:41:43.242+08:00")
+
public class EnumTest {
diff --git a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/FormatTest.java b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/FormatTest.java
index 2f80a5dc972..79376150017 100644
--- a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/FormatTest.java
+++ b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/FormatTest.java
@@ -6,13 +6,14 @@ import com.fasterxml.jackson.annotation.JsonProperty;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import java.math.BigDecimal;
-import java.util.Date;
+import org.joda.time.DateTime;
+import org.joda.time.LocalDate;
/**
* FormatTest
*/
-@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-06-03T00:41:43.242+08:00")
+
public class FormatTest {
private Integer integer = null;
@@ -24,8 +25,8 @@ public class FormatTest {
private String string = null;
private byte[] _byte = null;
private byte[] binary = null;
- private Date date = null;
- private Date dateTime = null;
+ private LocalDate date = null;
+ private DateTime dateTime = null;
private String uuid = null;
private String password = null;
@@ -195,34 +196,34 @@ public class FormatTest {
/**
**/
- public FormatTest date(Date date) {
+ public FormatTest date(LocalDate date) {
this.date = date;
return this;
}
@ApiModelProperty(example = "null", required = true, value = "")
@JsonProperty("date")
- public Date getDate() {
+ public LocalDate getDate() {
return date;
}
- public void setDate(Date date) {
+ public void setDate(LocalDate date) {
this.date = date;
}
/**
**/
- public FormatTest dateTime(Date dateTime) {
+ public FormatTest dateTime(DateTime dateTime) {
this.dateTime = dateTime;
return this;
}
@ApiModelProperty(example = "null", value = "")
@JsonProperty("dateTime")
- public Date getDateTime() {
+ public DateTime getDateTime() {
return dateTime;
}
- public void setDateTime(Date dateTime) {
+ public void setDateTime(DateTime dateTime) {
this.dateTime = dateTime;
}
diff --git a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/MixedPropertiesAndAdditionalPropertiesClass.java b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/MixedPropertiesAndAdditionalPropertiesClass.java
index c55c44aa4c7..2f0972bf41e 100644
--- a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/MixedPropertiesAndAdditionalPropertiesClass.java
+++ b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/MixedPropertiesAndAdditionalPropertiesClass.java
@@ -6,20 +6,20 @@ import com.fasterxml.jackson.annotation.JsonProperty;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import io.swagger.client.model.Animal;
-import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
+import org.joda.time.DateTime;
/**
* MixedPropertiesAndAdditionalPropertiesClass
*/
-@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-06-03T00:41:43.242+08:00")
+
public class MixedPropertiesAndAdditionalPropertiesClass {
private String uuid = null;
- private Date dateTime = null;
+ private DateTime dateTime = null;
private Map map = new HashMap();
@@ -42,17 +42,17 @@ public class MixedPropertiesAndAdditionalPropertiesClass {
/**
**/
- public MixedPropertiesAndAdditionalPropertiesClass dateTime(Date dateTime) {
+ public MixedPropertiesAndAdditionalPropertiesClass dateTime(DateTime dateTime) {
this.dateTime = dateTime;
return this;
}
@ApiModelProperty(example = "null", value = "")
@JsonProperty("dateTime")
- public Date getDateTime() {
+ public DateTime getDateTime() {
return dateTime;
}
- public void setDateTime(Date dateTime) {
+ public void setDateTime(DateTime dateTime) {
this.dateTime = dateTime;
}
diff --git a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/Model200Response.java b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/Model200Response.java
index 3a3014b87c0..b2809525c7f 100644
--- a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/Model200Response.java
+++ b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/Model200Response.java
@@ -11,7 +11,7 @@ import io.swagger.annotations.ApiModelProperty;
* Model for testing model name starting with number
*/
@ApiModel(description = "Model for testing model name starting with number")
-@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-06-03T00:41:43.242+08:00")
+
public class Model200Response {
private Integer name = null;
diff --git a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/ModelApiResponse.java b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/ModelApiResponse.java
index b8e916043e5..32fb86dd323 100644
--- a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/ModelApiResponse.java
+++ b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/ModelApiResponse.java
@@ -10,7 +10,7 @@ import io.swagger.annotations.ApiModelProperty;
/**
* ModelApiResponse
*/
-@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-06-03T00:41:43.242+08:00")
+
public class ModelApiResponse {
private Integer code = null;
diff --git a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/ModelReturn.java b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/ModelReturn.java
index 28df30b73f0..a076d16f964 100644
--- a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/ModelReturn.java
+++ b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/ModelReturn.java
@@ -11,7 +11,7 @@ import io.swagger.annotations.ApiModelProperty;
* Model for testing reserved words
*/
@ApiModel(description = "Model for testing reserved words")
-@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-06-03T00:41:43.242+08:00")
+
public class ModelReturn {
private Integer _return = null;
diff --git a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/Name.java b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/Name.java
index 091e716d948..1ba2cc5e4a3 100644
--- a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/Name.java
+++ b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/Name.java
@@ -11,7 +11,7 @@ import io.swagger.annotations.ApiModelProperty;
* Model for testing model name same as property name
*/
@ApiModel(description = "Model for testing model name same as property name")
-@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-06-03T00:41:43.242+08:00")
+
public class Name {
private Integer name = null;
diff --git a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/Order.java b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/Order.java
index 40c54de3071..cec651e73a6 100644
--- a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/Order.java
+++ b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/Order.java
@@ -6,19 +6,19 @@ import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonValue;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
-import java.util.Date;
+import org.joda.time.DateTime;
/**
* Order
*/
-@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-06-03T00:41:43.242+08:00")
+
public class Order {
private Long id = null;
private Long petId = null;
private Integer quantity = null;
- private Date shipDate = null;
+ private DateTime shipDate = null;
/**
* Order Status
@@ -98,17 +98,17 @@ public class Order {
/**
**/
- public Order shipDate(Date shipDate) {
+ public Order shipDate(DateTime shipDate) {
this.shipDate = shipDate;
return this;
}
@ApiModelProperty(example = "null", value = "")
@JsonProperty("shipDate")
- public Date getShipDate() {
+ public DateTime getShipDate() {
return shipDate;
}
- public void setShipDate(Date shipDate) {
+ public void setShipDate(DateTime shipDate) {
this.shipDate = shipDate;
}
diff --git a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/Pet.java b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/Pet.java
index 2ec54dd8d8f..da8b76ad024 100644
--- a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/Pet.java
+++ b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/Pet.java
@@ -15,7 +15,7 @@ import java.util.List;
/**
* Pet
*/
-@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-06-03T00:41:43.242+08:00")
+
public class Pet {
private Long id = null;
diff --git a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/ReadOnlyFirst.java b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/ReadOnlyFirst.java
index 268c6adc65e..fdc3587df0e 100644
--- a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/ReadOnlyFirst.java
+++ b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/ReadOnlyFirst.java
@@ -10,7 +10,7 @@ import io.swagger.annotations.ApiModelProperty;
/**
* ReadOnlyFirst
*/
-@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-06-03T00:41:43.242+08:00")
+
public class ReadOnlyFirst {
private String bar = null;
diff --git a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/SpecialModelName.java b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/SpecialModelName.java
index 3b2003b6e47..24e57756cb2 100644
--- a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/SpecialModelName.java
+++ b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/SpecialModelName.java
@@ -10,7 +10,7 @@ import io.swagger.annotations.ApiModelProperty;
/**
* SpecialModelName
*/
-@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-06-03T00:41:43.242+08:00")
+
public class SpecialModelName {
private Long specialPropertyName = null;
diff --git a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/Tag.java b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/Tag.java
index 277e48fa0b2..9d3bdd8cb9e 100644
--- a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/Tag.java
+++ b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/Tag.java
@@ -10,7 +10,7 @@ import io.swagger.annotations.ApiModelProperty;
/**
* Tag
*/
-@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-06-03T00:41:43.242+08:00")
+
public class Tag {
private Long id = null;
diff --git a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/User.java b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/User.java
index d1f924eb2a8..f23553660de 100644
--- a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/User.java
+++ b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/User.java
@@ -10,7 +10,7 @@ import io.swagger.annotations.ApiModelProperty;
/**
* User
*/
-@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-06-03T00:41:43.242+08:00")
+
public class User {
private Long id = null;
diff --git a/samples/client/petstore/java/jersey2/src/test/java/io/swagger/client/ApiClientTest.java b/samples/client/petstore/java/jersey2/src/test/java/io/swagger/client/ApiClientTest.java
index 47f004c283b..19b55257d0c 100644
--- a/samples/client/petstore/java/jersey2/src/test/java/io/swagger/client/ApiClientTest.java
+++ b/samples/client/petstore/java/jersey2/src/test/java/io/swagger/client/ApiClientTest.java
@@ -111,6 +111,7 @@ public class ApiClientTest {
}
}
+ @Ignore("There is no more basic auth in petstore security definitions")
@Test
public void testSetUsernameAndPassword() {
HttpBasicAuth auth = null;
diff --git a/samples/client/petstore/java/jersey2/src/test/java/io/swagger/client/JSONTest.java b/samples/client/petstore/java/jersey2/src/test/java/io/swagger/client/JSONTest.java
index f10909ab9e7..9386b3d5236 100644
--- a/samples/client/petstore/java/jersey2/src/test/java/io/swagger/client/JSONTest.java
+++ b/samples/client/petstore/java/jersey2/src/test/java/io/swagger/client/JSONTest.java
@@ -3,10 +3,10 @@ package io.swagger.client;
import io.swagger.client.model.Order;
import java.lang.Exception;
-import java.text.DateFormat;
-import java.text.SimpleDateFormat;
-import java.util.TimeZone;
+import org.joda.time.DateTimeZone;
+import org.joda.time.format.DateTimeFormatter;
+import org.joda.time.format.ISODateTimeFormat;
import org.junit.*;
import static org.junit.Assert.*;
@@ -23,26 +23,23 @@ public class JSONTest {
@Test
public void testDefaultDate() throws Exception {
- final DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSXXX");
- dateFormat.setTimeZone(TimeZone.getTimeZone("UTC"));
+ final DateTimeFormatter dateFormat = ISODateTimeFormat.dateTime();
final String dateStr = "2015-11-07T14:11:05.267Z";
- order.setShipDate(dateFormat.parse(dateStr));
+ order.setShipDate(dateFormat.parseDateTime(dateStr));
String str = json.getContext(null).writeValueAsString(order);
Order o = json.getContext(null).readValue(str, Order.class);
- assertEquals(dateStr, dateFormat.format(o.getShipDate()));
+ assertEquals(dateStr, dateFormat.print(o.getShipDate()));
}
@Test
public void testCustomDate() throws Exception {
- final DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssXXX");
- dateFormat.setTimeZone(TimeZone.getTimeZone("GMT-2"));
+ final DateTimeFormatter dateFormat = ISODateTimeFormat.dateTimeNoMillis().withZone(DateTimeZone.forID("Etc/GMT+2"));
final String dateStr = "2015-11-07T14:11:05-02:00";
- order.setShipDate(dateFormat.parse(dateStr));
+ order.setShipDate(dateFormat.parseDateTime(dateStr));
- json.setDateFormat(dateFormat);
String str = json.getContext(null).writeValueAsString(order);
Order o = json.getContext(null).readValue(str, Order.class);
- assertEquals(dateStr, dateFormat.format(o.getShipDate()));
+ assertEquals(dateStr, dateFormat.print(o.getShipDate()));
}
}
\ No newline at end of file
diff --git a/samples/client/petstore/java/jersey2/src/test/java/io/swagger/client/api/PetApiTest.java b/samples/client/petstore/java/jersey2/src/test/java/io/swagger/client/api/PetApiTest.java
index c25e0d8bfa2..7f4d27c8b77 100644
--- a/samples/client/petstore/java/jersey2/src/test/java/io/swagger/client/api/PetApiTest.java
+++ b/samples/client/petstore/java/jersey2/src/test/java/io/swagger/client/api/PetApiTest.java
@@ -1,155 +1,288 @@
package io.swagger.client.api;
-import io.swagger.client.ApiException;
-import io.swagger.client.model.Pet;
-import io.swagger.client.model.ModelApiResponse;
-import java.io.File;
-import org.junit.Test;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import io.swagger.TestUtils;
+
+import io.swagger.client.*;
+import io.swagger.client.api.*;
+import io.swagger.client.auth.*;
+import io.swagger.client.model.*;
+
+import java.io.BufferedWriter;
+import java.io.File;
+import java.io.FileWriter;
import java.util.ArrayList;
-import java.util.HashMap;
+import java.util.Arrays;
import java.util.List;
import java.util.Map;
-/**
- * API tests for PetApi
- */
+import org.junit.*;
+import static org.junit.Assert.*;
+
public class PetApiTest {
+ PetApi api = null;
- private final PetApi api = new PetApi();
-
-
- /**
- * Add a new pet to the store
- *
- *
- *
- * @throws ApiException
- * if the Api call fails
- */
- @Test
- public void addPetTest() throws ApiException {
- Pet body = null;
- // api.addPet(body);
-
- // TODO: test validations
+ @Before
+ public void setup() {
+ api = new PetApi();
+ // setup authentication
+ ApiKeyAuth apiKeyAuth = (ApiKeyAuth) api.getApiClient().getAuthentication("api_key");
+ apiKeyAuth.setApiKey("special-key");
}
-
- /**
- * Deletes a pet
- *
- *
- *
- * @throws ApiException
- * if the Api call fails
- */
- @Test
- public void deletePetTest() throws ApiException {
- Long petId = null;
- String apiKey = null;
- // api.deletePet(petId, apiKey);
- // TODO: test validations
- }
-
- /**
- * Finds Pets by status
- *
- * Multiple status values can be provided with comma separated strings
- *
- * @throws ApiException
- * if the Api call fails
- */
@Test
- public void findPetsByStatusTest() throws ApiException {
- List status = null;
- // List response = api.findPetsByStatus(status);
+ public void testApiClient() {
+ // the default api client is used
+ assertEquals(Configuration.getDefaultApiClient(), api.getApiClient());
+ assertNotNull(api.getApiClient());
+ assertEquals("http://petstore.swagger.io/v2", api.getApiClient().getBasePath());
+ assertFalse(api.getApiClient().isDebugging());
- // TODO: test validations
+ ApiClient oldClient = api.getApiClient();
+
+ ApiClient newClient = new ApiClient();
+ newClient.setBasePath("http://example.com");
+ newClient.setDebugging(true);
+
+ // set api client via constructor
+ api = new PetApi(newClient);
+ assertNotNull(api.getApiClient());
+ assertEquals("http://example.com", api.getApiClient().getBasePath());
+ assertTrue(api.getApiClient().isDebugging());
+
+ // set api client via setter method
+ api.setApiClient(oldClient);
+ assertNotNull(api.getApiClient());
+ assertEquals("http://petstore.swagger.io/v2", api.getApiClient().getBasePath());
+ assertFalse(api.getApiClient().isDebugging());
}
-
- /**
- * Finds Pets by tags
- *
- * Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.
- *
- * @throws ApiException
- * if the Api call fails
- */
+
@Test
- public void findPetsByTagsTest() throws ApiException {
- List tags = null;
- // List response = api.findPetsByTags(tags);
+ public void testCreateAndGetPet() throws Exception {
+ Pet pet = createRandomPet();
+ api.addPet(pet);
- // TODO: test validations
+ Pet fetched = api.getPetById(pet.getId());
+ assertNotNull(fetched);
+ assertEquals(pet.getId(), fetched.getId());
+ assertNotNull(fetched.getCategory());
+ assertEquals(fetched.getCategory().getName(), pet.getCategory().getName());
}
-
- /**
- * Find pet by ID
- *
- * Returns a single pet
- *
- * @throws ApiException
- * if the Api call fails
- */
+
+ /*
@Test
- public void getPetByIdTest() throws ApiException {
- Long petId = null;
- // Pet response = api.getPetById(petId);
+ public void testCreateAndGetPetWithByteArray() throws Exception {
+ Pet pet = createRandomPet();
+ byte[] bytes = serializeJson(pet, api.getApiClient()).getBytes();
+ api.addPetUsingByteArray(bytes);
- // TODO: test validations
+ byte[] fetchedBytes = api.petPetIdtestingByteArraytrueGet(pet.getId());
+ Pet fetched = deserializeJson(new String(fetchedBytes), Pet.class, api.getApiClient());
+ assertNotNull(fetched);
+ assertEquals(pet.getId(), fetched.getId());
+ assertNotNull(fetched.getCategory());
+ assertEquals(fetched.getCategory().getName(), pet.getCategory().getName());
}
-
- /**
- * Update an existing pet
- *
- *
- *
- * @throws ApiException
- * if the Api call fails
- */
+
@Test
- public void updatePetTest() throws ApiException {
- Pet body = null;
- // api.updatePet(body);
+ public void testGetPetByIdInObject() throws Exception {
+ Pet pet = new Pet();
+ pet.setId(TestUtils.nextId());
+ pet.setName("pet " + pet.getId());
- // TODO: test validations
+ Category category = new Category();
+ category.setId(TestUtils.nextId());
+ category.setName("category " + category.getId());
+ pet.setCategory(category);
+
+ pet.setStatus(Pet.StatusEnum.PENDING);
+ List photos = Arrays.asList(new String[]{"http://foo.bar.com/1"});
+ pet.setPhotoUrls(photos);
+
+ api.addPet(pet);
+
+ InlineResponse200 fetched = api.getPetByIdInObject(pet.getId());
+ assertEquals(pet.getId(), fetched.getId());
+ assertEquals(pet.getName(), fetched.getName());
+
+ Object categoryObj = fetched.getCategory();
+ assertNotNull(categoryObj);
+ assertTrue(categoryObj instanceof Map);
+
+ Map categoryMap = (Map) categoryObj;
+ Object categoryIdObj = categoryMap.get("id");
+ assertTrue(categoryIdObj instanceof Integer);
+ Integer categoryIdInt = (Integer) categoryIdObj;
+ assertEquals(category.getId(), Long.valueOf(categoryIdInt));
+ assertEquals(category.getName(), categoryMap.get("name"));
}
-
- /**
- * Updates a pet in the store with form data
- *
- *
- *
- * @throws ApiException
- * if the Api call fails
- */
+ */
+
@Test
- public void updatePetWithFormTest() throws ApiException {
- Long petId = null;
- String name = null;
- String status = null;
- // api.updatePetWithForm(petId, name, status);
+ public void testUpdatePet() throws Exception {
+ Pet pet = createRandomPet();
+ pet.setName("programmer");
- // TODO: test validations
+ 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());
}
-
- /**
- * uploads an image
- *
- *
- *
- * @throws ApiException
- * if the Api call fails
- */
+
@Test
- public void uploadFileTest() throws ApiException {
- Long petId = null;
- String additionalMetadata = null;
- File file = null;
- // ModelApiResponse response = api.uploadFile(petId, additionalMetadata, file);
+ public void testFindPetsByStatus() throws Exception {
+ Pet pet = createRandomPet();
+ pet.setName("programmer");
+ pet.setStatus(Pet.StatusEnum.AVAILABLE);
- // TODO: test validations
+ api.updatePet(pet);
+
+ List pets = api.findPetsByStatus(Arrays.asList(new String[]{"available"}));
+ assertNotNull(pets);
+
+ boolean found = false;
+ for (Pet fetched : pets) {
+ if (fetched.getId().equals(pet.getId())) {
+ found = true;
+ break;
+ }
+ }
+
+ assertTrue(found);
+ }
+
+ @Test
+ public void testFindPetsByTags() throws Exception {
+ Pet pet = createRandomPet();
+ pet.setName("monster");
+ pet.setStatus(Pet.StatusEnum.AVAILABLE);
+
+ List tags = new ArrayList();
+ Tag tag1 = new Tag();
+ tag1.setName("friendly");
+ tags.add(tag1);
+ pet.setTags(tags);
+
+ api.updatePet(pet);
+
+ List pets = api.findPetsByTags(Arrays.asList(new String[]{"friendly"}));
+ assertNotNull(pets);
+
+ boolean found = false;
+ for (Pet fetched : pets) {
+ if (fetched.getId().equals(pet.getId())) {
+ found = true;
+ break;
+ }
+ }
+ assertTrue(found);
+ }
+
+ @Test
+ public void testUpdatePetWithForm() throws Exception {
+ Pet pet = createRandomPet();
+ pet.setName("frank");
+ api.addPet(pet);
+
+ Pet fetched = api.getPetById(pet.getId());
+
+ api.updatePetWithForm(fetched.getId(), "furt", null);
+ Pet updated = api.getPetById(fetched.getId());
+
+ assertEquals(updated.getName(), "furt");
+ }
+
+ @Test
+ public void testDeletePet() throws Exception {
+ Pet pet = createRandomPet();
+ api.addPet(pet);
+
+ Pet fetched = api.getPetById(pet.getId());
+ api.deletePet(fetched.getId(), null);
+
+ try {
+ fetched = api.getPetById(fetched.getId());
+ fail("expected an error");
+ } catch (ApiException e) {
+ assertEquals(404, e.getCode());
+ }
+ }
+
+ @Test
+ public void testUploadFile() throws Exception {
+ Pet pet = createRandomPet();
+ api.addPet(pet);
+
+ 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()));
+ }
+
+ @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());
+
+ pet2.setName("really-happy");
+ pet2.setPhotoUrls(Arrays.asList(new String[]{"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(new String[]{"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());
+ }
+
+ 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 photos = Arrays.asList(new String[]{"http://foo.bar.com/1", "http://foo.bar.com/2"});
+ pet.setPhotoUrls(photos);
+
+ return pet;
+ }
+
+ private String serializeJson(Object o, ApiClient apiClient) {
+ ObjectMapper mapper = apiClient.getJSON().getContext(null);
+ try {
+ return mapper.writeValueAsString(o);
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ private T deserializeJson(String json, Class klass, ApiClient apiClient) {
+ ObjectMapper mapper = apiClient.getJSON().getContext(null);
+ try {
+ return mapper.readValue(json, klass);
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
}
-
}
diff --git a/samples/client/petstore/java/jersey2/src/test/java/io/swagger/client/api/StoreApiTest.java b/samples/client/petstore/java/jersey2/src/test/java/io/swagger/client/api/StoreApiTest.java
index 31abbbeae4e..3cc2442c64d 100644
--- a/samples/client/petstore/java/jersey2/src/test/java/io/swagger/client/api/StoreApiTest.java
+++ b/samples/client/petstore/java/jersey2/src/test/java/io/swagger/client/api/StoreApiTest.java
@@ -1,83 +1,100 @@
package io.swagger.client.api;
-import io.swagger.client.ApiException;
-import io.swagger.client.model.Order;
-import org.junit.Test;
+import io.swagger.TestUtils;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
+import io.swagger.client.*;
+import io.swagger.client.auth.*;
+import io.swagger.client.model.*;
+
+import java.lang.reflect.Field;
import java.util.Map;
+import java.text.SimpleDateFormat;
+
+import org.joda.time.DateTime;
+import org.joda.time.DateTimeZone;
+import org.junit.*;
+import static org.junit.Assert.*;
-/**
- * API tests for StoreApi
- */
public class StoreApiTest {
+ StoreApi api = null;
- private final StoreApi api = new StoreApi();
-
-
- /**
- * Delete purchase order by ID
- *
- * For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors
- *
- * @throws ApiException
- * if the Api call fails
- */
- @Test
- public void deleteOrderTest() throws ApiException {
- String orderId = null;
- // api.deleteOrder(orderId);
-
- // TODO: test validations
+ @Before
+ public void setup() {
+ api = new StoreApi();
+ // setup authentication
+ ApiKeyAuth apiKeyAuth = (ApiKeyAuth) api.getApiClient().getAuthentication("api_key");
+ apiKeyAuth.setApiKey("special-key");
+ // set custom date format that is used by the petstore server
+ api.getApiClient().setDateFormat(new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSZ"));
}
-
- /**
- * Returns pet inventories by status
- *
- * Returns a map of status codes to quantities
- *
- * @throws ApiException
- * if the Api call fails
- */
- @Test
- public void getInventoryTest() throws ApiException {
- // Map response = api.getInventory();
- // TODO: test validations
- }
-
- /**
- * Find purchase order by ID
- *
- * For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions
- *
- * @throws ApiException
- * if the Api call fails
- */
@Test
- public void getOrderByIdTest() throws ApiException {
- Long orderId = null;
- // Order response = api.getOrderById(orderId);
-
- // TODO: test validations
+ public void testGetInventory() throws Exception {
+ Map inventory = api.getInventory();
+ assertTrue(inventory.keySet().size() > 0);
}
-
- /**
- * Place an order for a pet
- *
- *
- *
- * @throws ApiException
- * if the Api call fails
- */
+
+ /*
@Test
- public void placeOrderTest() throws ApiException {
- Order body = null;
- // Order response = api.placeOrder(body);
+ public void testGetInventoryInObject() throws Exception {
+ Object inventoryObj = api.getInventoryInObject();
+ assertTrue(inventoryObj instanceof Map);
- // TODO: test validations
+ Map inventoryMap = (Map) inventoryObj;
+ assertTrue(inventoryMap.keySet().size() > 0);
+
+ Map.Entry firstEntry = (Map.Entry) inventoryMap.entrySet().iterator().next();
+ assertTrue(firstEntry.getKey() instanceof String);
+ assertTrue(firstEntry.getValue() instanceof Integer);
+ }
+ */
+
+ @Test
+ public void testPlaceOrder() throws Exception {
+ Order order = createOrder();
+ api.placeOrder(order);
+
+ Order fetched = api.getOrderById(order.getId());
+ assertEquals(order.getId(), fetched.getId());
+ assertEquals(order.getPetId(), fetched.getPetId());
+ assertEquals(order.getQuantity(), fetched.getQuantity());
+ assertEquals(order.getShipDate().withZone(DateTimeZone.UTC), fetched.getShipDate().withZone(DateTimeZone.UTC));
+ }
+
+ @Test
+ public void testDeleteOrder() throws Exception {
+ Order order = createOrder();
+ api.placeOrder(order);
+
+ Order fetched = api.getOrderById(order.getId());
+ assertEquals(fetched.getId(), order.getId());
+
+ api.deleteOrder(String.valueOf(order.getId()));
+
+ try {
+ api.getOrderById(order.getId());
+ // fail("expected an error");
+ } catch (ApiException e) {
+ // ok
+ }
+ }
+
+ private Order createOrder() {
+ Order order = new Order();
+ order.setPetId(new Long(200));
+ order.setQuantity(new Integer(13));
+ order.setShipDate(DateTime.now());
+ order.setStatus(Order.StatusEnum.PLACED);
+ order.setComplete(true);
+
+ try {
+ Field idField = Order.class.getDeclaredField("id");
+ idField.setAccessible(true);
+ idField.set(order, TestUtils.nextId());
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+
+ return order;
}
-
}
diff --git a/samples/client/petstore/java/jersey2/src/test/java/io/swagger/client/api/UserApiTest.java b/samples/client/petstore/java/jersey2/src/test/java/io/swagger/client/api/UserApiTest.java
index 7e96762ff4e..c7fb92d2552 100644
--- a/samples/client/petstore/java/jersey2/src/test/java/io/swagger/client/api/UserApiTest.java
+++ b/samples/client/petstore/java/jersey2/src/test/java/io/swagger/client/api/UserApiTest.java
@@ -1,149 +1,88 @@
package io.swagger.client.api;
-import io.swagger.client.ApiException;
-import io.swagger.client.model.User;
-import org.junit.Test;
+import io.swagger.TestUtils;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
+import io.swagger.client.api.*;
+import io.swagger.client.auth.*;
+import io.swagger.client.model.*;
+
+import java.util.Arrays;
+
+import org.junit.*;
+import static org.junit.Assert.*;
-/**
- * API tests for UserApi
- */
public class UserApiTest {
+ UserApi api = null;
- private final UserApi api = new UserApi();
-
-
- /**
- * Create user
- *
- * This can only be done by the logged in user.
- *
- * @throws ApiException
- * if the Api call fails
- */
- @Test
- public void createUserTest() throws ApiException {
- User body = null;
- // api.createUser(body);
-
- // TODO: test validations
+ @Before
+ public void setup() {
+ api = new UserApi();
+ // setup authentication
+ ApiKeyAuth apiKeyAuth = (ApiKeyAuth) api.getApiClient().getAuthentication("api_key");
+ apiKeyAuth.setApiKey("special-key");
}
-
- /**
- * Creates list of users with given input array
- *
- *
- *
- * @throws ApiException
- * if the Api call fails
- */
- @Test
- public void createUsersWithArrayInputTest() throws ApiException {
- List body = null;
- // api.createUsersWithArrayInput(body);
- // TODO: test validations
- }
-
- /**
- * Creates list of users with given input array
- *
- *
- *
- * @throws ApiException
- * if the Api call fails
- */
@Test
- public void createUsersWithListInputTest() throws ApiException {
- List body = null;
- // api.createUsersWithListInput(body);
+ public void testCreateUser() throws Exception {
+ User user = createUser();
- // TODO: test validations
+ api.createUser(user);
+
+ User fetched = api.getUserByName(user.getUsername());
+ assertEquals(user.getId(), fetched.getId());
}
-
- /**
- * Delete user
- *
- * This can only be done by the logged in user.
- *
- * @throws ApiException
- * if the Api call fails
- */
+
@Test
- public void deleteUserTest() throws ApiException {
- String username = null;
- // api.deleteUser(username);
+ public void testCreateUsersWithArray() throws Exception {
+ User user1 = createUser();
+ user1.setUsername("user" + user1.getId());
+ User user2 = createUser();
+ user2.setUsername("user" + user2.getId());
- // TODO: test validations
+ api.createUsersWithArrayInput(Arrays.asList(new User[]{user1, user2}));
+
+ User fetched = api.getUserByName(user1.getUsername());
+ assertEquals(user1.getId(), fetched.getId());
}
-
- /**
- * Get user by user name
- *
- *
- *
- * @throws ApiException
- * if the Api call fails
- */
+
@Test
- public void getUserByNameTest() throws ApiException {
- String username = null;
- // User response = api.getUserByName(username);
+ public void testCreateUsersWithList() throws Exception {
+ User user1 = createUser();
+ user1.setUsername("user" + user1.getId());
+ User user2 = createUser();
+ user2.setUsername("user" + user2.getId());
- // TODO: test validations
+ api.createUsersWithListInput(Arrays.asList(new User[]{user1, user2}));
+
+ User fetched = api.getUserByName(user1.getUsername());
+ assertEquals(user1.getId(), fetched.getId());
}
-
- /**
- * Logs user into the system
- *
- *
- *
- * @throws ApiException
- * if the Api call fails
- */
+
@Test
- public void loginUserTest() throws ApiException {
- String username = null;
- String password = null;
- // String response = api.loginUser(username, password);
+ public void testLoginUser() throws Exception {
+ User user = createUser();
+ api.createUser(user);
- // TODO: test validations
+ String token = api.loginUser(user.getUsername(), user.getPassword());
+ assertTrue(token.startsWith("logged in user session:"));
}
-
- /**
- * Logs out current logged in user session
- *
- *
- *
- * @throws ApiException
- * if the Api call fails
- */
+
@Test
- public void logoutUserTest() throws ApiException {
- // api.logoutUser();
-
- // TODO: test validations
+ public void logoutUser() throws Exception {
+ api.logoutUser();
}
-
- /**
- * Updated user
- *
- * This can only be done by the logged in user.
- *
- * @throws ApiException
- * if the Api call fails
- */
- @Test
- public void updateUserTest() throws ApiException {
- String username = null;
- User body = null;
- // api.updateUser(username, body);
- // 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);
+
+ return user;
}
-
}
diff --git a/samples/client/petstore/java/jersey2/src/test/java/io/swagger/petstore/test/PetApiTest.java b/samples/client/petstore/java/jersey2/src/test/java/io/swagger/petstore/test/PetApiTest.java
deleted file mode 100644
index 51583853257..00000000000
--- a/samples/client/petstore/java/jersey2/src/test/java/io/swagger/petstore/test/PetApiTest.java
+++ /dev/null
@@ -1,288 +0,0 @@
-package io.swagger.petstore.test;
-
-import com.fasterxml.jackson.databind.ObjectMapper;
-
-import io.swagger.TestUtils;
-
-import io.swagger.client.*;
-import io.swagger.client.api.*;
-import io.swagger.client.auth.*;
-import io.swagger.client.model.*;
-
-import java.io.BufferedWriter;
-import java.io.File;
-import java.io.FileWriter;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
-import java.util.Map;
-
-import org.junit.*;
-import static org.junit.Assert.*;
-
-public class PetApiTest {
- PetApi api = null;
-
- @Before
- public void setup() {
- api = new PetApi();
- // setup authentication
- ApiKeyAuth apiKeyAuth = (ApiKeyAuth) api.getApiClient().getAuthentication("api_key");
- apiKeyAuth.setApiKey("special-key");
- }
-
- @Test
- public void testApiClient() {
- // the default api client is used
- assertEquals(Configuration.getDefaultApiClient(), api.getApiClient());
- assertNotNull(api.getApiClient());
- assertEquals("http://petstore.swagger.io/v2", api.getApiClient().getBasePath());
- assertFalse(api.getApiClient().isDebugging());
-
- ApiClient oldClient = api.getApiClient();
-
- ApiClient newClient = new ApiClient();
- newClient.setBasePath("http://example.com");
- newClient.setDebugging(true);
-
- // set api client via constructor
- api = new PetApi(newClient);
- assertNotNull(api.getApiClient());
- assertEquals("http://example.com", api.getApiClient().getBasePath());
- assertTrue(api.getApiClient().isDebugging());
-
- // set api client via setter method
- api.setApiClient(oldClient);
- assertNotNull(api.getApiClient());
- assertEquals("http://petstore.swagger.io/v2", api.getApiClient().getBasePath());
- assertFalse(api.getApiClient().isDebugging());
- }
-
- @Test
- public void testCreateAndGetPet() throws Exception {
- Pet pet = createRandomPet();
- api.addPet(pet);
-
- Pet fetched = api.getPetById(pet.getId());
- assertNotNull(fetched);
- assertEquals(pet.getId(), fetched.getId());
- assertNotNull(fetched.getCategory());
- assertEquals(fetched.getCategory().getName(), pet.getCategory().getName());
- }
-
- /*
- @Test
- public void testCreateAndGetPetWithByteArray() throws Exception {
- Pet pet = createRandomPet();
- byte[] bytes = serializeJson(pet, api.getApiClient()).getBytes();
- api.addPetUsingByteArray(bytes);
-
- byte[] fetchedBytes = api.petPetIdtestingByteArraytrueGet(pet.getId());
- Pet fetched = deserializeJson(new String(fetchedBytes), Pet.class, api.getApiClient());
- assertNotNull(fetched);
- assertEquals(pet.getId(), fetched.getId());
- assertNotNull(fetched.getCategory());
- assertEquals(fetched.getCategory().getName(), pet.getCategory().getName());
- }
-
- @Test
- public void testGetPetByIdInObject() throws Exception {
- Pet pet = new Pet();
- pet.setId(TestUtils.nextId());
- pet.setName("pet " + pet.getId());
-
- Category category = new Category();
- category.setId(TestUtils.nextId());
- category.setName("category " + category.getId());
- pet.setCategory(category);
-
- pet.setStatus(Pet.StatusEnum.PENDING);
- List photos = Arrays.asList(new String[]{"http://foo.bar.com/1"});
- pet.setPhotoUrls(photos);
-
- api.addPet(pet);
-
- InlineResponse200 fetched = api.getPetByIdInObject(pet.getId());
- assertEquals(pet.getId(), fetched.getId());
- assertEquals(pet.getName(), fetched.getName());
-
- Object categoryObj = fetched.getCategory();
- assertNotNull(categoryObj);
- assertTrue(categoryObj instanceof Map);
-
- Map categoryMap = (Map) categoryObj;
- Object categoryIdObj = categoryMap.get("id");
- assertTrue(categoryIdObj instanceof Integer);
- Integer categoryIdInt = (Integer) categoryIdObj;
- assertEquals(category.getId(), Long.valueOf(categoryIdInt));
- assertEquals(category.getName(), categoryMap.get("name"));
- }
- */
-
- @Test
- public void testUpdatePet() throws Exception {
- Pet pet = createRandomPet();
- pet.setName("programmer");
-
- 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());
- }
-
- @Test
- public void testFindPetsByStatus() throws Exception {
- Pet pet = createRandomPet();
- pet.setName("programmer");
- pet.setStatus(Pet.StatusEnum.AVAILABLE);
-
- api.updatePet(pet);
-
- List pets = api.findPetsByStatus(Arrays.asList(new String[]{"available"}));
- assertNotNull(pets);
-
- boolean found = false;
- for (Pet fetched : pets) {
- if (fetched.getId().equals(pet.getId())) {
- found = true;
- break;
- }
- }
-
- assertTrue(found);
- }
-
- @Test
- public void testFindPetsByTags() throws Exception {
- Pet pet = createRandomPet();
- pet.setName("monster");
- pet.setStatus(Pet.StatusEnum.AVAILABLE);
-
- List tags = new ArrayList();
- Tag tag1 = new Tag();
- tag1.setName("friendly");
- tags.add(tag1);
- pet.setTags(tags);
-
- api.updatePet(pet);
-
- List pets = api.findPetsByTags(Arrays.asList(new String[]{"friendly"}));
- assertNotNull(pets);
-
- boolean found = false;
- for (Pet fetched : pets) {
- if (fetched.getId().equals(pet.getId())) {
- found = true;
- break;
- }
- }
- assertTrue(found);
- }
-
- @Test
- public void testUpdatePetWithForm() throws Exception {
- Pet pet = createRandomPet();
- pet.setName("frank");
- api.addPet(pet);
-
- Pet fetched = api.getPetById(pet.getId());
-
- api.updatePetWithForm(fetched.getId(), "furt", null);
- Pet updated = api.getPetById(fetched.getId());
-
- assertEquals(updated.getName(), "furt");
- }
-
- @Test
- public void testDeletePet() throws Exception {
- Pet pet = createRandomPet();
- api.addPet(pet);
-
- Pet fetched = api.getPetById(pet.getId());
- api.deletePet(fetched.getId(), null);
-
- try {
- fetched = api.getPetById(fetched.getId());
- fail("expected an error");
- } catch (ApiException e) {
- assertEquals(404, e.getCode());
- }
- }
-
- @Test
- public void testUploadFile() throws Exception {
- Pet pet = createRandomPet();
- api.addPet(pet);
-
- 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()));
- }
-
- @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());
-
- pet2.setName("really-happy");
- pet2.setPhotoUrls(Arrays.asList(new String[]{"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(new String[]{"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());
- }
-
- 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 photos = Arrays.asList(new String[]{"http://foo.bar.com/1", "http://foo.bar.com/2"});
- pet.setPhotoUrls(photos);
-
- return pet;
- }
-
- private String serializeJson(Object o, ApiClient apiClient) {
- ObjectMapper mapper = apiClient.getJSON().getContext(null);
- try {
- return mapper.writeValueAsString(o);
- } catch (Exception e) {
- throw new RuntimeException(e);
- }
- }
-
- private T deserializeJson(String json, Class klass, ApiClient apiClient) {
- ObjectMapper mapper = apiClient.getJSON().getContext(null);
- try {
- return mapper.readValue(json, klass);
- } catch (Exception e) {
- throw new RuntimeException(e);
- }
- }
-}
diff --git a/samples/client/petstore/java/jersey2/src/test/java/io/swagger/petstore/test/StoreApiTest.java b/samples/client/petstore/java/jersey2/src/test/java/io/swagger/petstore/test/StoreApiTest.java
deleted file mode 100644
index 7ccbdf3f32b..00000000000
--- a/samples/client/petstore/java/jersey2/src/test/java/io/swagger/petstore/test/StoreApiTest.java
+++ /dev/null
@@ -1,98 +0,0 @@
-package io.swagger.petstore.test;
-
-import io.swagger.TestUtils;
-
-import io.swagger.client.*;
-import io.swagger.client.api.*;
-import io.swagger.client.auth.*;
-import io.swagger.client.model.*;
-
-import java.lang.reflect.Field;
-import java.util.Map;
-import java.text.SimpleDateFormat;
-
-import org.junit.*;
-import static org.junit.Assert.*;
-
-public class StoreApiTest {
- StoreApi api = null;
-
- @Before
- public void setup() {
- api = new StoreApi();
- // setup authentication
- ApiKeyAuth apiKeyAuth = (ApiKeyAuth) api.getApiClient().getAuthentication("api_key");
- apiKeyAuth.setApiKey("special-key");
- // set custom date format that is used by the petstore server
- api.getApiClient().setDateFormat(new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSZ"));
- }
-
- @Test
- public void testGetInventory() throws Exception {
- Map inventory = api.getInventory();
- assertTrue(inventory.keySet().size() > 0);
- }
-
- /*
- @Test
- public void testGetInventoryInObject() throws Exception {
- Object inventoryObj = api.getInventoryInObject();
- assertTrue(inventoryObj instanceof Map);
-
- Map inventoryMap = (Map) inventoryObj;
- assertTrue(inventoryMap.keySet().size() > 0);
-
- Map.Entry firstEntry = (Map.Entry) inventoryMap.entrySet().iterator().next();
- assertTrue(firstEntry.getKey() instanceof String);
- assertTrue(firstEntry.getValue() instanceof Integer);
- }
- */
-
- @Test
- public void testPlaceOrder() throws Exception {
- Order order = createOrder();
- api.placeOrder(order);
-
- Order fetched = api.getOrderById(order.getId());
- assertEquals(order.getId(), fetched.getId());
- assertEquals(order.getPetId(), fetched.getPetId());
- assertEquals(order.getQuantity(), fetched.getQuantity());
- }
-
- @Test
- public void testDeleteOrder() throws Exception {
- Order order = createOrder();
- api.placeOrder(order);
-
- Order fetched = api.getOrderById(order.getId());
- assertEquals(fetched.getId(), order.getId());
-
- api.deleteOrder(String.valueOf(order.getId()));
-
- try {
- api.getOrderById(order.getId());
- // fail("expected an error");
- } catch (ApiException e) {
- // ok
- }
- }
-
- private Order createOrder() {
- Order order = new Order();
- order.setPetId(new Long(200));
- order.setQuantity(new Integer(13));
- order.setShipDate(new java.util.Date());
- order.setStatus(Order.StatusEnum.PLACED);
- order.setComplete(true);
-
- try {
- Field idField = Order.class.getDeclaredField("id");
- idField.setAccessible(true);
- idField.set(order, TestUtils.nextId());
- } catch (Exception e) {
- throw new RuntimeException(e);
- }
-
- return order;
- }
-}
diff --git a/samples/client/petstore/java/jersey2/src/test/java/io/swagger/petstore/test/UserApiTest.java b/samples/client/petstore/java/jersey2/src/test/java/io/swagger/petstore/test/UserApiTest.java
deleted file mode 100644
index 195e5c1e861..00000000000
--- a/samples/client/petstore/java/jersey2/src/test/java/io/swagger/petstore/test/UserApiTest.java
+++ /dev/null
@@ -1,88 +0,0 @@
-package io.swagger.petstore.test;
-
-import io.swagger.TestUtils;
-
-import io.swagger.client.api.*;
-import io.swagger.client.auth.*;
-import io.swagger.client.model.*;
-
-import java.util.Arrays;
-
-import org.junit.*;
-import static org.junit.Assert.*;
-
-public class UserApiTest {
- UserApi api = null;
-
- @Before
- public void setup() {
- api = new UserApi();
- // setup authentication
- ApiKeyAuth apiKeyAuth = (ApiKeyAuth) api.getApiClient().getAuthentication("api_key");
- apiKeyAuth.setApiKey("special-key");
- }
-
- @Test
- public void testCreateUser() throws Exception {
- User user = createUser();
-
- api.createUser(user);
-
- User fetched = api.getUserByName(user.getUsername());
- assertEquals(user.getId(), fetched.getId());
- }
-
- @Test
- public void testCreateUsersWithArray() throws Exception {
- User user1 = createUser();
- user1.setUsername("user" + user1.getId());
- User user2 = createUser();
- user2.setUsername("user" + user2.getId());
-
- api.createUsersWithArrayInput(Arrays.asList(new User[]{user1, user2}));
-
- User fetched = api.getUserByName(user1.getUsername());
- assertEquals(user1.getId(), fetched.getId());
- }
-
- @Test
- public void testCreateUsersWithList() throws Exception {
- User user1 = createUser();
- user1.setUsername("user" + user1.getId());
- User user2 = createUser();
- user2.setUsername("user" + user2.getId());
-
- api.createUsersWithListInput(Arrays.asList(new User[]{user1, user2}));
-
- User fetched = api.getUserByName(user1.getUsername());
- assertEquals(user1.getId(), fetched.getId());
- }
-
- @Test
- public void testLoginUser() throws Exception {
- User user = createUser();
- api.createUser(user);
-
- String token = api.loginUser(user.getUsername(), user.getPassword());
- assertTrue(token.startsWith("logged in user session:"));
- }
-
- @Test
- public void logoutUser() throws Exception {
- api.logoutUser();
- }
-
- 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);
-
- return user;
- }
-}