Skip to content

Commit

Permalink
Release 5.0.0 (#353)
Browse files Browse the repository at this point in the history
Co-authored-by: Ivan Terekhin <[email protected]>
Co-authored-by: István Juhos <[email protected]>
Co-authored-by: Meysam Karimi <[email protected]>
Co-authored-by: Youssef Raafat <[email protected]>
Co-authored-by: luis901101 <[email protected]>
Co-authored-by: melvspace <[email protected]>
Co-authored-by: Michal Šrůtek <[email protected]>
Co-authored-by: Andre <[email protected]>
Co-authored-by: John Wimer <[email protected]>
Co-authored-by: Max Röhrl <[email protected]>
Co-authored-by: ipcjs <[email protected]>
Co-authored-by: ibadin <[email protected]>
Co-authored-by: Meysam Karimi <[email protected]>
Co-authored-by: Klemen Tusar <[email protected]>
Co-authored-by: Klemen Tusar <[email protected]>
  • Loading branch information
15 people authored Sep 13, 2022
1 parent f672b10 commit 140849c
Show file tree
Hide file tree
Showing 47 changed files with 1,170 additions and 711 deletions.
18 changes: 2 additions & 16 deletions chopper/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,22 +1,8 @@
# Changelog

## 4.0.6
## 5.0.0

- FieldMap added
- Example migrated to null safety / Angular removed

## 4.0.5

- Add additional param for the authenticator

## 4.0.4

- Fix for authenticator usage

## 4.0.3

- Fix for authenticator usage
- Null-safety fixes
- API breaking changes (FutureOr)

## 4.0.1

Expand Down
35 changes: 34 additions & 1 deletion chopper/analysis_options.yaml
Original file line number Diff line number Diff line change
@@ -1 +1,34 @@
include: package:pedantic/analysis_options.yaml
include: package:lints/recommended.yaml

analyzer:
exclude:
- "**.g.dart"
- "**.chopper.dart"
- "**.mocks.dart"
- "example/**"
plugins:
- dart_code_metrics

dart_code_metrics:
metrics:
cyclomatic-complexity: 20
number-of-arguments: 4
maximum-nesting-level: 5
number-of-parameters: 7
metrics-exclude:
- test/**
rules:
- newline-before-return
- no-boolean-literal-compare
- no-empty-block
- prefer-trailing-comma
- prefer-conditional-expressions
- no-equal-then-else
anti-patterns:
- long-method
- long-parameter-list

linter:
rules:
avoid_print: true
prefer_single_quotes: true
4 changes: 2 additions & 2 deletions chopper/example/definition.chopper.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions chopper/example/definition.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import 'dart:async';

import 'package:chopper/chopper.dart';

part 'definition.chopper.dart';
Expand Down
3 changes: 2 additions & 1 deletion chopper/example/main.dart
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import 'package:chopper/chopper.dart';

import 'definition.dart';

Future<void> main() async {
final chopper = ChopperClient(
baseUrl: 'http://localhost:8000',
services: [
// the generated service
MyService.create(ChopperClient())
MyService.create(ChopperClient()),
],
converter: JsonConverter(),
);
Expand Down
2 changes: 1 addition & 1 deletion chopper/lib/chopper.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ library chopper;
export 'src/annotations.dart';
export 'src/authenticator.dart';
export 'src/base.dart';
export 'src/constants.dart';
export 'src/interceptor.dart';
export 'src/request.dart';
export 'src/response.dart';
export 'src/utils.dart' hide mapToQuery;
export 'src/constants.dart';
96 changes: 32 additions & 64 deletions chopper/lib/src/annotations.dart
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import 'dart:async';

import 'package:meta/meta.dart';

import 'constants.dart';
import 'request.dart';
import 'response.dart';
import 'constants.dart';

/// Defines a Chopper API.
///
Expand Down Expand Up @@ -171,15 +173,10 @@ class Method {
@immutable
class Get extends Method {
const Get({
bool optionalBody = true,
String path = '',
Map<String, String> headers = const {},
}) : super(
HttpMethod.Get,
optionalBody: optionalBody,
path: path,
headers: headers,
);
super.optionalBody = true,
super.path,
super.headers,
}) : super(HttpMethod.Get);
}

/// Defines a method as an HTTP POST request.
Expand All @@ -188,30 +185,20 @@ class Get extends Method {
@immutable
class Post extends Method {
const Post({
bool optionalBody = false,
String path = '',
Map<String, String> headers = const {},
}) : super(
HttpMethod.Post,
optionalBody: optionalBody,
path: path,
headers: headers,
);
super.optionalBody,
super.path,
super.headers,
}) : super(HttpMethod.Post);
}

/// Defines a method as an HTTP DELETE request.
@immutable
class Delete extends Method {
const Delete({
bool optionalBody = true,
String path = '',
Map<String, String> headers = const {},
}) : super(
HttpMethod.Delete,
optionalBody: optionalBody,
path: path,
headers: headers,
);
super.optionalBody = true,
super.path,
super.headers,
}) : super(HttpMethod.Delete);
}

/// Defines a method as an HTTP PUT request.
Expand All @@ -220,60 +207,40 @@ class Delete extends Method {
@immutable
class Put extends Method {
const Put({
bool optionalBody = false,
String path = '',
Map<String, String> headers = const {},
}) : super(
HttpMethod.Put,
optionalBody: optionalBody,
path: path,
headers: headers,
);
super.optionalBody,
super.path,
super.headers,
}) : super(HttpMethod.Put);
}

/// Defines a method as an HTTP PATCH request.
/// Use the [Body] annotation to pass data to send.
@immutable
class Patch extends Method {
const Patch({
bool optionalBody = false,
String path = '',
Map<String, String> headers = const {},
}) : super(
HttpMethod.Patch,
optionalBody: optionalBody,
path: path,
headers: headers,
);
super.optionalBody,
super.path,
super.headers,
}) : super(HttpMethod.Patch);
}

/// Defines a method as an HTTP HEAD request.
@immutable
class Head extends Method {
const Head({
bool optionalBody = true,
String path = '',
Map<String, String> headers = const {},
}) : super(
HttpMethod.Head,
optionalBody: optionalBody,
path: path,
headers: headers,
);
super.optionalBody = true,
super.path,
super.headers,
}) : super(HttpMethod.Head);
}

@immutable
class Options extends Method {
const Options({
bool optionalBody = true,
String path = '',
Map<String, String> headers = const {},
}) : super(
HttpMethod.Options,
optionalBody: optionalBody,
path: path,
headers: headers,
);
super.optionalBody = true,
super.path,
super.headers,
}) : super(HttpMethod.Options);
}

/// A function that should convert the body of a [Request] to the HTTP representation.
Expand Down Expand Up @@ -377,6 +344,7 @@ class Multipart {
@immutable
class Part {
final String? name;

const Part([this.name]);
}

Expand Down
7 changes: 5 additions & 2 deletions chopper/lib/src/authenticator.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ import 'package:chopper/chopper.dart';
/// This method should return a [Request] that includes credentials to satisfy an authentication challenge received in
/// [response]. It should return `null` if the challenge cannot be satisfied.
abstract class Authenticator {
FutureOr<Request?> authenticate(Request request, Response response,
[Request? originalRequest]);
FutureOr<Request?> authenticate(
Request request,
Response response, [
Request? originalRequest,
]);
}
Loading

0 comments on commit 140849c

Please sign in to comment.