Nikolas Rimikis
1 year ago
committed by
GitHub
9 changed files with 3991 additions and 0 deletions
@ -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<ObjectAllOf, ObjectAllOfBuilder> { |
||||
factory ObjectAllOf([final void Function(ObjectAllOfBuilder)? b]) = _$ObjectAllOf; |
||||
|
||||
const ObjectAllOf._(); |
||||
|
||||
factory ObjectAllOf.fromJson(final Map<String, dynamic> json) => _jsonSerializers.deserializeWith(serializer, json)!; |
||||
|
||||
Map<String, dynamic> toJson() => _jsonSerializers.serializeWith(serializer, this)! as Map<String, dynamic>; |
||||
|
||||
static Serializer<ObjectAllOf> 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 |
@ -0,0 +1,170 @@
|
||||
// GENERATED CODE - DO NOT MODIFY BY HAND |
||||
|
||||
part of 'all_of.openapi.dart'; |
||||
|
||||
// ************************************************************************** |
||||
// BuiltValueGenerator |
||||
// ************************************************************************** |
||||
|
||||
Serializer<ObjectAllOf> _$objectAllOfSerializer = _$ObjectAllOfSerializer(); |
||||
|
||||
class _$ObjectAllOfSerializer implements StructuredSerializer<ObjectAllOf> { |
||||
@override |
||||
final Iterable<Type> types = const [ObjectAllOf, _$ObjectAllOf]; |
||||
@override |
||||
final String wireName = 'ObjectAllOf'; |
||||
|
||||
@override |
||||
Iterable<Object?> serialize(Serializers serializers, ObjectAllOf object, |
||||
{FullType specifiedType = FullType.unspecified}) { |
||||
final result = <Object?>[ |
||||
'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<Object?> 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<ObjectAllOf, ObjectAllOfBuilder>, 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 |
@ -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": [] |
||||
} |
@ -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<ObjectAnyOf0, ObjectAnyOf0Builder> { |
||||
factory ObjectAnyOf0([final void Function(ObjectAnyOf0Builder)? b]) = _$ObjectAnyOf0; |
||||
|
||||
const ObjectAnyOf0._(); |
||||
|
||||
factory ObjectAnyOf0.fromJson(final Map<String, dynamic> json) => _jsonSerializers.deserializeWith(serializer, json)!; |
||||
|
||||
Map<String, dynamic> toJson() => _jsonSerializers.serializeWith(serializer, this)! as Map<String, dynamic>; |
||||
|
||||
static Serializer<ObjectAnyOf0> get serializer => _$objectAnyOf0Serializer; |
||||
} |
||||
|
||||
@BuiltValue(instantiable: false) |
||||
abstract interface class ObjectAnyOf1Interface { |
||||
@BuiltValueField(wireName: 'attribute2-anyOf') |
||||
String get attribute2AnyOf; |
||||
} |
||||
|
||||
abstract class ObjectAnyOf1 implements ObjectAnyOf1Interface, Built<ObjectAnyOf1, ObjectAnyOf1Builder> { |
||||
factory ObjectAnyOf1([final void Function(ObjectAnyOf1Builder)? b]) = _$ObjectAnyOf1; |
||||
|
||||
const ObjectAnyOf1._(); |
||||
|
||||
factory ObjectAnyOf1.fromJson(final Map<String, dynamic> json) => _jsonSerializers.deserializeWith(serializer, json)!; |
||||
|
||||
Map<String, dynamic> toJson() => _jsonSerializers.serializeWith(serializer, this)! as Map<String, dynamic>; |
||||
|
||||
static Serializer<ObjectAnyOf1> get serializer => _$objectAnyOf1Serializer; |
||||
} |
||||
|
||||
@BuiltValue(instantiable: false) |
||||
abstract interface class ObjectAnyOfInterface { |
||||
ObjectAnyOf0? get objectAnyOf0; |
||||
ObjectAnyOf1? get objectAnyOf1; |
||||
} |
||||
|
||||
abstract class ObjectAnyOf implements ObjectAnyOfInterface, Built<ObjectAnyOf, ObjectAnyOfBuilder> { |
||||
factory ObjectAnyOf([final void Function(ObjectAnyOfBuilder)? b]) = _$ObjectAnyOf; |
||||
|
||||
const ObjectAnyOf._(); |
||||
|
||||
factory ObjectAnyOf.fromJson(final Map<String, dynamic> json) => _jsonSerializers.deserializeWith(serializer, json)!; |
||||
|
||||
Map<String, dynamic> toJson() => _jsonSerializers.serializeWith(serializer, this)! as Map<String, dynamic>; |
||||
|
||||
@BuiltValueSerializer(custom: true) |
||||
static Serializer<ObjectAnyOf> 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<ObjectAnyOf> { |
||||
@override |
||||
final Iterable<Type> 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<MixedAnyOf1, MixedAnyOf1Builder> { |
||||
factory MixedAnyOf1([final void Function(MixedAnyOf1Builder)? b]) = _$MixedAnyOf1; |
||||
|
||||
const MixedAnyOf1._(); |
||||
|
||||
factory MixedAnyOf1.fromJson(final Map<String, dynamic> json) => _jsonSerializers.deserializeWith(serializer, json)!; |
||||
|
||||
Map<String, dynamic> toJson() => _jsonSerializers.serializeWith(serializer, this)! as Map<String, dynamic>; |
||||
|
||||
static Serializer<MixedAnyOf1> get serializer => _$mixedAnyOf1Serializer; |
||||
} |
||||
|
||||
@BuiltValue(instantiable: false) |
||||
abstract interface class MixedAnyOfInterface { |
||||
String? get string; |
||||
MixedAnyOf1? get mixedAnyOf1; |
||||
} |
||||
|
||||
abstract class MixedAnyOf implements MixedAnyOfInterface, Built<MixedAnyOf, MixedAnyOfBuilder> { |
||||
factory MixedAnyOf([final void Function(MixedAnyOfBuilder)? b]) = _$MixedAnyOf; |
||||
|
||||
const MixedAnyOf._(); |
||||
|
||||
factory MixedAnyOf.fromJson(final Map<String, dynamic> json) => _jsonSerializers.deserializeWith(serializer, json)!; |
||||
|
||||
Map<String, dynamic> toJson() => _jsonSerializers.serializeWith(serializer, this)! as Map<String, dynamic>; |
||||
|
||||
@BuiltValueSerializer(custom: true) |
||||
static Serializer<MixedAnyOf> 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<MixedAnyOf> { |
||||
@override |
||||
final Iterable<Type> 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<OneObjectAnyOf0, OneObjectAnyOf0Builder> { |
||||
factory OneObjectAnyOf0([final void Function(OneObjectAnyOf0Builder)? b]) = _$OneObjectAnyOf0; |
||||
|
||||
const OneObjectAnyOf0._(); |
||||
|
||||
factory OneObjectAnyOf0.fromJson(final Map<String, dynamic> json) => |
||||
_jsonSerializers.deserializeWith(serializer, json)!; |
||||
|
||||
Map<String, dynamic> toJson() => _jsonSerializers.serializeWith(serializer, this)! as Map<String, dynamic>; |
||||
|
||||
static Serializer<OneObjectAnyOf0> get serializer => _$oneObjectAnyOf0Serializer; |
||||
} |
||||
|
||||
@BuiltValue(instantiable: false) |
||||
abstract interface class OneObjectAnyOfInterface { |
||||
OneObjectAnyOf0? get oneObjectAnyOf0; |
||||
} |
||||
|
||||
abstract class OneObjectAnyOf implements OneObjectAnyOfInterface, Built<OneObjectAnyOf, OneObjectAnyOfBuilder> { |
||||
factory OneObjectAnyOf([final void Function(OneObjectAnyOfBuilder)? b]) = _$OneObjectAnyOf; |
||||
|
||||
const OneObjectAnyOf._(); |
||||
|
||||
factory OneObjectAnyOf.fromJson(final Map<String, dynamic> json) => |
||||
_jsonSerializers.deserializeWith(serializer, json)!; |
||||
|
||||
Map<String, dynamic> toJson() => _jsonSerializers.serializeWith(serializer, this)! as Map<String, dynamic>; |
||||
|
||||
@BuiltValueSerializer(custom: true) |
||||
static Serializer<OneObjectAnyOf> 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<OneObjectAnyOf> { |
||||
@override |
||||
final Iterable<Type> 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<OneValueAnyOf, OneValueAnyOfBuilder> { |
||||
factory OneValueAnyOf([final void Function(OneValueAnyOfBuilder)? b]) = _$OneValueAnyOf; |
||||
|
||||
const OneValueAnyOf._(); |
||||
|
||||
factory OneValueAnyOf.fromJson(final Map<String, dynamic> json) => |
||||
_jsonSerializers.deserializeWith(serializer, json)!; |
||||
|
||||
Map<String, dynamic> toJson() => _jsonSerializers.serializeWith(serializer, this)! as Map<String, dynamic>; |
||||
|
||||
@BuiltValueSerializer(custom: true) |
||||
static Serializer<OneValueAnyOf> 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<OneValueAnyOf> { |
||||
@override |
||||
final Iterable<Type> 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<AnyOfIntDouble, AnyOfIntDoubleBuilder> { |
||||
factory AnyOfIntDouble([final void Function(AnyOfIntDoubleBuilder)? b]) = _$AnyOfIntDouble; |
||||
|
||||
const AnyOfIntDouble._(); |
||||
|
||||
factory AnyOfIntDouble.fromJson(final Map<String, dynamic> json) => |
||||
_jsonSerializers.deserializeWith(serializer, json)!; |
||||
|
||||
Map<String, dynamic> toJson() => _jsonSerializers.serializeWith(serializer, this)! as Map<String, dynamic>; |
||||
|
||||
@BuiltValueSerializer(custom: true) |
||||
static Serializer<AnyOfIntDouble> 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<AnyOfIntDouble> { |
||||
@override |
||||
final Iterable<Type> 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<AnyOfIntDoubleOther, AnyOfIntDoubleOtherBuilder> { |
||||
factory AnyOfIntDoubleOther([final void Function(AnyOfIntDoubleOtherBuilder)? b]) = _$AnyOfIntDoubleOther; |
||||
|
||||
const AnyOfIntDoubleOther._(); |
||||
|
||||
factory AnyOfIntDoubleOther.fromJson(final Map<String, dynamic> json) => |
||||
_jsonSerializers.deserializeWith(serializer, json)!; |
||||
|
||||
Map<String, dynamic> toJson() => _jsonSerializers.serializeWith(serializer, this)! as Map<String, dynamic>; |
||||
|
||||
@BuiltValueSerializer(custom: true) |
||||
static Serializer<AnyOfIntDoubleOther> 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<AnyOfIntDoubleOther> { |
||||
@override |
||||
final Iterable<Type> 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 |
File diff suppressed because it is too large
Load Diff
@ -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": [] |
||||
} |
@ -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<ObjectOneOf0, ObjectOneOf0Builder> { |
||||
factory ObjectOneOf0([final void Function(ObjectOneOf0Builder)? b]) = _$ObjectOneOf0; |
||||
|
||||
const ObjectOneOf0._(); |
||||
|
||||
factory ObjectOneOf0.fromJson(final Map<String, dynamic> json) => _jsonSerializers.deserializeWith(serializer, json)!; |
||||
|
||||
Map<String, dynamic> toJson() => _jsonSerializers.serializeWith(serializer, this)! as Map<String, dynamic>; |
||||
|
||||
static Serializer<ObjectOneOf0> get serializer => _$objectOneOf0Serializer; |
||||
} |
||||
|
||||
@BuiltValue(instantiable: false) |
||||
abstract interface class ObjectOneOf1Interface { |
||||
@BuiltValueField(wireName: 'attribute2-oneOf') |
||||
String get attribute2OneOf; |
||||
} |
||||
|
||||
abstract class ObjectOneOf1 implements ObjectOneOf1Interface, Built<ObjectOneOf1, ObjectOneOf1Builder> { |
||||
factory ObjectOneOf1([final void Function(ObjectOneOf1Builder)? b]) = _$ObjectOneOf1; |
||||
|
||||
const ObjectOneOf1._(); |
||||
|
||||
factory ObjectOneOf1.fromJson(final Map<String, dynamic> json) => _jsonSerializers.deserializeWith(serializer, json)!; |
||||
|
||||
Map<String, dynamic> toJson() => _jsonSerializers.serializeWith(serializer, this)! as Map<String, dynamic>; |
||||
|
||||
static Serializer<ObjectOneOf1> get serializer => _$objectOneOf1Serializer; |
||||
} |
||||
|
||||
@BuiltValue(instantiable: false) |
||||
abstract interface class ObjectOneOfInterface { |
||||
ObjectOneOf0? get objectOneOf0; |
||||
ObjectOneOf1? get objectOneOf1; |
||||
} |
||||
|
||||
abstract class ObjectOneOf implements ObjectOneOfInterface, Built<ObjectOneOf, ObjectOneOfBuilder> { |
||||
factory ObjectOneOf([final void Function(ObjectOneOfBuilder)? b]) = _$ObjectOneOf; |
||||
|
||||
const ObjectOneOf._(); |
||||
|
||||
factory ObjectOneOf.fromJson(final Map<String, dynamic> json) => _jsonSerializers.deserializeWith(serializer, json)!; |
||||
|
||||
Map<String, dynamic> toJson() => _jsonSerializers.serializeWith(serializer, this)! as Map<String, dynamic>; |
||||
|
||||
@BuiltValueSerializer(custom: true) |
||||
static Serializer<ObjectOneOf> 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<ObjectOneOf> { |
||||
@override |
||||
final Iterable<Type> 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<MixedOneOf1, MixedOneOf1Builder> { |
||||
factory MixedOneOf1([final void Function(MixedOneOf1Builder)? b]) = _$MixedOneOf1; |
||||
|
||||
const MixedOneOf1._(); |
||||
|
||||
factory MixedOneOf1.fromJson(final Map<String, dynamic> json) => _jsonSerializers.deserializeWith(serializer, json)!; |
||||
|
||||
Map<String, dynamic> toJson() => _jsonSerializers.serializeWith(serializer, this)! as Map<String, dynamic>; |
||||
|
||||
static Serializer<MixedOneOf1> get serializer => _$mixedOneOf1Serializer; |
||||
} |
||||
|
||||
@BuiltValue(instantiable: false) |
||||
abstract interface class MixedOneOfInterface { |
||||
String? get string; |
||||
MixedOneOf1? get mixedOneOf1; |
||||
} |
||||
|
||||
abstract class MixedOneOf implements MixedOneOfInterface, Built<MixedOneOf, MixedOneOfBuilder> { |
||||
factory MixedOneOf([final void Function(MixedOneOfBuilder)? b]) = _$MixedOneOf; |
||||
|
||||
const MixedOneOf._(); |
||||
|
||||
factory MixedOneOf.fromJson(final Map<String, dynamic> json) => _jsonSerializers.deserializeWith(serializer, json)!; |
||||
|
||||
Map<String, dynamic> toJson() => _jsonSerializers.serializeWith(serializer, this)! as Map<String, dynamic>; |
||||
|
||||
@BuiltValueSerializer(custom: true) |
||||
static Serializer<MixedOneOf> 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<MixedOneOf> { |
||||
@override |
||||
final Iterable<Type> 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<OneObjectOneOf0, OneObjectOneOf0Builder> { |
||||
factory OneObjectOneOf0([final void Function(OneObjectOneOf0Builder)? b]) = _$OneObjectOneOf0; |
||||
|
||||
const OneObjectOneOf0._(); |
||||
|
||||
factory OneObjectOneOf0.fromJson(final Map<String, dynamic> json) => |
||||
_jsonSerializers.deserializeWith(serializer, json)!; |
||||
|
||||
Map<String, dynamic> toJson() => _jsonSerializers.serializeWith(serializer, this)! as Map<String, dynamic>; |
||||
|
||||
static Serializer<OneObjectOneOf0> get serializer => _$oneObjectOneOf0Serializer; |
||||
} |
||||
|
||||
@BuiltValue(instantiable: false) |
||||
abstract interface class OneObjectOneOfInterface { |
||||
OneObjectOneOf0? get oneObjectOneOf0; |
||||
} |
||||
|
||||
abstract class OneObjectOneOf implements OneObjectOneOfInterface, Built<OneObjectOneOf, OneObjectOneOfBuilder> { |
||||
factory OneObjectOneOf([final void Function(OneObjectOneOfBuilder)? b]) = _$OneObjectOneOf; |
||||
|
||||
const OneObjectOneOf._(); |
||||
|
||||
factory OneObjectOneOf.fromJson(final Map<String, dynamic> json) => |
||||
_jsonSerializers.deserializeWith(serializer, json)!; |
||||
|
||||
Map<String, dynamic> toJson() => _jsonSerializers.serializeWith(serializer, this)! as Map<String, dynamic>; |
||||
|
||||
@BuiltValueSerializer(custom: true) |
||||
static Serializer<OneObjectOneOf> 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<OneObjectOneOf> { |
||||
@override |
||||
final Iterable<Type> 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<OneValueOneOf, OneValueOneOfBuilder> { |
||||
factory OneValueOneOf([final void Function(OneValueOneOfBuilder)? b]) = _$OneValueOneOf; |
||||
|
||||
const OneValueOneOf._(); |
||||
|
||||
factory OneValueOneOf.fromJson(final Map<String, dynamic> json) => |
||||
_jsonSerializers.deserializeWith(serializer, json)!; |
||||
|
||||
Map<String, dynamic> toJson() => _jsonSerializers.serializeWith(serializer, this)! as Map<String, dynamic>; |
||||
|
||||
@BuiltValueSerializer(custom: true) |
||||
static Serializer<OneValueOneOf> 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<OneValueOneOf> { |
||||
@override |
||||
final Iterable<Type> 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<OneOfIntDouble, OneOfIntDoubleBuilder> { |
||||
factory OneOfIntDouble([final void Function(OneOfIntDoubleBuilder)? b]) = _$OneOfIntDouble; |
||||
|
||||
const OneOfIntDouble._(); |
||||
|
||||
factory OneOfIntDouble.fromJson(final Map<String, dynamic> json) => |
||||
_jsonSerializers.deserializeWith(serializer, json)!; |
||||
|
||||
Map<String, dynamic> toJson() => _jsonSerializers.serializeWith(serializer, this)! as Map<String, dynamic>; |
||||
|
||||
@BuiltValueSerializer(custom: true) |
||||
static Serializer<OneOfIntDouble> 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<OneOfIntDouble> { |
||||
@override |
||||
final Iterable<Type> 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<OneOfIntDoubleOther, OneOfIntDoubleOtherBuilder> { |
||||
factory OneOfIntDoubleOther([final void Function(OneOfIntDoubleOtherBuilder)? b]) = _$OneOfIntDoubleOther; |
||||
|
||||
const OneOfIntDoubleOther._(); |
||||
|
||||
factory OneOfIntDoubleOther.fromJson(final Map<String, dynamic> json) => |
||||
_jsonSerializers.deserializeWith(serializer, json)!; |
||||
|
||||
Map<String, dynamic> toJson() => _jsonSerializers.serializeWith(serializer, this)! as Map<String, dynamic>; |
||||
|
||||
@BuiltValueSerializer(custom: true) |
||||
static Serializer<OneOfIntDoubleOther> 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<OneOfIntDoubleOther> { |
||||
@override |
||||
final Iterable<Type> 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 |
File diff suppressed because it is too large
Load Diff
@ -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": [] |
||||
} |
Loading…
Reference in new issue