mirror of
https://github.com/foss42/apidash.git
synced 2025-08-06 13:51:20 +08:00
feat: enhance AuthModel serialization with anyMap support and add default name for API key
This commit is contained in:
@ -29,7 +29,7 @@ class _ApiKeyAuthFieldsState extends State<ApiKeyAuthFields> {
|
|||||||
super.initState();
|
super.initState();
|
||||||
final apiAuth = widget.authData?.apikey;
|
final apiAuth = widget.authData?.apikey;
|
||||||
_keyController = TextEditingController(text: apiAuth?.key ?? '');
|
_keyController = TextEditingController(text: apiAuth?.key ?? '');
|
||||||
_nameController = TextEditingController(text: apiAuth?.name ?? '');
|
_nameController = TextEditingController(text: apiAuth?.name ?? 'x-api-key');
|
||||||
_addKeyTo = apiAuth?.location ?? 'header';
|
_addKeyTo = apiAuth?.location ?? 'header';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -10,7 +10,10 @@ part 'api_auth_model.freezed.dart';
|
|||||||
|
|
||||||
@freezed
|
@freezed
|
||||||
class AuthModel with _$AuthModel {
|
class AuthModel with _$AuthModel {
|
||||||
@JsonSerializable(explicitToJson: true)
|
@JsonSerializable(
|
||||||
|
explicitToJson: true,
|
||||||
|
anyMap: true,
|
||||||
|
)
|
||||||
const factory AuthModel({
|
const factory AuthModel({
|
||||||
required APIAuthType type,
|
required APIAuthType type,
|
||||||
AuthApiKeyModel? apikey,
|
AuthApiKeyModel? apikey,
|
||||||
|
@ -227,7 +227,7 @@ class __$$AuthModelImplCopyWithImpl<$Res>
|
|||||||
|
|
||||||
/// @nodoc
|
/// @nodoc
|
||||||
|
|
||||||
@JsonSerializable(explicitToJson: true)
|
@JsonSerializable(explicitToJson: true, anyMap: true)
|
||||||
class _$AuthModelImpl implements _AuthModel {
|
class _$AuthModelImpl implements _AuthModel {
|
||||||
const _$AuthModelImpl(
|
const _$AuthModelImpl(
|
||||||
{required this.type, this.apikey, this.bearer, this.basic, this.jwt});
|
{required this.type, this.apikey, this.bearer, this.basic, this.jwt});
|
||||||
|
@ -6,21 +6,24 @@ part of 'api_auth_model.dart';
|
|||||||
// JsonSerializableGenerator
|
// JsonSerializableGenerator
|
||||||
// **************************************************************************
|
// **************************************************************************
|
||||||
|
|
||||||
_$AuthModelImpl _$$AuthModelImplFromJson(Map<String, dynamic> json) =>
|
_$AuthModelImpl _$$AuthModelImplFromJson(Map json) => _$AuthModelImpl(
|
||||||
_$AuthModelImpl(
|
|
||||||
type: $enumDecode(_$APIAuthTypeEnumMap, json['type']),
|
type: $enumDecode(_$APIAuthTypeEnumMap, json['type']),
|
||||||
apikey: json['apikey'] == null
|
apikey: json['apikey'] == null
|
||||||
? null
|
? null
|
||||||
: AuthApiKeyModel.fromJson(json['apikey'] as Map<String, dynamic>),
|
: AuthApiKeyModel.fromJson(
|
||||||
|
Map<String, dynamic>.from(json['apikey'] as Map)),
|
||||||
bearer: json['bearer'] == null
|
bearer: json['bearer'] == null
|
||||||
? null
|
? null
|
||||||
: AuthBearerModel.fromJson(json['bearer'] as Map<String, dynamic>),
|
: AuthBearerModel.fromJson(
|
||||||
|
Map<String, dynamic>.from(json['bearer'] as Map)),
|
||||||
basic: json['basic'] == null
|
basic: json['basic'] == null
|
||||||
? null
|
? null
|
||||||
: AuthBasicAuthModel.fromJson(json['basic'] as Map<String, dynamic>),
|
: AuthBasicAuthModel.fromJson(
|
||||||
|
Map<String, dynamic>.from(json['basic'] as Map)),
|
||||||
jwt: json['jwt'] == null
|
jwt: json['jwt'] == null
|
||||||
? null
|
? null
|
||||||
: AuthJwtModel.fromJson(json['jwt'] as Map<String, dynamic>),
|
: AuthJwtModel.fromJson(
|
||||||
|
Map<String, dynamic>.from(json['jwt'] as Map)),
|
||||||
);
|
);
|
||||||
|
|
||||||
Map<String, dynamic> _$$AuthModelImplToJson(_$AuthModelImpl instance) =>
|
Map<String, dynamic> _$$AuthModelImplToJson(_$AuthModelImpl instance) =>
|
||||||
|
Reference in New Issue
Block a user