Browse Source

fix(dynamite,dynamite_end_to_end_test): fix class name collision on single member allOf

Signed-off-by: Nikolas Rimikis <leptopoda@users.noreply.github.com>
pull/1155/head
Nikolas Rimikis 1 year ago
parent
commit
e32d176cca
No known key found for this signature in database
GPG Key ID: 85ED1DE9786A4FF2
  1. 4
      packages/dynamite/dynamite/lib/src/builder/ofs_builder.dart
  2. 26
      packages/dynamite/dynamite_end_to_end_test/lib/all_of.openapi.dart
  3. 131
      packages/dynamite/dynamite_end_to_end_test/lib/all_of.openapi.g.dart
  4. 16
      packages/dynamite/dynamite_end_to_end_test/lib/all_of.openapi.json

4
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,
);
}

26
packages/dynamite/dynamite_end_to_end_test/lib/all_of.openapi.dart

@ -57,10 +57,34 @@ abstract class ObjectAllOf implements ObjectAllOfInterface, Built<ObjectAllOf, O
static Serializer<ObjectAllOf> 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<OneObjectAllOf, OneObjectAllOfBuilder> {
factory OneObjectAllOf([final void Function(OneObjectAllOfBuilder)? b]) = _$OneObjectAllOf;
const OneObjectAllOf._();
factory OneObjectAllOf.fromJson(final Map<String, dynamic> json) =>
_jsonSerializers.deserializeWith(serializer, json)!;
Map<String, dynamic> toJson() => _jsonSerializers.serializeWith(serializer, this)! as Map<String, dynamic>;
static Serializer<OneObjectAllOf> 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()

131
packages/dynamite/dynamite_end_to_end_test/lib/all_of.openapi.g.dart

@ -7,6 +7,7 @@ part of 'all_of.openapi.dart';
// **************************************************************************
Serializer<ObjectAllOf> _$objectAllOfSerializer = _$ObjectAllOfSerializer();
Serializer<OneObjectAllOf> _$oneObjectAllOfSerializer = _$OneObjectAllOfSerializer();
class _$ObjectAllOfSerializer implements StructuredSerializer<ObjectAllOf> {
@override
@ -51,6 +52,44 @@ class _$ObjectAllOfSerializer implements StructuredSerializer<ObjectAllOf> {
}
}
class _$OneObjectAllOfSerializer implements StructuredSerializer<OneObjectAllOf> {
@override
final Iterable<Type> types = const [OneObjectAllOf, _$OneObjectAllOf];
@override
final String wireName = 'OneObjectAllOf';
@override
Iterable<Object?> serialize(Serializers serializers, OneObjectAllOf object,
{FullType specifiedType = FullType.unspecified}) {
final result = <Object?>[
'attribute-allOf',
serializers.serialize(object.attributeAllOf, specifiedType: const FullType(String)),
];
return result;
}
@override
OneObjectAllOf deserialize(Serializers serializers, Iterable<Object?> 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<ObjectAllOf, ObjectAllOfBuilder>, 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<OneObjectAllOf, OneObjectAllOfBuilder>, 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

16
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"
}
}
}
]
}
}
},

Loading…
Cancel
Save