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

View File

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

View File

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