Update Model to JSON

This commit is contained in:
Ashita Prasad
2024-12-23 05:16:15 +05:30
parent ed8fd5d626
commit 5cba158b7d
3 changed files with 99 additions and 48 deletions

View File

@@ -15,6 +15,10 @@ String postmanCollectionToJsonStr(PostmanCollection data) =>
@freezed @freezed
class PostmanCollection with _$PostmanCollection { class PostmanCollection with _$PostmanCollection {
@JsonSerializable(
explicitToJson: true,
anyMap: true,
)
const factory PostmanCollection({ const factory PostmanCollection({
Info? info, Info? info,
List<Item>? item, List<Item>? item,
@@ -26,6 +30,10 @@ class PostmanCollection with _$PostmanCollection {
@freezed @freezed
class Info with _$Info { class Info with _$Info {
@JsonSerializable(
explicitToJson: true,
anyMap: true,
)
const factory Info({ const factory Info({
@JsonKey(name: '_postman_id') String? postmanId, @JsonKey(name: '_postman_id') String? postmanId,
String? name, String? name,
@@ -38,6 +46,10 @@ class Info with _$Info {
@freezed @freezed
class Item with _$Item { class Item with _$Item {
@JsonSerializable(
explicitToJson: true,
anyMap: true,
)
const factory Item({ const factory Item({
String? name, String? name,
List<Item>? item, List<Item>? item,
@@ -50,6 +62,10 @@ class Item with _$Item {
@freezed @freezed
class Request with _$Request { class Request with _$Request {
@JsonSerializable(
explicitToJson: true,
anyMap: true,
)
const factory Request({ const factory Request({
String? method, String? method,
List<Header>? header, List<Header>? header,
@@ -63,6 +79,10 @@ class Request with _$Request {
@freezed @freezed
class Header with _$Header { class Header with _$Header {
@JsonSerializable(
explicitToJson: true,
anyMap: true,
)
const factory Header({ const factory Header({
String? key, String? key,
String? value, String? value,
@@ -75,6 +95,10 @@ class Header with _$Header {
@freezed @freezed
class Url with _$Url { class Url with _$Url {
@JsonSerializable(
explicitToJson: true,
anyMap: true,
)
const factory Url({ const factory Url({
String? raw, String? raw,
String? protocol, String? protocol,
@@ -88,6 +112,10 @@ class Url with _$Url {
@freezed @freezed
class Query with _$Query { class Query with _$Query {
@JsonSerializable(
explicitToJson: true,
anyMap: true,
)
const factory Query({ const factory Query({
String? key, String? key,
String? value, String? value,
@@ -99,6 +127,10 @@ class Query with _$Query {
@freezed @freezed
class Body with _$Body { class Body with _$Body {
@JsonSerializable(
explicitToJson: true,
anyMap: true,
)
const factory Body({ const factory Body({
String? mode, String? mode,
String? raw, String? raw,
@@ -111,6 +143,10 @@ class Body with _$Body {
@freezed @freezed
class Options with _$Options { class Options with _$Options {
@JsonSerializable(
explicitToJson: true,
anyMap: true,
)
const factory Options({ const factory Options({
Raw? raw, Raw? raw,
}) = _Options; }) = _Options;
@@ -121,6 +157,10 @@ class Options with _$Options {
@freezed @freezed
class Raw with _$Raw { class Raw with _$Raw {
@JsonSerializable(
explicitToJson: true,
anyMap: true,
)
const factory Raw({ const factory Raw({
String? language, String? language,
}) = _Raw; }) = _Raw;
@@ -130,6 +170,10 @@ class Raw with _$Raw {
@freezed @freezed
class Formdatum with _$Formdatum { class Formdatum with _$Formdatum {
@JsonSerializable(
explicitToJson: true,
anyMap: true,
)
const factory Formdatum({ const factory Formdatum({
String? key, String? key,
String? value, String? value,

View File

@@ -133,7 +133,8 @@ class __$$PostmanCollectionImplCopyWithImpl<$Res>
} }
/// @nodoc /// @nodoc
@JsonSerializable()
@JsonSerializable(explicitToJson: true, anyMap: true)
class _$PostmanCollectionImpl implements _PostmanCollection { class _$PostmanCollectionImpl implements _PostmanCollection {
const _$PostmanCollectionImpl({this.info, final List<Item>? item}) const _$PostmanCollectionImpl({this.info, final List<Item>? item})
: _item = item; : _item = item;
@@ -337,7 +338,8 @@ class __$$InfoImplCopyWithImpl<$Res>
} }
/// @nodoc /// @nodoc
@JsonSerializable()
@JsonSerializable(explicitToJson: true, anyMap: true)
class _$InfoImpl implements _Info { class _$InfoImpl implements _Info {
const _$InfoImpl( const _$InfoImpl(
{@JsonKey(name: '_postman_id') this.postmanId, {@JsonKey(name: '_postman_id') this.postmanId,
@@ -571,7 +573,8 @@ class __$$ItemImplCopyWithImpl<$Res>
} }
/// @nodoc /// @nodoc
@JsonSerializable()
@JsonSerializable(explicitToJson: true, anyMap: true)
class _$ItemImpl implements _Item { class _$ItemImpl implements _Item {
const _$ItemImpl( const _$ItemImpl(
{this.name, {this.name,
@@ -830,7 +833,8 @@ class __$$RequestImplCopyWithImpl<$Res>
} }
/// @nodoc /// @nodoc
@JsonSerializable()
@JsonSerializable(explicitToJson: true, anyMap: true)
class _$RequestImpl implements _Request { class _$RequestImpl implements _Request {
const _$RequestImpl( const _$RequestImpl(
{this.method, final List<Header>? header, this.body, this.url}) {this.method, final List<Header>? header, this.body, this.url})
@@ -1038,7 +1042,8 @@ class __$$HeaderImplCopyWithImpl<$Res>
} }
/// @nodoc /// @nodoc
@JsonSerializable()
@JsonSerializable(explicitToJson: true, anyMap: true)
class _$HeaderImpl implements _Header { class _$HeaderImpl implements _Header {
const _$HeaderImpl({this.key, this.value, this.type, this.disabled}); const _$HeaderImpl({this.key, this.value, this.type, this.disabled});
@@ -1253,7 +1258,8 @@ class __$$UrlImplCopyWithImpl<$Res> extends _$UrlCopyWithImpl<$Res, _$UrlImpl>
} }
/// @nodoc /// @nodoc
@JsonSerializable()
@JsonSerializable(explicitToJson: true, anyMap: true)
class _$UrlImpl implements _Url { class _$UrlImpl implements _Url {
const _$UrlImpl( const _$UrlImpl(
{this.raw, {this.raw,
@@ -1483,7 +1489,8 @@ class __$$QueryImplCopyWithImpl<$Res>
} }
/// @nodoc /// @nodoc
@JsonSerializable()
@JsonSerializable(explicitToJson: true, anyMap: true)
class _$QueryImpl implements _Query { class _$QueryImpl implements _Query {
const _$QueryImpl({this.key, this.value, this.disabled}); const _$QueryImpl({this.key, this.value, this.disabled});
@@ -1695,7 +1702,8 @@ class __$$BodyImplCopyWithImpl<$Res>
} }
/// @nodoc /// @nodoc
@JsonSerializable()
@JsonSerializable(explicitToJson: true, anyMap: true)
class _$BodyImpl implements _Body { class _$BodyImpl implements _Body {
const _$BodyImpl( const _$BodyImpl(
{this.mode, this.raw, this.options, final List<Formdatum>? formdata}) {this.mode, this.raw, this.options, final List<Formdatum>? formdata})
@@ -1888,7 +1896,8 @@ class __$$OptionsImplCopyWithImpl<$Res>
} }
/// @nodoc /// @nodoc
@JsonSerializable()
@JsonSerializable(explicitToJson: true, anyMap: true)
class _$OptionsImpl implements _Options { class _$OptionsImpl implements _Options {
const _$OptionsImpl({this.raw}); const _$OptionsImpl({this.raw});
@@ -2029,7 +2038,8 @@ class __$$RawImplCopyWithImpl<$Res> extends _$RawCopyWithImpl<$Res, _$RawImpl>
} }
/// @nodoc /// @nodoc
@JsonSerializable()
@JsonSerializable(explicitToJson: true, anyMap: true)
class _$RawImpl implements _Raw { class _$RawImpl implements _Raw {
const _$RawImpl({this.language}); const _$RawImpl({this.language});
@@ -2210,7 +2220,8 @@ class __$$FormdatumImplCopyWithImpl<$Res>
} }
/// @nodoc /// @nodoc
@JsonSerializable()
@JsonSerializable(explicitToJson: true, anyMap: true)
class _$FormdatumImpl implements _Formdatum { class _$FormdatumImpl implements _Formdatum {
const _$FormdatumImpl({this.key, this.value, this.type, this.src}); const _$FormdatumImpl({this.key, this.value, this.type, this.src});

View File

@@ -6,25 +6,24 @@ part of 'postman_collection.dart';
// JsonSerializableGenerator // JsonSerializableGenerator
// ************************************************************************** // **************************************************************************
_$PostmanCollectionImpl _$$PostmanCollectionImplFromJson( _$PostmanCollectionImpl _$$PostmanCollectionImplFromJson(Map json) =>
Map<String, dynamic> json) =>
_$PostmanCollectionImpl( _$PostmanCollectionImpl(
info: json['info'] == null info: json['info'] == null
? null ? null
: Info.fromJson(json['info'] as Map<String, dynamic>), : Info.fromJson(Map<String, dynamic>.from(json['info'] as Map)),
item: (json['item'] as List<dynamic>?) item: (json['item'] as List<dynamic>?)
?.map((e) => Item.fromJson(e as Map<String, dynamic>)) ?.map((e) => Item.fromJson(Map<String, dynamic>.from(e as Map)))
.toList(), .toList(),
); );
Map<String, dynamic> _$$PostmanCollectionImplToJson( Map<String, dynamic> _$$PostmanCollectionImplToJson(
_$PostmanCollectionImpl instance) => _$PostmanCollectionImpl instance) =>
<String, dynamic>{ <String, dynamic>{
'info': instance.info, 'info': instance.info?.toJson(),
'item': instance.item, 'item': instance.item?.map((e) => e.toJson()).toList(),
}; };
_$InfoImpl _$$InfoImplFromJson(Map<String, dynamic> json) => _$InfoImpl( _$InfoImpl _$$InfoImplFromJson(Map json) => _$InfoImpl(
postmanId: json['_postman_id'] as String?, postmanId: json['_postman_id'] as String?,
name: json['name'] as String?, name: json['name'] as String?,
schema: json['schema'] as String?, schema: json['schema'] as String?,
@@ -39,48 +38,47 @@ Map<String, dynamic> _$$InfoImplToJson(_$InfoImpl instance) =>
'_exporter_id': instance.exporterId, '_exporter_id': instance.exporterId,
}; };
_$ItemImpl _$$ItemImplFromJson(Map<String, dynamic> json) => _$ItemImpl( _$ItemImpl _$$ItemImplFromJson(Map json) => _$ItemImpl(
name: json['name'] as String?, name: json['name'] as String?,
item: (json['item'] as List<dynamic>?) item: (json['item'] as List<dynamic>?)
?.map((e) => Item.fromJson(e as Map<String, dynamic>)) ?.map((e) => Item.fromJson(Map<String, dynamic>.from(e as Map)))
.toList(), .toList(),
request: json['request'] == null request: json['request'] == null
? null ? null
: Request.fromJson(json['request'] as Map<String, dynamic>), : Request.fromJson(Map<String, dynamic>.from(json['request'] as Map)),
response: json['response'] as List<dynamic>?, response: json['response'] as List<dynamic>?,
); );
Map<String, dynamic> _$$ItemImplToJson(_$ItemImpl instance) => Map<String, dynamic> _$$ItemImplToJson(_$ItemImpl instance) =>
<String, dynamic>{ <String, dynamic>{
'name': instance.name, 'name': instance.name,
'item': instance.item, 'item': instance.item?.map((e) => e.toJson()).toList(),
'request': instance.request, 'request': instance.request?.toJson(),
'response': instance.response, 'response': instance.response,
}; };
_$RequestImpl _$$RequestImplFromJson(Map<String, dynamic> json) => _$RequestImpl _$$RequestImplFromJson(Map json) => _$RequestImpl(
_$RequestImpl(
method: json['method'] as String?, method: json['method'] as String?,
header: (json['header'] as List<dynamic>?) header: (json['header'] as List<dynamic>?)
?.map((e) => Header.fromJson(e as Map<String, dynamic>)) ?.map((e) => Header.fromJson(Map<String, dynamic>.from(e as Map)))
.toList(), .toList(),
body: json['body'] == null body: json['body'] == null
? null ? null
: Body.fromJson(json['body'] as Map<String, dynamic>), : Body.fromJson(Map<String, dynamic>.from(json['body'] as Map)),
url: json['url'] == null url: json['url'] == null
? null ? null
: Url.fromJson(json['url'] as Map<String, dynamic>), : Url.fromJson(Map<String, dynamic>.from(json['url'] as Map)),
); );
Map<String, dynamic> _$$RequestImplToJson(_$RequestImpl instance) => Map<String, dynamic> _$$RequestImplToJson(_$RequestImpl instance) =>
<String, dynamic>{ <String, dynamic>{
'method': instance.method, 'method': instance.method,
'header': instance.header, 'header': instance.header?.map((e) => e.toJson()).toList(),
'body': instance.body, 'body': instance.body?.toJson(),
'url': instance.url, 'url': instance.url?.toJson(),
}; };
_$HeaderImpl _$$HeaderImplFromJson(Map<String, dynamic> json) => _$HeaderImpl( _$HeaderImpl _$$HeaderImplFromJson(Map json) => _$HeaderImpl(
key: json['key'] as String?, key: json['key'] as String?,
value: json['value'] as String?, value: json['value'] as String?,
type: json['type'] as String?, type: json['type'] as String?,
@@ -95,13 +93,13 @@ Map<String, dynamic> _$$HeaderImplToJson(_$HeaderImpl instance) =>
'disabled': instance.disabled, 'disabled': instance.disabled,
}; };
_$UrlImpl _$$UrlImplFromJson(Map<String, dynamic> json) => _$UrlImpl( _$UrlImpl _$$UrlImplFromJson(Map json) => _$UrlImpl(
raw: json['raw'] as String?, raw: json['raw'] as String?,
protocol: json['protocol'] as String?, protocol: json['protocol'] as String?,
host: (json['host'] as List<dynamic>?)?.map((e) => e as String).toList(), host: (json['host'] as List<dynamic>?)?.map((e) => e as String).toList(),
path: (json['path'] as List<dynamic>?)?.map((e) => e as String).toList(), path: (json['path'] as List<dynamic>?)?.map((e) => e as String).toList(),
query: (json['query'] as List<dynamic>?) query: (json['query'] as List<dynamic>?)
?.map((e) => Query.fromJson(e as Map<String, dynamic>)) ?.map((e) => Query.fromJson(Map<String, dynamic>.from(e as Map)))
.toList(), .toList(),
); );
@@ -110,10 +108,10 @@ Map<String, dynamic> _$$UrlImplToJson(_$UrlImpl instance) => <String, dynamic>{
'protocol': instance.protocol, 'protocol': instance.protocol,
'host': instance.host, 'host': instance.host,
'path': instance.path, 'path': instance.path,
'query': instance.query, 'query': instance.query?.map((e) => e.toJson()).toList(),
}; };
_$QueryImpl _$$QueryImplFromJson(Map<String, dynamic> json) => _$QueryImpl( _$QueryImpl _$$QueryImplFromJson(Map json) => _$QueryImpl(
key: json['key'] as String?, key: json['key'] as String?,
value: json['value'] as String?, value: json['value'] as String?,
disabled: json['disabled'] as bool?, disabled: json['disabled'] as bool?,
@@ -126,14 +124,14 @@ Map<String, dynamic> _$$QueryImplToJson(_$QueryImpl instance) =>
'disabled': instance.disabled, 'disabled': instance.disabled,
}; };
_$BodyImpl _$$BodyImplFromJson(Map<String, dynamic> json) => _$BodyImpl( _$BodyImpl _$$BodyImplFromJson(Map json) => _$BodyImpl(
mode: json['mode'] as String?, mode: json['mode'] as String?,
raw: json['raw'] as String?, raw: json['raw'] as String?,
options: json['options'] == null options: json['options'] == null
? null ? null
: Options.fromJson(json['options'] as Map<String, dynamic>), : Options.fromJson(Map<String, dynamic>.from(json['options'] as Map)),
formdata: (json['formdata'] as List<dynamic>?) formdata: (json['formdata'] as List<dynamic>?)
?.map((e) => Formdatum.fromJson(e as Map<String, dynamic>)) ?.map((e) => Formdatum.fromJson(Map<String, dynamic>.from(e as Map)))
.toList(), .toList(),
); );
@@ -141,23 +139,22 @@ Map<String, dynamic> _$$BodyImplToJson(_$BodyImpl instance) =>
<String, dynamic>{ <String, dynamic>{
'mode': instance.mode, 'mode': instance.mode,
'raw': instance.raw, 'raw': instance.raw,
'options': instance.options, 'options': instance.options?.toJson(),
'formdata': instance.formdata, 'formdata': instance.formdata?.map((e) => e.toJson()).toList(),
}; };
_$OptionsImpl _$$OptionsImplFromJson(Map<String, dynamic> json) => _$OptionsImpl _$$OptionsImplFromJson(Map json) => _$OptionsImpl(
_$OptionsImpl(
raw: json['raw'] == null raw: json['raw'] == null
? null ? null
: Raw.fromJson(json['raw'] as Map<String, dynamic>), : Raw.fromJson(Map<String, dynamic>.from(json['raw'] as Map)),
); );
Map<String, dynamic> _$$OptionsImplToJson(_$OptionsImpl instance) => Map<String, dynamic> _$$OptionsImplToJson(_$OptionsImpl instance) =>
<String, dynamic>{ <String, dynamic>{
'raw': instance.raw, 'raw': instance.raw?.toJson(),
}; };
_$RawImpl _$$RawImplFromJson(Map<String, dynamic> json) => _$RawImpl( _$RawImpl _$$RawImplFromJson(Map json) => _$RawImpl(
language: json['language'] as String?, language: json['language'] as String?,
); );
@@ -165,8 +162,7 @@ Map<String, dynamic> _$$RawImplToJson(_$RawImpl instance) => <String, dynamic>{
'language': instance.language, 'language': instance.language,
}; };
_$FormdatumImpl _$$FormdatumImplFromJson(Map<String, dynamic> json) => _$FormdatumImpl _$$FormdatumImplFromJson(Map json) => _$FormdatumImpl(
_$FormdatumImpl(
key: json['key'] as String?, key: json['key'] as String?,
value: json['value'] as String?, value: json['value'] as String?,
type: json['type'] as String?, type: json['type'] as String?,