diff --git a/chopper/lib/chopper.dart b/chopper/lib/chopper.dart index a2b503ab..0096bbbb 100644 --- a/chopper/lib/chopper.dart +++ b/chopper/lib/chopper.dart @@ -3,6 +3,7 @@ /// [Getting Started](https://hadrien-lejard.gitbook.io/chopper) library chopper; +export 'package:qs_dart/qs_dart.dart' show ListFormat; export 'src/annotations.dart'; export 'src/authenticator.dart'; export 'src/base.dart'; @@ -14,7 +15,6 @@ export 'src/extensions.dart'; export 'src/chain/chain.dart'; export 'src/interceptors/interceptor.dart'; export 'src/converters.dart'; -export 'src/list_format.dart'; export 'src/request.dart'; export 'src/response.dart'; export 'src/utils.dart' hide mapToQuery; diff --git a/chopper/lib/src/annotations.dart b/chopper/lib/src/annotations.dart index 7c205346..c850b3b2 100644 --- a/chopper/lib/src/annotations.dart +++ b/chopper/lib/src/annotations.dart @@ -1,11 +1,11 @@ import 'dart:async'; import 'package:chopper/src/constants.dart'; -import 'package:chopper/src/list_format.dart'; import 'package:chopper/src/request.dart'; import 'package:chopper/src/response.dart'; import 'package:meta/meta.dart'; import 'package:meta/meta_meta.dart'; +import 'package:qs_dart/qs_dart.dart' show ListFormat; /// {@template ChopperApi} /// Defines a Chopper API. diff --git a/chopper/lib/src/list_format.dart b/chopper/lib/src/list_format.dart deleted file mode 100644 index dedb3d72..00000000 --- a/chopper/lib/src/list_format.dart +++ /dev/null @@ -1,29 +0,0 @@ -import 'package:qs_dart/qs_dart.dart' as qs show ListFormat; - -/// An enum of all available list format options. -/// -/// This is a wrapper around the [qs.ListFormat] enum. -enum ListFormat { - /// Use brackets to represent list items, for example - /// `foo[]=123&foo[]=456&foo[]=789` - brackets(qs.ListFormat.brackets), - - /// Use commas to represent list items, for example - /// `foo=123,456,789` - comma(qs.ListFormat.comma), - - /// Repeat the same key to represent list items, for example - /// `foo=123&foo=456&foo=789` - repeat(qs.ListFormat.repeat), - - /// Use indices in brackets to represent list items, for example - /// `foo[0]=123&foo[1]=456&foo[2]=789` - indices(qs.ListFormat.indices); - - const ListFormat(this.qsListFormat); - - final qs.ListFormat qsListFormat; - - @override - String toString() => name; -} diff --git a/chopper/lib/src/request.dart b/chopper/lib/src/request.dart index fbf1891b..511fca01 100644 --- a/chopper/lib/src/request.dart +++ b/chopper/lib/src/request.dart @@ -1,11 +1,11 @@ import 'dart:async' show Stream; import 'package:chopper/src/extensions.dart'; -import 'package:chopper/src/list_format.dart'; import 'package:chopper/src/utils.dart'; import 'package:equatable/equatable.dart' show EquatableMixin; import 'package:http/http.dart' as http; import 'package:meta/meta.dart'; +import 'package:qs_dart/qs_dart.dart' show ListFormat; /// {@template request} /// This class represents an HTTP request that can be made with Chopper. diff --git a/chopper/lib/src/utils.dart b/chopper/lib/src/utils.dart index 4906df9b..57643481 100644 --- a/chopper/lib/src/utils.dart +++ b/chopper/lib/src/utils.dart @@ -1,8 +1,8 @@ import 'dart:collection'; -import 'package:chopper/chopper.dart'; +import 'package:chopper/src/request.dart'; import 'package:logging/logging.dart'; -import 'package:qs_dart/qs_dart.dart' as qs; +import 'package:qs_dart/qs_dart.dart' show encode, EncodeOptions, ListFormat; /// Creates a new [Request] by copying [request] and adding a header with the /// provided key [name] and value [value] to the result. @@ -69,10 +69,10 @@ String mapToQuery( }) { listFormat ??= useBrackets == true ? ListFormat.brackets : ListFormat.repeat; - return qs.encode( + return encode( map, - qs.EncodeOptions( - listFormat: listFormat.qsListFormat, + EncodeOptions( + listFormat: listFormat, allowDots: listFormat == ListFormat.repeat, encodeDotInKeys: listFormat == ListFormat.repeat, encodeValuesOnly: listFormat == ListFormat.repeat, diff --git a/chopper/pubspec.yaml b/chopper/pubspec.yaml index b1edccc5..a4b1036d 100644 --- a/chopper/pubspec.yaml +++ b/chopper/pubspec.yaml @@ -12,7 +12,7 @@ dependencies: http: ^1.1.0 logging: ^1.2.0 meta: ^1.9.1 - qs_dart: ^1.1.0 + qs_dart: ^1.2.0 dev_dependencies: build_runner: ^2.4.9 diff --git a/chopper/test/utils_test.dart b/chopper/test/utils_test.dart index fc4e6810..9ff140db 100644 --- a/chopper/test/utils_test.dart +++ b/chopper/test/utils_test.dart @@ -1,8 +1,8 @@ // ignore_for_file: deprecated_member_use_from_same_package -import 'package:chopper/src/list_format.dart'; import 'package:chopper/src/request.dart'; import 'package:chopper/src/utils.dart'; +import 'package:qs_dart/qs_dart.dart' show ListFormat; import 'package:test/test.dart'; import 'fixtures/example_enum.dart'; diff --git a/chopper_generator/lib/src/generator.dart b/chopper_generator/lib/src/generator.dart index 20be4365..ce3efadf 100644 --- a/chopper_generator/lib/src/generator.dart +++ b/chopper_generator/lib/src/generator.dart @@ -14,7 +14,6 @@ import 'package:chopper_generator/src/vars.dart'; import 'package:code_builder/code_builder.dart'; import 'package:dart_style/dart_style.dart'; import 'package:logging/logging.dart'; -import 'package:qs_dart/qs_dart.dart' show ListFormat; import 'package:source_gen/source_gen.dart'; /// Code generator for [chopper.ChopperApi] annotated classes. @@ -406,7 +405,7 @@ final class ChopperGenerator final bool hasTag = tag.isNotEmpty; - final ListFormat? listFormat = Utils.getListFormat(method); + final chopper.ListFormat? listFormat = Utils.getListFormat(method); final bool? useBrackets = Utils.getUseBrackets(method); @@ -716,7 +715,7 @@ final class ChopperGenerator bool hasParts = false, bool useQueries = false, bool useHeaders = false, - ListFormat? listFormat, + chopper.ListFormat? listFormat, @Deprecated('Use listFormat instead') bool? useBrackets, bool? includeNullQueryVars, Reference? tagRefer, diff --git a/chopper_generator/lib/src/utils.dart b/chopper_generator/lib/src/utils.dart index 52387b45..cb26cfc6 100644 --- a/chopper_generator/lib/src/utils.dart +++ b/chopper_generator/lib/src/utils.dart @@ -3,10 +3,10 @@ import 'dart:math' show max; import 'package:analyzer/dart/element/element.dart'; +import 'package:chopper/chopper.dart' show ListFormat; import 'package:chopper_generator/src/extensions.dart'; import 'package:code_builder/code_builder.dart'; import 'package:collection/collection.dart'; -import 'package:qs_dart/qs_dart.dart' show ListFormat; import 'package:source_gen/source_gen.dart'; final class Utils { diff --git a/chopper_generator/pubspec.yaml b/chopper_generator/pubspec.yaml index 822b2ffb..ab65e440 100644 --- a/chopper_generator/pubspec.yaml +++ b/chopper_generator/pubspec.yaml @@ -18,7 +18,6 @@ dependencies: meta: ^1.9.1 source_gen: ^1.5.0 yaml: ^3.1.2 - qs_dart: ^1.1.0 collection: ^1.18.0 dev_dependencies: