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/dart-dio/petstore_client_lib_fake-json_serializable/doc/AdditionalPropertiesClass.md b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake-json_serializable/doc/AdditionalPropertiesClass.md index 863b8503db83..1aeacd46c55a 100644 --- a/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake-json_serializable/doc/AdditionalPropertiesClass.md +++ b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake-json_serializable/doc/AdditionalPropertiesClass.md @@ -10,6 +10,7 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- **mapProperty** | **Map<String, String>** | | [optional] **mapOfMapProperty** | [**Map<String, Map<String, String>>**](Map.md) | | [optional] +**mapOfArrayInteger** | [**Map<String, List<int>>**](List.md) | | [optional] [[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/dart-dio/petstore_client_lib_fake-json_serializable/lib/src/model/additional_properties_class.dart b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake-json_serializable/lib/src/model/additional_properties_class.dart index c0ce2a1090e9..cfbc5ef08f77 100644 --- a/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake-json_serializable/lib/src/model/additional_properties_class.dart +++ b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake-json_serializable/lib/src/model/additional_properties_class.dart @@ -23,6 +23,8 @@ class AdditionalPropertiesClass { this.mapProperty, this.mapOfMapProperty, + + this.mapOfArrayInteger, }); @JsonKey( @@ -49,17 +51,31 @@ class AdditionalPropertiesClass { + @JsonKey( + + name: r'map_of_array_integer', + required: false, + includeIfNull: false, + ) + + + final Map>? mapOfArrayInteger; + + + @override bool operator ==(Object other) => identical(this, other) || other is AdditionalPropertiesClass && other.mapProperty == mapProperty && - other.mapOfMapProperty == mapOfMapProperty; + other.mapOfMapProperty == mapOfMapProperty && + other.mapOfArrayInteger == mapOfArrayInteger; @override int get hashCode => mapProperty.hashCode + - mapOfMapProperty.hashCode; + mapOfMapProperty.hashCode + + mapOfArrayInteger.hashCode; factory AdditionalPropertiesClass.fromJson(Map json) => _$AdditionalPropertiesClassFromJson(json); diff --git a/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/doc/AdditionalPropertiesClass.md b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/doc/AdditionalPropertiesClass.md index f9f7857894d0..63860b8f089a 100644 --- a/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/doc/AdditionalPropertiesClass.md +++ b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/doc/AdditionalPropertiesClass.md @@ -10,6 +10,7 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- **mapProperty** | **BuiltMap<String, String>** | | [optional] **mapOfMapProperty** | [**BuiltMap<String, BuiltMap<String, String>>**](BuiltMap.md) | | [optional] +**mapOfArrayInteger** | [**BuiltMap<String, BuiltList<int>>**](BuiltList.md) | | [optional] [[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/dart-dio/petstore_client_lib_fake/lib/src/model/additional_properties_class.dart b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/lib/src/model/additional_properties_class.dart index 3fdac6d5a44f..145e4b61c3ed 100644 --- a/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/lib/src/model/additional_properties_class.dart +++ b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/lib/src/model/additional_properties_class.dart @@ -14,6 +14,7 @@ part 'additional_properties_class.g.dart'; /// Properties: /// * [mapProperty] /// * [mapOfMapProperty] +/// * [mapOfArrayInteger] @BuiltValue() abstract class AdditionalPropertiesClass implements Built { @BuiltValueField(wireName: r'map_property') @@ -22,6 +23,9 @@ abstract class AdditionalPropertiesClass implements Built>? get mapOfMapProperty; + @BuiltValueField(wireName: r'map_of_array_integer') + BuiltMap>? get mapOfArrayInteger; + AdditionalPropertiesClass._(); factory AdditionalPropertiesClass([void updates(AdditionalPropertiesClassBuilder b)]) = _$AdditionalPropertiesClass; @@ -59,6 +63,13 @@ class _$AdditionalPropertiesClassSerializer implements PrimitiveSerializer>; result.mapOfMapProperty.replace(valueDes); break; + case r'map_of_array_integer': + final valueDes = serializers.deserialize( + value, + specifiedType: const FullType(BuiltMap, [FullType(String), FullType(BuiltList, [FullType(int)])]), + ) as BuiltMap>; + result.mapOfArrayInteger.replace(valueDes); + break; default: unhandled.add(key); unhandled.add(value); 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;