diff --git a/modules/openapi-generator/src/main/resources/dart2/class.mustache b/modules/openapi-generator/src/main/resources/dart2/class.mustache index 636aab61b89..f65bce93991 100644 --- a/modules/openapi-generator/src/main/resources/dart2/class.mustache +++ b/modules/openapi-generator/src/main/resources/dart2/class.mustache @@ -50,7 +50,7 @@ class {{{classname}}} { {{/isEnum}} {{^isBinary}} @JsonKey( - nullable: {{#nullable}}true{{/nullable}}{{^nullable}}false{{/nullable}}, + {{#defaultValue}}defaultValue: {{{defaultValue}}},{{/defaultValue}}{{^defaultValue}}nullable: {{isNullable}},{{/defaultValue}} name: r'{{{baseName}}}', required: {{#required}}true{{/required}}{{^required}}false{{/required}}, ) diff --git a/samples/openapi3/client/petstore/dart2/petstore_json_serializable_client_lib_fake/lib/model/additional_properties_class.dart b/samples/openapi3/client/petstore/dart2/petstore_json_serializable_client_lib_fake/lib/model/additional_properties_class.dart index 85a663f6b10..558e7f204a3 100644 --- a/samples/openapi3/client/petstore/dart2/petstore_json_serializable_client_lib_fake/lib/model/additional_properties_class.dart +++ b/samples/openapi3/client/petstore/dart2/petstore_json_serializable_client_lib_fake/lib/model/additional_properties_class.dart @@ -23,14 +23,14 @@ class AdditionalPropertiesClass { }); @JsonKey( - nullable: false, + defaultValue: const {}, name: r'map_property', required: false, ) Map mapProperty; @JsonKey( - nullable: false, + defaultValue: const {}, name: r'map_of_map_property', required: false, ) diff --git a/samples/openapi3/client/petstore/dart2/petstore_json_serializable_client_lib_fake/lib/model/animal.dart b/samples/openapi3/client/petstore/dart2/petstore_json_serializable_client_lib_fake/lib/model/animal.dart index f8d223ed50e..b73140cc066 100644 --- a/samples/openapi3/client/petstore/dart2/petstore_json_serializable_client_lib_fake/lib/model/animal.dart +++ b/samples/openapi3/client/petstore/dart2/petstore_json_serializable_client_lib_fake/lib/model/animal.dart @@ -30,7 +30,7 @@ class Animal { String className; @JsonKey( - nullable: false, + defaultValue: 'red', name: r'color', required: false, ) diff --git a/samples/openapi3/client/petstore/dart2/petstore_json_serializable_client_lib_fake/lib/model/array_of_array_of_number_only.dart b/samples/openapi3/client/petstore/dart2/petstore_json_serializable_client_lib_fake/lib/model/array_of_array_of_number_only.dart index 969f1f788e6..e8d735fde05 100644 --- a/samples/openapi3/client/petstore/dart2/petstore_json_serializable_client_lib_fake/lib/model/array_of_array_of_number_only.dart +++ b/samples/openapi3/client/petstore/dart2/petstore_json_serializable_client_lib_fake/lib/model/array_of_array_of_number_only.dart @@ -22,7 +22,7 @@ class ArrayOfArrayOfNumberOnly { }); @JsonKey( - nullable: false, + defaultValue: const [], name: r'ArrayArrayNumber', required: false, ) diff --git a/samples/openapi3/client/petstore/dart2/petstore_json_serializable_client_lib_fake/lib/model/array_of_number_only.dart b/samples/openapi3/client/petstore/dart2/petstore_json_serializable_client_lib_fake/lib/model/array_of_number_only.dart index 18c3e29792c..bf821233a35 100644 --- a/samples/openapi3/client/petstore/dart2/petstore_json_serializable_client_lib_fake/lib/model/array_of_number_only.dart +++ b/samples/openapi3/client/petstore/dart2/petstore_json_serializable_client_lib_fake/lib/model/array_of_number_only.dart @@ -22,7 +22,7 @@ class ArrayOfNumberOnly { }); @JsonKey( - nullable: false, + defaultValue: const [], name: r'ArrayNumber', required: false, ) diff --git a/samples/openapi3/client/petstore/dart2/petstore_json_serializable_client_lib_fake/lib/model/array_test.dart b/samples/openapi3/client/petstore/dart2/petstore_json_serializable_client_lib_fake/lib/model/array_test.dart index f96fca86296..e155c201c7c 100644 --- a/samples/openapi3/client/petstore/dart2/petstore_json_serializable_client_lib_fake/lib/model/array_test.dart +++ b/samples/openapi3/client/petstore/dart2/petstore_json_serializable_client_lib_fake/lib/model/array_test.dart @@ -24,21 +24,21 @@ class ArrayTest { }); @JsonKey( - nullable: false, + defaultValue: const [], name: r'array_of_string', required: false, ) List arrayOfString; @JsonKey( - nullable: false, + defaultValue: const [], name: r'array_array_of_integer', required: false, ) List> arrayArrayOfInteger; @JsonKey( - nullable: false, + defaultValue: const [], name: r'array_array_of_model', required: false, ) diff --git a/samples/openapi3/client/petstore/dart2/petstore_json_serializable_client_lib_fake/lib/model/cat.dart b/samples/openapi3/client/petstore/dart2/petstore_json_serializable_client_lib_fake/lib/model/cat.dart index fe9ff5a5edd..6fc7a1fe3f0 100644 --- a/samples/openapi3/client/petstore/dart2/petstore_json_serializable_client_lib_fake/lib/model/cat.dart +++ b/samples/openapi3/client/petstore/dart2/petstore_json_serializable_client_lib_fake/lib/model/cat.dart @@ -31,7 +31,7 @@ class Cat { String className; @JsonKey( - nullable: false, + defaultValue: 'red', name: r'color', required: false, ) diff --git a/samples/openapi3/client/petstore/dart2/petstore_json_serializable_client_lib_fake/lib/model/category.dart b/samples/openapi3/client/petstore/dart2/petstore_json_serializable_client_lib_fake/lib/model/category.dart index 7725d8f4598..1943448babd 100644 --- a/samples/openapi3/client/petstore/dart2/petstore_json_serializable_client_lib_fake/lib/model/category.dart +++ b/samples/openapi3/client/petstore/dart2/petstore_json_serializable_client_lib_fake/lib/model/category.dart @@ -30,7 +30,7 @@ class Category { int id; @JsonKey( - nullable: false, + defaultValue: 'default-name', name: r'name', required: true, ) diff --git a/samples/openapi3/client/petstore/dart2/petstore_json_serializable_client_lib_fake/lib/model/dog.dart b/samples/openapi3/client/petstore/dart2/petstore_json_serializable_client_lib_fake/lib/model/dog.dart index 920424afa64..dc7b2bd0386 100644 --- a/samples/openapi3/client/petstore/dart2/petstore_json_serializable_client_lib_fake/lib/model/dog.dart +++ b/samples/openapi3/client/petstore/dart2/petstore_json_serializable_client_lib_fake/lib/model/dog.dart @@ -31,7 +31,7 @@ class Dog { String className; @JsonKey( - nullable: false, + defaultValue: 'red', name: r'color', required: false, ) diff --git a/samples/openapi3/client/petstore/dart2/petstore_json_serializable_client_lib_fake/lib/model/enum_arrays.dart b/samples/openapi3/client/petstore/dart2/petstore_json_serializable_client_lib_fake/lib/model/enum_arrays.dart index 1ca0a07a3fb..d39f69699d8 100644 --- a/samples/openapi3/client/petstore/dart2/petstore_json_serializable_client_lib_fake/lib/model/enum_arrays.dart +++ b/samples/openapi3/client/petstore/dart2/petstore_json_serializable_client_lib_fake/lib/model/enum_arrays.dart @@ -30,7 +30,7 @@ class EnumArrays { EnumArraysJustSymbolEnum justSymbol; @JsonKey( - nullable: false, + defaultValue: const [], name: r'array_enum', required: false, ) diff --git a/samples/openapi3/client/petstore/dart2/petstore_json_serializable_client_lib_fake/lib/model/enum_test.dart b/samples/openapi3/client/petstore/dart2/petstore_json_serializable_client_lib_fake/lib/model/enum_test.dart index a6159e20830..7389cf1246b 100644 --- a/samples/openapi3/client/petstore/dart2/petstore_json_serializable_client_lib_fake/lib/model/enum_test.dart +++ b/samples/openapi3/client/petstore/dart2/petstore_json_serializable_client_lib_fake/lib/model/enum_test.dart @@ -57,7 +57,7 @@ class EnumTest { EnumTestEnumNumberEnum enumNumber; @JsonKey( - nullable: false, + nullable: true, name: r'outerEnum', required: false, ) diff --git a/samples/openapi3/client/petstore/dart2/petstore_json_serializable_client_lib_fake/lib/model/file_schema_test_class.dart b/samples/openapi3/client/petstore/dart2/petstore_json_serializable_client_lib_fake/lib/model/file_schema_test_class.dart index 432ed75edb1..d3c07377d13 100644 --- a/samples/openapi3/client/petstore/dart2/petstore_json_serializable_client_lib_fake/lib/model/file_schema_test_class.dart +++ b/samples/openapi3/client/petstore/dart2/petstore_json_serializable_client_lib_fake/lib/model/file_schema_test_class.dart @@ -30,7 +30,7 @@ class FileSchemaTestClass { ModelFile file; @JsonKey( - nullable: false, + defaultValue: const [], name: r'files', required: false, ) diff --git a/samples/openapi3/client/petstore/dart2/petstore_json_serializable_client_lib_fake/lib/model/foo.dart b/samples/openapi3/client/petstore/dart2/petstore_json_serializable_client_lib_fake/lib/model/foo.dart index 90cecc2a17d..47375d9f05a 100644 --- a/samples/openapi3/client/petstore/dart2/petstore_json_serializable_client_lib_fake/lib/model/foo.dart +++ b/samples/openapi3/client/petstore/dart2/petstore_json_serializable_client_lib_fake/lib/model/foo.dart @@ -22,7 +22,7 @@ class Foo { }); @JsonKey( - nullable: false, + defaultValue: 'bar', name: r'bar', required: false, ) diff --git a/samples/openapi3/client/petstore/dart2/petstore_json_serializable_client_lib_fake/lib/model/health_check_result.dart b/samples/openapi3/client/petstore/dart2/petstore_json_serializable_client_lib_fake/lib/model/health_check_result.dart index 3150d9df5a5..506c7312ea0 100644 --- a/samples/openapi3/client/petstore/dart2/petstore_json_serializable_client_lib_fake/lib/model/health_check_result.dart +++ b/samples/openapi3/client/petstore/dart2/petstore_json_serializable_client_lib_fake/lib/model/health_check_result.dart @@ -22,7 +22,7 @@ class HealthCheckResult { }); @JsonKey( - nullable: false, + nullable: true, name: r'NullableMessage', required: false, ) diff --git a/samples/openapi3/client/petstore/dart2/petstore_json_serializable_client_lib_fake/lib/model/map_test.dart b/samples/openapi3/client/petstore/dart2/petstore_json_serializable_client_lib_fake/lib/model/map_test.dart index 2080fe0929a..034e4c6ab16 100644 --- a/samples/openapi3/client/petstore/dart2/petstore_json_serializable_client_lib_fake/lib/model/map_test.dart +++ b/samples/openapi3/client/petstore/dart2/petstore_json_serializable_client_lib_fake/lib/model/map_test.dart @@ -25,28 +25,28 @@ class MapTest { }); @JsonKey( - nullable: false, + defaultValue: const {}, name: r'map_map_of_string', required: false, ) Map> mapMapOfString; @JsonKey( - nullable: false, + defaultValue: const {}, name: r'map_of_enum_string', required: false, ) Map mapOfEnumString; @JsonKey( - nullable: false, + defaultValue: const {}, name: r'direct_map', required: false, ) Map directMap; @JsonKey( - nullable: false, + defaultValue: const {}, name: r'indirect_map', required: false, ) diff --git a/samples/openapi3/client/petstore/dart2/petstore_json_serializable_client_lib_fake/lib/model/mixed_properties_and_additional_properties_class.dart b/samples/openapi3/client/petstore/dart2/petstore_json_serializable_client_lib_fake/lib/model/mixed_properties_and_additional_properties_class.dart index 634753e657e..7f6305f2195 100644 --- a/samples/openapi3/client/petstore/dart2/petstore_json_serializable_client_lib_fake/lib/model/mixed_properties_and_additional_properties_class.dart +++ b/samples/openapi3/client/petstore/dart2/petstore_json_serializable_client_lib_fake/lib/model/mixed_properties_and_additional_properties_class.dart @@ -38,7 +38,7 @@ class MixedPropertiesAndAdditionalPropertiesClass { DateTime dateTime; @JsonKey( - nullable: false, + defaultValue: const {}, name: r'map', required: false, ) diff --git a/samples/openapi3/client/petstore/dart2/petstore_json_serializable_client_lib_fake/lib/model/nullable_class.dart b/samples/openapi3/client/petstore/dart2/petstore_json_serializable_client_lib_fake/lib/model/nullable_class.dart index 42c21d5c590..acbda5d7199 100644 --- a/samples/openapi3/client/petstore/dart2/petstore_json_serializable_client_lib_fake/lib/model/nullable_class.dart +++ b/samples/openapi3/client/petstore/dart2/petstore_json_serializable_client_lib_fake/lib/model/nullable_class.dart @@ -33,84 +33,84 @@ class NullableClass { }); @JsonKey( - nullable: false, + nullable: true, name: r'integer_prop', required: false, ) int integerProp; @JsonKey( - nullable: false, + nullable: true, name: r'number_prop', required: false, ) num numberProp; @JsonKey( - nullable: false, + nullable: true, name: r'boolean_prop', required: false, ) bool booleanProp; @JsonKey( - nullable: false, + nullable: true, name: r'string_prop', required: false, ) String stringProp; @JsonKey( - nullable: false, + nullable: true, name: r'date_prop', required: false, ) DateTime dateProp; @JsonKey( - nullable: false, + nullable: true, name: r'datetime_prop', required: false, ) DateTime datetimeProp; @JsonKey( - nullable: false, + defaultValue: const [], name: r'array_nullable_prop', required: false, ) List arrayNullableProp; @JsonKey( - nullable: false, + defaultValue: const [], name: r'array_and_items_nullable_prop', required: false, ) List arrayAndItemsNullableProp; @JsonKey( - nullable: false, + defaultValue: const [], name: r'array_items_nullable', required: false, ) List arrayItemsNullable; @JsonKey( - nullable: false, + defaultValue: const {}, name: r'object_nullable_prop', required: false, ) Map objectNullableProp; @JsonKey( - nullable: false, + defaultValue: const {}, name: r'object_and_items_nullable_prop', required: false, ) Map objectAndItemsNullableProp; @JsonKey( - nullable: false, + defaultValue: const {}, name: r'object_items_nullable', required: false, ) diff --git a/samples/openapi3/client/petstore/dart2/petstore_json_serializable_client_lib_fake/lib/model/order.dart b/samples/openapi3/client/petstore/dart2/petstore_json_serializable_client_lib_fake/lib/model/order.dart index e42c82c5cf1..6286697b172 100644 --- a/samples/openapi3/client/petstore/dart2/petstore_json_serializable_client_lib_fake/lib/model/order.dart +++ b/samples/openapi3/client/petstore/dart2/petstore_json_serializable_client_lib_fake/lib/model/order.dart @@ -63,7 +63,7 @@ class Order { OrderStatusEnum status; @JsonKey( - nullable: false, + defaultValue: false, name: r'complete', required: false, ) diff --git a/samples/openapi3/client/petstore/dart2/petstore_json_serializable_client_lib_fake/lib/model/pet.dart b/samples/openapi3/client/petstore/dart2/petstore_json_serializable_client_lib_fake/lib/model/pet.dart index b93a9a1100f..032d8ba77e6 100644 --- a/samples/openapi3/client/petstore/dart2/petstore_json_serializable_client_lib_fake/lib/model/pet.dart +++ b/samples/openapi3/client/petstore/dart2/petstore_json_serializable_client_lib_fake/lib/model/pet.dart @@ -48,14 +48,14 @@ class Pet { String name; @JsonKey( - nullable: false, + defaultValue: const {}, name: r'photoUrls', required: true, ) Set photoUrls; @JsonKey( - nullable: false, + defaultValue: const [], name: r'tags', required: false, )