Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Release 4.0.3 #305

Merged
merged 13 commits into from
Nov 6, 2021
5 changes: 5 additions & 0 deletions chopper/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Changelog

## 4.0.3

- Fix for authenticator usage
- Null-safety fixes

## 4.0.1

- Fix for the null safety support
Expand Down
14 changes: 12 additions & 2 deletions chopper/lib/src/base.dart
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,13 @@ class ChopperClient {

if (updatedRequest != null) {
res = await send<BodyType, InnerType>(updatedRequest);
// To prevent double call with typed response
if (_responseIsSuccessful(res.statusCode)) {
return _processResponse(res);
} else {
res = await _handleErrorResponse<BodyType, InnerType>(res);
return _processResponse(res);
}
}
}

Expand All @@ -327,10 +334,13 @@ class ChopperClient {
res = await _handleErrorResponse<BodyType, InnerType>(res);
}

res = await _interceptResponse<BodyType, InnerType>(res);
return _processResponse(res);
}

Future<Response<BodyType>> _processResponse<BodyType, InnerType>(
dynamic res) async {
res = await _interceptResponse<BodyType, InnerType>(res);
_responseController.add(res);

return res;
}

Expand Down
2 changes: 1 addition & 1 deletion chopper/lib/src/response.dart
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class Response<BodyType> {
}) =>
Response<NewBodyType>(
base ?? this.base,
body ?? (this.body as NewBodyType),
body ?? (this.body as NewBodyType?),
error: bodyError ?? error,
);

Expand Down
2 changes: 1 addition & 1 deletion chopper/lib/src/utils.dart
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ Iterable<_Pair<String, String>> _iterableToQuery(
) =>
values.map((v) => _Pair(name, _normalizeValue(v)));

String _normalizeValue(value) => Uri.encodeQueryComponent(value.toString());
String _normalizeValue(value) => Uri.encodeComponent(value.toString());

class _Pair<A, B> {
final A first;
Expand Down
2 changes: 1 addition & 1 deletion chopper/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: chopper
description: Chopper is an http client generator using source_gen, inspired by Retrofit
version: 4.0.1
version: 4.0.3
documentation: https://hadrien-lejard.gitbook.io/chopper
repository: https://github.com/lejard-h/chopper
author: Hadrien Lejard <[email protected]>
Expand Down
4 changes: 4 additions & 0 deletions chopper_generator/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## 4.0.3

- Interpolation fixes

## 4.0.2

- Analyzer dependency upgrade
Expand Down
2 changes: 1 addition & 1 deletion chopper_generator/lib/src/generator.dart
Original file line number Diff line number Diff line change
Expand Up @@ -366,7 +366,7 @@ class ChopperGenerator extends GeneratorForAnnotation<chopper.ChopperApi> {
var path = getMethodPath(method);
paths.forEach((p, ConstantReader r) {
final name = r.peek('name')?.stringValue ?? p.displayName;
path = path.replaceFirst('{$name}', '\$${p.displayName}');
path = path.replaceFirst('{$name}', '\${${p.displayName}}');
});

if (path.startsWith('http://') || path.startsWith('https://')) {
Expand Down
2 changes: 1 addition & 1 deletion chopper_generator/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: chopper_generator
description: Chopper is an http client generator using source_gen, inspired by Retrofit
version: 4.0.2
version: 4.0.3
documentation: https://hadrien-lejard.gitbook.io/chopper
repository: https://github.com/lejard-h/chopper
author: Hadrien Lejard <[email protected]>
Expand Down