From 616b44f3b1348d2ff751a33437871f07c3d94193 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20Herv=C3=A9?= Date: Thu, 26 Nov 2020 11:14:26 +0100 Subject: [PATCH] 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 --- .../languages/AbstractJavaCodegen.java | 63 +++++++++++++++++-- .../Java/libraries/jersey2/api_doc.mustache | 3 + .../java/google-api-client/docs/FakeApi.md | 6 +- .../petstore/java/jersey1/docs/FakeApi.md | 6 +- .../java/jersey2-java8/docs/FakeApi.md | 11 +++- .../java/jersey2-java8/docs/PetApi.md | 2 + .../java/native-async/docs/FakeApi.md | 12 ++-- .../petstore/java/native/docs/FakeApi.md | 12 ++-- .../docs/FakeApi.md | 6 +- .../petstore/java/okhttp-gson/docs/FakeApi.md | 6 +- .../petstore/java/resteasy/docs/FakeApi.md | 6 +- .../java/resttemplate-withXml/docs/FakeApi.md | 6 +- .../java/resttemplate/docs/FakeApi.md | 6 +- .../java/retrofit2-play26/docs/FakeApi.md | 6 +- .../petstore/java/retrofit2/docs/FakeApi.md | 6 +- .../java/retrofit2rx2/docs/FakeApi.md | 6 +- .../java/retrofit2rx3/docs/FakeApi.md | 6 +- .../java/vertx-no-nullable/docs/FakeApi.md | 6 +- .../petstore/java/vertx/docs/FakeApi.md | 6 +- .../petstore/java/webclient/docs/FakeApi.md | 6 +- .../java/jersey2-java8/docs/FakeApi.md | 11 +++- .../java/jersey2-java8/docs/PetApi.md | 2 + .../petstore/java/native/docs/FakeApi.md | 12 ++-- 23 files changed, 142 insertions(+), 70 deletions(-) diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractJavaCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractJavaCodegen.java index d08f93fe3ff..8bddc1feaf5 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractJavaCodegen.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractJavaCodegen.java @@ -21,10 +21,12 @@ import com.google.common.base.Strings; import io.swagger.v3.oas.models.OpenAPI; import io.swagger.v3.oas.models.Operation; import io.swagger.v3.oas.models.PathItem; +import io.swagger.v3.oas.models.examples.Example; import io.swagger.v3.oas.models.media.ArraySchema; import io.swagger.v3.oas.models.media.ComposedSchema; import io.swagger.v3.oas.models.media.Schema; import io.swagger.v3.oas.models.media.StringSchema; +import io.swagger.v3.oas.models.parameters.Parameter; import io.swagger.v3.oas.models.servers.Server; import io.swagger.v3.parser.util.SchemaTypeUtil; import org.apache.commons.io.FilenameUtils; @@ -931,6 +933,37 @@ public abstract class AbstractJavaCodegen extends DefaultCodegen implements Code return super.toDefaultValue(schema); } + /** + * Return the example value of the parameter. Overrides the + * setParameterExampleValue(CodegenParameter, Parameter) method in + * DefaultCodegen to always call setParameterExampleValue(CodegenParameter) + * in this class, which adds single quotes around strings from the + * x-example property. + * + * @param codegenParameter Codegen parameter + * @param parameter Parameter + */ + @Override + public void setParameterExampleValue(CodegenParameter codegenParameter, Parameter parameter) { + if (parameter.getExample() != null) { + codegenParameter.example = parameter.getExample().toString(); + } + + if (parameter.getExamples() != null && !parameter.getExamples().isEmpty()) { + Example example = parameter.getExamples().values().iterator().next(); + if (example.getValue() != null) { + codegenParameter.example = example.getValue().toString(); + } + } + + Schema schema = parameter.getSchema(); + if (schema != null && schema.getExample() != null) { + codegenParameter.example = schema.getExample().toString(); + } + + setParameterExampleValue(codegenParameter); + } + @Override public void setParameterExampleValue(CodegenParameter p) { String example; @@ -959,15 +992,17 @@ public abstract class AbstractJavaCodegen extends DefaultCodegen implements Code if (example == null) { example = "56"; } - example = example + "L"; + example = StringUtils.appendIfMissingIgnoreCase(example, "L"); } else if ("Float".equals(type)) { if (example == null) { example = "3.4"; } - example = example + "F"; + example = StringUtils.appendIfMissingIgnoreCase(example, "F"); } else if ("Double".equals(type)) { - example = "3.4"; - example = example + "D"; + if (example == null) { + example = "3.4"; + } + example = StringUtils.appendIfMissingIgnoreCase(example, "D"); } else if ("Boolean".equals(type)) { if (example == null) { example = "true"; @@ -979,6 +1014,14 @@ public abstract class AbstractJavaCodegen extends DefaultCodegen implements Code example = "new File(\"" + escapeText(example) + "\")"; } else if ("Date".equals(type)) { example = "new Date()"; + } else if ("OffsetDateTime".equals(type)) { + example = "OffsetDateTime.now()"; + } else if ("BigDecimal".equals(type)) { + example = "new BigDecimal(78)"; + } else if (p.allowableValues != null && !p.allowableValues.isEmpty()) { + Map allowableValues = p.allowableValues; + List values = (List) allowableValues.get("values"); + example = type + ".fromValue(\"" + String.valueOf(values.get(0)) + "\")"; } else if (!languageSpecificPrimitives.contains(type)) { // type is a model class, e.g. User example = "new " + type + "()"; @@ -1141,6 +1184,18 @@ public abstract class AbstractJavaCodegen extends DefaultCodegen implements Code itr.remove(); } } + + Map operations = (Map) objs.get("operations"); + List operationList = (List) operations.get("operation"); + for (CodegenOperation op : operationList) { + Collection operationImports = new TreeSet(); + for (CodegenParameter p : op.allParams) { + if (importMapping.containsKey(p.dataType)) { + operationImports.add(importMapping.get(p.dataType)); + } + } + op.vendorExtensions.put("x-java-import", operationImports); + } return objs; } diff --git a/modules/openapi-generator/src/main/resources/Java/libraries/jersey2/api_doc.mustache b/modules/openapi-generator/src/main/resources/Java/libraries/jersey2/api_doc.mustache index e0c65a61d60..e9270ceb18f 100644 --- a/modules/openapi-generator/src/main/resources/Java/libraries/jersey2/api_doc.mustache +++ b/modules/openapi-generator/src/main/resources/Java/libraries/jersey2/api_doc.mustache @@ -28,6 +28,9 @@ Method | HTTP request | Description ### Example ```java +{{#vendorExtensions.x-java-import}} +import {{.}}; +{{/vendorExtensions.x-java-import}} // Import classes: import {{{invokerPackage}}}.ApiClient; import {{{invokerPackage}}}.ApiException; diff --git a/samples/client/petstore/java/google-api-client/docs/FakeApi.md b/samples/client/petstore/java/google-api-client/docs/FakeApi.md index 1ce9c124e91..9c46433be47 100644 --- a/samples/client/petstore/java/google-api-client/docs/FakeApi.md +++ b/samples/client/petstore/java/google-api-client/docs/FakeApi.md @@ -239,7 +239,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); @@ -568,7 +568,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 @@ -579,7 +579,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 { diff --git a/samples/client/petstore/java/jersey1/docs/FakeApi.md b/samples/client/petstore/java/jersey1/docs/FakeApi.md index 1ce9c124e91..9c46433be47 100644 --- a/samples/client/petstore/java/jersey1/docs/FakeApi.md +++ b/samples/client/petstore/java/jersey1/docs/FakeApi.md @@ -239,7 +239,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); @@ -568,7 +568,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 @@ -579,7 +579,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 { diff --git a/samples/client/petstore/java/jersey2-java8/docs/FakeApi.md b/samples/client/petstore/java/jersey2-java8/docs/FakeApi.md index e3367417f5e..7a40f905450 100644 --- a/samples/client/petstore/java/jersey2-java8/docs/FakeApi.md +++ b/samples/client/petstore/java/jersey2-java8/docs/FakeApi.md @@ -226,6 +226,7 @@ Test serialization of outer number types ### Example ```java +import java.math.BigDecimal; // Import classes: import org.openapitools.client.ApiClient; import org.openapitools.client.ApiException; @@ -239,7 +240,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); @@ -552,6 +553,10 @@ Fake endpoint for testing various parameters ### Example ```java +import java.io.File; +import java.math.BigDecimal; +import java.time.LocalDate; +import java.time.OffsetDateTime; // Import classes: import org.openapitools.client.ApiClient; import org.openapitools.client.ApiException; @@ -571,7 +576,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 @@ -582,7 +587,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 { diff --git a/samples/client/petstore/java/jersey2-java8/docs/PetApi.md b/samples/client/petstore/java/jersey2-java8/docs/PetApi.md index 4df6b212278..c7709e17d96 100644 --- a/samples/client/petstore/java/jersey2-java8/docs/PetApi.md +++ b/samples/client/petstore/java/jersey2-java8/docs/PetApi.md @@ -520,6 +520,7 @@ uploads an image ### Example ```java +import java.io.File; // Import classes: import org.openapitools.client.ApiClient; import org.openapitools.client.ApiException; @@ -592,6 +593,7 @@ uploads an image (required) ### Example ```java +import java.io.File; // Import classes: import org.openapitools.client.ApiClient; import org.openapitools.client.ApiException; diff --git a/samples/client/petstore/java/native-async/docs/FakeApi.md b/samples/client/petstore/java/native-async/docs/FakeApi.md index 2d1e4a87552..63c991b4b15 100644 --- a/samples/client/petstore/java/native-async/docs/FakeApi.md +++ b/samples/client/petstore/java/native-async/docs/FakeApi.md @@ -487,7 +487,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 { CompletableFuture result = apiInstance.fakeOuterNumberSerialize(body); System.out.println(result.get()); @@ -554,7 +554,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 { CompletableFuture> response = apiInstance.fakeOuterNumberSerializeWithHttpInfo(body); System.out.println("Status code: " + response.get().getStatusCode()); @@ -1204,7 +1204,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 @@ -1215,7 +1215,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 { @@ -1303,7 +1303,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 @@ -1314,7 +1314,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 { diff --git a/samples/client/petstore/java/native/docs/FakeApi.md b/samples/client/petstore/java/native/docs/FakeApi.md index 16ce9829375..ef82fb3dc69 100644 --- a/samples/client/petstore/java/native/docs/FakeApi.md +++ b/samples/client/petstore/java/native/docs/FakeApi.md @@ -459,7 +459,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); @@ -525,7 +525,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 response = apiInstance.fakeOuterNumberSerializeWithHttpInfo(body); System.out.println("Status code: " + response.getStatusCode()); @@ -1131,7 +1131,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 @@ -1142,7 +1142,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 { @@ -1229,7 +1229,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 @@ -1240,7 +1240,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 { diff --git a/samples/client/petstore/java/okhttp-gson-parcelableModel/docs/FakeApi.md b/samples/client/petstore/java/okhttp-gson-parcelableModel/docs/FakeApi.md index b8c2112acb8..e1daf9b0e7f 100644 --- a/samples/client/petstore/java/okhttp-gson-parcelableModel/docs/FakeApi.md +++ b/samples/client/petstore/java/okhttp-gson-parcelableModel/docs/FakeApi.md @@ -228,7 +228,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); @@ -542,7 +542,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 @@ -553,7 +553,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 { diff --git a/samples/client/petstore/java/okhttp-gson/docs/FakeApi.md b/samples/client/petstore/java/okhttp-gson/docs/FakeApi.md index b8c2112acb8..e1daf9b0e7f 100644 --- a/samples/client/petstore/java/okhttp-gson/docs/FakeApi.md +++ b/samples/client/petstore/java/okhttp-gson/docs/FakeApi.md @@ -228,7 +228,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); @@ -542,7 +542,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 @@ -553,7 +553,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 { diff --git a/samples/client/petstore/java/resteasy/docs/FakeApi.md b/samples/client/petstore/java/resteasy/docs/FakeApi.md index 1ce9c124e91..9c46433be47 100644 --- a/samples/client/petstore/java/resteasy/docs/FakeApi.md +++ b/samples/client/petstore/java/resteasy/docs/FakeApi.md @@ -239,7 +239,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); @@ -568,7 +568,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 @@ -579,7 +579,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 { diff --git a/samples/client/petstore/java/resttemplate-withXml/docs/FakeApi.md b/samples/client/petstore/java/resttemplate-withXml/docs/FakeApi.md index 1ce9c124e91..9c46433be47 100644 --- a/samples/client/petstore/java/resttemplate-withXml/docs/FakeApi.md +++ b/samples/client/petstore/java/resttemplate-withXml/docs/FakeApi.md @@ -239,7 +239,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); @@ -568,7 +568,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 @@ -579,7 +579,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 { diff --git a/samples/client/petstore/java/resttemplate/docs/FakeApi.md b/samples/client/petstore/java/resttemplate/docs/FakeApi.md index 1ce9c124e91..9c46433be47 100644 --- a/samples/client/petstore/java/resttemplate/docs/FakeApi.md +++ b/samples/client/petstore/java/resttemplate/docs/FakeApi.md @@ -239,7 +239,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); @@ -568,7 +568,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 @@ -579,7 +579,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 { diff --git a/samples/client/petstore/java/retrofit2-play26/docs/FakeApi.md b/samples/client/petstore/java/retrofit2-play26/docs/FakeApi.md index 8de4500212e..c531ab56df2 100644 --- a/samples/client/petstore/java/retrofit2-play26/docs/FakeApi.md +++ b/samples/client/petstore/java/retrofit2-play26/docs/FakeApi.md @@ -239,7 +239,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); @@ -568,7 +568,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 @@ -579,7 +579,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 { diff --git a/samples/client/petstore/java/retrofit2/docs/FakeApi.md b/samples/client/petstore/java/retrofit2/docs/FakeApi.md index 8de4500212e..c531ab56df2 100644 --- a/samples/client/petstore/java/retrofit2/docs/FakeApi.md +++ b/samples/client/petstore/java/retrofit2/docs/FakeApi.md @@ -239,7 +239,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); @@ -568,7 +568,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 @@ -579,7 +579,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 { diff --git a/samples/client/petstore/java/retrofit2rx2/docs/FakeApi.md b/samples/client/petstore/java/retrofit2rx2/docs/FakeApi.md index 8de4500212e..c531ab56df2 100644 --- a/samples/client/petstore/java/retrofit2rx2/docs/FakeApi.md +++ b/samples/client/petstore/java/retrofit2rx2/docs/FakeApi.md @@ -239,7 +239,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); @@ -568,7 +568,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 @@ -579,7 +579,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 { diff --git a/samples/client/petstore/java/retrofit2rx3/docs/FakeApi.md b/samples/client/petstore/java/retrofit2rx3/docs/FakeApi.md index 8de4500212e..c531ab56df2 100644 --- a/samples/client/petstore/java/retrofit2rx3/docs/FakeApi.md +++ b/samples/client/petstore/java/retrofit2rx3/docs/FakeApi.md @@ -239,7 +239,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); @@ -568,7 +568,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 @@ -579,7 +579,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 { diff --git a/samples/client/petstore/java/vertx-no-nullable/docs/FakeApi.md b/samples/client/petstore/java/vertx-no-nullable/docs/FakeApi.md index df0f92ee9ab..38bf96d4fad 100644 --- a/samples/client/petstore/java/vertx-no-nullable/docs/FakeApi.md +++ b/samples/client/petstore/java/vertx-no-nullable/docs/FakeApi.md @@ -239,7 +239,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); @@ -568,7 +568,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 @@ -579,7 +579,7 @@ public class Example { String string = "string_example"; // String | None AsyncFile binary = new AsyncFile(); // AsyncFile | 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 { diff --git a/samples/client/petstore/java/vertx/docs/FakeApi.md b/samples/client/petstore/java/vertx/docs/FakeApi.md index df0f92ee9ab..38bf96d4fad 100644 --- a/samples/client/petstore/java/vertx/docs/FakeApi.md +++ b/samples/client/petstore/java/vertx/docs/FakeApi.md @@ -239,7 +239,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); @@ -568,7 +568,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 @@ -579,7 +579,7 @@ public class Example { String string = "string_example"; // String | None AsyncFile binary = new AsyncFile(); // AsyncFile | 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 { diff --git a/samples/client/petstore/java/webclient/docs/FakeApi.md b/samples/client/petstore/java/webclient/docs/FakeApi.md index 1ce9c124e91..9c46433be47 100644 --- a/samples/client/petstore/java/webclient/docs/FakeApi.md +++ b/samples/client/petstore/java/webclient/docs/FakeApi.md @@ -239,7 +239,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); @@ -568,7 +568,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 @@ -579,7 +579,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 { diff --git a/samples/openapi3/client/petstore/java/jersey2-java8/docs/FakeApi.md b/samples/openapi3/client/petstore/java/jersey2-java8/docs/FakeApi.md index 6c571568f0c..20065b831e7 100644 --- a/samples/openapi3/client/petstore/java/jersey2-java8/docs/FakeApi.md +++ b/samples/openapi3/client/petstore/java/jersey2-java8/docs/FakeApi.md @@ -222,6 +222,7 @@ Test serialization of outer number types ### Example ```java +import java.math.BigDecimal; // Import classes: import org.openapitools.client.ApiClient; import org.openapitools.client.ApiException; @@ -235,7 +236,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); @@ -608,6 +609,10 @@ Fake endpoint for testing various parameters ### Example ```java +import java.io.File; +import java.math.BigDecimal; +import java.time.LocalDate; +import java.time.OffsetDateTime; // Import classes: import org.openapitools.client.ApiClient; import org.openapitools.client.ApiException; @@ -627,7 +632,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 @@ -638,7 +643,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 { diff --git a/samples/openapi3/client/petstore/java/jersey2-java8/docs/PetApi.md b/samples/openapi3/client/petstore/java/jersey2-java8/docs/PetApi.md index 200f9cda210..7e3f3f0540c 100644 --- a/samples/openapi3/client/petstore/java/jersey2-java8/docs/PetApi.md +++ b/samples/openapi3/client/petstore/java/jersey2-java8/docs/PetApi.md @@ -521,6 +521,7 @@ uploads an image ### Example ```java +import java.io.File; // Import classes: import org.openapitools.client.ApiClient; import org.openapitools.client.ApiException; @@ -593,6 +594,7 @@ uploads an image (required) ### Example ```java +import java.io.File; // Import classes: import org.openapitools.client.ApiClient; import org.openapitools.client.ApiException; diff --git a/samples/openapi3/client/petstore/java/native/docs/FakeApi.md b/samples/openapi3/client/petstore/java/native/docs/FakeApi.md index 0569ef8836d..c9c9f047303 100644 --- a/samples/openapi3/client/petstore/java/native/docs/FakeApi.md +++ b/samples/openapi3/client/petstore/java/native/docs/FakeApi.md @@ -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 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 {