Skip to content

Commit

Permalink
🔖 release v7.0.0 (#454)
Browse files Browse the repository at this point in the history
  • Loading branch information
techouse authored Jul 29, 2023
1 parent f1c929c commit e178640
Show file tree
Hide file tree
Showing 31 changed files with 235 additions and 286 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ jobs:
strategy:
matrix:
package: [ chopper, chopper_generator, chopper_built_value ]
fail-fast: true
max-parallel: 1
steps:
- uses: dart-lang/setup-dart@v1
with:
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/publish_dry_run.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ jobs:
strategy:
matrix:
package: [ chopper, chopper_generator, chopper_built_value ]
fail-fast: true
max-parallel: 1
steps:
- uses: dart-lang/setup-dart@v1
with:
Expand Down
5 changes: 5 additions & 0 deletions chopper/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Changelog

## 7.0.0

- Require Dart 3.0 or later
- Add base, final, and interface modifiers to some classes ([#453](https://github.com/lejard-h/chopper/pull/453))

## 6.1.4

- Fix Multipart for List<int> and List<String> ([#439](https://github.com/lejard-h/chopper/pull/439))
Expand Down
21 changes: 0 additions & 21 deletions chopper/analysis_options.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,27 +6,6 @@ analyzer:
- "**.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:
Expand Down
44 changes: 22 additions & 22 deletions chopper/lib/src/annotations.dart
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import 'package:meta/meta.dart';
///
/// See [Method] to define an HTTP request
@immutable
class ChopperApi {
final class ChopperApi {
/// A part of a URL that every request defined inside a class annotated with [ChopperApi] will be prefixed with.
final String baseUrl;

Expand All @@ -42,7 +42,7 @@ class ChopperApi {
/// Future<Response> fetch(@Path() String param);
/// ```
@immutable
class Path {
final class Path {
/// Name is used to bind a method parameter to
/// a URL path parameter.
/// ```dart
Expand All @@ -65,7 +65,7 @@ class Path {
///
/// See [QueryMap] to pass an [Map<String, dynamic>] as value
@immutable
class Query {
final class Query {
/// Name is used to bind a method parameter to
/// the query parameter.
/// ```dart
Expand All @@ -90,7 +90,7 @@ class Query {
/// // something?foo=bar&list=1&list=2
/// ```
@immutable
class QueryMap {
final class QueryMap {
const QueryMap();
}

Expand All @@ -104,7 +104,7 @@ class QueryMap {
/// The body can be of any type, but chopper does not automatically convert it to JSON.
/// See [Converter] to apply conversion to the body.
@immutable
class Body {
final class Body {
const Body();
}

Expand All @@ -117,7 +117,7 @@ class Body {
/// Future<Response> fetch(@Header() String foo);
/// ```
@immutable
class Header {
final class Header {
/// Name is used to bind a method parameter to
/// a header name.
/// ```dart
Expand Down Expand Up @@ -147,7 +147,7 @@ class Header {
/// However, chopper will not automatically convert the body response to your type.
/// A [Converter] needs to be specified for conversion.
@immutable
class Method {
sealed class Method {
/// HTTP method for the request
final String method;

Expand Down Expand Up @@ -207,7 +207,7 @@ class Method {

/// Defines a method as an HTTP GET request.
@immutable
class Get extends Method {
final class Get extends Method {
const Get({
super.optionalBody = true,
super.path,
Expand All @@ -221,7 +221,7 @@ class Get extends Method {
///
/// Use the [Body] annotation to pass data to send.
@immutable
class Post extends Method {
final class Post extends Method {
const Post({
super.optionalBody,
super.path,
Expand All @@ -233,7 +233,7 @@ class Post extends Method {

/// Defines a method as an HTTP DELETE request.
@immutable
class Delete extends Method {
final class Delete extends Method {
const Delete({
super.optionalBody = true,
super.path,
Expand All @@ -247,7 +247,7 @@ class Delete extends Method {
///
/// Use the [Body] annotation to pass data to send.
@immutable
class Put extends Method {
final class Put extends Method {
const Put({
super.optionalBody,
super.path,
Expand All @@ -260,7 +260,7 @@ class Put extends Method {
/// Defines a method as an HTTP PATCH request.
/// Use the [Body] annotation to pass data to send.
@immutable
class Patch extends Method {
final class Patch extends Method {
const Patch({
super.optionalBody,
super.path,
Expand All @@ -272,7 +272,7 @@ class Patch extends Method {

/// Defines a method as an HTTP HEAD request.
@immutable
class Head extends Method {
final class Head extends Method {
const Head({
super.optionalBody = true,
super.path,
Expand All @@ -283,7 +283,7 @@ class Head extends Method {
}

@immutable
class Options extends Method {
final class Options extends Method {
const Options({
super.optionalBody = true,
super.path,
Expand Down Expand Up @@ -330,7 +330,7 @@ typedef ConvertResponse<T> = FutureOr<Response> Function(Response response);
/// }
/// ```
@immutable
class FactoryConverter {
final class FactoryConverter {
final ConvertRequest? request;
final ConvertResponse? response;

Expand All @@ -349,7 +349,7 @@ class FactoryConverter {
/// ```
/// Will be converted to `{ 'name': value }`.
@immutable
class Field {
final class Field {
/// Name can be use to specify the name of the field
/// ```dart
/// @Post(path: '/')
Expand All @@ -367,7 +367,7 @@ class Field {
/// Future<Response> fetch(@FieldMap List<Map<String, dynamic>> query);
/// ```
@immutable
class FieldMap {
final class FieldMap {
const FieldMap();
}

Expand All @@ -382,7 +382,7 @@ class FieldMap {
/// Use [Part] annotation to send simple data.
/// Use [PartFile] annotation to send `File` or `List<int>`.
@immutable
class Multipart {
final class Multipart {
const Multipart();
}

Expand All @@ -392,7 +392,7 @@ class Multipart {
///
/// Also accepts `MultipartFile` (from package:http).
@immutable
class Part {
final class Part {
final String? name;

const Part([this.name]);
Expand All @@ -406,7 +406,7 @@ class Part {
/// Future<Response> fetch(@PartMap() List<PartValue> query);
/// ```
@immutable
class PartMap {
final class PartMap {
const PartMap();
}

Expand All @@ -423,7 +423,7 @@ class PartMap {
/// - [String] (path of your file)
/// - `MultipartFile` (from package:http)
@immutable
class PartFile {
final class PartFile {
final String? name;

const PartFile([this.name]);
Expand All @@ -437,7 +437,7 @@ class PartFile {
/// Future<Response> fetch(@PartFileMap() List<PartValueFile> query);
/// ```
@immutable
class PartFileMap {
final class PartFileMap {
const PartFileMap();
}

Expand Down
4 changes: 2 additions & 2 deletions chopper/lib/src/base.dart
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import 'package:meta/meta.dart';
Type _typeOf<T>() => T;

@visibleForTesting
final List<Type> allowedInterceptorsType = [
const List<Type> allowedInterceptorsType = [
RequestInterceptor,
RequestInterceptorFunc,
ResponseInterceptor,
Expand All @@ -26,7 +26,7 @@ final List<Type> allowedInterceptorsType = [
///
/// It manages registered services, encodes and decodes data, and intercepts
/// requests and responses.
class ChopperClient {
base class ChopperClient {
/// Base URL of each request of the registered services.
/// E.g., the hostname of your service.
final Uri baseUrl;
Expand Down
2 changes: 1 addition & 1 deletion chopper/lib/src/constants.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ const String formEncodedHeaders = 'application/x-www-form-urlencoded';
// Represent the header for a json api response https://jsonapi.org/#mime-types
const String jsonApiHeaders = 'application/vnd.api+json';

abstract class HttpMethod {
abstract final class HttpMethod {
static const String Get = 'GET';
static const String Post = 'POST';
static const String Put = 'PUT';
Expand Down
8 changes: 4 additions & 4 deletions chopper/lib/src/interceptor.dart
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ import 'package:meta/meta.dart';
/// }
/// ```
@immutable
abstract class ResponseInterceptor {
abstract interface class ResponseInterceptor {
FutureOr<Response> onResponse(Response response);
}

Expand All @@ -58,7 +58,7 @@ abstract class ResponseInterceptor {
///
/// (See [applyHeader(request, name, value)] and [applyHeaders(request, headers)].)
@immutable
abstract class RequestInterceptor {
abstract interface class RequestInterceptor {
FutureOr<Request> onRequest(Request request);
}

Expand All @@ -72,7 +72,7 @@ abstract class RequestInterceptor {
///
/// See [JsonConverter] and [FormUrlEncodedConverter] for example implementations.
@immutable
abstract class Converter {
abstract interface class Converter {
/// Converts the received [Request] to a [Request] which has a body with the
/// HTTP representation of the original body.
FutureOr<Request> convertRequest(Request request);
Expand All @@ -94,7 +94,7 @@ abstract class Converter {
///
/// An `ErrorConverter` is called only on error responses
/// (statusCode < 200 || statusCode >= 300) and before any [ResponseInterceptor]s.
abstract class ErrorConverter {
abstract interface class ErrorConverter {
/// Converts the received [Response] to a [Response] which has a body with the
/// HTTP representation of the original body.
FutureOr<Response> convertError<BodyType, InnerType>(Response response);
Expand Down
6 changes: 3 additions & 3 deletions chopper/lib/src/request.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import 'package:http/http.dart' as http;
import 'package:meta/meta.dart';

/// This class represents an HTTP request that can be made with Chopper.
class Request extends http.BaseRequest with EquatableMixin {
base class Request extends http.BaseRequest with EquatableMixin {
final Uri uri;
final Uri baseUri;
final dynamic body;
Expand Down Expand Up @@ -232,7 +232,7 @@ class Request extends http.BaseRequest with EquatableMixin {

/// Represents a part in a multipart request.
@immutable
class PartValue<T> with EquatableMixin {
final class PartValue<T> with EquatableMixin {
final T value;
final String name;

Expand All @@ -258,6 +258,6 @@ class PartValue<T> with EquatableMixin {

/// Represents a file [PartValue] in a multipart request.
@immutable
class PartValueFile<T> extends PartValue<T> {
final class PartValueFile<T> extends PartValue<T> {
const PartValueFile(super.name, super.value);
}
2 changes: 1 addition & 1 deletion chopper/lib/src/response.dart
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import 'package:meta/meta.dart';
/// Future<Response<Item>> fetchItem();
/// ```
@immutable
class Response<BodyType> with EquatableMixin {
base class Response<BodyType> with EquatableMixin {
/// The [http.BaseResponse] from `package:http` that this [Response] wraps.
final http.BaseResponse base;

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 @@ -131,7 +131,7 @@ Iterable<_Pair<String, String>> _iterableToQuery(

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

class _Pair<A, B> with EquatableMixin {
final class _Pair<A, B> with EquatableMixin {
final A first;
final B second;
final bool useBrackets;
Expand Down
Loading

0 comments on commit e178640

Please sign in to comment.