From bd8d4fcb98c0cf5e97edd75f1fbacb4b3d09184c Mon Sep 17 00:00:00 2001 From: Nikolas Rimikis Date: Fri, 3 Nov 2023 23:03:28 +0100 Subject: [PATCH] test(dynamite_end_to_end_test): test problematic ofs Signed-off-by: Nikolas Rimikis --- .../lib/all_of.openapi.dart | 71 + .../lib/all_of.openapi.g.dart | 170 +++ .../lib/all_of.openapi.json | 40 + .../lib/any_of.openapi.dart | 540 ++++++++ .../lib/any_of.openapi.g.dart | 1205 +++++++++++++++++ .../lib/any_of.openapi.json | 110 ++ .../lib/one_of.openapi.dart | 540 ++++++++ .../lib/one_of.openapi.g.dart | 1205 +++++++++++++++++ .../lib/one_of.openapi.json | 110 ++ 9 files changed, 3991 insertions(+) create mode 100644 packages/dynamite/dynamite_end_to_end_test/lib/all_of.openapi.dart create mode 100644 packages/dynamite/dynamite_end_to_end_test/lib/all_of.openapi.g.dart create mode 100644 packages/dynamite/dynamite_end_to_end_test/lib/all_of.openapi.json create mode 100644 packages/dynamite/dynamite_end_to_end_test/lib/any_of.openapi.dart create mode 100644 packages/dynamite/dynamite_end_to_end_test/lib/any_of.openapi.g.dart create mode 100644 packages/dynamite/dynamite_end_to_end_test/lib/any_of.openapi.json create mode 100644 packages/dynamite/dynamite_end_to_end_test/lib/one_of.openapi.dart create mode 100644 packages/dynamite/dynamite_end_to_end_test/lib/one_of.openapi.g.dart create mode 100644 packages/dynamite/dynamite_end_to_end_test/lib/one_of.openapi.json 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 new file mode 100644 index 00000000..2edb2c9d --- /dev/null +++ b/packages/dynamite/dynamite_end_to_end_test/lib/all_of.openapi.dart @@ -0,0 +1,71 @@ +// ignore_for_file: camel_case_types +// ignore_for_file: discarded_futures +// ignore_for_file: public_member_api_docs +// ignore_for_file: unreachable_switch_case + +import 'package:built_value/built_value.dart'; +import 'package:built_value/serializer.dart'; +import 'package:built_value/standard_json_plugin.dart'; +import 'package:dynamite_runtime/built_value.dart'; +import 'package:dynamite_runtime/http_client.dart'; + +part 'all_of.openapi.g.dart'; + +class Client extends DynamiteClient { + Client( + super.baseURL, { + super.baseHeaders, + super.userAgent, + super.httpClient, + super.cookieJar, + }); + + Client.fromClient(final DynamiteClient client) + : super( + client.baseURL, + baseHeaders: client.baseHeaders, + httpClient: client.httpClient, + cookieJar: client.cookieJar, + authentications: client.authentications, + ); +} + +@BuiltValue(instantiable: false) +abstract interface class ObjectAllOf_0Interface { + @BuiltValueField(wireName: 'attribute1-allOf') + String get attribute1AllOf; +} + +@BuiltValue(instantiable: false) +abstract interface class ObjectAllOf_1Interface { + @BuiltValueField(wireName: 'attribute2-allOf') + String get attribute2AllOf; +} + +@BuiltValue(instantiable: false) +abstract interface class ObjectAllOfInterface implements ObjectAllOf_0Interface, ObjectAllOf_1Interface {} + +abstract class ObjectAllOf implements ObjectAllOfInterface, Built { + factory ObjectAllOf([final void Function(ObjectAllOfBuilder)? b]) = _$ObjectAllOf; + + const ObjectAllOf._(); + + factory ObjectAllOf.fromJson(final Map json) => _jsonSerializers.deserializeWith(serializer, json)!; + + Map toJson() => _jsonSerializers.serializeWith(serializer, this)! as Map; + + static Serializer get serializer => _$objectAllOfSerializer; +} + +// coverage:ignore-start +final Serializers _serializers = (Serializers().toBuilder() + ..addBuilderFactory(const FullType(ObjectAllOf), ObjectAllOf.new) + ..add(ObjectAllOf.serializer)) + .build(); + +final Serializers _jsonSerializers = (_serializers.toBuilder() + ..add(DynamiteDoubleSerializer()) + ..addPlugin(StandardJsonPlugin()) + ..addPlugin(const ContentStringPlugin())) + .build(); +// coverage:ignore-end 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 new file mode 100644 index 00000000..32b10f06 --- /dev/null +++ b/packages/dynamite/dynamite_end_to_end_test/lib/all_of.openapi.g.dart @@ -0,0 +1,170 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'all_of.openapi.dart'; + +// ************************************************************************** +// BuiltValueGenerator +// ************************************************************************** + +Serializer _$objectAllOfSerializer = _$ObjectAllOfSerializer(); + +class _$ObjectAllOfSerializer implements StructuredSerializer { + @override + final Iterable types = const [ObjectAllOf, _$ObjectAllOf]; + @override + final String wireName = 'ObjectAllOf'; + + @override + Iterable serialize(Serializers serializers, ObjectAllOf object, + {FullType specifiedType = FullType.unspecified}) { + final result = [ + 'attribute1-allOf', + serializers.serialize(object.attribute1AllOf, specifiedType: const FullType(String)), + 'attribute2-allOf', + serializers.serialize(object.attribute2AllOf, specifiedType: const FullType(String)), + ]; + + return result; + } + + @override + ObjectAllOf deserialize(Serializers serializers, Iterable serialized, + {FullType specifiedType = FullType.unspecified}) { + final result = ObjectAllOfBuilder(); + + final iterator = serialized.iterator; + while (iterator.moveNext()) { + final key = iterator.current! as String; + iterator.moveNext(); + final Object? value = iterator.current; + switch (key) { + case 'attribute1-allOf': + result.attribute1AllOf = serializers.deserialize(value, specifiedType: const FullType(String))! as String; + break; + case 'attribute2-allOf': + result.attribute2AllOf = 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); + String? get attribute1AllOf; + set attribute1AllOf(String? attribute1AllOf); +} + +abstract mixin class ObjectAllOf_1InterfaceBuilder { + void replace(ObjectAllOf_1Interface other); + void update(void Function(ObjectAllOf_1InterfaceBuilder) updates); + String? get attribute2AllOf; + set attribute2AllOf(String? attribute2AllOf); +} + +abstract mixin class ObjectAllOfInterfaceBuilder + implements ObjectAllOf_0InterfaceBuilder, ObjectAllOf_1InterfaceBuilder { + void replace(covariant ObjectAllOfInterface other); + void update(void Function(ObjectAllOfInterfaceBuilder) updates); + String? get attribute1AllOf; + set attribute1AllOf(covariant String? attribute1AllOf); + + String? get attribute2AllOf; + set attribute2AllOf(covariant String? attribute2AllOf); +} + +class _$ObjectAllOf extends ObjectAllOf { + @override + final String attribute1AllOf; + @override + final String attribute2AllOf; + + factory _$ObjectAllOf([void Function(ObjectAllOfBuilder)? updates]) => + (ObjectAllOfBuilder()..update(updates))._build(); + + _$ObjectAllOf._({required this.attribute1AllOf, required this.attribute2AllOf}) : super._() { + BuiltValueNullFieldError.checkNotNull(attribute1AllOf, r'ObjectAllOf', 'attribute1AllOf'); + BuiltValueNullFieldError.checkNotNull(attribute2AllOf, r'ObjectAllOf', 'attribute2AllOf'); + } + + @override + ObjectAllOf rebuild(void Function(ObjectAllOfBuilder) updates) => (toBuilder()..update(updates)).build(); + + @override + ObjectAllOfBuilder toBuilder() => ObjectAllOfBuilder()..replace(this); + + @override + bool operator ==(Object other) { + if (identical(other, this)) return true; + return other is ObjectAllOf && attribute1AllOf == other.attribute1AllOf && attribute2AllOf == other.attribute2AllOf; + } + + @override + int get hashCode { + var _$hash = 0; + _$hash = $jc(_$hash, attribute1AllOf.hashCode); + _$hash = $jc(_$hash, attribute2AllOf.hashCode); + _$hash = $jf(_$hash); + return _$hash; + } + + @override + String toString() { + return (newBuiltValueToStringHelper(r'ObjectAllOf') + ..add('attribute1AllOf', attribute1AllOf) + ..add('attribute2AllOf', attribute2AllOf)) + .toString(); + } +} + +class ObjectAllOfBuilder implements Builder, ObjectAllOfInterfaceBuilder { + _$ObjectAllOf? _$v; + + String? _attribute1AllOf; + String? get attribute1AllOf => _$this._attribute1AllOf; + set attribute1AllOf(covariant String? attribute1AllOf) => _$this._attribute1AllOf = attribute1AllOf; + + String? _attribute2AllOf; + String? get attribute2AllOf => _$this._attribute2AllOf; + set attribute2AllOf(covariant String? attribute2AllOf) => _$this._attribute2AllOf = attribute2AllOf; + + ObjectAllOfBuilder(); + + ObjectAllOfBuilder get _$this { + final $v = _$v; + if ($v != null) { + _attribute1AllOf = $v.attribute1AllOf; + _attribute2AllOf = $v.attribute2AllOf; + _$v = null; + } + return this; + } + + @override + void replace(covariant ObjectAllOf other) { + ArgumentError.checkNotNull(other, 'other'); + _$v = other as _$ObjectAllOf; + } + + @override + void update(void Function(ObjectAllOfBuilder)? updates) { + if (updates != null) updates(this); + } + + @override + ObjectAllOf build() => _build(); + + _$ObjectAllOf _build() { + final _$result = _$v ?? + _$ObjectAllOf._( + attribute1AllOf: BuiltValueNullFieldError.checkNotNull(attribute1AllOf, r'ObjectAllOf', 'attribute1AllOf'), + attribute2AllOf: BuiltValueNullFieldError.checkNotNull(attribute2AllOf, r'ObjectAllOf', 'attribute2AllOf')); + 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 new file mode 100644 index 00000000..b56feda1 --- /dev/null +++ b/packages/dynamite/dynamite_end_to_end_test/lib/all_of.openapi.json @@ -0,0 +1,40 @@ +{ + "openapi": "3.1.0", + "info": { + "title": "all of test", + "version": "0.0.1" + }, + "components": { + "schemas": { + "ObjectAllOf": { + "description": "All of with objects only.", + "allOf": [ + { + "type": "object", + "required": [ + "attribute1-allOf" + ], + "properties": { + "attribute1-allOf": { + "type": "string" + } + } + }, + { + "type": "object", + "required": [ + "attribute2-allOf" + ], + "properties": { + "attribute2-allOf": { + "type": "string" + } + } + } + ] + } + } + }, + "paths": {}, + "tags": [] +} diff --git a/packages/dynamite/dynamite_end_to_end_test/lib/any_of.openapi.dart b/packages/dynamite/dynamite_end_to_end_test/lib/any_of.openapi.dart new file mode 100644 index 00000000..7115c38b --- /dev/null +++ b/packages/dynamite/dynamite_end_to_end_test/lib/any_of.openapi.dart @@ -0,0 +1,540 @@ +// ignore_for_file: camel_case_types +// ignore_for_file: discarded_futures +// ignore_for_file: public_member_api_docs +// ignore_for_file: unreachable_switch_case + +import 'package:built_value/built_value.dart'; +import 'package:built_value/json_object.dart'; +import 'package:built_value/serializer.dart'; +import 'package:built_value/standard_json_plugin.dart'; +import 'package:collection/collection.dart'; +import 'package:dynamite_runtime/built_value.dart'; +import 'package:dynamite_runtime/http_client.dart'; + +part 'any_of.openapi.g.dart'; + +class Client extends DynamiteClient { + Client( + super.baseURL, { + super.baseHeaders, + super.userAgent, + super.httpClient, + super.cookieJar, + }); + + Client.fromClient(final DynamiteClient client) + : super( + client.baseURL, + baseHeaders: client.baseHeaders, + httpClient: client.httpClient, + cookieJar: client.cookieJar, + authentications: client.authentications, + ); +} + +@BuiltValue(instantiable: false) +abstract interface class ObjectAnyOf0Interface { + @BuiltValueField(wireName: 'attribute1-anyOf') + String get attribute1AnyOf; +} + +abstract class ObjectAnyOf0 implements ObjectAnyOf0Interface, Built { + factory ObjectAnyOf0([final void Function(ObjectAnyOf0Builder)? b]) = _$ObjectAnyOf0; + + const ObjectAnyOf0._(); + + factory ObjectAnyOf0.fromJson(final Map json) => _jsonSerializers.deserializeWith(serializer, json)!; + + Map toJson() => _jsonSerializers.serializeWith(serializer, this)! as Map; + + static Serializer get serializer => _$objectAnyOf0Serializer; +} + +@BuiltValue(instantiable: false) +abstract interface class ObjectAnyOf1Interface { + @BuiltValueField(wireName: 'attribute2-anyOf') + String get attribute2AnyOf; +} + +abstract class ObjectAnyOf1 implements ObjectAnyOf1Interface, Built { + factory ObjectAnyOf1([final void Function(ObjectAnyOf1Builder)? b]) = _$ObjectAnyOf1; + + const ObjectAnyOf1._(); + + factory ObjectAnyOf1.fromJson(final Map json) => _jsonSerializers.deserializeWith(serializer, json)!; + + Map toJson() => _jsonSerializers.serializeWith(serializer, this)! as Map; + + static Serializer get serializer => _$objectAnyOf1Serializer; +} + +@BuiltValue(instantiable: false) +abstract interface class ObjectAnyOfInterface { + ObjectAnyOf0? get objectAnyOf0; + ObjectAnyOf1? get objectAnyOf1; +} + +abstract class ObjectAnyOf implements ObjectAnyOfInterface, Built { + factory ObjectAnyOf([final void Function(ObjectAnyOfBuilder)? b]) = _$ObjectAnyOf; + + const ObjectAnyOf._(); + + factory ObjectAnyOf.fromJson(final Map json) => _jsonSerializers.deserializeWith(serializer, json)!; + + Map toJson() => _jsonSerializers.serializeWith(serializer, this)! as Map; + + @BuiltValueSerializer(custom: true) + static Serializer get serializer => _$ObjectAnyOfSerializer(); + + JsonObject get data; + @BuiltValueHook(finalizeBuilder: true) + static void _validate(final ObjectAnyOfBuilder b) { + // When this is rebuild from another builder + if (b._data == null) { + return; + } + + final match = [b._objectAnyOf0, b._objectAnyOf1].firstWhereOrNull((final x) => x != null); + if (match == null) { + throw StateError("Need at least one of 'objectAnyOf0', 'objectAnyOf1' for ${b._data}"); + } + } +} + +class _$ObjectAnyOfSerializer implements PrimitiveSerializer { + @override + final Iterable types = const [ObjectAnyOf, _$ObjectAnyOf]; + + @override + final String wireName = 'ObjectAnyOf'; + + @override + Object serialize( + final Serializers serializers, + final ObjectAnyOf object, { + final FullType specifiedType = FullType.unspecified, + }) => + object.data.value; + + @override + ObjectAnyOf deserialize( + final Serializers serializers, + final Object data, { + final FullType specifiedType = FullType.unspecified, + }) { + final result = ObjectAnyOfBuilder()..data = JsonObject(data); + try { + final value = _jsonSerializers.deserialize(data, specifiedType: const FullType(ObjectAnyOf0))! as ObjectAnyOf0; + result.objectAnyOf0.replace(value); + } catch (_) {} + try { + final value = _jsonSerializers.deserialize(data, specifiedType: const FullType(ObjectAnyOf1))! as ObjectAnyOf1; + result.objectAnyOf1.replace(value); + } catch (_) {} + return result.build(); + } +} + +@BuiltValue(instantiable: false) +abstract interface class MixedAnyOf1Interface { + @BuiltValueField(wireName: 'attribute-anyOf') + String get attributeAnyOf; +} + +abstract class MixedAnyOf1 implements MixedAnyOf1Interface, Built { + factory MixedAnyOf1([final void Function(MixedAnyOf1Builder)? b]) = _$MixedAnyOf1; + + const MixedAnyOf1._(); + + factory MixedAnyOf1.fromJson(final Map json) => _jsonSerializers.deserializeWith(serializer, json)!; + + Map toJson() => _jsonSerializers.serializeWith(serializer, this)! as Map; + + static Serializer get serializer => _$mixedAnyOf1Serializer; +} + +@BuiltValue(instantiable: false) +abstract interface class MixedAnyOfInterface { + String? get string; + MixedAnyOf1? get mixedAnyOf1; +} + +abstract class MixedAnyOf implements MixedAnyOfInterface, Built { + factory MixedAnyOf([final void Function(MixedAnyOfBuilder)? b]) = _$MixedAnyOf; + + const MixedAnyOf._(); + + factory MixedAnyOf.fromJson(final Map json) => _jsonSerializers.deserializeWith(serializer, json)!; + + Map toJson() => _jsonSerializers.serializeWith(serializer, this)! as Map; + + @BuiltValueSerializer(custom: true) + static Serializer get serializer => _$MixedAnyOfSerializer(); + + JsonObject get data; + @BuiltValueHook(finalizeBuilder: true) + static void _validate(final MixedAnyOfBuilder b) { + // When this is rebuild from another builder + if (b._data == null) { + return; + } + + final match = [b._string, b._mixedAnyOf1].firstWhereOrNull((final x) => x != null); + if (match == null) { + throw StateError("Need at least one of 'string', 'mixedAnyOf1' for ${b._data}"); + } + } +} + +class _$MixedAnyOfSerializer implements PrimitiveSerializer { + @override + final Iterable types = const [MixedAnyOf, _$MixedAnyOf]; + + @override + final String wireName = 'MixedAnyOf'; + + @override + Object serialize( + final Serializers serializers, + final MixedAnyOf object, { + final FullType specifiedType = FullType.unspecified, + }) => + object.data.value; + + @override + MixedAnyOf deserialize( + final Serializers serializers, + final Object data, { + final FullType specifiedType = FullType.unspecified, + }) { + final result = MixedAnyOfBuilder()..data = JsonObject(data); + try { + final value = _jsonSerializers.deserialize(data, specifiedType: const FullType(String))! as String; + result.string = value; + } catch (_) {} + try { + final value = _jsonSerializers.deserialize(data, specifiedType: const FullType(MixedAnyOf1))! as MixedAnyOf1; + result.mixedAnyOf1.replace(value); + } catch (_) {} + return result.build(); + } +} + +@BuiltValue(instantiable: false) +abstract interface class OneObjectAnyOf0Interface { + @BuiltValueField(wireName: 'attribute-anyOf') + String get attributeAnyOf; +} + +abstract class OneObjectAnyOf0 implements OneObjectAnyOf0Interface, Built { + factory OneObjectAnyOf0([final void Function(OneObjectAnyOf0Builder)? b]) = _$OneObjectAnyOf0; + + const OneObjectAnyOf0._(); + + factory OneObjectAnyOf0.fromJson(final Map json) => + _jsonSerializers.deserializeWith(serializer, json)!; + + Map toJson() => _jsonSerializers.serializeWith(serializer, this)! as Map; + + static Serializer get serializer => _$oneObjectAnyOf0Serializer; +} + +@BuiltValue(instantiable: false) +abstract interface class OneObjectAnyOfInterface { + OneObjectAnyOf0? get oneObjectAnyOf0; +} + +abstract class OneObjectAnyOf implements OneObjectAnyOfInterface, Built { + factory OneObjectAnyOf([final void Function(OneObjectAnyOfBuilder)? b]) = _$OneObjectAnyOf; + + const OneObjectAnyOf._(); + + factory OneObjectAnyOf.fromJson(final Map json) => + _jsonSerializers.deserializeWith(serializer, json)!; + + Map toJson() => _jsonSerializers.serializeWith(serializer, this)! as Map; + + @BuiltValueSerializer(custom: true) + static Serializer get serializer => _$OneObjectAnyOfSerializer(); + + JsonObject get data; + @BuiltValueHook(finalizeBuilder: true) + static void _validate(final OneObjectAnyOfBuilder b) { + // When this is rebuild from another builder + if (b._data == null) { + return; + } + + final match = [b._oneObjectAnyOf0].firstWhereOrNull((final x) => x != null); + if (match == null) { + throw StateError("Need at least one of 'oneObjectAnyOf0' for ${b._data}"); + } + } +} + +class _$OneObjectAnyOfSerializer implements PrimitiveSerializer { + @override + final Iterable types = const [OneObjectAnyOf, _$OneObjectAnyOf]; + + @override + final String wireName = 'OneObjectAnyOf'; + + @override + Object serialize( + final Serializers serializers, + final OneObjectAnyOf object, { + final FullType specifiedType = FullType.unspecified, + }) => + object.data.value; + + @override + OneObjectAnyOf deserialize( + final Serializers serializers, + final Object data, { + final FullType specifiedType = FullType.unspecified, + }) { + final result = OneObjectAnyOfBuilder()..data = JsonObject(data); + try { + final value = + _jsonSerializers.deserialize(data, specifiedType: const FullType(OneObjectAnyOf0))! as OneObjectAnyOf0; + result.oneObjectAnyOf0.replace(value); + } catch (_) {} + return result.build(); + } +} + +@BuiltValue(instantiable: false) +abstract interface class OneValueAnyOfInterface { + String? get string; +} + +abstract class OneValueAnyOf implements OneValueAnyOfInterface, Built { + factory OneValueAnyOf([final void Function(OneValueAnyOfBuilder)? b]) = _$OneValueAnyOf; + + const OneValueAnyOf._(); + + factory OneValueAnyOf.fromJson(final Map json) => + _jsonSerializers.deserializeWith(serializer, json)!; + + Map toJson() => _jsonSerializers.serializeWith(serializer, this)! as Map; + + @BuiltValueSerializer(custom: true) + static Serializer get serializer => _$OneValueAnyOfSerializer(); + + JsonObject get data; + @BuiltValueHook(finalizeBuilder: true) + static void _validate(final OneValueAnyOfBuilder b) { + // When this is rebuild from another builder + if (b._data == null) { + return; + } + + final match = [b._string].firstWhereOrNull((final x) => x != null); + if (match == null) { + throw StateError("Need at least one of 'string' for ${b._data}"); + } + } +} + +class _$OneValueAnyOfSerializer implements PrimitiveSerializer { + @override + final Iterable types = const [OneValueAnyOf, _$OneValueAnyOf]; + + @override + final String wireName = 'OneValueAnyOf'; + + @override + Object serialize( + final Serializers serializers, + final OneValueAnyOf object, { + final FullType specifiedType = FullType.unspecified, + }) => + object.data.value; + + @override + OneValueAnyOf deserialize( + final Serializers serializers, + final Object data, { + final FullType specifiedType = FullType.unspecified, + }) { + final result = OneValueAnyOfBuilder()..data = JsonObject(data); + try { + final value = _jsonSerializers.deserialize(data, specifiedType: const FullType(String))! as String; + result.string = value; + } catch (_) {} + return result.build(); + } +} + +@BuiltValue(instantiable: false) +abstract interface class AnyOfIntDoubleInterface { + int? get $int; + double? get $double; +} + +abstract class AnyOfIntDouble implements AnyOfIntDoubleInterface, Built { + factory AnyOfIntDouble([final void Function(AnyOfIntDoubleBuilder)? b]) = _$AnyOfIntDouble; + + const AnyOfIntDouble._(); + + factory AnyOfIntDouble.fromJson(final Map json) => + _jsonSerializers.deserializeWith(serializer, json)!; + + Map toJson() => _jsonSerializers.serializeWith(serializer, this)! as Map; + + @BuiltValueSerializer(custom: true) + static Serializer get serializer => _$AnyOfIntDoubleSerializer(); + + JsonObject get data; + @BuiltValueHook(finalizeBuilder: true) + static void _validate(final AnyOfIntDoubleBuilder b) { + // When this is rebuild from another builder + if (b._data == null) { + return; + } + + final match = [b._$int, b._$double].firstWhereOrNull((final x) => x != null); + if (match == null) { + throw StateError("Need at least one of '$int', '$double' for ${b._data}"); + } + } +} + +class _$AnyOfIntDoubleSerializer implements PrimitiveSerializer { + @override + final Iterable types = const [AnyOfIntDouble, _$AnyOfIntDouble]; + + @override + final String wireName = 'AnyOfIntDouble'; + + @override + Object serialize( + final Serializers serializers, + final AnyOfIntDouble object, { + final FullType specifiedType = FullType.unspecified, + }) => + object.data.value; + + @override + AnyOfIntDouble deserialize( + final Serializers serializers, + final Object data, { + final FullType specifiedType = FullType.unspecified, + }) { + final result = AnyOfIntDoubleBuilder()..data = JsonObject(data); + try { + final value = _jsonSerializers.deserialize(data, specifiedType: const FullType(int))! as int; + result.$int = value; + } catch (_) {} + try { + final value = _jsonSerializers.deserialize(data, specifiedType: const FullType(double))! as double; + result.$double = value; + } catch (_) {} + return result.build(); + } +} + +@BuiltValue(instantiable: false) +abstract interface class AnyOfIntDoubleOtherInterface { + int? get $int; + double? get $double; + String? get string; +} + +abstract class AnyOfIntDoubleOther + implements AnyOfIntDoubleOtherInterface, Built { + factory AnyOfIntDoubleOther([final void Function(AnyOfIntDoubleOtherBuilder)? b]) = _$AnyOfIntDoubleOther; + + const AnyOfIntDoubleOther._(); + + factory AnyOfIntDoubleOther.fromJson(final Map json) => + _jsonSerializers.deserializeWith(serializer, json)!; + + Map toJson() => _jsonSerializers.serializeWith(serializer, this)! as Map; + + @BuiltValueSerializer(custom: true) + static Serializer get serializer => _$AnyOfIntDoubleOtherSerializer(); + + JsonObject get data; + @BuiltValueHook(finalizeBuilder: true) + static void _validate(final AnyOfIntDoubleOtherBuilder b) { + // When this is rebuild from another builder + if (b._data == null) { + return; + } + + final match = [b._$int, b._$double, b._string].firstWhereOrNull((final x) => x != null); + if (match == null) { + throw StateError("Need at least one of '$int', '$double', 'string' for ${b._data}"); + } + } +} + +class _$AnyOfIntDoubleOtherSerializer implements PrimitiveSerializer { + @override + final Iterable types = const [AnyOfIntDoubleOther, _$AnyOfIntDoubleOther]; + + @override + final String wireName = 'AnyOfIntDoubleOther'; + + @override + Object serialize( + final Serializers serializers, + final AnyOfIntDoubleOther object, { + final FullType specifiedType = FullType.unspecified, + }) => + object.data.value; + + @override + AnyOfIntDoubleOther deserialize( + final Serializers serializers, + final Object data, { + final FullType specifiedType = FullType.unspecified, + }) { + final result = AnyOfIntDoubleOtherBuilder()..data = JsonObject(data); + try { + final value = _jsonSerializers.deserialize(data, specifiedType: const FullType(int))! as int; + result.$int = value; + } catch (_) {} + try { + final value = _jsonSerializers.deserialize(data, specifiedType: const FullType(double))! as double; + result.$double = value; + } catch (_) {} + try { + final value = _jsonSerializers.deserialize(data, specifiedType: const FullType(String))! as String; + result.string = value; + } catch (_) {} + return result.build(); + } +} + +// coverage:ignore-start +final Serializers _serializers = (Serializers().toBuilder() + ..addBuilderFactory(const FullType(ObjectAnyOf), ObjectAnyOf.new) + ..add(ObjectAnyOf.serializer) + ..addBuilderFactory(const FullType(ObjectAnyOf0), ObjectAnyOf0.new) + ..add(ObjectAnyOf0.serializer) + ..addBuilderFactory(const FullType(ObjectAnyOf1), ObjectAnyOf1.new) + ..add(ObjectAnyOf1.serializer) + ..addBuilderFactory(const FullType(MixedAnyOf), MixedAnyOf.new) + ..add(MixedAnyOf.serializer) + ..addBuilderFactory(const FullType(MixedAnyOf1), MixedAnyOf1.new) + ..add(MixedAnyOf1.serializer) + ..addBuilderFactory(const FullType(OneObjectAnyOf), OneObjectAnyOf.new) + ..add(OneObjectAnyOf.serializer) + ..addBuilderFactory(const FullType(OneObjectAnyOf0), OneObjectAnyOf0.new) + ..add(OneObjectAnyOf0.serializer) + ..addBuilderFactory(const FullType(OneValueAnyOf), OneValueAnyOf.new) + ..add(OneValueAnyOf.serializer) + ..addBuilderFactory(const FullType(AnyOfIntDouble), AnyOfIntDouble.new) + ..add(AnyOfIntDouble.serializer) + ..addBuilderFactory(const FullType(AnyOfIntDoubleOther), AnyOfIntDoubleOther.new) + ..add(AnyOfIntDoubleOther.serializer)) + .build(); + +final Serializers _jsonSerializers = (_serializers.toBuilder() + ..add(DynamiteDoubleSerializer()) + ..addPlugin(StandardJsonPlugin()) + ..addPlugin(const ContentStringPlugin())) + .build(); +// coverage:ignore-end diff --git a/packages/dynamite/dynamite_end_to_end_test/lib/any_of.openapi.g.dart b/packages/dynamite/dynamite_end_to_end_test/lib/any_of.openapi.g.dart new file mode 100644 index 00000000..c0bc1795 --- /dev/null +++ b/packages/dynamite/dynamite_end_to_end_test/lib/any_of.openapi.g.dart @@ -0,0 +1,1205 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'any_of.openapi.dart'; + +// ************************************************************************** +// BuiltValueGenerator +// ************************************************************************** + +Serializer _$objectAnyOf0Serializer = _$ObjectAnyOf0Serializer(); +Serializer _$objectAnyOf1Serializer = _$ObjectAnyOf1Serializer(); +Serializer _$mixedAnyOf1Serializer = _$MixedAnyOf1Serializer(); +Serializer _$oneObjectAnyOf0Serializer = _$OneObjectAnyOf0Serializer(); + +class _$ObjectAnyOf0Serializer implements StructuredSerializer { + @override + final Iterable types = const [ObjectAnyOf0, _$ObjectAnyOf0]; + @override + final String wireName = 'ObjectAnyOf0'; + + @override + Iterable serialize(Serializers serializers, ObjectAnyOf0 object, + {FullType specifiedType = FullType.unspecified}) { + final result = [ + 'attribute1-anyOf', + serializers.serialize(object.attribute1AnyOf, specifiedType: const FullType(String)), + ]; + + return result; + } + + @override + ObjectAnyOf0 deserialize(Serializers serializers, Iterable serialized, + {FullType specifiedType = FullType.unspecified}) { + final result = ObjectAnyOf0Builder(); + + final iterator = serialized.iterator; + while (iterator.moveNext()) { + final key = iterator.current! as String; + iterator.moveNext(); + final Object? value = iterator.current; + switch (key) { + case 'attribute1-anyOf': + result.attribute1AnyOf = serializers.deserialize(value, specifiedType: const FullType(String))! as String; + break; + } + } + + return result.build(); + } +} + +class _$ObjectAnyOf1Serializer implements StructuredSerializer { + @override + final Iterable types = const [ObjectAnyOf1, _$ObjectAnyOf1]; + @override + final String wireName = 'ObjectAnyOf1'; + + @override + Iterable serialize(Serializers serializers, ObjectAnyOf1 object, + {FullType specifiedType = FullType.unspecified}) { + final result = [ + 'attribute2-anyOf', + serializers.serialize(object.attribute2AnyOf, specifiedType: const FullType(String)), + ]; + + return result; + } + + @override + ObjectAnyOf1 deserialize(Serializers serializers, Iterable serialized, + {FullType specifiedType = FullType.unspecified}) { + final result = ObjectAnyOf1Builder(); + + final iterator = serialized.iterator; + while (iterator.moveNext()) { + final key = iterator.current! as String; + iterator.moveNext(); + final Object? value = iterator.current; + switch (key) { + case 'attribute2-anyOf': + result.attribute2AnyOf = serializers.deserialize(value, specifiedType: const FullType(String))! as String; + break; + } + } + + return result.build(); + } +} + +class _$MixedAnyOf1Serializer implements StructuredSerializer { + @override + final Iterable types = const [MixedAnyOf1, _$MixedAnyOf1]; + @override + final String wireName = 'MixedAnyOf1'; + + @override + Iterable serialize(Serializers serializers, MixedAnyOf1 object, + {FullType specifiedType = FullType.unspecified}) { + final result = [ + 'attribute-anyOf', + serializers.serialize(object.attributeAnyOf, specifiedType: const FullType(String)), + ]; + + return result; + } + + @override + MixedAnyOf1 deserialize(Serializers serializers, Iterable serialized, + {FullType specifiedType = FullType.unspecified}) { + final result = MixedAnyOf1Builder(); + + final iterator = serialized.iterator; + while (iterator.moveNext()) { + final key = iterator.current! as String; + iterator.moveNext(); + final Object? value = iterator.current; + switch (key) { + case 'attribute-anyOf': + result.attributeAnyOf = serializers.deserialize(value, specifiedType: const FullType(String))! as String; + break; + } + } + + return result.build(); + } +} + +class _$OneObjectAnyOf0Serializer implements StructuredSerializer { + @override + final Iterable types = const [OneObjectAnyOf0, _$OneObjectAnyOf0]; + @override + final String wireName = 'OneObjectAnyOf0'; + + @override + Iterable serialize(Serializers serializers, OneObjectAnyOf0 object, + {FullType specifiedType = FullType.unspecified}) { + final result = [ + 'attribute-anyOf', + serializers.serialize(object.attributeAnyOf, specifiedType: const FullType(String)), + ]; + + return result; + } + + @override + OneObjectAnyOf0 deserialize(Serializers serializers, Iterable serialized, + {FullType specifiedType = FullType.unspecified}) { + final result = OneObjectAnyOf0Builder(); + + final iterator = serialized.iterator; + while (iterator.moveNext()) { + final key = iterator.current! as String; + iterator.moveNext(); + final Object? value = iterator.current; + switch (key) { + case 'attribute-anyOf': + result.attributeAnyOf = serializers.deserialize(value, specifiedType: const FullType(String))! as String; + break; + } + } + + return result.build(); + } +} + +abstract mixin class ObjectAnyOf0InterfaceBuilder { + void replace(ObjectAnyOf0Interface other); + void update(void Function(ObjectAnyOf0InterfaceBuilder) updates); + String? get attribute1AnyOf; + set attribute1AnyOf(String? attribute1AnyOf); +} + +class _$ObjectAnyOf0 extends ObjectAnyOf0 { + @override + final String attribute1AnyOf; + + factory _$ObjectAnyOf0([void Function(ObjectAnyOf0Builder)? updates]) => + (ObjectAnyOf0Builder()..update(updates))._build(); + + _$ObjectAnyOf0._({required this.attribute1AnyOf}) : super._() { + BuiltValueNullFieldError.checkNotNull(attribute1AnyOf, r'ObjectAnyOf0', 'attribute1AnyOf'); + } + + @override + ObjectAnyOf0 rebuild(void Function(ObjectAnyOf0Builder) updates) => (toBuilder()..update(updates)).build(); + + @override + ObjectAnyOf0Builder toBuilder() => ObjectAnyOf0Builder()..replace(this); + + @override + bool operator ==(Object other) { + if (identical(other, this)) return true; + return other is ObjectAnyOf0 && attribute1AnyOf == other.attribute1AnyOf; + } + + @override + int get hashCode { + var _$hash = 0; + _$hash = $jc(_$hash, attribute1AnyOf.hashCode); + _$hash = $jf(_$hash); + return _$hash; + } + + @override + String toString() { + return (newBuiltValueToStringHelper(r'ObjectAnyOf0')..add('attribute1AnyOf', attribute1AnyOf)).toString(); + } +} + +class ObjectAnyOf0Builder implements Builder, ObjectAnyOf0InterfaceBuilder { + _$ObjectAnyOf0? _$v; + + String? _attribute1AnyOf; + String? get attribute1AnyOf => _$this._attribute1AnyOf; + set attribute1AnyOf(covariant String? attribute1AnyOf) => _$this._attribute1AnyOf = attribute1AnyOf; + + ObjectAnyOf0Builder(); + + ObjectAnyOf0Builder get _$this { + final $v = _$v; + if ($v != null) { + _attribute1AnyOf = $v.attribute1AnyOf; + _$v = null; + } + return this; + } + + @override + void replace(covariant ObjectAnyOf0 other) { + ArgumentError.checkNotNull(other, 'other'); + _$v = other as _$ObjectAnyOf0; + } + + @override + void update(void Function(ObjectAnyOf0Builder)? updates) { + if (updates != null) updates(this); + } + + @override + ObjectAnyOf0 build() => _build(); + + _$ObjectAnyOf0 _build() { + final _$result = _$v ?? + _$ObjectAnyOf0._( + attribute1AnyOf: + BuiltValueNullFieldError.checkNotNull(attribute1AnyOf, r'ObjectAnyOf0', 'attribute1AnyOf')); + replace(_$result); + return _$result; + } +} + +abstract mixin class ObjectAnyOf1InterfaceBuilder { + void replace(ObjectAnyOf1Interface other); + void update(void Function(ObjectAnyOf1InterfaceBuilder) updates); + String? get attribute2AnyOf; + set attribute2AnyOf(String? attribute2AnyOf); +} + +class _$ObjectAnyOf1 extends ObjectAnyOf1 { + @override + final String attribute2AnyOf; + + factory _$ObjectAnyOf1([void Function(ObjectAnyOf1Builder)? updates]) => + (ObjectAnyOf1Builder()..update(updates))._build(); + + _$ObjectAnyOf1._({required this.attribute2AnyOf}) : super._() { + BuiltValueNullFieldError.checkNotNull(attribute2AnyOf, r'ObjectAnyOf1', 'attribute2AnyOf'); + } + + @override + ObjectAnyOf1 rebuild(void Function(ObjectAnyOf1Builder) updates) => (toBuilder()..update(updates)).build(); + + @override + ObjectAnyOf1Builder toBuilder() => ObjectAnyOf1Builder()..replace(this); + + @override + bool operator ==(Object other) { + if (identical(other, this)) return true; + return other is ObjectAnyOf1 && attribute2AnyOf == other.attribute2AnyOf; + } + + @override + int get hashCode { + var _$hash = 0; + _$hash = $jc(_$hash, attribute2AnyOf.hashCode); + _$hash = $jf(_$hash); + return _$hash; + } + + @override + String toString() { + return (newBuiltValueToStringHelper(r'ObjectAnyOf1')..add('attribute2AnyOf', attribute2AnyOf)).toString(); + } +} + +class ObjectAnyOf1Builder implements Builder, ObjectAnyOf1InterfaceBuilder { + _$ObjectAnyOf1? _$v; + + String? _attribute2AnyOf; + String? get attribute2AnyOf => _$this._attribute2AnyOf; + set attribute2AnyOf(covariant String? attribute2AnyOf) => _$this._attribute2AnyOf = attribute2AnyOf; + + ObjectAnyOf1Builder(); + + ObjectAnyOf1Builder get _$this { + final $v = _$v; + if ($v != null) { + _attribute2AnyOf = $v.attribute2AnyOf; + _$v = null; + } + return this; + } + + @override + void replace(covariant ObjectAnyOf1 other) { + ArgumentError.checkNotNull(other, 'other'); + _$v = other as _$ObjectAnyOf1; + } + + @override + void update(void Function(ObjectAnyOf1Builder)? updates) { + if (updates != null) updates(this); + } + + @override + ObjectAnyOf1 build() => _build(); + + _$ObjectAnyOf1 _build() { + final _$result = _$v ?? + _$ObjectAnyOf1._( + attribute2AnyOf: + BuiltValueNullFieldError.checkNotNull(attribute2AnyOf, r'ObjectAnyOf1', 'attribute2AnyOf')); + replace(_$result); + return _$result; + } +} + +abstract mixin class ObjectAnyOfInterfaceBuilder { + void replace(ObjectAnyOfInterface other); + void update(void Function(ObjectAnyOfInterfaceBuilder) updates); + ObjectAnyOf0Builder get objectAnyOf0; + set objectAnyOf0(ObjectAnyOf0Builder? objectAnyOf0); + + ObjectAnyOf1Builder get objectAnyOf1; + set objectAnyOf1(ObjectAnyOf1Builder? objectAnyOf1); +} + +class _$ObjectAnyOf extends ObjectAnyOf { + @override + final JsonObject data; + @override + final ObjectAnyOf0? objectAnyOf0; + @override + final ObjectAnyOf1? objectAnyOf1; + + factory _$ObjectAnyOf([void Function(ObjectAnyOfBuilder)? updates]) => + (ObjectAnyOfBuilder()..update(updates))._build(); + + _$ObjectAnyOf._({required this.data, this.objectAnyOf0, this.objectAnyOf1}) : super._() { + BuiltValueNullFieldError.checkNotNull(data, r'ObjectAnyOf', 'data'); + } + + @override + ObjectAnyOf rebuild(void Function(ObjectAnyOfBuilder) updates) => (toBuilder()..update(updates)).build(); + + @override + ObjectAnyOfBuilder toBuilder() => ObjectAnyOfBuilder()..replace(this); + + @override + bool operator ==(Object other) { + if (identical(other, this)) return true; + return other is ObjectAnyOf && + data == other.data && + objectAnyOf0 == other.objectAnyOf0 && + objectAnyOf1 == other.objectAnyOf1; + } + + @override + int get hashCode { + var _$hash = 0; + _$hash = $jc(_$hash, data.hashCode); + _$hash = $jc(_$hash, objectAnyOf0.hashCode); + _$hash = $jc(_$hash, objectAnyOf1.hashCode); + _$hash = $jf(_$hash); + return _$hash; + } + + @override + String toString() { + return (newBuiltValueToStringHelper(r'ObjectAnyOf') + ..add('data', data) + ..add('objectAnyOf0', objectAnyOf0) + ..add('objectAnyOf1', objectAnyOf1)) + .toString(); + } +} + +class ObjectAnyOfBuilder implements Builder, ObjectAnyOfInterfaceBuilder { + _$ObjectAnyOf? _$v; + + JsonObject? _data; + JsonObject? get data => _$this._data; + set data(covariant JsonObject? data) => _$this._data = data; + + ObjectAnyOf0Builder? _objectAnyOf0; + ObjectAnyOf0Builder get objectAnyOf0 => _$this._objectAnyOf0 ??= ObjectAnyOf0Builder(); + set objectAnyOf0(covariant ObjectAnyOf0Builder? objectAnyOf0) => _$this._objectAnyOf0 = objectAnyOf0; + + ObjectAnyOf1Builder? _objectAnyOf1; + ObjectAnyOf1Builder get objectAnyOf1 => _$this._objectAnyOf1 ??= ObjectAnyOf1Builder(); + set objectAnyOf1(covariant ObjectAnyOf1Builder? objectAnyOf1) => _$this._objectAnyOf1 = objectAnyOf1; + + ObjectAnyOfBuilder(); + + ObjectAnyOfBuilder get _$this { + final $v = _$v; + if ($v != null) { + _data = $v.data; + _objectAnyOf0 = $v.objectAnyOf0?.toBuilder(); + _objectAnyOf1 = $v.objectAnyOf1?.toBuilder(); + _$v = null; + } + return this; + } + + @override + void replace(covariant ObjectAnyOf other) { + ArgumentError.checkNotNull(other, 'other'); + _$v = other as _$ObjectAnyOf; + } + + @override + void update(void Function(ObjectAnyOfBuilder)? updates) { + if (updates != null) updates(this); + } + + @override + ObjectAnyOf build() => _build(); + + _$ObjectAnyOf _build() { + ObjectAnyOf._validate(this); + _$ObjectAnyOf _$result; + try { + _$result = _$v ?? + _$ObjectAnyOf._( + data: BuiltValueNullFieldError.checkNotNull(data, r'ObjectAnyOf', 'data'), + objectAnyOf0: _objectAnyOf0?.build(), + objectAnyOf1: _objectAnyOf1?.build()); + } catch (_) { + late String _$failedField; + try { + _$failedField = 'objectAnyOf0'; + _objectAnyOf0?.build(); + _$failedField = 'objectAnyOf1'; + _objectAnyOf1?.build(); + } catch (e) { + throw BuiltValueNestedFieldError(r'ObjectAnyOf', _$failedField, e.toString()); + } + rethrow; + } + replace(_$result); + return _$result; + } +} + +abstract mixin class MixedAnyOf1InterfaceBuilder { + void replace(MixedAnyOf1Interface other); + void update(void Function(MixedAnyOf1InterfaceBuilder) updates); + String? get attributeAnyOf; + set attributeAnyOf(String? attributeAnyOf); +} + +class _$MixedAnyOf1 extends MixedAnyOf1 { + @override + final String attributeAnyOf; + + factory _$MixedAnyOf1([void Function(MixedAnyOf1Builder)? updates]) => + (MixedAnyOf1Builder()..update(updates))._build(); + + _$MixedAnyOf1._({required this.attributeAnyOf}) : super._() { + BuiltValueNullFieldError.checkNotNull(attributeAnyOf, r'MixedAnyOf1', 'attributeAnyOf'); + } + + @override + MixedAnyOf1 rebuild(void Function(MixedAnyOf1Builder) updates) => (toBuilder()..update(updates)).build(); + + @override + MixedAnyOf1Builder toBuilder() => MixedAnyOf1Builder()..replace(this); + + @override + bool operator ==(Object other) { + if (identical(other, this)) return true; + return other is MixedAnyOf1 && attributeAnyOf == other.attributeAnyOf; + } + + @override + int get hashCode { + var _$hash = 0; + _$hash = $jc(_$hash, attributeAnyOf.hashCode); + _$hash = $jf(_$hash); + return _$hash; + } + + @override + String toString() { + return (newBuiltValueToStringHelper(r'MixedAnyOf1')..add('attributeAnyOf', attributeAnyOf)).toString(); + } +} + +class MixedAnyOf1Builder implements Builder, MixedAnyOf1InterfaceBuilder { + _$MixedAnyOf1? _$v; + + String? _attributeAnyOf; + String? get attributeAnyOf => _$this._attributeAnyOf; + set attributeAnyOf(covariant String? attributeAnyOf) => _$this._attributeAnyOf = attributeAnyOf; + + MixedAnyOf1Builder(); + + MixedAnyOf1Builder get _$this { + final $v = _$v; + if ($v != null) { + _attributeAnyOf = $v.attributeAnyOf; + _$v = null; + } + return this; + } + + @override + void replace(covariant MixedAnyOf1 other) { + ArgumentError.checkNotNull(other, 'other'); + _$v = other as _$MixedAnyOf1; + } + + @override + void update(void Function(MixedAnyOf1Builder)? updates) { + if (updates != null) updates(this); + } + + @override + MixedAnyOf1 build() => _build(); + + _$MixedAnyOf1 _build() { + final _$result = _$v ?? + _$MixedAnyOf1._( + attributeAnyOf: BuiltValueNullFieldError.checkNotNull(attributeAnyOf, r'MixedAnyOf1', 'attributeAnyOf')); + replace(_$result); + return _$result; + } +} + +abstract mixin class MixedAnyOfInterfaceBuilder { + void replace(MixedAnyOfInterface other); + void update(void Function(MixedAnyOfInterfaceBuilder) updates); + String? get string; + set string(String? string); + + MixedAnyOf1Builder get mixedAnyOf1; + set mixedAnyOf1(MixedAnyOf1Builder? mixedAnyOf1); +} + +class _$MixedAnyOf extends MixedAnyOf { + @override + final JsonObject data; + @override + final String? string; + @override + final MixedAnyOf1? mixedAnyOf1; + + factory _$MixedAnyOf([void Function(MixedAnyOfBuilder)? updates]) => (MixedAnyOfBuilder()..update(updates))._build(); + + _$MixedAnyOf._({required this.data, this.string, this.mixedAnyOf1}) : super._() { + BuiltValueNullFieldError.checkNotNull(data, r'MixedAnyOf', 'data'); + } + + @override + MixedAnyOf rebuild(void Function(MixedAnyOfBuilder) updates) => (toBuilder()..update(updates)).build(); + + @override + MixedAnyOfBuilder toBuilder() => MixedAnyOfBuilder()..replace(this); + + @override + bool operator ==(Object other) { + if (identical(other, this)) return true; + return other is MixedAnyOf && data == other.data && string == other.string && mixedAnyOf1 == other.mixedAnyOf1; + } + + @override + int get hashCode { + var _$hash = 0; + _$hash = $jc(_$hash, data.hashCode); + _$hash = $jc(_$hash, string.hashCode); + _$hash = $jc(_$hash, mixedAnyOf1.hashCode); + _$hash = $jf(_$hash); + return _$hash; + } + + @override + String toString() { + return (newBuiltValueToStringHelper(r'MixedAnyOf') + ..add('data', data) + ..add('string', string) + ..add('mixedAnyOf1', mixedAnyOf1)) + .toString(); + } +} + +class MixedAnyOfBuilder implements Builder, MixedAnyOfInterfaceBuilder { + _$MixedAnyOf? _$v; + + JsonObject? _data; + JsonObject? get data => _$this._data; + set data(covariant JsonObject? data) => _$this._data = data; + + String? _string; + String? get string => _$this._string; + set string(covariant String? string) => _$this._string = string; + + MixedAnyOf1Builder? _mixedAnyOf1; + MixedAnyOf1Builder get mixedAnyOf1 => _$this._mixedAnyOf1 ??= MixedAnyOf1Builder(); + set mixedAnyOf1(covariant MixedAnyOf1Builder? mixedAnyOf1) => _$this._mixedAnyOf1 = mixedAnyOf1; + + MixedAnyOfBuilder(); + + MixedAnyOfBuilder get _$this { + final $v = _$v; + if ($v != null) { + _data = $v.data; + _string = $v.string; + _mixedAnyOf1 = $v.mixedAnyOf1?.toBuilder(); + _$v = null; + } + return this; + } + + @override + void replace(covariant MixedAnyOf other) { + ArgumentError.checkNotNull(other, 'other'); + _$v = other as _$MixedAnyOf; + } + + @override + void update(void Function(MixedAnyOfBuilder)? updates) { + if (updates != null) updates(this); + } + + @override + MixedAnyOf build() => _build(); + + _$MixedAnyOf _build() { + MixedAnyOf._validate(this); + _$MixedAnyOf _$result; + try { + _$result = _$v ?? + _$MixedAnyOf._( + data: BuiltValueNullFieldError.checkNotNull(data, r'MixedAnyOf', 'data'), + string: string, + mixedAnyOf1: _mixedAnyOf1?.build()); + } catch (_) { + late String _$failedField; + try { + _$failedField = 'mixedAnyOf1'; + _mixedAnyOf1?.build(); + } catch (e) { + throw BuiltValueNestedFieldError(r'MixedAnyOf', _$failedField, e.toString()); + } + rethrow; + } + replace(_$result); + return _$result; + } +} + +abstract mixin class OneObjectAnyOf0InterfaceBuilder { + void replace(OneObjectAnyOf0Interface other); + void update(void Function(OneObjectAnyOf0InterfaceBuilder) updates); + String? get attributeAnyOf; + set attributeAnyOf(String? attributeAnyOf); +} + +class _$OneObjectAnyOf0 extends OneObjectAnyOf0 { + @override + final String attributeAnyOf; + + factory _$OneObjectAnyOf0([void Function(OneObjectAnyOf0Builder)? updates]) => + (OneObjectAnyOf0Builder()..update(updates))._build(); + + _$OneObjectAnyOf0._({required this.attributeAnyOf}) : super._() { + BuiltValueNullFieldError.checkNotNull(attributeAnyOf, r'OneObjectAnyOf0', 'attributeAnyOf'); + } + + @override + OneObjectAnyOf0 rebuild(void Function(OneObjectAnyOf0Builder) updates) => (toBuilder()..update(updates)).build(); + + @override + OneObjectAnyOf0Builder toBuilder() => OneObjectAnyOf0Builder()..replace(this); + + @override + bool operator ==(Object other) { + if (identical(other, this)) return true; + return other is OneObjectAnyOf0 && attributeAnyOf == other.attributeAnyOf; + } + + @override + int get hashCode { + var _$hash = 0; + _$hash = $jc(_$hash, attributeAnyOf.hashCode); + _$hash = $jf(_$hash); + return _$hash; + } + + @override + String toString() { + return (newBuiltValueToStringHelper(r'OneObjectAnyOf0')..add('attributeAnyOf', attributeAnyOf)).toString(); + } +} + +class OneObjectAnyOf0Builder + implements Builder, OneObjectAnyOf0InterfaceBuilder { + _$OneObjectAnyOf0? _$v; + + String? _attributeAnyOf; + String? get attributeAnyOf => _$this._attributeAnyOf; + set attributeAnyOf(covariant String? attributeAnyOf) => _$this._attributeAnyOf = attributeAnyOf; + + OneObjectAnyOf0Builder(); + + OneObjectAnyOf0Builder get _$this { + final $v = _$v; + if ($v != null) { + _attributeAnyOf = $v.attributeAnyOf; + _$v = null; + } + return this; + } + + @override + void replace(covariant OneObjectAnyOf0 other) { + ArgumentError.checkNotNull(other, 'other'); + _$v = other as _$OneObjectAnyOf0; + } + + @override + void update(void Function(OneObjectAnyOf0Builder)? updates) { + if (updates != null) updates(this); + } + + @override + OneObjectAnyOf0 build() => _build(); + + _$OneObjectAnyOf0 _build() { + final _$result = _$v ?? + _$OneObjectAnyOf0._( + attributeAnyOf: + BuiltValueNullFieldError.checkNotNull(attributeAnyOf, r'OneObjectAnyOf0', 'attributeAnyOf')); + replace(_$result); + return _$result; + } +} + +abstract mixin class OneObjectAnyOfInterfaceBuilder { + void replace(OneObjectAnyOfInterface other); + void update(void Function(OneObjectAnyOfInterfaceBuilder) updates); + OneObjectAnyOf0Builder get oneObjectAnyOf0; + set oneObjectAnyOf0(OneObjectAnyOf0Builder? oneObjectAnyOf0); +} + +class _$OneObjectAnyOf extends OneObjectAnyOf { + @override + final JsonObject data; + @override + final OneObjectAnyOf0? oneObjectAnyOf0; + + factory _$OneObjectAnyOf([void Function(OneObjectAnyOfBuilder)? updates]) => + (OneObjectAnyOfBuilder()..update(updates))._build(); + + _$OneObjectAnyOf._({required this.data, this.oneObjectAnyOf0}) : super._() { + BuiltValueNullFieldError.checkNotNull(data, r'OneObjectAnyOf', 'data'); + } + + @override + OneObjectAnyOf rebuild(void Function(OneObjectAnyOfBuilder) updates) => (toBuilder()..update(updates)).build(); + + @override + OneObjectAnyOfBuilder toBuilder() => OneObjectAnyOfBuilder()..replace(this); + + @override + bool operator ==(Object other) { + if (identical(other, this)) return true; + return other is OneObjectAnyOf && data == other.data && oneObjectAnyOf0 == other.oneObjectAnyOf0; + } + + @override + int get hashCode { + var _$hash = 0; + _$hash = $jc(_$hash, data.hashCode); + _$hash = $jc(_$hash, oneObjectAnyOf0.hashCode); + _$hash = $jf(_$hash); + return _$hash; + } + + @override + String toString() { + return (newBuiltValueToStringHelper(r'OneObjectAnyOf') + ..add('data', data) + ..add('oneObjectAnyOf0', oneObjectAnyOf0)) + .toString(); + } +} + +class OneObjectAnyOfBuilder implements Builder, OneObjectAnyOfInterfaceBuilder { + _$OneObjectAnyOf? _$v; + + JsonObject? _data; + JsonObject? get data => _$this._data; + set data(covariant JsonObject? data) => _$this._data = data; + + OneObjectAnyOf0Builder? _oneObjectAnyOf0; + OneObjectAnyOf0Builder get oneObjectAnyOf0 => _$this._oneObjectAnyOf0 ??= OneObjectAnyOf0Builder(); + set oneObjectAnyOf0(covariant OneObjectAnyOf0Builder? oneObjectAnyOf0) => _$this._oneObjectAnyOf0 = oneObjectAnyOf0; + + OneObjectAnyOfBuilder(); + + OneObjectAnyOfBuilder get _$this { + final $v = _$v; + if ($v != null) { + _data = $v.data; + _oneObjectAnyOf0 = $v.oneObjectAnyOf0?.toBuilder(); + _$v = null; + } + return this; + } + + @override + void replace(covariant OneObjectAnyOf other) { + ArgumentError.checkNotNull(other, 'other'); + _$v = other as _$OneObjectAnyOf; + } + + @override + void update(void Function(OneObjectAnyOfBuilder)? updates) { + if (updates != null) updates(this); + } + + @override + OneObjectAnyOf build() => _build(); + + _$OneObjectAnyOf _build() { + OneObjectAnyOf._validate(this); + _$OneObjectAnyOf _$result; + try { + _$result = _$v ?? + _$OneObjectAnyOf._( + data: BuiltValueNullFieldError.checkNotNull(data, r'OneObjectAnyOf', 'data'), + oneObjectAnyOf0: _oneObjectAnyOf0?.build()); + } catch (_) { + late String _$failedField; + try { + _$failedField = 'oneObjectAnyOf0'; + _oneObjectAnyOf0?.build(); + } catch (e) { + throw BuiltValueNestedFieldError(r'OneObjectAnyOf', _$failedField, e.toString()); + } + rethrow; + } + replace(_$result); + return _$result; + } +} + +abstract mixin class OneValueAnyOfInterfaceBuilder { + void replace(OneValueAnyOfInterface other); + void update(void Function(OneValueAnyOfInterfaceBuilder) updates); + String? get string; + set string(String? string); +} + +class _$OneValueAnyOf extends OneValueAnyOf { + @override + final JsonObject data; + @override + final String? string; + + factory _$OneValueAnyOf([void Function(OneValueAnyOfBuilder)? updates]) => + (OneValueAnyOfBuilder()..update(updates))._build(); + + _$OneValueAnyOf._({required this.data, this.string}) : super._() { + BuiltValueNullFieldError.checkNotNull(data, r'OneValueAnyOf', 'data'); + } + + @override + OneValueAnyOf rebuild(void Function(OneValueAnyOfBuilder) updates) => (toBuilder()..update(updates)).build(); + + @override + OneValueAnyOfBuilder toBuilder() => OneValueAnyOfBuilder()..replace(this); + + @override + bool operator ==(Object other) { + if (identical(other, this)) return true; + return other is OneValueAnyOf && data == other.data && string == other.string; + } + + @override + int get hashCode { + var _$hash = 0; + _$hash = $jc(_$hash, data.hashCode); + _$hash = $jc(_$hash, string.hashCode); + _$hash = $jf(_$hash); + return _$hash; + } + + @override + String toString() { + return (newBuiltValueToStringHelper(r'OneValueAnyOf') + ..add('data', data) + ..add('string', string)) + .toString(); + } +} + +class OneValueAnyOfBuilder implements Builder, OneValueAnyOfInterfaceBuilder { + _$OneValueAnyOf? _$v; + + JsonObject? _data; + JsonObject? get data => _$this._data; + set data(covariant JsonObject? data) => _$this._data = data; + + String? _string; + String? get string => _$this._string; + set string(covariant String? string) => _$this._string = string; + + OneValueAnyOfBuilder(); + + OneValueAnyOfBuilder get _$this { + final $v = _$v; + if ($v != null) { + _data = $v.data; + _string = $v.string; + _$v = null; + } + return this; + } + + @override + void replace(covariant OneValueAnyOf other) { + ArgumentError.checkNotNull(other, 'other'); + _$v = other as _$OneValueAnyOf; + } + + @override + void update(void Function(OneValueAnyOfBuilder)? updates) { + if (updates != null) updates(this); + } + + @override + OneValueAnyOf build() => _build(); + + _$OneValueAnyOf _build() { + OneValueAnyOf._validate(this); + final _$result = _$v ?? + _$OneValueAnyOf._(data: BuiltValueNullFieldError.checkNotNull(data, r'OneValueAnyOf', 'data'), string: string); + replace(_$result); + return _$result; + } +} + +abstract mixin class AnyOfIntDoubleInterfaceBuilder { + void replace(AnyOfIntDoubleInterface other); + void update(void Function(AnyOfIntDoubleInterfaceBuilder) updates); + int? get $int; + set $int(int? $int); + + double? get $double; + set $double(double? $double); +} + +class _$AnyOfIntDouble extends AnyOfIntDouble { + @override + final JsonObject data; + @override + final int? $int; + @override + final double? $double; + + factory _$AnyOfIntDouble([void Function(AnyOfIntDoubleBuilder)? updates]) => + (AnyOfIntDoubleBuilder()..update(updates))._build(); + + _$AnyOfIntDouble._({required this.data, this.$int, this.$double}) : super._() { + BuiltValueNullFieldError.checkNotNull(data, r'AnyOfIntDouble', 'data'); + } + + @override + AnyOfIntDouble rebuild(void Function(AnyOfIntDoubleBuilder) updates) => (toBuilder()..update(updates)).build(); + + @override + AnyOfIntDoubleBuilder toBuilder() => AnyOfIntDoubleBuilder()..replace(this); + + @override + bool operator ==(Object other) { + if (identical(other, this)) return true; + return other is AnyOfIntDouble && data == other.data && $int == other.$int && $double == other.$double; + } + + @override + int get hashCode { + var _$hash = 0; + _$hash = $jc(_$hash, data.hashCode); + _$hash = $jc(_$hash, $int.hashCode); + _$hash = $jc(_$hash, $double.hashCode); + _$hash = $jf(_$hash); + return _$hash; + } + + @override + String toString() { + return (newBuiltValueToStringHelper(r'AnyOfIntDouble') + ..add('data', data) + ..add('\$int', $int) + ..add('\$double', $double)) + .toString(); + } +} + +class AnyOfIntDoubleBuilder implements Builder, AnyOfIntDoubleInterfaceBuilder { + _$AnyOfIntDouble? _$v; + + JsonObject? _data; + JsonObject? get data => _$this._data; + set data(covariant JsonObject? data) => _$this._data = data; + + int? _$int; + int? get $int => _$this._$int; + set $int(covariant int? $int) => _$this._$int = $int; + + double? _$double; + double? get $double => _$this._$double; + set $double(covariant double? $double) => _$this._$double = $double; + + AnyOfIntDoubleBuilder(); + + AnyOfIntDoubleBuilder get _$this { + final $v = _$v; + if ($v != null) { + _data = $v.data; + _$int = $v.$int; + _$double = $v.$double; + _$v = null; + } + return this; + } + + @override + void replace(covariant AnyOfIntDouble other) { + ArgumentError.checkNotNull(other, 'other'); + _$v = other as _$AnyOfIntDouble; + } + + @override + void update(void Function(AnyOfIntDoubleBuilder)? updates) { + if (updates != null) updates(this); + } + + @override + AnyOfIntDouble build() => _build(); + + _$AnyOfIntDouble _build() { + AnyOfIntDouble._validate(this); + final _$result = _$v ?? + _$AnyOfIntDouble._( + data: BuiltValueNullFieldError.checkNotNull(data, r'AnyOfIntDouble', 'data'), $int: $int, $double: $double); + replace(_$result); + return _$result; + } +} + +abstract mixin class AnyOfIntDoubleOtherInterfaceBuilder { + void replace(AnyOfIntDoubleOtherInterface other); + void update(void Function(AnyOfIntDoubleOtherInterfaceBuilder) updates); + int? get $int; + set $int(int? $int); + + double? get $double; + set $double(double? $double); + + String? get string; + set string(String? string); +} + +class _$AnyOfIntDoubleOther extends AnyOfIntDoubleOther { + @override + final JsonObject data; + @override + final int? $int; + @override + final double? $double; + @override + final String? string; + + factory _$AnyOfIntDoubleOther([void Function(AnyOfIntDoubleOtherBuilder)? updates]) => + (AnyOfIntDoubleOtherBuilder()..update(updates))._build(); + + _$AnyOfIntDoubleOther._({required this.data, this.$int, this.$double, this.string}) : super._() { + BuiltValueNullFieldError.checkNotNull(data, r'AnyOfIntDoubleOther', 'data'); + } + + @override + AnyOfIntDoubleOther rebuild(void Function(AnyOfIntDoubleOtherBuilder) updates) => + (toBuilder()..update(updates)).build(); + + @override + AnyOfIntDoubleOtherBuilder toBuilder() => AnyOfIntDoubleOtherBuilder()..replace(this); + + @override + bool operator ==(Object other) { + if (identical(other, this)) return true; + return other is AnyOfIntDoubleOther && + data == other.data && + $int == other.$int && + $double == other.$double && + string == other.string; + } + + @override + int get hashCode { + var _$hash = 0; + _$hash = $jc(_$hash, data.hashCode); + _$hash = $jc(_$hash, $int.hashCode); + _$hash = $jc(_$hash, $double.hashCode); + _$hash = $jc(_$hash, string.hashCode); + _$hash = $jf(_$hash); + return _$hash; + } + + @override + String toString() { + return (newBuiltValueToStringHelper(r'AnyOfIntDoubleOther') + ..add('data', data) + ..add('\$int', $int) + ..add('\$double', $double) + ..add('string', string)) + .toString(); + } +} + +class AnyOfIntDoubleOtherBuilder + implements Builder, AnyOfIntDoubleOtherInterfaceBuilder { + _$AnyOfIntDoubleOther? _$v; + + JsonObject? _data; + JsonObject? get data => _$this._data; + set data(covariant JsonObject? data) => _$this._data = data; + + int? _$int; + int? get $int => _$this._$int; + set $int(covariant int? $int) => _$this._$int = $int; + + double? _$double; + double? get $double => _$this._$double; + set $double(covariant double? $double) => _$this._$double = $double; + + String? _string; + String? get string => _$this._string; + set string(covariant String? string) => _$this._string = string; + + AnyOfIntDoubleOtherBuilder(); + + AnyOfIntDoubleOtherBuilder get _$this { + final $v = _$v; + if ($v != null) { + _data = $v.data; + _$int = $v.$int; + _$double = $v.$double; + _string = $v.string; + _$v = null; + } + return this; + } + + @override + void replace(covariant AnyOfIntDoubleOther other) { + ArgumentError.checkNotNull(other, 'other'); + _$v = other as _$AnyOfIntDoubleOther; + } + + @override + void update(void Function(AnyOfIntDoubleOtherBuilder)? updates) { + if (updates != null) updates(this); + } + + @override + AnyOfIntDoubleOther build() => _build(); + + _$AnyOfIntDoubleOther _build() { + AnyOfIntDoubleOther._validate(this); + final _$result = _$v ?? + _$AnyOfIntDoubleOther._( + data: BuiltValueNullFieldError.checkNotNull(data, r'AnyOfIntDoubleOther', 'data'), + $int: $int, + $double: $double, + string: string); + 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/any_of.openapi.json b/packages/dynamite/dynamite_end_to_end_test/lib/any_of.openapi.json new file mode 100644 index 00000000..4d0cfdf1 --- /dev/null +++ b/packages/dynamite/dynamite_end_to_end_test/lib/any_of.openapi.json @@ -0,0 +1,110 @@ +{ + "openapi": "3.1.0", + "info": { + "title": "any of test", + "version": "0.0.1" + }, + "components": { + "schemas": { + "ObjectAnyOf": { + "description": "Any of with objects only.", + "anyOf": [ + { + "type": "object", + "required": [ + "attribute1-anyOf" + ], + "properties": { + "attribute1-anyOf": { + "type": "string" + } + } + }, + { + "type": "object", + "required": [ + "attribute2-anyOf" + ], + "properties": { + "attribute2-anyOf": { + "type": "string" + } + } + } + ] + }, + "MixedAnyOf": { + "description": "Any of with object and primitive value.", + "anyOf": [ + { + "type": "string" + }, + { + "type": "object", + "required": [ + "attribute-anyOf" + ], + "properties": { + "attribute-anyOf": { + "type": "string" + } + } + } + ] + }, + "OneObjectAnyOf": { + "description": "Any of with one object value.", + "anyOf": [ + { + "type": "object", + "required": [ + "attribute-anyOf" + ], + "properties": { + "attribute-anyOf": { + "type": "string" + } + } + } + ] + }, + "OneValueAnyOf": { + "description": "Any of with one primitive value.", + "anyOf": [ + { + "type": "string" + } + ] + }, + "AnyOfIntDouble": { + "description": "Any of with an integer and double.", + "anyOf": [ + { + "type": "integer" + }, + { + "type": "number", + "format": "float" + } + ] + }, + "AnyOfIntDoubleOther": { + "description": "Any of with an integer, double and other value.", + "anyOf": [ + { + "type": "integer" + }, + { + "type": "number", + "format": "float" + }, + { + "type": "string" + } + ] + } + } + }, + "paths": {}, + "tags": [] +} diff --git a/packages/dynamite/dynamite_end_to_end_test/lib/one_of.openapi.dart b/packages/dynamite/dynamite_end_to_end_test/lib/one_of.openapi.dart new file mode 100644 index 00000000..5cc846ad --- /dev/null +++ b/packages/dynamite/dynamite_end_to_end_test/lib/one_of.openapi.dart @@ -0,0 +1,540 @@ +// ignore_for_file: camel_case_types +// ignore_for_file: discarded_futures +// ignore_for_file: public_member_api_docs +// ignore_for_file: unreachable_switch_case + +import 'package:built_value/built_value.dart'; +import 'package:built_value/json_object.dart'; +import 'package:built_value/serializer.dart'; +import 'package:built_value/standard_json_plugin.dart'; +import 'package:collection/collection.dart'; +import 'package:dynamite_runtime/built_value.dart'; +import 'package:dynamite_runtime/http_client.dart'; + +part 'one_of.openapi.g.dart'; + +class Client extends DynamiteClient { + Client( + super.baseURL, { + super.baseHeaders, + super.userAgent, + super.httpClient, + super.cookieJar, + }); + + Client.fromClient(final DynamiteClient client) + : super( + client.baseURL, + baseHeaders: client.baseHeaders, + httpClient: client.httpClient, + cookieJar: client.cookieJar, + authentications: client.authentications, + ); +} + +@BuiltValue(instantiable: false) +abstract interface class ObjectOneOf0Interface { + @BuiltValueField(wireName: 'attribute1-oneOf') + String get attribute1OneOf; +} + +abstract class ObjectOneOf0 implements ObjectOneOf0Interface, Built { + factory ObjectOneOf0([final void Function(ObjectOneOf0Builder)? b]) = _$ObjectOneOf0; + + const ObjectOneOf0._(); + + factory ObjectOneOf0.fromJson(final Map json) => _jsonSerializers.deserializeWith(serializer, json)!; + + Map toJson() => _jsonSerializers.serializeWith(serializer, this)! as Map; + + static Serializer get serializer => _$objectOneOf0Serializer; +} + +@BuiltValue(instantiable: false) +abstract interface class ObjectOneOf1Interface { + @BuiltValueField(wireName: 'attribute2-oneOf') + String get attribute2OneOf; +} + +abstract class ObjectOneOf1 implements ObjectOneOf1Interface, Built { + factory ObjectOneOf1([final void Function(ObjectOneOf1Builder)? b]) = _$ObjectOneOf1; + + const ObjectOneOf1._(); + + factory ObjectOneOf1.fromJson(final Map json) => _jsonSerializers.deserializeWith(serializer, json)!; + + Map toJson() => _jsonSerializers.serializeWith(serializer, this)! as Map; + + static Serializer get serializer => _$objectOneOf1Serializer; +} + +@BuiltValue(instantiable: false) +abstract interface class ObjectOneOfInterface { + ObjectOneOf0? get objectOneOf0; + ObjectOneOf1? get objectOneOf1; +} + +abstract class ObjectOneOf implements ObjectOneOfInterface, Built { + factory ObjectOneOf([final void Function(ObjectOneOfBuilder)? b]) = _$ObjectOneOf; + + const ObjectOneOf._(); + + factory ObjectOneOf.fromJson(final Map json) => _jsonSerializers.deserializeWith(serializer, json)!; + + Map toJson() => _jsonSerializers.serializeWith(serializer, this)! as Map; + + @BuiltValueSerializer(custom: true) + static Serializer get serializer => _$ObjectOneOfSerializer(); + + JsonObject get data; + @BuiltValueHook(finalizeBuilder: true) + static void _validate(final ObjectOneOfBuilder b) { + // When this is rebuild from another builder + if (b._data == null) { + return; + } + + final match = [b._objectOneOf0, b._objectOneOf1].singleWhereOrNull((final x) => x != null); + if (match == null) { + throw StateError("Need exactly one of 'objectOneOf0', 'objectOneOf1' for ${b._data}"); + } + } +} + +class _$ObjectOneOfSerializer implements PrimitiveSerializer { + @override + final Iterable types = const [ObjectOneOf, _$ObjectOneOf]; + + @override + final String wireName = 'ObjectOneOf'; + + @override + Object serialize( + final Serializers serializers, + final ObjectOneOf object, { + final FullType specifiedType = FullType.unspecified, + }) => + object.data.value; + + @override + ObjectOneOf deserialize( + final Serializers serializers, + final Object data, { + final FullType specifiedType = FullType.unspecified, + }) { + final result = ObjectOneOfBuilder()..data = JsonObject(data); + try { + final value = _jsonSerializers.deserialize(data, specifiedType: const FullType(ObjectOneOf0))! as ObjectOneOf0; + result.objectOneOf0.replace(value); + } catch (_) {} + try { + final value = _jsonSerializers.deserialize(data, specifiedType: const FullType(ObjectOneOf1))! as ObjectOneOf1; + result.objectOneOf1.replace(value); + } catch (_) {} + return result.build(); + } +} + +@BuiltValue(instantiable: false) +abstract interface class MixedOneOf1Interface { + @BuiltValueField(wireName: 'attribute-oneOf') + String get attributeOneOf; +} + +abstract class MixedOneOf1 implements MixedOneOf1Interface, Built { + factory MixedOneOf1([final void Function(MixedOneOf1Builder)? b]) = _$MixedOneOf1; + + const MixedOneOf1._(); + + factory MixedOneOf1.fromJson(final Map json) => _jsonSerializers.deserializeWith(serializer, json)!; + + Map toJson() => _jsonSerializers.serializeWith(serializer, this)! as Map; + + static Serializer get serializer => _$mixedOneOf1Serializer; +} + +@BuiltValue(instantiable: false) +abstract interface class MixedOneOfInterface { + String? get string; + MixedOneOf1? get mixedOneOf1; +} + +abstract class MixedOneOf implements MixedOneOfInterface, Built { + factory MixedOneOf([final void Function(MixedOneOfBuilder)? b]) = _$MixedOneOf; + + const MixedOneOf._(); + + factory MixedOneOf.fromJson(final Map json) => _jsonSerializers.deserializeWith(serializer, json)!; + + Map toJson() => _jsonSerializers.serializeWith(serializer, this)! as Map; + + @BuiltValueSerializer(custom: true) + static Serializer get serializer => _$MixedOneOfSerializer(); + + JsonObject get data; + @BuiltValueHook(finalizeBuilder: true) + static void _validate(final MixedOneOfBuilder b) { + // When this is rebuild from another builder + if (b._data == null) { + return; + } + + final match = [b._string, b._mixedOneOf1].singleWhereOrNull((final x) => x != null); + if (match == null) { + throw StateError("Need exactly one of 'string', 'mixedOneOf1' for ${b._data}"); + } + } +} + +class _$MixedOneOfSerializer implements PrimitiveSerializer { + @override + final Iterable types = const [MixedOneOf, _$MixedOneOf]; + + @override + final String wireName = 'MixedOneOf'; + + @override + Object serialize( + final Serializers serializers, + final MixedOneOf object, { + final FullType specifiedType = FullType.unspecified, + }) => + object.data.value; + + @override + MixedOneOf deserialize( + final Serializers serializers, + final Object data, { + final FullType specifiedType = FullType.unspecified, + }) { + final result = MixedOneOfBuilder()..data = JsonObject(data); + try { + final value = _jsonSerializers.deserialize(data, specifiedType: const FullType(String))! as String; + result.string = value; + } catch (_) {} + try { + final value = _jsonSerializers.deserialize(data, specifiedType: const FullType(MixedOneOf1))! as MixedOneOf1; + result.mixedOneOf1.replace(value); + } catch (_) {} + return result.build(); + } +} + +@BuiltValue(instantiable: false) +abstract interface class OneObjectOneOf0Interface { + @BuiltValueField(wireName: 'attribute-oneOf') + String get attributeOneOf; +} + +abstract class OneObjectOneOf0 implements OneObjectOneOf0Interface, Built { + factory OneObjectOneOf0([final void Function(OneObjectOneOf0Builder)? b]) = _$OneObjectOneOf0; + + const OneObjectOneOf0._(); + + factory OneObjectOneOf0.fromJson(final Map json) => + _jsonSerializers.deserializeWith(serializer, json)!; + + Map toJson() => _jsonSerializers.serializeWith(serializer, this)! as Map; + + static Serializer get serializer => _$oneObjectOneOf0Serializer; +} + +@BuiltValue(instantiable: false) +abstract interface class OneObjectOneOfInterface { + OneObjectOneOf0? get oneObjectOneOf0; +} + +abstract class OneObjectOneOf implements OneObjectOneOfInterface, Built { + factory OneObjectOneOf([final void Function(OneObjectOneOfBuilder)? b]) = _$OneObjectOneOf; + + const OneObjectOneOf._(); + + factory OneObjectOneOf.fromJson(final Map json) => + _jsonSerializers.deserializeWith(serializer, json)!; + + Map toJson() => _jsonSerializers.serializeWith(serializer, this)! as Map; + + @BuiltValueSerializer(custom: true) + static Serializer get serializer => _$OneObjectOneOfSerializer(); + + JsonObject get data; + @BuiltValueHook(finalizeBuilder: true) + static void _validate(final OneObjectOneOfBuilder b) { + // When this is rebuild from another builder + if (b._data == null) { + return; + } + + final match = [b._oneObjectOneOf0].singleWhereOrNull((final x) => x != null); + if (match == null) { + throw StateError("Need exactly one of 'oneObjectOneOf0' for ${b._data}"); + } + } +} + +class _$OneObjectOneOfSerializer implements PrimitiveSerializer { + @override + final Iterable types = const [OneObjectOneOf, _$OneObjectOneOf]; + + @override + final String wireName = 'OneObjectOneOf'; + + @override + Object serialize( + final Serializers serializers, + final OneObjectOneOf object, { + final FullType specifiedType = FullType.unspecified, + }) => + object.data.value; + + @override + OneObjectOneOf deserialize( + final Serializers serializers, + final Object data, { + final FullType specifiedType = FullType.unspecified, + }) { + final result = OneObjectOneOfBuilder()..data = JsonObject(data); + try { + final value = + _jsonSerializers.deserialize(data, specifiedType: const FullType(OneObjectOneOf0))! as OneObjectOneOf0; + result.oneObjectOneOf0.replace(value); + } catch (_) {} + return result.build(); + } +} + +@BuiltValue(instantiable: false) +abstract interface class OneValueOneOfInterface { + String? get string; +} + +abstract class OneValueOneOf implements OneValueOneOfInterface, Built { + factory OneValueOneOf([final void Function(OneValueOneOfBuilder)? b]) = _$OneValueOneOf; + + const OneValueOneOf._(); + + factory OneValueOneOf.fromJson(final Map json) => + _jsonSerializers.deserializeWith(serializer, json)!; + + Map toJson() => _jsonSerializers.serializeWith(serializer, this)! as Map; + + @BuiltValueSerializer(custom: true) + static Serializer get serializer => _$OneValueOneOfSerializer(); + + JsonObject get data; + @BuiltValueHook(finalizeBuilder: true) + static void _validate(final OneValueOneOfBuilder b) { + // When this is rebuild from another builder + if (b._data == null) { + return; + } + + final match = [b._string].singleWhereOrNull((final x) => x != null); + if (match == null) { + throw StateError("Need exactly one of 'string' for ${b._data}"); + } + } +} + +class _$OneValueOneOfSerializer implements PrimitiveSerializer { + @override + final Iterable types = const [OneValueOneOf, _$OneValueOneOf]; + + @override + final String wireName = 'OneValueOneOf'; + + @override + Object serialize( + final Serializers serializers, + final OneValueOneOf object, { + final FullType specifiedType = FullType.unspecified, + }) => + object.data.value; + + @override + OneValueOneOf deserialize( + final Serializers serializers, + final Object data, { + final FullType specifiedType = FullType.unspecified, + }) { + final result = OneValueOneOfBuilder()..data = JsonObject(data); + try { + final value = _jsonSerializers.deserialize(data, specifiedType: const FullType(String))! as String; + result.string = value; + } catch (_) {} + return result.build(); + } +} + +@BuiltValue(instantiable: false) +abstract interface class OneOfIntDoubleInterface { + int? get $int; + double? get $double; +} + +abstract class OneOfIntDouble implements OneOfIntDoubleInterface, Built { + factory OneOfIntDouble([final void Function(OneOfIntDoubleBuilder)? b]) = _$OneOfIntDouble; + + const OneOfIntDouble._(); + + factory OneOfIntDouble.fromJson(final Map json) => + _jsonSerializers.deserializeWith(serializer, json)!; + + Map toJson() => _jsonSerializers.serializeWith(serializer, this)! as Map; + + @BuiltValueSerializer(custom: true) + static Serializer get serializer => _$OneOfIntDoubleSerializer(); + + JsonObject get data; + @BuiltValueHook(finalizeBuilder: true) + static void _validate(final OneOfIntDoubleBuilder b) { + // When this is rebuild from another builder + if (b._data == null) { + return; + } + + final match = [b._$int, b._$double].singleWhereOrNull((final x) => x != null); + if (match == null) { + throw StateError("Need exactly one of '$int', '$double' for ${b._data}"); + } + } +} + +class _$OneOfIntDoubleSerializer implements PrimitiveSerializer { + @override + final Iterable types = const [OneOfIntDouble, _$OneOfIntDouble]; + + @override + final String wireName = 'OneOfIntDouble'; + + @override + Object serialize( + final Serializers serializers, + final OneOfIntDouble object, { + final FullType specifiedType = FullType.unspecified, + }) => + object.data.value; + + @override + OneOfIntDouble deserialize( + final Serializers serializers, + final Object data, { + final FullType specifiedType = FullType.unspecified, + }) { + final result = OneOfIntDoubleBuilder()..data = JsonObject(data); + try { + final value = _jsonSerializers.deserialize(data, specifiedType: const FullType(int))! as int; + result.$int = value; + } catch (_) {} + try { + final value = _jsonSerializers.deserialize(data, specifiedType: const FullType(double))! as double; + result.$double = value; + } catch (_) {} + return result.build(); + } +} + +@BuiltValue(instantiable: false) +abstract interface class OneOfIntDoubleOtherInterface { + int? get $int; + double? get $double; + String? get string; +} + +abstract class OneOfIntDoubleOther + implements OneOfIntDoubleOtherInterface, Built { + factory OneOfIntDoubleOther([final void Function(OneOfIntDoubleOtherBuilder)? b]) = _$OneOfIntDoubleOther; + + const OneOfIntDoubleOther._(); + + factory OneOfIntDoubleOther.fromJson(final Map json) => + _jsonSerializers.deserializeWith(serializer, json)!; + + Map toJson() => _jsonSerializers.serializeWith(serializer, this)! as Map; + + @BuiltValueSerializer(custom: true) + static Serializer get serializer => _$OneOfIntDoubleOtherSerializer(); + + JsonObject get data; + @BuiltValueHook(finalizeBuilder: true) + static void _validate(final OneOfIntDoubleOtherBuilder b) { + // When this is rebuild from another builder + if (b._data == null) { + return; + } + + final match = [b._$int, b._$double, b._string].singleWhereOrNull((final x) => x != null); + if (match == null) { + throw StateError("Need exactly one of '$int', '$double', 'string' for ${b._data}"); + } + } +} + +class _$OneOfIntDoubleOtherSerializer implements PrimitiveSerializer { + @override + final Iterable types = const [OneOfIntDoubleOther, _$OneOfIntDoubleOther]; + + @override + final String wireName = 'OneOfIntDoubleOther'; + + @override + Object serialize( + final Serializers serializers, + final OneOfIntDoubleOther object, { + final FullType specifiedType = FullType.unspecified, + }) => + object.data.value; + + @override + OneOfIntDoubleOther deserialize( + final Serializers serializers, + final Object data, { + final FullType specifiedType = FullType.unspecified, + }) { + final result = OneOfIntDoubleOtherBuilder()..data = JsonObject(data); + try { + final value = _jsonSerializers.deserialize(data, specifiedType: const FullType(int))! as int; + result.$int = value; + } catch (_) {} + try { + final value = _jsonSerializers.deserialize(data, specifiedType: const FullType(double))! as double; + result.$double = value; + } catch (_) {} + try { + final value = _jsonSerializers.deserialize(data, specifiedType: const FullType(String))! as String; + result.string = value; + } catch (_) {} + return result.build(); + } +} + +// coverage:ignore-start +final Serializers _serializers = (Serializers().toBuilder() + ..addBuilderFactory(const FullType(ObjectOneOf), ObjectOneOf.new) + ..add(ObjectOneOf.serializer) + ..addBuilderFactory(const FullType(ObjectOneOf0), ObjectOneOf0.new) + ..add(ObjectOneOf0.serializer) + ..addBuilderFactory(const FullType(ObjectOneOf1), ObjectOneOf1.new) + ..add(ObjectOneOf1.serializer) + ..addBuilderFactory(const FullType(MixedOneOf), MixedOneOf.new) + ..add(MixedOneOf.serializer) + ..addBuilderFactory(const FullType(MixedOneOf1), MixedOneOf1.new) + ..add(MixedOneOf1.serializer) + ..addBuilderFactory(const FullType(OneObjectOneOf), OneObjectOneOf.new) + ..add(OneObjectOneOf.serializer) + ..addBuilderFactory(const FullType(OneObjectOneOf0), OneObjectOneOf0.new) + ..add(OneObjectOneOf0.serializer) + ..addBuilderFactory(const FullType(OneValueOneOf), OneValueOneOf.new) + ..add(OneValueOneOf.serializer) + ..addBuilderFactory(const FullType(OneOfIntDouble), OneOfIntDouble.new) + ..add(OneOfIntDouble.serializer) + ..addBuilderFactory(const FullType(OneOfIntDoubleOther), OneOfIntDoubleOther.new) + ..add(OneOfIntDoubleOther.serializer)) + .build(); + +final Serializers _jsonSerializers = (_serializers.toBuilder() + ..add(DynamiteDoubleSerializer()) + ..addPlugin(StandardJsonPlugin()) + ..addPlugin(const ContentStringPlugin())) + .build(); +// coverage:ignore-end diff --git a/packages/dynamite/dynamite_end_to_end_test/lib/one_of.openapi.g.dart b/packages/dynamite/dynamite_end_to_end_test/lib/one_of.openapi.g.dart new file mode 100644 index 00000000..5a1ad85d --- /dev/null +++ b/packages/dynamite/dynamite_end_to_end_test/lib/one_of.openapi.g.dart @@ -0,0 +1,1205 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'one_of.openapi.dart'; + +// ************************************************************************** +// BuiltValueGenerator +// ************************************************************************** + +Serializer _$objectOneOf0Serializer = _$ObjectOneOf0Serializer(); +Serializer _$objectOneOf1Serializer = _$ObjectOneOf1Serializer(); +Serializer _$mixedOneOf1Serializer = _$MixedOneOf1Serializer(); +Serializer _$oneObjectOneOf0Serializer = _$OneObjectOneOf0Serializer(); + +class _$ObjectOneOf0Serializer implements StructuredSerializer { + @override + final Iterable types = const [ObjectOneOf0, _$ObjectOneOf0]; + @override + final String wireName = 'ObjectOneOf0'; + + @override + Iterable serialize(Serializers serializers, ObjectOneOf0 object, + {FullType specifiedType = FullType.unspecified}) { + final result = [ + 'attribute1-oneOf', + serializers.serialize(object.attribute1OneOf, specifiedType: const FullType(String)), + ]; + + return result; + } + + @override + ObjectOneOf0 deserialize(Serializers serializers, Iterable serialized, + {FullType specifiedType = FullType.unspecified}) { + final result = ObjectOneOf0Builder(); + + final iterator = serialized.iterator; + while (iterator.moveNext()) { + final key = iterator.current! as String; + iterator.moveNext(); + final Object? value = iterator.current; + switch (key) { + case 'attribute1-oneOf': + result.attribute1OneOf = serializers.deserialize(value, specifiedType: const FullType(String))! as String; + break; + } + } + + return result.build(); + } +} + +class _$ObjectOneOf1Serializer implements StructuredSerializer { + @override + final Iterable types = const [ObjectOneOf1, _$ObjectOneOf1]; + @override + final String wireName = 'ObjectOneOf1'; + + @override + Iterable serialize(Serializers serializers, ObjectOneOf1 object, + {FullType specifiedType = FullType.unspecified}) { + final result = [ + 'attribute2-oneOf', + serializers.serialize(object.attribute2OneOf, specifiedType: const FullType(String)), + ]; + + return result; + } + + @override + ObjectOneOf1 deserialize(Serializers serializers, Iterable serialized, + {FullType specifiedType = FullType.unspecified}) { + final result = ObjectOneOf1Builder(); + + final iterator = serialized.iterator; + while (iterator.moveNext()) { + final key = iterator.current! as String; + iterator.moveNext(); + final Object? value = iterator.current; + switch (key) { + case 'attribute2-oneOf': + result.attribute2OneOf = serializers.deserialize(value, specifiedType: const FullType(String))! as String; + break; + } + } + + return result.build(); + } +} + +class _$MixedOneOf1Serializer implements StructuredSerializer { + @override + final Iterable types = const [MixedOneOf1, _$MixedOneOf1]; + @override + final String wireName = 'MixedOneOf1'; + + @override + Iterable serialize(Serializers serializers, MixedOneOf1 object, + {FullType specifiedType = FullType.unspecified}) { + final result = [ + 'attribute-oneOf', + serializers.serialize(object.attributeOneOf, specifiedType: const FullType(String)), + ]; + + return result; + } + + @override + MixedOneOf1 deserialize(Serializers serializers, Iterable serialized, + {FullType specifiedType = FullType.unspecified}) { + final result = MixedOneOf1Builder(); + + final iterator = serialized.iterator; + while (iterator.moveNext()) { + final key = iterator.current! as String; + iterator.moveNext(); + final Object? value = iterator.current; + switch (key) { + case 'attribute-oneOf': + result.attributeOneOf = serializers.deserialize(value, specifiedType: const FullType(String))! as String; + break; + } + } + + return result.build(); + } +} + +class _$OneObjectOneOf0Serializer implements StructuredSerializer { + @override + final Iterable types = const [OneObjectOneOf0, _$OneObjectOneOf0]; + @override + final String wireName = 'OneObjectOneOf0'; + + @override + Iterable serialize(Serializers serializers, OneObjectOneOf0 object, + {FullType specifiedType = FullType.unspecified}) { + final result = [ + 'attribute-oneOf', + serializers.serialize(object.attributeOneOf, specifiedType: const FullType(String)), + ]; + + return result; + } + + @override + OneObjectOneOf0 deserialize(Serializers serializers, Iterable serialized, + {FullType specifiedType = FullType.unspecified}) { + final result = OneObjectOneOf0Builder(); + + final iterator = serialized.iterator; + while (iterator.moveNext()) { + final key = iterator.current! as String; + iterator.moveNext(); + final Object? value = iterator.current; + switch (key) { + case 'attribute-oneOf': + result.attributeOneOf = serializers.deserialize(value, specifiedType: const FullType(String))! as String; + break; + } + } + + return result.build(); + } +} + +abstract mixin class ObjectOneOf0InterfaceBuilder { + void replace(ObjectOneOf0Interface other); + void update(void Function(ObjectOneOf0InterfaceBuilder) updates); + String? get attribute1OneOf; + set attribute1OneOf(String? attribute1OneOf); +} + +class _$ObjectOneOf0 extends ObjectOneOf0 { + @override + final String attribute1OneOf; + + factory _$ObjectOneOf0([void Function(ObjectOneOf0Builder)? updates]) => + (ObjectOneOf0Builder()..update(updates))._build(); + + _$ObjectOneOf0._({required this.attribute1OneOf}) : super._() { + BuiltValueNullFieldError.checkNotNull(attribute1OneOf, r'ObjectOneOf0', 'attribute1OneOf'); + } + + @override + ObjectOneOf0 rebuild(void Function(ObjectOneOf0Builder) updates) => (toBuilder()..update(updates)).build(); + + @override + ObjectOneOf0Builder toBuilder() => ObjectOneOf0Builder()..replace(this); + + @override + bool operator ==(Object other) { + if (identical(other, this)) return true; + return other is ObjectOneOf0 && attribute1OneOf == other.attribute1OneOf; + } + + @override + int get hashCode { + var _$hash = 0; + _$hash = $jc(_$hash, attribute1OneOf.hashCode); + _$hash = $jf(_$hash); + return _$hash; + } + + @override + String toString() { + return (newBuiltValueToStringHelper(r'ObjectOneOf0')..add('attribute1OneOf', attribute1OneOf)).toString(); + } +} + +class ObjectOneOf0Builder implements Builder, ObjectOneOf0InterfaceBuilder { + _$ObjectOneOf0? _$v; + + String? _attribute1OneOf; + String? get attribute1OneOf => _$this._attribute1OneOf; + set attribute1OneOf(covariant String? attribute1OneOf) => _$this._attribute1OneOf = attribute1OneOf; + + ObjectOneOf0Builder(); + + ObjectOneOf0Builder get _$this { + final $v = _$v; + if ($v != null) { + _attribute1OneOf = $v.attribute1OneOf; + _$v = null; + } + return this; + } + + @override + void replace(covariant ObjectOneOf0 other) { + ArgumentError.checkNotNull(other, 'other'); + _$v = other as _$ObjectOneOf0; + } + + @override + void update(void Function(ObjectOneOf0Builder)? updates) { + if (updates != null) updates(this); + } + + @override + ObjectOneOf0 build() => _build(); + + _$ObjectOneOf0 _build() { + final _$result = _$v ?? + _$ObjectOneOf0._( + attribute1OneOf: + BuiltValueNullFieldError.checkNotNull(attribute1OneOf, r'ObjectOneOf0', 'attribute1OneOf')); + replace(_$result); + return _$result; + } +} + +abstract mixin class ObjectOneOf1InterfaceBuilder { + void replace(ObjectOneOf1Interface other); + void update(void Function(ObjectOneOf1InterfaceBuilder) updates); + String? get attribute2OneOf; + set attribute2OneOf(String? attribute2OneOf); +} + +class _$ObjectOneOf1 extends ObjectOneOf1 { + @override + final String attribute2OneOf; + + factory _$ObjectOneOf1([void Function(ObjectOneOf1Builder)? updates]) => + (ObjectOneOf1Builder()..update(updates))._build(); + + _$ObjectOneOf1._({required this.attribute2OneOf}) : super._() { + BuiltValueNullFieldError.checkNotNull(attribute2OneOf, r'ObjectOneOf1', 'attribute2OneOf'); + } + + @override + ObjectOneOf1 rebuild(void Function(ObjectOneOf1Builder) updates) => (toBuilder()..update(updates)).build(); + + @override + ObjectOneOf1Builder toBuilder() => ObjectOneOf1Builder()..replace(this); + + @override + bool operator ==(Object other) { + if (identical(other, this)) return true; + return other is ObjectOneOf1 && attribute2OneOf == other.attribute2OneOf; + } + + @override + int get hashCode { + var _$hash = 0; + _$hash = $jc(_$hash, attribute2OneOf.hashCode); + _$hash = $jf(_$hash); + return _$hash; + } + + @override + String toString() { + return (newBuiltValueToStringHelper(r'ObjectOneOf1')..add('attribute2OneOf', attribute2OneOf)).toString(); + } +} + +class ObjectOneOf1Builder implements Builder, ObjectOneOf1InterfaceBuilder { + _$ObjectOneOf1? _$v; + + String? _attribute2OneOf; + String? get attribute2OneOf => _$this._attribute2OneOf; + set attribute2OneOf(covariant String? attribute2OneOf) => _$this._attribute2OneOf = attribute2OneOf; + + ObjectOneOf1Builder(); + + ObjectOneOf1Builder get _$this { + final $v = _$v; + if ($v != null) { + _attribute2OneOf = $v.attribute2OneOf; + _$v = null; + } + return this; + } + + @override + void replace(covariant ObjectOneOf1 other) { + ArgumentError.checkNotNull(other, 'other'); + _$v = other as _$ObjectOneOf1; + } + + @override + void update(void Function(ObjectOneOf1Builder)? updates) { + if (updates != null) updates(this); + } + + @override + ObjectOneOf1 build() => _build(); + + _$ObjectOneOf1 _build() { + final _$result = _$v ?? + _$ObjectOneOf1._( + attribute2OneOf: + BuiltValueNullFieldError.checkNotNull(attribute2OneOf, r'ObjectOneOf1', 'attribute2OneOf')); + replace(_$result); + return _$result; + } +} + +abstract mixin class ObjectOneOfInterfaceBuilder { + void replace(ObjectOneOfInterface other); + void update(void Function(ObjectOneOfInterfaceBuilder) updates); + ObjectOneOf0Builder get objectOneOf0; + set objectOneOf0(ObjectOneOf0Builder? objectOneOf0); + + ObjectOneOf1Builder get objectOneOf1; + set objectOneOf1(ObjectOneOf1Builder? objectOneOf1); +} + +class _$ObjectOneOf extends ObjectOneOf { + @override + final JsonObject data; + @override + final ObjectOneOf0? objectOneOf0; + @override + final ObjectOneOf1? objectOneOf1; + + factory _$ObjectOneOf([void Function(ObjectOneOfBuilder)? updates]) => + (ObjectOneOfBuilder()..update(updates))._build(); + + _$ObjectOneOf._({required this.data, this.objectOneOf0, this.objectOneOf1}) : super._() { + BuiltValueNullFieldError.checkNotNull(data, r'ObjectOneOf', 'data'); + } + + @override + ObjectOneOf rebuild(void Function(ObjectOneOfBuilder) updates) => (toBuilder()..update(updates)).build(); + + @override + ObjectOneOfBuilder toBuilder() => ObjectOneOfBuilder()..replace(this); + + @override + bool operator ==(Object other) { + if (identical(other, this)) return true; + return other is ObjectOneOf && + data == other.data && + objectOneOf0 == other.objectOneOf0 && + objectOneOf1 == other.objectOneOf1; + } + + @override + int get hashCode { + var _$hash = 0; + _$hash = $jc(_$hash, data.hashCode); + _$hash = $jc(_$hash, objectOneOf0.hashCode); + _$hash = $jc(_$hash, objectOneOf1.hashCode); + _$hash = $jf(_$hash); + return _$hash; + } + + @override + String toString() { + return (newBuiltValueToStringHelper(r'ObjectOneOf') + ..add('data', data) + ..add('objectOneOf0', objectOneOf0) + ..add('objectOneOf1', objectOneOf1)) + .toString(); + } +} + +class ObjectOneOfBuilder implements Builder, ObjectOneOfInterfaceBuilder { + _$ObjectOneOf? _$v; + + JsonObject? _data; + JsonObject? get data => _$this._data; + set data(covariant JsonObject? data) => _$this._data = data; + + ObjectOneOf0Builder? _objectOneOf0; + ObjectOneOf0Builder get objectOneOf0 => _$this._objectOneOf0 ??= ObjectOneOf0Builder(); + set objectOneOf0(covariant ObjectOneOf0Builder? objectOneOf0) => _$this._objectOneOf0 = objectOneOf0; + + ObjectOneOf1Builder? _objectOneOf1; + ObjectOneOf1Builder get objectOneOf1 => _$this._objectOneOf1 ??= ObjectOneOf1Builder(); + set objectOneOf1(covariant ObjectOneOf1Builder? objectOneOf1) => _$this._objectOneOf1 = objectOneOf1; + + ObjectOneOfBuilder(); + + ObjectOneOfBuilder get _$this { + final $v = _$v; + if ($v != null) { + _data = $v.data; + _objectOneOf0 = $v.objectOneOf0?.toBuilder(); + _objectOneOf1 = $v.objectOneOf1?.toBuilder(); + _$v = null; + } + return this; + } + + @override + void replace(covariant ObjectOneOf other) { + ArgumentError.checkNotNull(other, 'other'); + _$v = other as _$ObjectOneOf; + } + + @override + void update(void Function(ObjectOneOfBuilder)? updates) { + if (updates != null) updates(this); + } + + @override + ObjectOneOf build() => _build(); + + _$ObjectOneOf _build() { + ObjectOneOf._validate(this); + _$ObjectOneOf _$result; + try { + _$result = _$v ?? + _$ObjectOneOf._( + data: BuiltValueNullFieldError.checkNotNull(data, r'ObjectOneOf', 'data'), + objectOneOf0: _objectOneOf0?.build(), + objectOneOf1: _objectOneOf1?.build()); + } catch (_) { + late String _$failedField; + try { + _$failedField = 'objectOneOf0'; + _objectOneOf0?.build(); + _$failedField = 'objectOneOf1'; + _objectOneOf1?.build(); + } catch (e) { + throw BuiltValueNestedFieldError(r'ObjectOneOf', _$failedField, e.toString()); + } + rethrow; + } + replace(_$result); + return _$result; + } +} + +abstract mixin class MixedOneOf1InterfaceBuilder { + void replace(MixedOneOf1Interface other); + void update(void Function(MixedOneOf1InterfaceBuilder) updates); + String? get attributeOneOf; + set attributeOneOf(String? attributeOneOf); +} + +class _$MixedOneOf1 extends MixedOneOf1 { + @override + final String attributeOneOf; + + factory _$MixedOneOf1([void Function(MixedOneOf1Builder)? updates]) => + (MixedOneOf1Builder()..update(updates))._build(); + + _$MixedOneOf1._({required this.attributeOneOf}) : super._() { + BuiltValueNullFieldError.checkNotNull(attributeOneOf, r'MixedOneOf1', 'attributeOneOf'); + } + + @override + MixedOneOf1 rebuild(void Function(MixedOneOf1Builder) updates) => (toBuilder()..update(updates)).build(); + + @override + MixedOneOf1Builder toBuilder() => MixedOneOf1Builder()..replace(this); + + @override + bool operator ==(Object other) { + if (identical(other, this)) return true; + return other is MixedOneOf1 && attributeOneOf == other.attributeOneOf; + } + + @override + int get hashCode { + var _$hash = 0; + _$hash = $jc(_$hash, attributeOneOf.hashCode); + _$hash = $jf(_$hash); + return _$hash; + } + + @override + String toString() { + return (newBuiltValueToStringHelper(r'MixedOneOf1')..add('attributeOneOf', attributeOneOf)).toString(); + } +} + +class MixedOneOf1Builder implements Builder, MixedOneOf1InterfaceBuilder { + _$MixedOneOf1? _$v; + + String? _attributeOneOf; + String? get attributeOneOf => _$this._attributeOneOf; + set attributeOneOf(covariant String? attributeOneOf) => _$this._attributeOneOf = attributeOneOf; + + MixedOneOf1Builder(); + + MixedOneOf1Builder get _$this { + final $v = _$v; + if ($v != null) { + _attributeOneOf = $v.attributeOneOf; + _$v = null; + } + return this; + } + + @override + void replace(covariant MixedOneOf1 other) { + ArgumentError.checkNotNull(other, 'other'); + _$v = other as _$MixedOneOf1; + } + + @override + void update(void Function(MixedOneOf1Builder)? updates) { + if (updates != null) updates(this); + } + + @override + MixedOneOf1 build() => _build(); + + _$MixedOneOf1 _build() { + final _$result = _$v ?? + _$MixedOneOf1._( + attributeOneOf: BuiltValueNullFieldError.checkNotNull(attributeOneOf, r'MixedOneOf1', 'attributeOneOf')); + replace(_$result); + return _$result; + } +} + +abstract mixin class MixedOneOfInterfaceBuilder { + void replace(MixedOneOfInterface other); + void update(void Function(MixedOneOfInterfaceBuilder) updates); + String? get string; + set string(String? string); + + MixedOneOf1Builder get mixedOneOf1; + set mixedOneOf1(MixedOneOf1Builder? mixedOneOf1); +} + +class _$MixedOneOf extends MixedOneOf { + @override + final JsonObject data; + @override + final String? string; + @override + final MixedOneOf1? mixedOneOf1; + + factory _$MixedOneOf([void Function(MixedOneOfBuilder)? updates]) => (MixedOneOfBuilder()..update(updates))._build(); + + _$MixedOneOf._({required this.data, this.string, this.mixedOneOf1}) : super._() { + BuiltValueNullFieldError.checkNotNull(data, r'MixedOneOf', 'data'); + } + + @override + MixedOneOf rebuild(void Function(MixedOneOfBuilder) updates) => (toBuilder()..update(updates)).build(); + + @override + MixedOneOfBuilder toBuilder() => MixedOneOfBuilder()..replace(this); + + @override + bool operator ==(Object other) { + if (identical(other, this)) return true; + return other is MixedOneOf && data == other.data && string == other.string && mixedOneOf1 == other.mixedOneOf1; + } + + @override + int get hashCode { + var _$hash = 0; + _$hash = $jc(_$hash, data.hashCode); + _$hash = $jc(_$hash, string.hashCode); + _$hash = $jc(_$hash, mixedOneOf1.hashCode); + _$hash = $jf(_$hash); + return _$hash; + } + + @override + String toString() { + return (newBuiltValueToStringHelper(r'MixedOneOf') + ..add('data', data) + ..add('string', string) + ..add('mixedOneOf1', mixedOneOf1)) + .toString(); + } +} + +class MixedOneOfBuilder implements Builder, MixedOneOfInterfaceBuilder { + _$MixedOneOf? _$v; + + JsonObject? _data; + JsonObject? get data => _$this._data; + set data(covariant JsonObject? data) => _$this._data = data; + + String? _string; + String? get string => _$this._string; + set string(covariant String? string) => _$this._string = string; + + MixedOneOf1Builder? _mixedOneOf1; + MixedOneOf1Builder get mixedOneOf1 => _$this._mixedOneOf1 ??= MixedOneOf1Builder(); + set mixedOneOf1(covariant MixedOneOf1Builder? mixedOneOf1) => _$this._mixedOneOf1 = mixedOneOf1; + + MixedOneOfBuilder(); + + MixedOneOfBuilder get _$this { + final $v = _$v; + if ($v != null) { + _data = $v.data; + _string = $v.string; + _mixedOneOf1 = $v.mixedOneOf1?.toBuilder(); + _$v = null; + } + return this; + } + + @override + void replace(covariant MixedOneOf other) { + ArgumentError.checkNotNull(other, 'other'); + _$v = other as _$MixedOneOf; + } + + @override + void update(void Function(MixedOneOfBuilder)? updates) { + if (updates != null) updates(this); + } + + @override + MixedOneOf build() => _build(); + + _$MixedOneOf _build() { + MixedOneOf._validate(this); + _$MixedOneOf _$result; + try { + _$result = _$v ?? + _$MixedOneOf._( + data: BuiltValueNullFieldError.checkNotNull(data, r'MixedOneOf', 'data'), + string: string, + mixedOneOf1: _mixedOneOf1?.build()); + } catch (_) { + late String _$failedField; + try { + _$failedField = 'mixedOneOf1'; + _mixedOneOf1?.build(); + } catch (e) { + throw BuiltValueNestedFieldError(r'MixedOneOf', _$failedField, e.toString()); + } + rethrow; + } + replace(_$result); + return _$result; + } +} + +abstract mixin class OneObjectOneOf0InterfaceBuilder { + void replace(OneObjectOneOf0Interface other); + void update(void Function(OneObjectOneOf0InterfaceBuilder) updates); + String? get attributeOneOf; + set attributeOneOf(String? attributeOneOf); +} + +class _$OneObjectOneOf0 extends OneObjectOneOf0 { + @override + final String attributeOneOf; + + factory _$OneObjectOneOf0([void Function(OneObjectOneOf0Builder)? updates]) => + (OneObjectOneOf0Builder()..update(updates))._build(); + + _$OneObjectOneOf0._({required this.attributeOneOf}) : super._() { + BuiltValueNullFieldError.checkNotNull(attributeOneOf, r'OneObjectOneOf0', 'attributeOneOf'); + } + + @override + OneObjectOneOf0 rebuild(void Function(OneObjectOneOf0Builder) updates) => (toBuilder()..update(updates)).build(); + + @override + OneObjectOneOf0Builder toBuilder() => OneObjectOneOf0Builder()..replace(this); + + @override + bool operator ==(Object other) { + if (identical(other, this)) return true; + return other is OneObjectOneOf0 && attributeOneOf == other.attributeOneOf; + } + + @override + int get hashCode { + var _$hash = 0; + _$hash = $jc(_$hash, attributeOneOf.hashCode); + _$hash = $jf(_$hash); + return _$hash; + } + + @override + String toString() { + return (newBuiltValueToStringHelper(r'OneObjectOneOf0')..add('attributeOneOf', attributeOneOf)).toString(); + } +} + +class OneObjectOneOf0Builder + implements Builder, OneObjectOneOf0InterfaceBuilder { + _$OneObjectOneOf0? _$v; + + String? _attributeOneOf; + String? get attributeOneOf => _$this._attributeOneOf; + set attributeOneOf(covariant String? attributeOneOf) => _$this._attributeOneOf = attributeOneOf; + + OneObjectOneOf0Builder(); + + OneObjectOneOf0Builder get _$this { + final $v = _$v; + if ($v != null) { + _attributeOneOf = $v.attributeOneOf; + _$v = null; + } + return this; + } + + @override + void replace(covariant OneObjectOneOf0 other) { + ArgumentError.checkNotNull(other, 'other'); + _$v = other as _$OneObjectOneOf0; + } + + @override + void update(void Function(OneObjectOneOf0Builder)? updates) { + if (updates != null) updates(this); + } + + @override + OneObjectOneOf0 build() => _build(); + + _$OneObjectOneOf0 _build() { + final _$result = _$v ?? + _$OneObjectOneOf0._( + attributeOneOf: + BuiltValueNullFieldError.checkNotNull(attributeOneOf, r'OneObjectOneOf0', 'attributeOneOf')); + replace(_$result); + return _$result; + } +} + +abstract mixin class OneObjectOneOfInterfaceBuilder { + void replace(OneObjectOneOfInterface other); + void update(void Function(OneObjectOneOfInterfaceBuilder) updates); + OneObjectOneOf0Builder get oneObjectOneOf0; + set oneObjectOneOf0(OneObjectOneOf0Builder? oneObjectOneOf0); +} + +class _$OneObjectOneOf extends OneObjectOneOf { + @override + final JsonObject data; + @override + final OneObjectOneOf0? oneObjectOneOf0; + + factory _$OneObjectOneOf([void Function(OneObjectOneOfBuilder)? updates]) => + (OneObjectOneOfBuilder()..update(updates))._build(); + + _$OneObjectOneOf._({required this.data, this.oneObjectOneOf0}) : super._() { + BuiltValueNullFieldError.checkNotNull(data, r'OneObjectOneOf', 'data'); + } + + @override + OneObjectOneOf rebuild(void Function(OneObjectOneOfBuilder) updates) => (toBuilder()..update(updates)).build(); + + @override + OneObjectOneOfBuilder toBuilder() => OneObjectOneOfBuilder()..replace(this); + + @override + bool operator ==(Object other) { + if (identical(other, this)) return true; + return other is OneObjectOneOf && data == other.data && oneObjectOneOf0 == other.oneObjectOneOf0; + } + + @override + int get hashCode { + var _$hash = 0; + _$hash = $jc(_$hash, data.hashCode); + _$hash = $jc(_$hash, oneObjectOneOf0.hashCode); + _$hash = $jf(_$hash); + return _$hash; + } + + @override + String toString() { + return (newBuiltValueToStringHelper(r'OneObjectOneOf') + ..add('data', data) + ..add('oneObjectOneOf0', oneObjectOneOf0)) + .toString(); + } +} + +class OneObjectOneOfBuilder implements Builder, OneObjectOneOfInterfaceBuilder { + _$OneObjectOneOf? _$v; + + JsonObject? _data; + JsonObject? get data => _$this._data; + set data(covariant JsonObject? data) => _$this._data = data; + + OneObjectOneOf0Builder? _oneObjectOneOf0; + OneObjectOneOf0Builder get oneObjectOneOf0 => _$this._oneObjectOneOf0 ??= OneObjectOneOf0Builder(); + set oneObjectOneOf0(covariant OneObjectOneOf0Builder? oneObjectOneOf0) => _$this._oneObjectOneOf0 = oneObjectOneOf0; + + OneObjectOneOfBuilder(); + + OneObjectOneOfBuilder get _$this { + final $v = _$v; + if ($v != null) { + _data = $v.data; + _oneObjectOneOf0 = $v.oneObjectOneOf0?.toBuilder(); + _$v = null; + } + return this; + } + + @override + void replace(covariant OneObjectOneOf other) { + ArgumentError.checkNotNull(other, 'other'); + _$v = other as _$OneObjectOneOf; + } + + @override + void update(void Function(OneObjectOneOfBuilder)? updates) { + if (updates != null) updates(this); + } + + @override + OneObjectOneOf build() => _build(); + + _$OneObjectOneOf _build() { + OneObjectOneOf._validate(this); + _$OneObjectOneOf _$result; + try { + _$result = _$v ?? + _$OneObjectOneOf._( + data: BuiltValueNullFieldError.checkNotNull(data, r'OneObjectOneOf', 'data'), + oneObjectOneOf0: _oneObjectOneOf0?.build()); + } catch (_) { + late String _$failedField; + try { + _$failedField = 'oneObjectOneOf0'; + _oneObjectOneOf0?.build(); + } catch (e) { + throw BuiltValueNestedFieldError(r'OneObjectOneOf', _$failedField, e.toString()); + } + rethrow; + } + replace(_$result); + return _$result; + } +} + +abstract mixin class OneValueOneOfInterfaceBuilder { + void replace(OneValueOneOfInterface other); + void update(void Function(OneValueOneOfInterfaceBuilder) updates); + String? get string; + set string(String? string); +} + +class _$OneValueOneOf extends OneValueOneOf { + @override + final JsonObject data; + @override + final String? string; + + factory _$OneValueOneOf([void Function(OneValueOneOfBuilder)? updates]) => + (OneValueOneOfBuilder()..update(updates))._build(); + + _$OneValueOneOf._({required this.data, this.string}) : super._() { + BuiltValueNullFieldError.checkNotNull(data, r'OneValueOneOf', 'data'); + } + + @override + OneValueOneOf rebuild(void Function(OneValueOneOfBuilder) updates) => (toBuilder()..update(updates)).build(); + + @override + OneValueOneOfBuilder toBuilder() => OneValueOneOfBuilder()..replace(this); + + @override + bool operator ==(Object other) { + if (identical(other, this)) return true; + return other is OneValueOneOf && data == other.data && string == other.string; + } + + @override + int get hashCode { + var _$hash = 0; + _$hash = $jc(_$hash, data.hashCode); + _$hash = $jc(_$hash, string.hashCode); + _$hash = $jf(_$hash); + return _$hash; + } + + @override + String toString() { + return (newBuiltValueToStringHelper(r'OneValueOneOf') + ..add('data', data) + ..add('string', string)) + .toString(); + } +} + +class OneValueOneOfBuilder implements Builder, OneValueOneOfInterfaceBuilder { + _$OneValueOneOf? _$v; + + JsonObject? _data; + JsonObject? get data => _$this._data; + set data(covariant JsonObject? data) => _$this._data = data; + + String? _string; + String? get string => _$this._string; + set string(covariant String? string) => _$this._string = string; + + OneValueOneOfBuilder(); + + OneValueOneOfBuilder get _$this { + final $v = _$v; + if ($v != null) { + _data = $v.data; + _string = $v.string; + _$v = null; + } + return this; + } + + @override + void replace(covariant OneValueOneOf other) { + ArgumentError.checkNotNull(other, 'other'); + _$v = other as _$OneValueOneOf; + } + + @override + void update(void Function(OneValueOneOfBuilder)? updates) { + if (updates != null) updates(this); + } + + @override + OneValueOneOf build() => _build(); + + _$OneValueOneOf _build() { + OneValueOneOf._validate(this); + final _$result = _$v ?? + _$OneValueOneOf._(data: BuiltValueNullFieldError.checkNotNull(data, r'OneValueOneOf', 'data'), string: string); + replace(_$result); + return _$result; + } +} + +abstract mixin class OneOfIntDoubleInterfaceBuilder { + void replace(OneOfIntDoubleInterface other); + void update(void Function(OneOfIntDoubleInterfaceBuilder) updates); + int? get $int; + set $int(int? $int); + + double? get $double; + set $double(double? $double); +} + +class _$OneOfIntDouble extends OneOfIntDouble { + @override + final JsonObject data; + @override + final int? $int; + @override + final double? $double; + + factory _$OneOfIntDouble([void Function(OneOfIntDoubleBuilder)? updates]) => + (OneOfIntDoubleBuilder()..update(updates))._build(); + + _$OneOfIntDouble._({required this.data, this.$int, this.$double}) : super._() { + BuiltValueNullFieldError.checkNotNull(data, r'OneOfIntDouble', 'data'); + } + + @override + OneOfIntDouble rebuild(void Function(OneOfIntDoubleBuilder) updates) => (toBuilder()..update(updates)).build(); + + @override + OneOfIntDoubleBuilder toBuilder() => OneOfIntDoubleBuilder()..replace(this); + + @override + bool operator ==(Object other) { + if (identical(other, this)) return true; + return other is OneOfIntDouble && data == other.data && $int == other.$int && $double == other.$double; + } + + @override + int get hashCode { + var _$hash = 0; + _$hash = $jc(_$hash, data.hashCode); + _$hash = $jc(_$hash, $int.hashCode); + _$hash = $jc(_$hash, $double.hashCode); + _$hash = $jf(_$hash); + return _$hash; + } + + @override + String toString() { + return (newBuiltValueToStringHelper(r'OneOfIntDouble') + ..add('data', data) + ..add('\$int', $int) + ..add('\$double', $double)) + .toString(); + } +} + +class OneOfIntDoubleBuilder implements Builder, OneOfIntDoubleInterfaceBuilder { + _$OneOfIntDouble? _$v; + + JsonObject? _data; + JsonObject? get data => _$this._data; + set data(covariant JsonObject? data) => _$this._data = data; + + int? _$int; + int? get $int => _$this._$int; + set $int(covariant int? $int) => _$this._$int = $int; + + double? _$double; + double? get $double => _$this._$double; + set $double(covariant double? $double) => _$this._$double = $double; + + OneOfIntDoubleBuilder(); + + OneOfIntDoubleBuilder get _$this { + final $v = _$v; + if ($v != null) { + _data = $v.data; + _$int = $v.$int; + _$double = $v.$double; + _$v = null; + } + return this; + } + + @override + void replace(covariant OneOfIntDouble other) { + ArgumentError.checkNotNull(other, 'other'); + _$v = other as _$OneOfIntDouble; + } + + @override + void update(void Function(OneOfIntDoubleBuilder)? updates) { + if (updates != null) updates(this); + } + + @override + OneOfIntDouble build() => _build(); + + _$OneOfIntDouble _build() { + OneOfIntDouble._validate(this); + final _$result = _$v ?? + _$OneOfIntDouble._( + data: BuiltValueNullFieldError.checkNotNull(data, r'OneOfIntDouble', 'data'), $int: $int, $double: $double); + replace(_$result); + return _$result; + } +} + +abstract mixin class OneOfIntDoubleOtherInterfaceBuilder { + void replace(OneOfIntDoubleOtherInterface other); + void update(void Function(OneOfIntDoubleOtherInterfaceBuilder) updates); + int? get $int; + set $int(int? $int); + + double? get $double; + set $double(double? $double); + + String? get string; + set string(String? string); +} + +class _$OneOfIntDoubleOther extends OneOfIntDoubleOther { + @override + final JsonObject data; + @override + final int? $int; + @override + final double? $double; + @override + final String? string; + + factory _$OneOfIntDoubleOther([void Function(OneOfIntDoubleOtherBuilder)? updates]) => + (OneOfIntDoubleOtherBuilder()..update(updates))._build(); + + _$OneOfIntDoubleOther._({required this.data, this.$int, this.$double, this.string}) : super._() { + BuiltValueNullFieldError.checkNotNull(data, r'OneOfIntDoubleOther', 'data'); + } + + @override + OneOfIntDoubleOther rebuild(void Function(OneOfIntDoubleOtherBuilder) updates) => + (toBuilder()..update(updates)).build(); + + @override + OneOfIntDoubleOtherBuilder toBuilder() => OneOfIntDoubleOtherBuilder()..replace(this); + + @override + bool operator ==(Object other) { + if (identical(other, this)) return true; + return other is OneOfIntDoubleOther && + data == other.data && + $int == other.$int && + $double == other.$double && + string == other.string; + } + + @override + int get hashCode { + var _$hash = 0; + _$hash = $jc(_$hash, data.hashCode); + _$hash = $jc(_$hash, $int.hashCode); + _$hash = $jc(_$hash, $double.hashCode); + _$hash = $jc(_$hash, string.hashCode); + _$hash = $jf(_$hash); + return _$hash; + } + + @override + String toString() { + return (newBuiltValueToStringHelper(r'OneOfIntDoubleOther') + ..add('data', data) + ..add('\$int', $int) + ..add('\$double', $double) + ..add('string', string)) + .toString(); + } +} + +class OneOfIntDoubleOtherBuilder + implements Builder, OneOfIntDoubleOtherInterfaceBuilder { + _$OneOfIntDoubleOther? _$v; + + JsonObject? _data; + JsonObject? get data => _$this._data; + set data(covariant JsonObject? data) => _$this._data = data; + + int? _$int; + int? get $int => _$this._$int; + set $int(covariant int? $int) => _$this._$int = $int; + + double? _$double; + double? get $double => _$this._$double; + set $double(covariant double? $double) => _$this._$double = $double; + + String? _string; + String? get string => _$this._string; + set string(covariant String? string) => _$this._string = string; + + OneOfIntDoubleOtherBuilder(); + + OneOfIntDoubleOtherBuilder get _$this { + final $v = _$v; + if ($v != null) { + _data = $v.data; + _$int = $v.$int; + _$double = $v.$double; + _string = $v.string; + _$v = null; + } + return this; + } + + @override + void replace(covariant OneOfIntDoubleOther other) { + ArgumentError.checkNotNull(other, 'other'); + _$v = other as _$OneOfIntDoubleOther; + } + + @override + void update(void Function(OneOfIntDoubleOtherBuilder)? updates) { + if (updates != null) updates(this); + } + + @override + OneOfIntDoubleOther build() => _build(); + + _$OneOfIntDoubleOther _build() { + OneOfIntDoubleOther._validate(this); + final _$result = _$v ?? + _$OneOfIntDoubleOther._( + data: BuiltValueNullFieldError.checkNotNull(data, r'OneOfIntDoubleOther', 'data'), + $int: $int, + $double: $double, + string: string); + 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/one_of.openapi.json b/packages/dynamite/dynamite_end_to_end_test/lib/one_of.openapi.json new file mode 100644 index 00000000..e043f205 --- /dev/null +++ b/packages/dynamite/dynamite_end_to_end_test/lib/one_of.openapi.json @@ -0,0 +1,110 @@ +{ + "openapi": "3.1.0", + "info": { + "title": "one of test", + "version": "0.0.1" + }, + "components": { + "schemas": { + "ObjectOneOf": { + "description": "One of with objects only.", + "oneOf": [ + { + "type": "object", + "required": [ + "attribute1-oneOf" + ], + "properties": { + "attribute1-oneOf": { + "type": "string" + } + } + }, + { + "type": "object", + "required": [ + "attribute2-oneOf" + ], + "properties": { + "attribute2-oneOf": { + "type": "string" + } + } + } + ] + }, + "MixedOneOf": { + "description": "One of with object and primitive value.", + "oneOf": [ + { + "type": "string" + }, + { + "type": "object", + "required": [ + "attribute-oneOf" + ], + "properties": { + "attribute-oneOf": { + "type": "string" + } + } + } + ] + }, + "OneObjectOneOf": { + "description": "One of with one object value.", + "oneOf": [ + { + "type": "object", + "required": [ + "attribute-oneOf" + ], + "properties": { + "attribute-oneOf": { + "type": "string" + } + } + } + ] + }, + "OneValueOneOf": { + "description": "One of with one primitive value.", + "oneOf": [ + { + "type": "string" + } + ] + }, + "OneOfIntDouble": { + "description": "One of with an integer and double.", + "oneOf": [ + { + "type": "integer" + }, + { + "type": "number", + "format": "float" + } + ] + }, + "OneOfIntDoubleOther": { + "description": "One of with an integer, double and other value.", + "oneOf": [ + { + "type": "integer" + }, + { + "type": "number", + "format": "float" + }, + { + "type": "string" + } + ] + } + } + }, + "paths": {}, + "tags": [] +}