Skip to content

Commit

Permalink
🔖 release v7.4.0 (#595)
Browse files Browse the repository at this point in the history
* 🔖 release v7.4.0

# chopper

## 7.4.0

- #592

# chopper_generator

## 7.4.0

- #592

---------

Signed-off-by: dependabot[bot] <support@github.com>
  • Loading branch information
techouse authored Apr 5, 2024
1 parent d2a4c46 commit 3b3952e
Show file tree
Hide file tree
Showing 33 changed files with 2,948 additions and 233 deletions.
24 changes: 12 additions & 12 deletions .github/workflows/dart.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,20 +22,20 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Cache Pub hosted dependencies
uses: actions/cache@ab5e6d0c87105b4c9c2047343972218f562e4319
uses: actions/cache@v4
with:
path: "~/.pub-cache/hosted"
key: "os:ubuntu-latest;pub-cache-hosted;sdk:stable"
restore-keys: |
os:ubuntu-latest;pub-cache-hosted
os:ubuntu-latest
- name: Setup Dart SDK
uses: dart-lang/setup-dart@d6a63dab3335f427404425de0fbfed4686d93c4f
uses: dart-lang/setup-dart@v1
with:
sdk: stable
- id: checkout
name: Checkout repository
uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633
uses: actions/checkout@v4
- name: mono_repo self validate
run: dart pub global activate mono_repo 6.6.1
- name: mono_repo self validate
Expand All @@ -45,7 +45,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Cache Pub hosted dependencies
uses: actions/cache@ab5e6d0c87105b4c9c2047343972218f562e4319
uses: actions/cache@v4
with:
path: "~/.pub-cache/hosted"
key: "os:ubuntu-latest;pub-cache-hosted;sdk:stable;packages:chopper-chopper_built_value-chopper_generator;commands:format-analyze"
Expand All @@ -55,12 +55,12 @@ jobs:
os:ubuntu-latest;pub-cache-hosted
os:ubuntu-latest
- name: Setup Dart SDK
uses: dart-lang/setup-dart@d6a63dab3335f427404425de0fbfed4686d93c4f
uses: dart-lang/setup-dart@v1
with:
sdk: stable
- id: checkout
name: Checkout repository
uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633
uses: actions/checkout@v4
- id: chopper_pub_upgrade
name: chopper; dart pub upgrade
run: dart pub upgrade
Expand Down Expand Up @@ -105,7 +105,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Cache Pub hosted dependencies
uses: actions/cache@ab5e6d0c87105b4c9c2047343972218f562e4319
uses: actions/cache@v4
with:
path: "~/.pub-cache/hosted"
key: "os:ubuntu-latest;pub-cache-hosted;sdk:stable;packages:chopper-chopper_built_value-chopper_generator;commands:test_with_coverage"
Expand All @@ -115,14 +115,14 @@ jobs:
os:ubuntu-latest;pub-cache-hosted
os:ubuntu-latest
- name: Setup Dart SDK
uses: dart-lang/setup-dart@d6a63dab3335f427404425de0fbfed4686d93c4f
uses: dart-lang/setup-dart@v1
with:
sdk: stable
- name: "Activate package:coverage"
run: "dart pub global activate coverage '>=1.5.0'"
- id: checkout
name: Checkout repository
uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633
uses: actions/checkout@v4
- id: chopper_pub_upgrade
name: chopper; dart pub upgrade
run: dart pub upgrade
Expand Down Expand Up @@ -176,7 +176,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Cache Pub hosted dependencies
uses: actions/cache@ab5e6d0c87105b4c9c2047343972218f562e4319
uses: actions/cache@v4
with:
path: "~/.pub-cache/hosted"
key: "os:ubuntu-latest;pub-cache-hosted;sdk:stable;packages:chopper-chopper_built_value;commands:test"
Expand All @@ -186,12 +186,12 @@ jobs:
os:ubuntu-latest;pub-cache-hosted
os:ubuntu-latest
- name: Setup Dart SDK
uses: dart-lang/setup-dart@d6a63dab3335f427404425de0fbfed4686d93c4f
uses: dart-lang/setup-dart@v1
with:
sdk: stable
- id: checkout
name: Checkout repository
uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633
uses: actions/checkout@v4
- id: chopper_pub_upgrade
name: chopper; dart pub upgrade
run: dart pub upgrade
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:
with:
sdk: stable
- id: checkout
uses: actions/checkout@v4.1.2
uses: actions/checkout@v4
with:
fetch-depth: 2
- run: git checkout HEAD^
Expand All @@ -53,7 +53,7 @@ jobs:
with:
sdk: stable
- id: checkout
uses: actions/checkout@v4.1.2
uses: actions/checkout@v4
- name: Load this version
id: load_this_version
working-directory: ${{ matrix.package }}
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/publish_dry_run.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:
with:
sdk: stable
- id: checkout
uses: actions/checkout@v4.1.2
uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.base.ref }}
- name: Load base version
Expand All @@ -50,7 +50,7 @@ jobs:
with:
sdk: stable
- id: checkout
uses: actions/checkout@v4.1.2
uses: actions/checkout@v4
- name: Load this version
id: load_this_version
working-directory: ${{ matrix.package }}
Expand Down
4 changes: 4 additions & 0 deletions chopper/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## 7.4.0

- Use [qs_dart](https://pub.dev/packages/qs_dart) for query string encoding for query string encoding in order to support complex query objects ([#592](https://github.com/lejard-h/chopper/pull/592))

## 7.3.0

- Add support for `@Tag` annotation ([#586](https://github.com/lejard-h/chopper/pull/586))
Expand Down
1 change: 1 addition & 0 deletions chopper/analysis_options.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ include: package:lints/recommended.yaml
analyzer:
exclude:
- "**.g.dart"
- "**.chopper.dart"
- "**.mocks.dart"
- "example/**"

Expand Down
1 change: 1 addition & 0 deletions chopper/lib/chopper.dart
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ export 'src/constants.dart';
export 'src/extensions.dart';
export 'src/http_logging_interceptor.dart';
export 'src/interceptor.dart';
export 'src/list_format.dart';
export 'src/request.dart';
export 'src/response.dart';
export 'src/utils.dart' hide mapToQuery;
32 changes: 25 additions & 7 deletions chopper/lib/src/annotations.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
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';
Expand Down Expand Up @@ -190,14 +191,23 @@ sealed class Method {
/// Mark the body as optional to suppress warnings during code generation
final bool optionalBody;

/// Use brackets [ ] to when encoding
/// List format to use when encoding lists
///
/// - [ListFormat.repeat] `hxxp://path/to/script?foo=123&foo=456&foo=789` (default)
/// - [ListFormat.brackets] `hxxp://path/to/script?foo[]=123&foo[]=456&foo[]=789`
/// - [ListFormat.indices] `hxxp://path/to/script?foo[0]=123&foo[1]=456&foo[2]=789`
/// - [ListFormat.comma] `hxxp://path/to/script?foo=123,456,789`
final ListFormat? listFormat;

/// Use brackets `[ ]` to when encoding
///
/// - lists
/// hxxp://path/to/script?foo[]=123&foo[]=456&foo[]=789
/// `hxxp://path/to/script?foo[]=123&foo[]=456&foo[]=789`
///
/// - maps
/// hxxp://path/to/script?user[name]=john&user[surname]=doe&user[age]=21
final bool useBrackets;
/// `hxxp://path/to/script?user[name]=john&user[surname]=doe&user[age]=21`
@Deprecated('Use listFormat instead')
final bool? useBrackets;

/// Set to [true] to include query variables with null values. This includes nested maps.
/// The default is to exclude them.
Expand All @@ -223,16 +233,17 @@ sealed class Method {
/// ```
///
/// The above code produces hxxp://path/to/script&foo=foo_var&bar=&baz=baz_var
final bool includeNullQueryVars;
final bool? includeNullQueryVars;

/// {@macro Method}
const Method(
this.method, {
this.optionalBody = false,
this.path = '',
this.headers = const {},
this.useBrackets = false,
this.includeNullQueryVars = false,
this.listFormat,
@Deprecated('Use listFormat instead') this.useBrackets,
this.includeNullQueryVars,
});
}

Expand All @@ -247,6 +258,7 @@ final class Get extends Method {
super.optionalBody = true,
super.path,
super.headers,
super.listFormat,
super.useBrackets,
super.includeNullQueryVars,
}) : super(HttpMethod.Get);
Expand All @@ -265,6 +277,7 @@ final class Post extends Method {
super.optionalBody,
super.path,
super.headers,
super.listFormat,
super.useBrackets,
super.includeNullQueryVars,
}) : super(HttpMethod.Post);
Expand All @@ -281,6 +294,7 @@ final class Delete extends Method {
super.optionalBody = true,
super.path,
super.headers,
super.listFormat,
super.useBrackets,
super.includeNullQueryVars,
}) : super(HttpMethod.Delete);
Expand All @@ -299,6 +313,7 @@ final class Put extends Method {
super.optionalBody,
super.path,
super.headers,
super.listFormat,
super.useBrackets,
super.includeNullQueryVars,
}) : super(HttpMethod.Put);
Expand All @@ -316,6 +331,7 @@ final class Patch extends Method {
super.optionalBody,
super.path,
super.headers,
super.listFormat,
super.useBrackets,
super.includeNullQueryVars,
}) : super(HttpMethod.Patch);
Expand All @@ -332,6 +348,7 @@ final class Head extends Method {
super.optionalBody = true,
super.path,
super.headers,
super.listFormat,
super.useBrackets,
super.includeNullQueryVars,
}) : super(HttpMethod.Head);
Expand All @@ -348,6 +365,7 @@ final class Options extends Method {
super.optionalBody = true,
super.path,
super.headers,
super.listFormat,
super.useBrackets,
super.includeNullQueryVars,
}) : super(HttpMethod.Options);
Expand Down
29 changes: 29 additions & 0 deletions chopper/lib/src/list_format.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
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;

Check warning on line 28 in chopper/lib/src/list_format.dart

View check run for this annotation

Codecov / codecov/patch

chopper/lib/src/list_format.dart#L27-L28

Added lines #L27 - L28 were not covered by tests
}
30 changes: 22 additions & 8 deletions chopper/lib/src/request.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import 'dart:async';
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;
Expand All @@ -17,8 +18,10 @@ base class Request extends http.BaseRequest with EquatableMixin {
final Object? tag;
final bool multipart;
final List<PartValue> parts;
final bool useBrackets;
final bool includeNullQueryVars;
final ListFormat? listFormat;
@Deprecated('Use listFormat instead')
final bool? useBrackets;
final bool? includeNullQueryVars;

/// {@macro request}
Request(
Expand All @@ -31,8 +34,9 @@ base class Request extends http.BaseRequest with EquatableMixin {
this.multipart = false,
this.parts = const [],
this.tag,
this.useBrackets = false,
this.includeNullQueryVars = false,
this.listFormat,
@Deprecated('Use listFormat instead') this.useBrackets,
this.includeNullQueryVars,
}) : assert(
!baseUri.hasQuery,
'baseUri should not contain query parameters.'
Expand All @@ -45,6 +49,8 @@ base class Request extends http.BaseRequest with EquatableMixin {
baseUri,
uri,
{...uri.queryParametersAll, ...?parameters},
listFormat: listFormat,
// ignore: deprecated_member_use_from_same_package
useBrackets: useBrackets,
includeNullQueryVars: includeNullQueryVars,
),
Expand All @@ -62,7 +68,8 @@ base class Request extends http.BaseRequest with EquatableMixin {
Map<String, String>? headers,
bool? multipart,
List<PartValue>? parts,
bool? useBrackets,
ListFormat? listFormat,
@Deprecated('Use listFormat instead') bool? useBrackets,
bool? includeNullQueryVars,
Object? tag,
}) =>
Expand All @@ -75,6 +82,8 @@ base class Request extends http.BaseRequest with EquatableMixin {
headers: headers ?? this.headers,
multipart: multipart ?? this.multipart,
parts: parts ?? this.parts,
listFormat: listFormat ?? this.listFormat,
// ignore: deprecated_member_use_from_same_package
useBrackets: useBrackets ?? this.useBrackets,
includeNullQueryVars: includeNullQueryVars ?? this.includeNullQueryVars,
tag: tag ?? this.tag,
Expand All @@ -88,8 +97,9 @@ base class Request extends http.BaseRequest with EquatableMixin {
Uri baseUrl,
Uri url,
Map<String, dynamic> parameters, {
bool useBrackets = false,
bool includeNullQueryVars = false,
ListFormat? listFormat,
@Deprecated('Use listFormat instead') bool? useBrackets,
bool? includeNullQueryVars,
}) {
// If the request's url is already a fully qualified URL, we can use it
// as-is and ignore the baseUrl.
Expand All @@ -106,6 +116,8 @@ base class Request extends http.BaseRequest with EquatableMixin {

final String query = mapToQuery(
allParameters,
listFormat: listFormat,
// ignore: deprecated_member_use_from_same_package
useBrackets: useBrackets,
includeNullQueryVars: includeNullQueryVars,
);
Expand Down Expand Up @@ -239,6 +251,8 @@ base class Request extends http.BaseRequest with EquatableMixin {
headers,
multipart,
parts,
listFormat,
// ignore: deprecated_member_use_from_same_package
useBrackets,
includeNullQueryVars,
];
Expand Down
Loading

0 comments on commit 3b3952e

Please sign in to comment.