Improve generated Java examples (#8012)

* Add basic types imports to generated examples

This adds an extension to include basic types imports to generated Java
examples.

* Make some fixes to example generation

* Generate OffsetDatetime correctly

* Create a useful sample for enums, regenerate samples

* Fix BigDecimal as well
This commit is contained in:
Thomas Hervé
2020-11-26 11:14:26 +01:00
committed by GitHub
parent 157ad1ce73
commit 616b44f3b1
23 changed files with 142 additions and 70 deletions

View File

@@ -451,7 +451,7 @@ public class Example {
defaultClient.setBasePath("http://petstore.swagger.io:80/v2");
FakeApi apiInstance = new FakeApi(defaultClient);
BigDecimal body = new BigDecimal(); // BigDecimal | Input number as post body
BigDecimal body = new BigDecimal(78); // BigDecimal | Input number as post body
try {
BigDecimal result = apiInstance.fakeOuterNumberSerialize(body);
System.out.println(result);
@@ -517,7 +517,7 @@ public class Example {
defaultClient.setBasePath("http://petstore.swagger.io:80/v2");
FakeApi apiInstance = new FakeApi(defaultClient);
BigDecimal body = new BigDecimal(); // BigDecimal | Input number as post body
BigDecimal body = new BigDecimal(78); // BigDecimal | Input number as post body
try {
ApiResponse<BigDecimal> response = apiInstance.fakeOuterNumberSerializeWithHttpInfo(body);
System.out.println("Status code: " + response.getStatusCode());
@@ -1245,7 +1245,7 @@ public class Example {
http_basic_test.setPassword("YOUR PASSWORD");
FakeApi apiInstance = new FakeApi(defaultClient);
BigDecimal number = new BigDecimal(); // BigDecimal | None
BigDecimal number = new BigDecimal(78); // BigDecimal | None
Double _double = 3.4D; // Double | None
String patternWithoutDelimiter = "patternWithoutDelimiter_example"; // String | None
byte[] _byte = null; // byte[] | None
@@ -1256,7 +1256,7 @@ public class Example {
String string = "string_example"; // String | None
File binary = new File("/path/to/file"); // File | None
LocalDate date = new LocalDate(); // LocalDate | None
OffsetDateTime dateTime = new OffsetDateTime(); // OffsetDateTime | None
OffsetDateTime dateTime = OffsetDateTime.now(); // OffsetDateTime | None
String password = "password_example"; // String | None
String paramCallback = "paramCallback_example"; // String | None
try {
@@ -1343,7 +1343,7 @@ public class Example {
http_basic_test.setPassword("YOUR PASSWORD");
FakeApi apiInstance = new FakeApi(defaultClient);
BigDecimal number = new BigDecimal(); // BigDecimal | None
BigDecimal number = new BigDecimal(78); // BigDecimal | None
Double _double = 3.4D; // Double | None
String patternWithoutDelimiter = "patternWithoutDelimiter_example"; // String | None
byte[] _byte = null; // byte[] | None
@@ -1354,7 +1354,7 @@ public class Example {
String string = "string_example"; // String | None
File binary = new File("/path/to/file"); // File | None
LocalDate date = new LocalDate(); // LocalDate | None
OffsetDateTime dateTime = new OffsetDateTime(); // OffsetDateTime | None
OffsetDateTime dateTime = OffsetDateTime.now(); // OffsetDateTime | None
String password = "password_example"; // String | None
String paramCallback = "paramCallback_example"; // String | None
try {