jld3103
2 years ago
6 changed files with 87 additions and 6 deletions
@ -0,0 +1,18 @@
|
||||
import 'package:json_annotation/json_annotation.dart'; |
||||
|
||||
part 'discriminator.g.dart'; |
||||
|
||||
@JsonSerializable() |
||||
class Discriminator { |
||||
Discriminator({ |
||||
required this.propertyName, |
||||
this.mapping, |
||||
}); |
||||
|
||||
factory Discriminator.fromJson(final Map<String, dynamic> json) => _$DiscriminatorFromJson(json); |
||||
Map<String, dynamic> toJson() => _$DiscriminatorToJson(this); |
||||
|
||||
final String propertyName; |
||||
|
||||
final Map<String, String>? mapping; |
||||
} |
@ -0,0 +1,35 @@
|
||||
// GENERATED CODE - DO NOT MODIFY BY HAND |
||||
|
||||
part of 'discriminator.dart'; |
||||
|
||||
// ************************************************************************** |
||||
// JsonSerializableGenerator |
||||
// ************************************************************************** |
||||
|
||||
Discriminator _$DiscriminatorFromJson(Map<String, dynamic> json) { |
||||
$checkKeys( |
||||
json, |
||||
allowedKeys: const ['propertyName', 'mapping'], |
||||
); |
||||
return Discriminator( |
||||
propertyName: json['propertyName'] as String, |
||||
mapping: (json['mapping'] as Map<String, dynamic>?)?.map( |
||||
(k, e) => MapEntry(k, e as String), |
||||
), |
||||
); |
||||
} |
||||
|
||||
Map<String, dynamic> _$DiscriminatorToJson(Discriminator instance) { |
||||
final val = <String, dynamic>{ |
||||
'propertyName': instance.propertyName, |
||||
}; |
||||
|
||||
void writeNotNull(String key, dynamic value) { |
||||
if (value != null) { |
||||
val[key] = value; |
||||
} |
||||
} |
||||
|
||||
writeNotNull('mapping', instance.mapping); |
||||
return val; |
||||
} |
Loading…
Reference in new issue