diff --git a/modules/openapi-generator/src/main/resources/dart2/serialization/native/native_class.mustache b/modules/openapi-generator/src/main/resources/dart2/serialization/native/native_class.mustache index b4ba0b716a12..f48f75d3d215 100644 --- a/modules/openapi-generator/src/main/resources/dart2/serialization/native/native_class.mustache +++ b/modules/openapi-generator/src/main/resources/dart2/serialization/native/native_class.mustache @@ -163,7 +163,7 @@ class {{{classname}}} { : {{items.complexType}}.mapListFromJson(json[r'{{{baseName}}}']), {{/items.complexType}} {{^items.complexType}} - : mapCastOfType(json, r'{{{baseName}}}'), + : (json[r'{{{baseName}}}'] as Map).map((k, v) => MapEntry(k, v == null ? {{#items.isNullable}}null{{/items.isNullable}}{{^items.isNullable}}const <{{items.items.dataType}}>[]{{/items.isNullable}} : (v as List).cast<{{items.items.dataType}}>())), {{/items.complexType}} {{/items.isArray}} {{^items.isArray}} diff --git a/modules/openapi-generator/src/test/resources/3_0/dart/petstore-with-fake-endpoints-models-for-testing.yaml b/modules/openapi-generator/src/test/resources/3_0/dart/petstore-with-fake-endpoints-models-for-testing.yaml index a5700aa697f2..eec97cecc18f 100644 --- a/modules/openapi-generator/src/test/resources/3_0/dart/petstore-with-fake-endpoints-models-for-testing.yaml +++ b/modules/openapi-generator/src/test/resources/3_0/dart/petstore-with-fake-endpoints-models-for-testing.yaml @@ -1731,6 +1731,12 @@ components: type: object additionalProperties: type: string + map_of_array_integer: + type: object + additionalProperties: + type: array + items: + type: integer MixedPropertiesAndAdditionalPropertiesClass: type: object properties: diff --git a/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/doc/AdditionalPropertiesClass.md b/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/doc/AdditionalPropertiesClass.md index 859d4d0b7a0c..a563b58b9375 100644 --- a/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/doc/AdditionalPropertiesClass.md +++ b/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/doc/AdditionalPropertiesClass.md @@ -10,6 +10,7 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- **mapProperty** | **Map** | | [optional] [default to const {}] **mapOfMapProperty** | [**Map>**](Map.md) | | [optional] [default to const {}] +**mapOfArrayInteger** | [**Map>**](List.md) | | [optional] [default to const {}] [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/additional_properties_class.dart b/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/additional_properties_class.dart index 1986d67dc9d9..4feb30a2c68a 100644 --- a/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/additional_properties_class.dart +++ b/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/additional_properties_class.dart @@ -15,30 +15,36 @@ class AdditionalPropertiesClass { AdditionalPropertiesClass({ this.mapProperty = const {}, this.mapOfMapProperty = const {}, + this.mapOfArrayInteger = const {}, }); Map mapProperty; Map> mapOfMapProperty; + Map> mapOfArrayInteger; + @override bool operator ==(Object other) => identical(this, other) || other is AdditionalPropertiesClass && _deepEquality.equals(other.mapProperty, mapProperty) && - _deepEquality.equals(other.mapOfMapProperty, mapOfMapProperty); + _deepEquality.equals(other.mapOfMapProperty, mapOfMapProperty) && + _deepEquality.equals(other.mapOfArrayInteger, mapOfArrayInteger); @override int get hashCode => // ignore: unnecessary_parenthesis (mapProperty.hashCode) + - (mapOfMapProperty.hashCode); + (mapOfMapProperty.hashCode) + + (mapOfArrayInteger.hashCode); @override - String toString() => 'AdditionalPropertiesClass[mapProperty=$mapProperty, mapOfMapProperty=$mapOfMapProperty]'; + String toString() => 'AdditionalPropertiesClass[mapProperty=$mapProperty, mapOfMapProperty=$mapOfMapProperty, mapOfArrayInteger=$mapOfArrayInteger]'; Map toJson() { final json = {}; json[r'map_property'] = this.mapProperty; json[r'map_of_map_property'] = this.mapOfMapProperty; + json[r'map_of_array_integer'] = this.mapOfArrayInteger; return json; } @@ -63,6 +69,9 @@ class AdditionalPropertiesClass { return AdditionalPropertiesClass( mapProperty: mapCastOfType(json, r'map_property') ?? const {}, mapOfMapProperty: mapCastOfType(json, r'map_of_map_property') ?? const {}, + mapOfArrayInteger: json[r'map_of_array_integer'] == null + ? const {} + : (json[r'map_of_array_integer'] as Map).map((k, v) => MapEntry(k, v == null ? const [] : (v as List).cast())), ); } return null;