mirror of
https://github.com/foss42/apidash.git
synced 2025-06-07 20:08:42 +08:00
Update HttpRequestModel
This commit is contained in:
@ -7,7 +7,6 @@ import '../utils/utils.dart'
|
|||||||
import '../consts.dart';
|
import '../consts.dart';
|
||||||
|
|
||||||
part 'http_request_model.freezed.dart';
|
part 'http_request_model.freezed.dart';
|
||||||
|
|
||||||
part 'http_request_model.g.dart';
|
part 'http_request_model.g.dart';
|
||||||
|
|
||||||
@freezed
|
@freezed
|
||||||
@ -27,6 +26,7 @@ class HttpRequestModel with _$HttpRequestModel {
|
|||||||
List<bool>? isParamEnabledList,
|
List<bool>? isParamEnabledList,
|
||||||
@Default(ContentType.json) ContentType bodyContentType,
|
@Default(ContentType.json) ContentType bodyContentType,
|
||||||
String? body,
|
String? body,
|
||||||
|
String? query,
|
||||||
List<FormDataModel>? formData,
|
List<FormDataModel>? formData,
|
||||||
}) = _HttpRequestModel;
|
}) = _HttpRequestModel;
|
||||||
|
|
||||||
@ -61,6 +61,7 @@ class HttpRequestModel with _$HttpRequestModel {
|
|||||||
kMethodsWithBody.contains(method) &&
|
kMethodsWithBody.contains(method) &&
|
||||||
hasFormDataContentType &&
|
hasFormDataContentType &&
|
||||||
formDataMapList.isNotEmpty;
|
formDataMapList.isNotEmpty;
|
||||||
|
bool get hasQuery => query?.isNotEmpty ?? false;
|
||||||
List<FormDataModel> get formDataList => formData ?? <FormDataModel>[];
|
List<FormDataModel> get formDataList => formData ?? <FormDataModel>[];
|
||||||
List<Map<String, String>> get formDataMapList =>
|
List<Map<String, String>> get formDataMapList =>
|
||||||
rowsToFormDataMapList(formDataList) ?? [];
|
rowsToFormDataMapList(formDataList) ?? [];
|
||||||
|
@ -28,6 +28,7 @@ mixin _$HttpRequestModel {
|
|||||||
List<bool>? get isParamEnabledList => throw _privateConstructorUsedError;
|
List<bool>? get isParamEnabledList => throw _privateConstructorUsedError;
|
||||||
ContentType get bodyContentType => throw _privateConstructorUsedError;
|
ContentType get bodyContentType => throw _privateConstructorUsedError;
|
||||||
String? get body => throw _privateConstructorUsedError;
|
String? get body => throw _privateConstructorUsedError;
|
||||||
|
String? get query => throw _privateConstructorUsedError;
|
||||||
List<FormDataModel>? get formData => throw _privateConstructorUsedError;
|
List<FormDataModel>? get formData => throw _privateConstructorUsedError;
|
||||||
|
|
||||||
/// Serializes this HttpRequestModel to a JSON map.
|
/// Serializes this HttpRequestModel to a JSON map.
|
||||||
@ -55,6 +56,7 @@ abstract class $HttpRequestModelCopyWith<$Res> {
|
|||||||
List<bool>? isParamEnabledList,
|
List<bool>? isParamEnabledList,
|
||||||
ContentType bodyContentType,
|
ContentType bodyContentType,
|
||||||
String? body,
|
String? body,
|
||||||
|
String? query,
|
||||||
List<FormDataModel>? formData});
|
List<FormDataModel>? formData});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -81,6 +83,7 @@ class _$HttpRequestModelCopyWithImpl<$Res, $Val extends HttpRequestModel>
|
|||||||
Object? isParamEnabledList = freezed,
|
Object? isParamEnabledList = freezed,
|
||||||
Object? bodyContentType = null,
|
Object? bodyContentType = null,
|
||||||
Object? body = freezed,
|
Object? body = freezed,
|
||||||
|
Object? query = freezed,
|
||||||
Object? formData = freezed,
|
Object? formData = freezed,
|
||||||
}) {
|
}) {
|
||||||
return _then(_value.copyWith(
|
return _then(_value.copyWith(
|
||||||
@ -116,6 +119,10 @@ class _$HttpRequestModelCopyWithImpl<$Res, $Val extends HttpRequestModel>
|
|||||||
? _value.body
|
? _value.body
|
||||||
: body // ignore: cast_nullable_to_non_nullable
|
: body // ignore: cast_nullable_to_non_nullable
|
||||||
as String?,
|
as String?,
|
||||||
|
query: freezed == query
|
||||||
|
? _value.query
|
||||||
|
: query // ignore: cast_nullable_to_non_nullable
|
||||||
|
as String?,
|
||||||
formData: freezed == formData
|
formData: freezed == formData
|
||||||
? _value.formData
|
? _value.formData
|
||||||
: formData // ignore: cast_nullable_to_non_nullable
|
: formData // ignore: cast_nullable_to_non_nullable
|
||||||
@ -141,6 +148,7 @@ abstract class _$$HttpRequestModelImplCopyWith<$Res>
|
|||||||
List<bool>? isParamEnabledList,
|
List<bool>? isParamEnabledList,
|
||||||
ContentType bodyContentType,
|
ContentType bodyContentType,
|
||||||
String? body,
|
String? body,
|
||||||
|
String? query,
|
||||||
List<FormDataModel>? formData});
|
List<FormDataModel>? formData});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -165,6 +173,7 @@ class __$$HttpRequestModelImplCopyWithImpl<$Res>
|
|||||||
Object? isParamEnabledList = freezed,
|
Object? isParamEnabledList = freezed,
|
||||||
Object? bodyContentType = null,
|
Object? bodyContentType = null,
|
||||||
Object? body = freezed,
|
Object? body = freezed,
|
||||||
|
Object? query = freezed,
|
||||||
Object? formData = freezed,
|
Object? formData = freezed,
|
||||||
}) {
|
}) {
|
||||||
return _then(_$HttpRequestModelImpl(
|
return _then(_$HttpRequestModelImpl(
|
||||||
@ -200,6 +209,10 @@ class __$$HttpRequestModelImplCopyWithImpl<$Res>
|
|||||||
? _value.body
|
? _value.body
|
||||||
: body // ignore: cast_nullable_to_non_nullable
|
: body // ignore: cast_nullable_to_non_nullable
|
||||||
as String?,
|
as String?,
|
||||||
|
query: freezed == query
|
||||||
|
? _value.query
|
||||||
|
: query // ignore: cast_nullable_to_non_nullable
|
||||||
|
as String?,
|
||||||
formData: freezed == formData
|
formData: freezed == formData
|
||||||
? _value._formData
|
? _value._formData
|
||||||
: formData // ignore: cast_nullable_to_non_nullable
|
: formData // ignore: cast_nullable_to_non_nullable
|
||||||
@ -221,6 +234,7 @@ class _$HttpRequestModelImpl extends _HttpRequestModel {
|
|||||||
final List<bool>? isParamEnabledList,
|
final List<bool>? isParamEnabledList,
|
||||||
this.bodyContentType = ContentType.json,
|
this.bodyContentType = ContentType.json,
|
||||||
this.body,
|
this.body,
|
||||||
|
this.query,
|
||||||
final List<FormDataModel>? formData})
|
final List<FormDataModel>? formData})
|
||||||
: _headers = headers,
|
: _headers = headers,
|
||||||
_params = params,
|
_params = params,
|
||||||
@ -285,6 +299,8 @@ class _$HttpRequestModelImpl extends _HttpRequestModel {
|
|||||||
final ContentType bodyContentType;
|
final ContentType bodyContentType;
|
||||||
@override
|
@override
|
||||||
final String? body;
|
final String? body;
|
||||||
|
@override
|
||||||
|
final String? query;
|
||||||
final List<FormDataModel>? _formData;
|
final List<FormDataModel>? _formData;
|
||||||
@override
|
@override
|
||||||
List<FormDataModel>? get formData {
|
List<FormDataModel>? get formData {
|
||||||
@ -297,7 +313,7 @@ class _$HttpRequestModelImpl extends _HttpRequestModel {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
String toString() {
|
String toString() {
|
||||||
return 'HttpRequestModel(method: $method, url: $url, headers: $headers, params: $params, isHeaderEnabledList: $isHeaderEnabledList, isParamEnabledList: $isParamEnabledList, bodyContentType: $bodyContentType, body: $body, formData: $formData)';
|
return 'HttpRequestModel(method: $method, url: $url, headers: $headers, params: $params, isHeaderEnabledList: $isHeaderEnabledList, isParamEnabledList: $isParamEnabledList, bodyContentType: $bodyContentType, body: $body, query: $query, formData: $formData)';
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@ -316,6 +332,7 @@ class _$HttpRequestModelImpl extends _HttpRequestModel {
|
|||||||
(identical(other.bodyContentType, bodyContentType) ||
|
(identical(other.bodyContentType, bodyContentType) ||
|
||||||
other.bodyContentType == bodyContentType) &&
|
other.bodyContentType == bodyContentType) &&
|
||||||
(identical(other.body, body) || other.body == body) &&
|
(identical(other.body, body) || other.body == body) &&
|
||||||
|
(identical(other.query, query) || other.query == query) &&
|
||||||
const DeepCollectionEquality().equals(other._formData, _formData));
|
const DeepCollectionEquality().equals(other._formData, _formData));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -331,6 +348,7 @@ class _$HttpRequestModelImpl extends _HttpRequestModel {
|
|||||||
const DeepCollectionEquality().hash(_isParamEnabledList),
|
const DeepCollectionEquality().hash(_isParamEnabledList),
|
||||||
bodyContentType,
|
bodyContentType,
|
||||||
body,
|
body,
|
||||||
|
query,
|
||||||
const DeepCollectionEquality().hash(_formData));
|
const DeepCollectionEquality().hash(_formData));
|
||||||
|
|
||||||
/// Create a copy of HttpRequestModel
|
/// Create a copy of HttpRequestModel
|
||||||
@ -360,6 +378,7 @@ abstract class _HttpRequestModel extends HttpRequestModel {
|
|||||||
final List<bool>? isParamEnabledList,
|
final List<bool>? isParamEnabledList,
|
||||||
final ContentType bodyContentType,
|
final ContentType bodyContentType,
|
||||||
final String? body,
|
final String? body,
|
||||||
|
final String? query,
|
||||||
final List<FormDataModel>? formData}) = _$HttpRequestModelImpl;
|
final List<FormDataModel>? formData}) = _$HttpRequestModelImpl;
|
||||||
const _HttpRequestModel._() : super._();
|
const _HttpRequestModel._() : super._();
|
||||||
|
|
||||||
@ -383,6 +402,8 @@ abstract class _HttpRequestModel extends HttpRequestModel {
|
|||||||
@override
|
@override
|
||||||
String? get body;
|
String? get body;
|
||||||
@override
|
@override
|
||||||
|
String? get query;
|
||||||
|
@override
|
||||||
List<FormDataModel>? get formData;
|
List<FormDataModel>? get formData;
|
||||||
|
|
||||||
/// Create a copy of HttpRequestModel
|
/// Create a copy of HttpRequestModel
|
||||||
|
@ -29,6 +29,7 @@ _$HttpRequestModelImpl _$$HttpRequestModelImplFromJson(Map json) =>
|
|||||||
$enumDecodeNullable(_$ContentTypeEnumMap, json['bodyContentType']) ??
|
$enumDecodeNullable(_$ContentTypeEnumMap, json['bodyContentType']) ??
|
||||||
ContentType.json,
|
ContentType.json,
|
||||||
body: json['body'] as String?,
|
body: json['body'] as String?,
|
||||||
|
query: json['query'] as String?,
|
||||||
formData: (json['formData'] as List<dynamic>?)
|
formData: (json['formData'] as List<dynamic>?)
|
||||||
?.map((e) =>
|
?.map((e) =>
|
||||||
FormDataModel.fromJson(Map<String, Object?>.from(e as Map)))
|
FormDataModel.fromJson(Map<String, Object?>.from(e as Map)))
|
||||||
@ -46,6 +47,7 @@ Map<String, dynamic> _$$HttpRequestModelImplToJson(
|
|||||||
'isParamEnabledList': instance.isParamEnabledList,
|
'isParamEnabledList': instance.isParamEnabledList,
|
||||||
'bodyContentType': _$ContentTypeEnumMap[instance.bodyContentType]!,
|
'bodyContentType': _$ContentTypeEnumMap[instance.bodyContentType]!,
|
||||||
'body': instance.body,
|
'body': instance.body,
|
||||||
|
'query': instance.query,
|
||||||
'formData': instance.formData?.map((e) => e.toJson()).toList(),
|
'formData': instance.formData?.map((e) => e.toJson()).toList(),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user