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();
|
||||
final apiAuth = widget.authData?.apikey;
|
||||
_keyController = TextEditingController(text: apiAuth?.key ?? '');
|
||||
_nameController = TextEditingController(text: apiAuth?.name ?? '');
|
||||
_nameController = TextEditingController(text: apiAuth?.name ?? 'x-api-key');
|
||||
_addKeyTo = apiAuth?.location ?? 'header';
|
||||
}
|
||||
|
||||
|
@ -10,7 +10,10 @@ part 'api_auth_model.freezed.dart';
|
||||
|
||||
@freezed
|
||||
class AuthModel with _$AuthModel {
|
||||
@JsonSerializable(explicitToJson: true)
|
||||
@JsonSerializable(
|
||||
explicitToJson: true,
|
||||
anyMap: true,
|
||||
)
|
||||
const factory AuthModel({
|
||||
required APIAuthType type,
|
||||
AuthApiKeyModel? apikey,
|
||||
|
@ -227,7 +227,7 @@ class __$$AuthModelImplCopyWithImpl<$Res>
|
||||
|
||||
/// @nodoc
|
||||
|
||||
@JsonSerializable(explicitToJson: true)
|
||||
@JsonSerializable(explicitToJson: true, anyMap: true)
|
||||
class _$AuthModelImpl implements _AuthModel {
|
||||
const _$AuthModelImpl(
|
||||
{required this.type, this.apikey, this.bearer, this.basic, this.jwt});
|
||||
|
@ -6,21 +6,24 @@ part of 'api_auth_model.dart';
|
||||
// JsonSerializableGenerator
|
||||
// **************************************************************************
|
||||
|
||||
_$AuthModelImpl _$$AuthModelImplFromJson(Map<String, dynamic> json) =>
|
||||
_$AuthModelImpl(
|
||||
_$AuthModelImpl _$$AuthModelImplFromJson(Map json) => _$AuthModelImpl(
|
||||
type: $enumDecode(_$APIAuthTypeEnumMap, json['type']),
|
||||
apikey: json['apikey'] == null
|
||||
? null
|
||||
: AuthApiKeyModel.fromJson(json['apikey'] as Map<String, dynamic>),
|
||||
: AuthApiKeyModel.fromJson(
|
||||
Map<String, dynamic>.from(json['apikey'] as Map)),
|
||||
bearer: json['bearer'] == null
|
||||
? null
|
||||
: AuthBearerModel.fromJson(json['bearer'] as Map<String, dynamic>),
|
||||
: AuthBearerModel.fromJson(
|
||||
Map<String, dynamic>.from(json['bearer'] as Map)),
|
||||
basic: json['basic'] == null
|
||||
? null
|
||||
: AuthBasicAuthModel.fromJson(json['basic'] as Map<String, dynamic>),
|
||||
: AuthBasicAuthModel.fromJson(
|
||||
Map<String, dynamic>.from(json['basic'] as Map)),
|
||||
jwt: json['jwt'] == 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) =>
|
||||
|
Reference in New Issue
Block a user