diff --git a/packages/dynamite/dynamite/lib/src/builder/ofs_builder.dart b/packages/dynamite/dynamite/lib/src/builder/ofs_builder.dart index 11bab57b..5412459e 100644 --- a/packages/dynamite/dynamite/lib/src/builder/ofs_builder.dart +++ b/packages/dynamite/dynamite/lib/src/builder/ofs_builder.dart @@ -40,12 +40,10 @@ TypeResult resolveAllOf( interfaceClass = object; } else { - final interfaceName = schema.ofs!.length == 1 ? identifier : '${identifier}_${schema.allOf!.indexOf(s)}'; - interfaceClass = resolveInterface( spec, state, - interfaceName, + '${identifier}_${schema.allOf!.indexOf(s)}', s, ); } diff --git a/packages/dynamite/dynamite_end_to_end_test/lib/all_of.openapi.dart b/packages/dynamite/dynamite_end_to_end_test/lib/all_of.openapi.dart index 2edb2c9d..4fa14e4a 100644 --- a/packages/dynamite/dynamite_end_to_end_test/lib/all_of.openapi.dart +++ b/packages/dynamite/dynamite_end_to_end_test/lib/all_of.openapi.dart @@ -57,10 +57,34 @@ abstract class ObjectAllOf implements ObjectAllOfInterface, Built get serializer => _$objectAllOfSerializer; } +@BuiltValue(instantiable: false) +abstract interface class OneObjectAllOf_0Interface { + @BuiltValueField(wireName: 'attribute-allOf') + String get attributeAllOf; +} + +@BuiltValue(instantiable: false) +abstract interface class OneObjectAllOfInterface implements OneObjectAllOf_0Interface {} + +abstract class OneObjectAllOf implements OneObjectAllOfInterface, Built { + factory OneObjectAllOf([final void Function(OneObjectAllOfBuilder)? b]) = _$OneObjectAllOf; + + const OneObjectAllOf._(); + + factory OneObjectAllOf.fromJson(final Map json) => + _jsonSerializers.deserializeWith(serializer, json)!; + + Map toJson() => _jsonSerializers.serializeWith(serializer, this)! as Map; + + static Serializer get serializer => _$oneObjectAllOfSerializer; +} + // coverage:ignore-start final Serializers _serializers = (Serializers().toBuilder() ..addBuilderFactory(const FullType(ObjectAllOf), ObjectAllOf.new) - ..add(ObjectAllOf.serializer)) + ..add(ObjectAllOf.serializer) + ..addBuilderFactory(const FullType(OneObjectAllOf), OneObjectAllOf.new) + ..add(OneObjectAllOf.serializer)) .build(); final Serializers _jsonSerializers = (_serializers.toBuilder() diff --git a/packages/dynamite/dynamite_end_to_end_test/lib/all_of.openapi.g.dart b/packages/dynamite/dynamite_end_to_end_test/lib/all_of.openapi.g.dart index 32b10f06..5fe644f5 100644 --- a/packages/dynamite/dynamite_end_to_end_test/lib/all_of.openapi.g.dart +++ b/packages/dynamite/dynamite_end_to_end_test/lib/all_of.openapi.g.dart @@ -7,6 +7,7 @@ part of 'all_of.openapi.dart'; // ************************************************************************** Serializer _$objectAllOfSerializer = _$ObjectAllOfSerializer(); +Serializer _$oneObjectAllOfSerializer = _$OneObjectAllOfSerializer(); class _$ObjectAllOfSerializer implements StructuredSerializer { @override @@ -51,6 +52,44 @@ class _$ObjectAllOfSerializer implements StructuredSerializer { } } +class _$OneObjectAllOfSerializer implements StructuredSerializer { + @override + final Iterable types = const [OneObjectAllOf, _$OneObjectAllOf]; + @override + final String wireName = 'OneObjectAllOf'; + + @override + Iterable serialize(Serializers serializers, OneObjectAllOf object, + {FullType specifiedType = FullType.unspecified}) { + final result = [ + 'attribute-allOf', + serializers.serialize(object.attributeAllOf, specifiedType: const FullType(String)), + ]; + + return result; + } + + @override + OneObjectAllOf deserialize(Serializers serializers, Iterable serialized, + {FullType specifiedType = FullType.unspecified}) { + final result = OneObjectAllOfBuilder(); + + final iterator = serialized.iterator; + while (iterator.moveNext()) { + final key = iterator.current! as String; + iterator.moveNext(); + final Object? value = iterator.current; + switch (key) { + case 'attribute-allOf': + result.attributeAllOf = serializers.deserialize(value, specifiedType: const FullType(String))! as String; + break; + } + } + + return result.build(); + } +} + abstract mixin class ObjectAllOf_0InterfaceBuilder { void replace(ObjectAllOf_0Interface other); void update(void Function(ObjectAllOf_0InterfaceBuilder) updates); @@ -167,4 +206,96 @@ class ObjectAllOfBuilder implements Builder, Ob } } +abstract mixin class OneObjectAllOf_0InterfaceBuilder { + void replace(OneObjectAllOf_0Interface other); + void update(void Function(OneObjectAllOf_0InterfaceBuilder) updates); + String? get attributeAllOf; + set attributeAllOf(String? attributeAllOf); +} + +abstract mixin class OneObjectAllOfInterfaceBuilder implements OneObjectAllOf_0InterfaceBuilder { + void replace(covariant OneObjectAllOfInterface other); + void update(void Function(OneObjectAllOfInterfaceBuilder) updates); + String? get attributeAllOf; + set attributeAllOf(covariant String? attributeAllOf); +} + +class _$OneObjectAllOf extends OneObjectAllOf { + @override + final String attributeAllOf; + + factory _$OneObjectAllOf([void Function(OneObjectAllOfBuilder)? updates]) => + (OneObjectAllOfBuilder()..update(updates))._build(); + + _$OneObjectAllOf._({required this.attributeAllOf}) : super._() { + BuiltValueNullFieldError.checkNotNull(attributeAllOf, r'OneObjectAllOf', 'attributeAllOf'); + } + + @override + OneObjectAllOf rebuild(void Function(OneObjectAllOfBuilder) updates) => (toBuilder()..update(updates)).build(); + + @override + OneObjectAllOfBuilder toBuilder() => OneObjectAllOfBuilder()..replace(this); + + @override + bool operator ==(Object other) { + if (identical(other, this)) return true; + return other is OneObjectAllOf && attributeAllOf == other.attributeAllOf; + } + + @override + int get hashCode { + var _$hash = 0; + _$hash = $jc(_$hash, attributeAllOf.hashCode); + _$hash = $jf(_$hash); + return _$hash; + } + + @override + String toString() { + return (newBuiltValueToStringHelper(r'OneObjectAllOf')..add('attributeAllOf', attributeAllOf)).toString(); + } +} + +class OneObjectAllOfBuilder implements Builder, OneObjectAllOfInterfaceBuilder { + _$OneObjectAllOf? _$v; + + String? _attributeAllOf; + String? get attributeAllOf => _$this._attributeAllOf; + set attributeAllOf(covariant String? attributeAllOf) => _$this._attributeAllOf = attributeAllOf; + + OneObjectAllOfBuilder(); + + OneObjectAllOfBuilder get _$this { + final $v = _$v; + if ($v != null) { + _attributeAllOf = $v.attributeAllOf; + _$v = null; + } + return this; + } + + @override + void replace(covariant OneObjectAllOf other) { + ArgumentError.checkNotNull(other, 'other'); + _$v = other as _$OneObjectAllOf; + } + + @override + void update(void Function(OneObjectAllOfBuilder)? updates) { + if (updates != null) updates(this); + } + + @override + OneObjectAllOf build() => _build(); + + _$OneObjectAllOf _build() { + final _$result = _$v ?? + _$OneObjectAllOf._( + attributeAllOf: BuiltValueNullFieldError.checkNotNull(attributeAllOf, r'OneObjectAllOf', 'attributeAllOf')); + replace(_$result); + return _$result; + } +} + // ignore_for_file: deprecated_member_use_from_same_package,type=lint diff --git a/packages/dynamite/dynamite_end_to_end_test/lib/all_of.openapi.json b/packages/dynamite/dynamite_end_to_end_test/lib/all_of.openapi.json index b56feda1..c8afda95 100644 --- a/packages/dynamite/dynamite_end_to_end_test/lib/all_of.openapi.json +++ b/packages/dynamite/dynamite_end_to_end_test/lib/all_of.openapi.json @@ -32,6 +32,22 @@ } } ] + }, + "OneObjectAllOf": { + "description": "All of with one object value.", + "allOf": [ + { + "type": "object", + "required": [ + "attribute-allOf" + ], + "properties": { + "attribute-allOf": { + "type": "string" + } + } + } + ] } } },