diff --git a/lib/consts.dart b/lib/consts.dart index 3e9dcacd..88084406 100644 --- a/lib/consts.dart +++ b/lib/consts.dart @@ -448,6 +448,7 @@ const kLabelURLParams = "Params"; const kLabelHeaders = "Headers"; const kLabelBody = "Body"; const kLabelScripts = "Scripts"; +const kLabelAuth = "Authorization"; const kLabelQuery = "Query"; const kNameCheckbox = "Checkbox"; const kNameURLParam = "URL Parameter"; diff --git a/lib/models/request_model.dart b/lib/models/request_model.dart index 4d63c2ad..fa647f30 100644 --- a/lib/models/request_model.dart +++ b/lib/models/request_model.dart @@ -15,6 +15,8 @@ class RequestModel with _$RequestModel { @Default(APIType.rest) APIType apiType, @Default("") String name, @Default("") String description, + @Default(APIAuthType.none) APIAuthType authType, + APIAuthModel? authData, @JsonKey(includeToJson: false) @Default(0) requestTabIndex, HttpRequestModel? httpRequestModel, int? responseStatus, diff --git a/lib/models/request_model.freezed.dart b/lib/models/request_model.freezed.dart index 72f607bd..affd554e 100644 --- a/lib/models/request_model.freezed.dart +++ b/lib/models/request_model.freezed.dart @@ -24,6 +24,8 @@ mixin _$RequestModel { APIType get apiType => throw _privateConstructorUsedError; String get name => throw _privateConstructorUsedError; String get description => throw _privateConstructorUsedError; + APIAuthType get authType => throw _privateConstructorUsedError; + APIAuthModel? get authData => throw _privateConstructorUsedError; @JsonKey(includeToJson: false) dynamic get requestTabIndex => throw _privateConstructorUsedError; HttpRequestModel? get httpRequestModel => throw _privateConstructorUsedError; @@ -59,6 +61,8 @@ abstract class $RequestModelCopyWith<$Res> { APIType apiType, String name, String description, + APIAuthType authType, + APIAuthModel? authData, @JsonKey(includeToJson: false) dynamic requestTabIndex, HttpRequestModel? httpRequestModel, int? responseStatus, @@ -69,6 +73,7 @@ abstract class $RequestModelCopyWith<$Res> { String? preRequestScript, String? postRequestScript}); + $APIAuthModelCopyWith<$Res>? get authData; $HttpRequestModelCopyWith<$Res>? get httpRequestModel; $HttpResponseModelCopyWith<$Res>? get httpResponseModel; } @@ -92,6 +97,8 @@ class _$RequestModelCopyWithImpl<$Res, $Val extends RequestModel> Object? apiType = null, Object? name = null, Object? description = null, + Object? authType = null, + Object? authData = freezed, Object? requestTabIndex = freezed, Object? httpRequestModel = freezed, Object? responseStatus = freezed, @@ -119,6 +126,14 @@ class _$RequestModelCopyWithImpl<$Res, $Val extends RequestModel> ? _value.description : description // ignore: cast_nullable_to_non_nullable as String, + authType: null == authType + ? _value.authType + : authType // ignore: cast_nullable_to_non_nullable + as APIAuthType, + authData: freezed == authData + ? _value.authData + : authData // ignore: cast_nullable_to_non_nullable + as APIAuthModel?, requestTabIndex: freezed == requestTabIndex ? _value.requestTabIndex : requestTabIndex // ignore: cast_nullable_to_non_nullable @@ -158,6 +173,20 @@ class _$RequestModelCopyWithImpl<$Res, $Val extends RequestModel> ) as $Val); } + /// Create a copy of RequestModel + /// with the given fields replaced by the non-null parameter values. + @override + @pragma('vm:prefer-inline') + $APIAuthModelCopyWith<$Res>? get authData { + if (_value.authData == null) { + return null; + } + + return $APIAuthModelCopyWith<$Res>(_value.authData!, (value) { + return _then(_value.copyWith(authData: value) as $Val); + }); + } + /// Create a copy of RequestModel /// with the given fields replaced by the non-null parameter values. @override @@ -200,6 +229,8 @@ abstract class _$$RequestModelImplCopyWith<$Res> APIType apiType, String name, String description, + APIAuthType authType, + APIAuthModel? authData, @JsonKey(includeToJson: false) dynamic requestTabIndex, HttpRequestModel? httpRequestModel, int? responseStatus, @@ -210,6 +241,8 @@ abstract class _$$RequestModelImplCopyWith<$Res> String? preRequestScript, String? postRequestScript}); + @override + $APIAuthModelCopyWith<$Res>? get authData; @override $HttpRequestModelCopyWith<$Res>? get httpRequestModel; @override @@ -233,6 +266,8 @@ class __$$RequestModelImplCopyWithImpl<$Res> Object? apiType = null, Object? name = null, Object? description = null, + Object? authType = null, + Object? authData = freezed, Object? requestTabIndex = freezed, Object? httpRequestModel = freezed, Object? responseStatus = freezed, @@ -260,6 +295,14 @@ class __$$RequestModelImplCopyWithImpl<$Res> ? _value.description : description // ignore: cast_nullable_to_non_nullable as String, + authType: null == authType + ? _value.authType + : authType // ignore: cast_nullable_to_non_nullable + as APIAuthType, + authData: freezed == authData + ? _value.authData + : authData // ignore: cast_nullable_to_non_nullable + as APIAuthModel?, requestTabIndex: freezed == requestTabIndex ? _value.requestTabIndex! : requestTabIndex, @@ -308,6 +351,8 @@ class _$RequestModelImpl implements _RequestModel { this.apiType = APIType.rest, this.name = "", this.description = "", + this.authType = APIAuthType.none, + this.authData, @JsonKey(includeToJson: false) this.requestTabIndex = 0, this.httpRequestModel, this.responseStatus, @@ -333,6 +378,11 @@ class _$RequestModelImpl implements _RequestModel { @JsonKey() final String description; @override + @JsonKey() + final APIAuthType authType; + @override + final APIAuthModel? authData; + @override @JsonKey(includeToJson: false) final dynamic requestTabIndex; @override @@ -356,7 +406,7 @@ class _$RequestModelImpl implements _RequestModel { @override String toString() { - return 'RequestModel(id: $id, apiType: $apiType, name: $name, description: $description, requestTabIndex: $requestTabIndex, httpRequestModel: $httpRequestModel, responseStatus: $responseStatus, message: $message, httpResponseModel: $httpResponseModel, isWorking: $isWorking, sendingTime: $sendingTime, preRequestScript: $preRequestScript, postRequestScript: $postRequestScript)'; + return 'RequestModel(id: $id, apiType: $apiType, name: $name, description: $description, authType: $authType, authData: $authData, requestTabIndex: $requestTabIndex, httpRequestModel: $httpRequestModel, responseStatus: $responseStatus, message: $message, httpResponseModel: $httpResponseModel, isWorking: $isWorking, sendingTime: $sendingTime)'; } @override @@ -369,6 +419,10 @@ class _$RequestModelImpl implements _RequestModel { (identical(other.name, name) || other.name == name) && (identical(other.description, description) || other.description == description) && + (identical(other.authType, authType) || + other.authType == authType) && + (identical(other.authData, authData) || + other.authData == authData) && const DeepCollectionEquality() .equals(other.requestTabIndex, requestTabIndex) && (identical(other.httpRequestModel, httpRequestModel) || @@ -396,6 +450,8 @@ class _$RequestModelImpl implements _RequestModel { apiType, name, description, + authType, + authData, const DeepCollectionEquality().hash(requestTabIndex), httpRequestModel, responseStatus, @@ -424,19 +480,20 @@ class _$RequestModelImpl implements _RequestModel { abstract class _RequestModel implements RequestModel { const factory _RequestModel( - {required final String id, - final APIType apiType, - final String name, - final String description, - @JsonKey(includeToJson: false) final dynamic requestTabIndex, - final HttpRequestModel? httpRequestModel, - final int? responseStatus, - final String? message, - final HttpResponseModel? httpResponseModel, - @JsonKey(includeToJson: false) final bool isWorking, - @JsonKey(includeToJson: false) final DateTime? sendingTime, - final String? preRequestScript, - final String? postRequestScript}) = _$RequestModelImpl; + {required final String id, + final APIType apiType, + final String name, + final String description, + final APIAuthType authType, + final APIAuthModel? authData, + @JsonKey(includeToJson: false) final dynamic requestTabIndex, + final HttpRequestModel? httpRequestModel, + final int? responseStatus, + final String? message, + final HttpResponseModel? httpResponseModel, + @JsonKey(includeToJson: false) final bool isWorking, + @JsonKey(includeToJson: false) final DateTime? sendingTime}) = + _$RequestModelImpl; factory _RequestModel.fromJson(Map json) = _$RequestModelImpl.fromJson; @@ -450,6 +507,10 @@ abstract class _RequestModel implements RequestModel { @override String get description; @override + APIAuthType get authType; + @override + APIAuthModel? get authData; + @override @JsonKey(includeToJson: false) dynamic get requestTabIndex; @override diff --git a/lib/models/request_model.g.dart b/lib/models/request_model.g.dart index d4f6ec20..d684118c 100644 --- a/lib/models/request_model.g.dart +++ b/lib/models/request_model.g.dart @@ -12,6 +12,12 @@ _$RequestModelImpl _$$RequestModelImplFromJson(Map json) => _$RequestModelImpl( APIType.rest, name: json['name'] as String? ?? "", description: json['description'] as String? ?? "", + authType: $enumDecodeNullable(_$APIAuthTypeEnumMap, json['authType']) ?? + APIAuthType.none, + authData: json['authData'] == null + ? null + : APIAuthModel.fromJson( + Map.from(json['authData'] as Map)), requestTabIndex: json['requestTabIndex'] ?? 0, httpRequestModel: json['httpRequestModel'] == null ? null @@ -37,6 +43,8 @@ Map _$$RequestModelImplToJson(_$RequestModelImpl instance) => 'apiType': _$APITypeEnumMap[instance.apiType]!, 'name': instance.name, 'description': instance.description, + 'authType': _$APIAuthTypeEnumMap[instance.authType]!, + 'authData': instance.authData?.toJson(), 'httpRequestModel': instance.httpRequestModel?.toJson(), 'responseStatus': instance.responseStatus, 'message': instance.message, @@ -49,3 +57,14 @@ const _$APITypeEnumMap = { APIType.rest: 'rest', APIType.graphql: 'graphql', }; + +const _$APIAuthTypeEnumMap = { + APIAuthType.none: 'none', + APIAuthType.basic: 'basic', + APIAuthType.apiKey: 'apiKey', + APIAuthType.bearerToken: 'bearerToken', + APIAuthType.jwtBearer: 'jwtBearer', + APIAuthType.digest: 'digest', + APIAuthType.oauth1: 'oauth1', + APIAuthType.oauth2: 'oauth2', +}; diff --git a/lib/providers/collection_providers.dart b/lib/providers/collection_providers.dart index 1bb9fba2..e46820a6 100644 --- a/lib/providers/collection_providers.dart +++ b/lib/providers/collection_providers.dart @@ -207,6 +207,8 @@ class CollectionStateNotifier String? id, HTTPVerb? method, APIType? apiType, + APIAuthType? authType, + APIAuthModel? authData, String? url, String? name, String? description, @@ -234,6 +236,8 @@ class CollectionStateNotifier var currentHttpRequestModel = currentModel.httpRequestModel; final newModel = currentModel.copyWith( apiType: apiType ?? currentModel.apiType, + authType: authType ?? currentModel.authType, + authData: authData ?? currentModel.authData, name: name ?? currentModel.name, description: description ?? currentModel.description, requestTabIndex: requestTabIndex ?? currentModel.requestTabIndex, diff --git a/lib/screens/home_page/editor_pane/details_card/request_pane/request_auth.dart b/lib/screens/home_page/editor_pane/details_card/request_pane/request_auth.dart new file mode 100644 index 00000000..94670580 --- /dev/null +++ b/lib/screens/home_page/editor_pane/details_card/request_pane/request_auth.dart @@ -0,0 +1,106 @@ +import 'package:flutter/material.dart'; +import 'package:flutter_riverpod/flutter_riverpod.dart'; +import 'package:apidash_core/apidash_core.dart'; +import 'package:apidash/providers/providers.dart'; + +class EditAuthType extends ConsumerWidget { + const EditAuthType({super.key}); + + @override + Widget build(BuildContext context, WidgetRef ref) { + final selectedRequest = ref.watch(selectedRequestModelProvider); + + if (selectedRequest == null) { + return const SizedBox.shrink(); + } + + final currentAuthType = selectedRequest.authType; + final currentAuthData = selectedRequest.authData; + + return Padding( + padding: const EdgeInsets.all(16.0), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + // Auth Type Dropdown + DropdownButtonFormField( + value: currentAuthType, + decoration: const InputDecoration( + labelText: 'Authentication Type', + border: OutlineInputBorder(), + ), + items: APIAuthType.values.map((type) { + return DropdownMenuItem( + value: type, + child: Text(type.name), + ); + }).toList(), + onChanged: (APIAuthType? newType) { + if (newType != null) { + ref.read(collectionStateNotifierProvider.notifier).update( + authType: newType, + authData: null, // reset when auth type changes + ); + } + }, + ), + const SizedBox(height: 16), + + // Dynamic Auth Input Fields + _buildAuthFields(ref, currentAuthType, currentAuthData), + ], + ), + ); + } + + Widget _buildAuthFields( + WidgetRef ref, + APIAuthType authType, + APIAuthModel? authData, + ) { + final controllerMap = {}; + + void updateAuth(APIAuthModel model) { + ref.read(collectionStateNotifierProvider.notifier).update( + authData: model, + ); + } + + switch (authType) { + case APIAuthType.basic: + final usernameController = TextEditingController( + text: (authData is BasicAuth) ? authData.username : '', + ); + final passwordController = TextEditingController( + text: (authData is BasicAuth) ? authData.password : '', + ); + return Column( + children: [ + TextField( + controller: usernameController, + decoration: const InputDecoration(labelText: 'Username'), + onChanged: (value) => updateAuth(BasicAuth( + username: value, password: passwordController.text)), + ), + const SizedBox(height: 8), + TextField( + controller: passwordController, + decoration: const InputDecoration(labelText: 'Password'), + obscureText: true, + onChanged: (value) => updateAuth(BasicAuth( + username: usernameController.text, password: value)), + ), + ], + ); + + // + + case APIAuthType.none: + return const Text("No authentication selected."); + + // TODO: Implement digest, oauth1, oauth2 later + default: + return const Text("This auth type is not implemented yet."); + } + } +} diff --git a/lib/screens/home_page/editor_pane/details_card/request_pane/request_pane_rest.dart b/lib/screens/home_page/editor_pane/details_card/request_pane/request_pane_rest.dart index 27d67567..ab0c2184 100644 --- a/lib/screens/home_page/editor_pane/details_card/request_pane/request_pane_rest.dart +++ b/lib/screens/home_page/editor_pane/details_card/request_pane/request_pane_rest.dart @@ -1,4 +1,6 @@ import 'package:apidash/consts.dart'; +import 'package:apidash/screens/home_page/editor_pane/details_card/request_pane/request_auth.dart'; +import 'package:apidash_core/apidash_core.dart'; import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:apidash/providers/providers.dart'; @@ -28,11 +30,9 @@ class EditRestRequestPane extends ConsumerWidget { .select((value) => value?.httpRequestModel?.hasBody)) ?? false; - final scriptsLength = ref.watch(selectedRequestModelProvider - .select((value) => value?.preRequestScript?.length)) ?? - ref.watch(selectedRequestModelProvider - .select((value) => value?.postRequestScript?.length)) ?? - 0; + final hasAuth = ref.watch( + selectedRequestModelProvider.select((value) => value?.authType != APIAuthType.none)); + false; return RequestPane( selectedId: selectedId, @@ -51,19 +51,19 @@ class EditRestRequestPane extends ConsumerWidget { paramLength > 0, headerLength > 0, hasBody, - scriptsLength > 0, + hasAuth ], tabLabels: const [ kLabelURLParams, kLabelHeaders, kLabelBody, - kLabelScripts, + kLabelAuth, ], children: const [ EditRequestURLParams(), EditRequestHeaders(), EditRequestBody(), - EditRequestScripts(), + EditAuthType(), ], ); } diff --git a/packages/apidash_core/lib/consts.dart b/packages/apidash_core/lib/consts.dart index 3d5d19c8..99a86c9f 100644 --- a/packages/apidash_core/lib/consts.dart +++ b/packages/apidash_core/lib/consts.dart @@ -1 +1,24 @@ +import 'dart:convert'; + +enum APIType { + rest("HTTP", "HTTP"), + graphql("GraphQL", "GQL"); + + const APIType(this.label, this.abbr); + final String label; + final String abbr; +} + +enum APIAuthType { + none, + basic, + apiKey, + bearerToken, + jwtBearer, + digest, + oauth1, + oauth2, +} + + enum EnvironmentVariableType { variable, secret } diff --git a/packages/apidash_core/lib/models/api_auth_model.dart b/packages/apidash_core/lib/models/api_auth_model.dart new file mode 100644 index 00000000..6a3449a1 --- /dev/null +++ b/packages/apidash_core/lib/models/api_auth_model.dart @@ -0,0 +1,17 @@ +import 'package:freezed_annotation/freezed_annotation.dart'; + +part 'api_auth_model.g.dart'; +part 'api_auth_model.freezed.dart'; + +@freezed +class APIAuthModel with _$APIAuthModel { + const factory APIAuthModel.none() = None; + + const factory APIAuthModel.basic({ + required String username, + required String password, + }) = BasicAuth; + + factory APIAuthModel.fromJson(Map json) => + _$APIAuthModelFromJson(json); +} diff --git a/packages/apidash_core/lib/models/api_auth_model.freezed.dart b/packages/apidash_core/lib/models/api_auth_model.freezed.dart new file mode 100644 index 00000000..c7cc47e6 --- /dev/null +++ b/packages/apidash_core/lib/models/api_auth_model.freezed.dart @@ -0,0 +1,386 @@ +// coverage:ignore-file +// GENERATED CODE - DO NOT MODIFY BY HAND +// ignore_for_file: type=lint +// ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target, unnecessary_question_mark + +part of 'api_auth_model.dart'; + +// ************************************************************************** +// FreezedGenerator +// ************************************************************************** + +T _$identity(T value) => value; + +final _privateConstructorUsedError = UnsupportedError( + 'It seems like you constructed your class using `MyClass._()`. This constructor is only meant to be used by freezed and you are not supposed to need it nor use it.\nPlease check the documentation here for more information: https://github.com/rrousselGit/freezed#adding-getters-and-methods-to-our-models'); + +APIAuthModel _$APIAuthModelFromJson(Map json) { + switch (json['runtimeType']) { + case 'none': + return None.fromJson(json); + case 'basic': + return BasicAuth.fromJson(json); + + default: + throw CheckedFromJsonException(json, 'runtimeType', 'APIAuthModel', + 'Invalid union type "${json['runtimeType']}"!'); + } +} + +/// @nodoc +mixin _$APIAuthModel { + @optionalTypeArgs + TResult when({ + required TResult Function() none, + required TResult Function(String username, String password) basic, + }) => + throw _privateConstructorUsedError; + @optionalTypeArgs + TResult? whenOrNull({ + TResult? Function()? none, + TResult? Function(String username, String password)? basic, + }) => + throw _privateConstructorUsedError; + @optionalTypeArgs + TResult maybeWhen({ + TResult Function()? none, + TResult Function(String username, String password)? basic, + required TResult orElse(), + }) => + throw _privateConstructorUsedError; + @optionalTypeArgs + TResult map({ + required TResult Function(None value) none, + required TResult Function(BasicAuth value) basic, + }) => + throw _privateConstructorUsedError; + @optionalTypeArgs + TResult? mapOrNull({ + TResult? Function(None value)? none, + TResult? Function(BasicAuth value)? basic, + }) => + throw _privateConstructorUsedError; + @optionalTypeArgs + TResult maybeMap({ + TResult Function(None value)? none, + TResult Function(BasicAuth value)? basic, + required TResult orElse(), + }) => + throw _privateConstructorUsedError; + + /// Serializes this APIAuthModel to a JSON map. + Map toJson() => throw _privateConstructorUsedError; +} + +/// @nodoc +abstract class $APIAuthModelCopyWith<$Res> { + factory $APIAuthModelCopyWith( + APIAuthModel value, $Res Function(APIAuthModel) then) = + _$APIAuthModelCopyWithImpl<$Res, APIAuthModel>; +} + +/// @nodoc +class _$APIAuthModelCopyWithImpl<$Res, $Val extends APIAuthModel> + implements $APIAuthModelCopyWith<$Res> { + _$APIAuthModelCopyWithImpl(this._value, this._then); + + // ignore: unused_field + final $Val _value; + // ignore: unused_field + final $Res Function($Val) _then; + + /// Create a copy of APIAuthModel + /// with the given fields replaced by the non-null parameter values. +} + +/// @nodoc +abstract class _$$NoneImplCopyWith<$Res> { + factory _$$NoneImplCopyWith( + _$NoneImpl value, $Res Function(_$NoneImpl) then) = + __$$NoneImplCopyWithImpl<$Res>; +} + +/// @nodoc +class __$$NoneImplCopyWithImpl<$Res> + extends _$APIAuthModelCopyWithImpl<$Res, _$NoneImpl> + implements _$$NoneImplCopyWith<$Res> { + __$$NoneImplCopyWithImpl(_$NoneImpl _value, $Res Function(_$NoneImpl) _then) + : super(_value, _then); + + /// Create a copy of APIAuthModel + /// with the given fields replaced by the non-null parameter values. +} + +/// @nodoc +@JsonSerializable() +class _$NoneImpl implements None { + const _$NoneImpl({final String? $type}) : $type = $type ?? 'none'; + + factory _$NoneImpl.fromJson(Map json) => + _$$NoneImplFromJson(json); + + @JsonKey(name: 'runtimeType') + final String $type; + + @override + String toString() { + return 'APIAuthModel.none()'; + } + + @override + bool operator ==(Object other) { + return identical(this, other) || + (other.runtimeType == runtimeType && other is _$NoneImpl); + } + + @JsonKey(includeFromJson: false, includeToJson: false) + @override + int get hashCode => runtimeType.hashCode; + + @override + @optionalTypeArgs + TResult when({ + required TResult Function() none, + required TResult Function(String username, String password) basic, + }) { + return none(); + } + + @override + @optionalTypeArgs + TResult? whenOrNull({ + TResult? Function()? none, + TResult? Function(String username, String password)? basic, + }) { + return none?.call(); + } + + @override + @optionalTypeArgs + TResult maybeWhen({ + TResult Function()? none, + TResult Function(String username, String password)? basic, + required TResult orElse(), + }) { + if (none != null) { + return none(); + } + return orElse(); + } + + @override + @optionalTypeArgs + TResult map({ + required TResult Function(None value) none, + required TResult Function(BasicAuth value) basic, + }) { + return none(this); + } + + @override + @optionalTypeArgs + TResult? mapOrNull({ + TResult? Function(None value)? none, + TResult? Function(BasicAuth value)? basic, + }) { + return none?.call(this); + } + + @override + @optionalTypeArgs + TResult maybeMap({ + TResult Function(None value)? none, + TResult Function(BasicAuth value)? basic, + required TResult orElse(), + }) { + if (none != null) { + return none(this); + } + return orElse(); + } + + @override + Map toJson() { + return _$$NoneImplToJson( + this, + ); + } +} + +abstract class None implements APIAuthModel { + const factory None() = _$NoneImpl; + + factory None.fromJson(Map json) = _$NoneImpl.fromJson; +} + +/// @nodoc +abstract class _$$BasicAuthImplCopyWith<$Res> { + factory _$$BasicAuthImplCopyWith( + _$BasicAuthImpl value, $Res Function(_$BasicAuthImpl) then) = + __$$BasicAuthImplCopyWithImpl<$Res>; + @useResult + $Res call({String username, String password}); +} + +/// @nodoc +class __$$BasicAuthImplCopyWithImpl<$Res> + extends _$APIAuthModelCopyWithImpl<$Res, _$BasicAuthImpl> + implements _$$BasicAuthImplCopyWith<$Res> { + __$$BasicAuthImplCopyWithImpl( + _$BasicAuthImpl _value, $Res Function(_$BasicAuthImpl) _then) + : super(_value, _then); + + /// Create a copy of APIAuthModel + /// with the given fields replaced by the non-null parameter values. + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? username = null, + Object? password = null, + }) { + return _then(_$BasicAuthImpl( + username: null == username + ? _value.username + : username // ignore: cast_nullable_to_non_nullable + as String, + password: null == password + ? _value.password + : password // ignore: cast_nullable_to_non_nullable + as String, + )); + } +} + +/// @nodoc +@JsonSerializable() +class _$BasicAuthImpl implements BasicAuth { + const _$BasicAuthImpl( + {required this.username, required this.password, final String? $type}) + : $type = $type ?? 'basic'; + + factory _$BasicAuthImpl.fromJson(Map json) => + _$$BasicAuthImplFromJson(json); + + @override + final String username; + @override + final String password; + + @JsonKey(name: 'runtimeType') + final String $type; + + @override + String toString() { + return 'APIAuthModel.basic(username: $username, password: $password)'; + } + + @override + bool operator ==(Object other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$BasicAuthImpl && + (identical(other.username, username) || + other.username == username) && + (identical(other.password, password) || + other.password == password)); + } + + @JsonKey(includeFromJson: false, includeToJson: false) + @override + int get hashCode => Object.hash(runtimeType, username, password); + + /// Create a copy of APIAuthModel + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + @override + @pragma('vm:prefer-inline') + _$$BasicAuthImplCopyWith<_$BasicAuthImpl> get copyWith => + __$$BasicAuthImplCopyWithImpl<_$BasicAuthImpl>(this, _$identity); + + @override + @optionalTypeArgs + TResult when({ + required TResult Function() none, + required TResult Function(String username, String password) basic, + }) { + return basic(username, password); + } + + @override + @optionalTypeArgs + TResult? whenOrNull({ + TResult? Function()? none, + TResult? Function(String username, String password)? basic, + }) { + return basic?.call(username, password); + } + + @override + @optionalTypeArgs + TResult maybeWhen({ + TResult Function()? none, + TResult Function(String username, String password)? basic, + required TResult orElse(), + }) { + if (basic != null) { + return basic(username, password); + } + return orElse(); + } + + @override + @optionalTypeArgs + TResult map({ + required TResult Function(None value) none, + required TResult Function(BasicAuth value) basic, + }) { + return basic(this); + } + + @override + @optionalTypeArgs + TResult? mapOrNull({ + TResult? Function(None value)? none, + TResult? Function(BasicAuth value)? basic, + }) { + return basic?.call(this); + } + + @override + @optionalTypeArgs + TResult maybeMap({ + TResult Function(None value)? none, + TResult Function(BasicAuth value)? basic, + required TResult orElse(), + }) { + if (basic != null) { + return basic(this); + } + return orElse(); + } + + @override + Map toJson() { + return _$$BasicAuthImplToJson( + this, + ); + } +} + +abstract class BasicAuth implements APIAuthModel { + const factory BasicAuth( + {required final String username, + required final String password}) = _$BasicAuthImpl; + + factory BasicAuth.fromJson(Map json) = + _$BasicAuthImpl.fromJson; + + String get username; + String get password; + + /// Create a copy of APIAuthModel + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + _$$BasicAuthImplCopyWith<_$BasicAuthImpl> get copyWith => + throw _privateConstructorUsedError; +} diff --git a/packages/apidash_core/lib/models/api_auth_model.g.dart b/packages/apidash_core/lib/models/api_auth_model.g.dart new file mode 100644 index 00000000..83a5b868 --- /dev/null +++ b/packages/apidash_core/lib/models/api_auth_model.g.dart @@ -0,0 +1,30 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'api_auth_model.dart'; + +// ************************************************************************** +// JsonSerializableGenerator +// ************************************************************************** + +_$NoneImpl _$$NoneImplFromJson(Map json) => _$NoneImpl( + $type: json['runtimeType'] as String?, + ); + +Map _$$NoneImplToJson(_$NoneImpl instance) => + { + 'runtimeType': instance.$type, + }; + +_$BasicAuthImpl _$$BasicAuthImplFromJson(Map json) => + _$BasicAuthImpl( + username: json['username'] as String, + password: json['password'] as String, + $type: json['runtimeType'] as String?, + ); + +Map _$$BasicAuthImplToJson(_$BasicAuthImpl instance) => + { + 'username': instance.username, + 'password': instance.password, + 'runtimeType': instance.$type, + }; diff --git a/packages/apidash_core/lib/models/models.dart b/packages/apidash_core/lib/models/models.dart index c3206fd9..0fd9acef 100644 --- a/packages/apidash_core/lib/models/models.dart +++ b/packages/apidash_core/lib/models/models.dart @@ -1 +1,4 @@ export 'environment_model.dart'; +export 'http_request_model.dart'; +export 'http_response_model.dart'; +export 'api_auth_model.dart'; \ No newline at end of file diff --git a/packages/json_field_editor/example/pubspec.lock b/packages/json_field_editor/example/pubspec.lock index 49c1a06a..19d456fd 100644 --- a/packages/json_field_editor/example/pubspec.lock +++ b/packages/json_field_editor/example/pubspec.lock @@ -5,10 +5,10 @@ packages: dependency: transitive description: name: async - sha256: "758e6d74e971c3e5aceb4110bfd6698efc7f501675bcfe0c775459a8140750eb" + sha256: d2872f9c19731c2e5f10444b14686eb7cc85c76274bd6c16e1816bff9a3bab63 url: "https://pub.dev" source: hosted - version: "2.13.0" + version: "2.12.0" boolean_selector: dependency: transitive description: @@ -69,10 +69,10 @@ packages: dependency: transitive description: name: fake_async - sha256: "5368f224a74523e8d2e7399ea1638b37aecfca824a3cc4dfdf77bf1fa905ac44" + sha256: "6a95e56b2449df2273fd8c45a662d6947ce1ebb7aafe80e550a3f68297f3cacc" url: "https://pub.dev" source: hosted - version: "1.3.3" + version: "1.3.2" flutter: dependency: "direct main" description: flutter @@ -102,10 +102,10 @@ packages: dependency: transitive description: name: leak_tracker - sha256: "6bb818ecbdffe216e81182c2f0714a2e62b593f4a4f13098713ff1685dfb6ab0" + sha256: c35baad643ba394b40aac41080300150a4f08fd0fd6a10378f8f7c6bc161acec url: "https://pub.dev" source: hosted - version: "10.0.9" + version: "10.0.8" leak_tracker_flutter_testing: dependency: transitive description: @@ -227,10 +227,10 @@ packages: dependency: transitive description: name: vm_service - sha256: ddfa8d30d89985b96407efce8acbdd124701f96741f2d981ca860662f1c0dc02 + sha256: "0968250880a6c5fe7edc067ed0a13d4bae1577fe2771dcf3010d52c4a9d3ca14" url: "https://pub.dev" source: hosted - version: "15.0.0" + version: "14.3.1" sdks: dart: ">=3.7.0-0 <4.0.0" flutter: ">=3.24.0" diff --git a/packages/multi_trigger_autocomplete_plus/example/pubspec.lock b/packages/multi_trigger_autocomplete_plus/example/pubspec.lock index 7f847cdd..5bfc05a8 100644 --- a/packages/multi_trigger_autocomplete_plus/example/pubspec.lock +++ b/packages/multi_trigger_autocomplete_plus/example/pubspec.lock @@ -5,10 +5,10 @@ packages: dependency: transitive description: name: async - sha256: "758e6d74e971c3e5aceb4110bfd6698efc7f501675bcfe0c775459a8140750eb" + sha256: d2872f9c19731c2e5f10444b14686eb7cc85c76274bd6c16e1816bff9a3bab63 url: "https://pub.dev" source: hosted - version: "2.13.0" + version: "2.12.0" boolean_selector: dependency: transitive description: @@ -61,10 +61,10 @@ packages: dependency: transitive description: name: fake_async - sha256: "5368f224a74523e8d2e7399ea1638b37aecfca824a3cc4dfdf77bf1fa905ac44" + sha256: "6a95e56b2449df2273fd8c45a662d6947ce1ebb7aafe80e550a3f68297f3cacc" url: "https://pub.dev" source: hosted - version: "1.3.3" + version: "1.3.2" ffi: dependency: transitive description: @@ -135,10 +135,10 @@ packages: dependency: transitive description: name: leak_tracker - sha256: "6bb818ecbdffe216e81182c2f0714a2e62b593f4a4f13098713ff1685dfb6ab0" + sha256: c35baad643ba394b40aac41080300150a4f08fd0fd6a10378f8f7c6bc161acec url: "https://pub.dev" source: hosted - version: "10.0.9" + version: "10.0.8" leak_tracker_flutter_testing: dependency: transitive description: @@ -339,10 +339,10 @@ packages: dependency: transitive description: name: vm_service - sha256: ddfa8d30d89985b96407efce8acbdd124701f96741f2d981ca860662f1c0dc02 + sha256: "0968250880a6c5fe7edc067ed0a13d4bae1577fe2771dcf3010d52c4a9d3ca14" url: "https://pub.dev" source: hosted - version: "15.0.0" + version: "14.3.1" web: dependency: transitive description: diff --git a/pubspec.lock b/pubspec.lock index 590e147c..69e0c77d 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -67,10 +67,10 @@ packages: dependency: transitive description: name: async - sha256: "758e6d74e971c3e5aceb4110bfd6698efc7f501675bcfe0c775459a8140750eb" + sha256: d2872f9c19731c2e5f10444b14686eb7cc85c76274bd6c16e1816bff9a3bab63 url: "https://pub.dev" source: hosted - version: "2.13.0" + version: "2.12.0" audio_session: dependency: transitive description: @@ -409,10 +409,10 @@ packages: dependency: transitive description: name: fake_async - sha256: "5368f224a74523e8d2e7399ea1638b37aecfca824a3cc4dfdf77bf1fa905ac44" + sha256: "6a95e56b2449df2273fd8c45a662d6947ce1ebb7aafe80e550a3f68297f3cacc" url: "https://pub.dev" source: hosted - version: "1.3.3" + version: "1.3.2" fetch_api: dependency: transitive description: @@ -947,10 +947,10 @@ packages: dependency: transitive description: name: leak_tracker - sha256: "6bb818ecbdffe216e81182c2f0714a2e62b593f4a4f13098713ff1685dfb6ab0" + sha256: c35baad643ba394b40aac41080300150a4f08fd0fd6a10378f8f7c6bc161acec url: "https://pub.dev" source: hosted - version: "10.0.9" + version: "10.0.8" leak_tracker_flutter_testing: dependency: transitive description: @@ -1878,10 +1878,10 @@ packages: dependency: transitive description: name: vm_service - sha256: ddfa8d30d89985b96407efce8acbdd124701f96741f2d981ca860662f1c0dc02 + sha256: "0968250880a6c5fe7edc067ed0a13d4bae1577fe2771dcf3010d52c4a9d3ca14" url: "https://pub.dev" source: hosted - version: "15.0.0" + version: "14.3.1" watcher: dependency: transitive description: @@ -1918,10 +1918,10 @@ packages: dependency: transitive description: name: webdriver - sha256: "2f3a14ca026957870cfd9c635b83507e0e51d8091568e90129fbf805aba7cade" + sha256: "3d773670966f02a646319410766d3b5e1037efb7f07cc68f844d5e06cd4d61c8" url: "https://pub.dev" source: hosted - version: "3.1.0" + version: "3.0.4" webkit_inspection_protocol: dependency: transitive description: