Skip to content

Commit 16f2bc0

Browse files
authored
v5.1.0 (#125)
1 parent 58f7d63 commit 16f2bc0

18 files changed

+53
-35
lines changed

.github/workflows/dart.yml

+3-3
Original file line numberDiff line numberDiff line change
@@ -12,17 +12,17 @@ jobs:
1212
runs-on: ubuntu-latest
1313

1414
container:
15-
image: google/dart:latest
15+
image: dart:stable
1616

1717
steps:
1818
- uses: actions/checkout@v2
1919
- name: Install dependencies
2020
run: dart pub get
2121
- name: Format
22-
run: dartfmt --dry-run --set-exit-if-changed lib test
22+
run: dart format --output none --set-exit-if-changed example lib test
2323
- name: Analyzer
2424
run: dart analyze --fatal-infos --fatal-warnings
2525
- name: Tests
2626
run: dart test --coverage=.coverage -j1
2727
- name: Coverage
28-
run: dart run coverage:format_coverage -l -c -i .coverage --report-on=lib --packages=.packages | dart run check_coverage:check_coverage
28+
run: dart run coverage:format_coverage -l -c -i .coverage --report-on=lib | dart run check_coverage:check_coverage

CHANGELOG.md

+6
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,11 @@ All notable changes to this project will be documented in this file.
44
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
55
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
66

7+
## [5.1.0] - 2022-05-11
8+
### Changed
9+
- Dependency versions bump
10+
- Minor formatting improvements
11+
712
## [5.0.5] - 2021-07-19
813
### Fixed
914
- Pagination with null values crashes json parser (#123)
@@ -208,6 +213,7 @@ the Document model.
208213
### Added
209214
- Client: fetch resources, collections, related resources and relationships
210215

216+
[5.1.0]: https://github.com/f3ath/json-api-dart/compare/5.0.5...5.1.0
211217
[5.0.5]: https://github.com/f3ath/json-api-dart/compare/5.0.4...5.0.5
212218
[5.0.4]: https://github.com/f3ath/json-api-dart/compare/5.0.3...5.0.4
213219
[5.0.3]: https://github.com/f3ath/json-api-dart/compare/5.0.2...5.0.3

analysis_options.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
include: package:pedantic/analysis_options.yaml
1+
include: package:lints/recommended.yaml
22
linter:
33
rules:
44
- sort_constructors_first

example/client.dart

+3-1
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ void main() async {
2727
});
2828
} on RequestFailure catch (e) {
2929
/// Catch error response
30-
e.errors.forEach((error) => print('${error.title}'));
30+
for (var error in e.errors) {
31+
print(error.title);
32+
}
3133
}
3234
}

example/server.dart

+2-2
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,9 @@ Future<void> main() async {
3535

3636
print('The server is listening at $host:$port.'
3737
' Try opening the following URL(s) in your browser:');
38-
resources.forEach((resource) {
38+
for (var resource in resources) {
3939
print('http://$host:$port/$resource');
40-
});
40+
}
4141
}
4242

4343
Future addColors(Repository repo) async {

example/server/in_memory_repo.dart

+3-3
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@ import 'repository.dart';
55

66
class InMemoryRepo implements Repository {
77
InMemoryRepo(Iterable<String> types) {
8-
types.forEach((_) {
9-
_storage[_] = {};
10-
});
8+
for (var type in types) {
9+
_storage[type] = {};
10+
}
1111
}
1212

1313
final _storage = <String, Map<String, Model>>{};

lib/src/client/response/resource_updated.dart

+1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ class ResourceUpdated {
1717
return doc.dataAsResource();
1818
}
1919
}
20+
return null;
2021
}
2122

2223
final HttpResponse http;

lib/src/client/routing_client.dart

+11-5
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import 'package:json_api/client.dart';
21
import 'package:json_api/document.dart';
32
import 'package:json_api/routing.dart';
43
import 'package:json_api/src/client/client.dart';
@@ -8,6 +7,7 @@ import 'package:json_api/src/client/response/collection_fetched.dart';
87
import 'package:json_api/src/client/response/related_resource_fetched.dart';
98
import 'package:json_api/src/client/response/relationship_fetched.dart';
109
import 'package:json_api/src/client/response/relationship_updated.dart';
10+
import 'package:json_api/src/client/response/request_failure.dart';
1111
import 'package:json_api/src/client/response/resource_created.dart';
1212
import 'package:json_api/src/client/response/resource_fetched.dart';
1313
import 'package:json_api/src/client/response/resource_updated.dart';
@@ -176,8 +176,11 @@ class RoutingClient {
176176
Map<String, String> headers = const {},
177177
Map<String, String> query = const {},
178178
}) async {
179-
final response = await send(baseUri.relationship(type, id, relationship),
180-
Request.get()..headers.addAll(headers)..query.addAll(query));
179+
final response = await send(
180+
baseUri.relationship(type, id, relationship),
181+
Request.get()
182+
..headers.addAll(headers)
183+
..query.addAll(query));
181184
return RelationshipFetched.one(
182185
response.http, response.document ?? (throw FormatException()));
183186
}
@@ -189,8 +192,11 @@ class RoutingClient {
189192
Map<String, String> headers = const {},
190193
Map<String, String> query = const {},
191194
}) async {
192-
final response = await send(baseUri.relationship(type, id, relationship),
193-
Request.get()..headers.addAll(headers)..query.addAll(query));
195+
final response = await send(
196+
baseUri.relationship(type, id, relationship),
197+
Request.get()
198+
..headers.addAll(headers)
199+
..query.addAll(query));
194200
return RelationshipFetched.many(
195201
response.http, response.document ?? (throw FormatException()));
196202
}

lib/src/document/inbound_document.dart

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import 'package:json_api/document.dart';
21
import 'package:json_api/src/document/error_object.dart';
32
import 'package:json_api/src/document/error_source.dart';
43
import 'package:json_api/src/document/identifier.dart';

lib/src/document/many.dart

+6-5
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
1-
import 'package:json_api/document.dart';
21
import 'package:json_api/src/document/identifier.dart';
32
import 'package:json_api/src/document/relationship.dart';
3+
import 'package:json_api/src/document/resource.dart';
44
import 'package:json_api/src/document/resource_collection.dart';
55

66
class ToMany extends Relationship {
77
ToMany(Iterable<Identifier> identifiers) {
8-
identifiers.forEach((_) => _map[_.key] = _);
8+
for (var id in identifiers) {
9+
_map[id.key] = id;
10+
}
911
}
1012

1113
final _map = <String, Identifier>{};
@@ -20,7 +22,6 @@ class ToMany extends Relationship {
2022
/// Finds the referenced elements which are found in the [collection].
2123
/// The resulting [Iterable] may contain fewer elements than referred by the
2224
/// relationship if the [collection] does not have all of them.
23-
Iterable<Resource> findIn(ResourceCollection collection) {
24-
return _map.keys.map((key) => collection[key]).whereType();
25-
}
25+
Iterable<Resource> findIn(ResourceCollection collection) =>
26+
_map.keys.map((key) => collection[key]).whereType();
2627
}

lib/src/document/outbound_document.dart

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
1-
import 'package:json_api/document.dart';
1+
import 'package:json_api/src/document/error_object.dart';
22
import 'package:json_api/src/document/link.dart';
3+
import 'package:json_api/src/document/many.dart';
4+
import 'package:json_api/src/document/new_resource.dart';
5+
import 'package:json_api/src/document/one.dart';
36
import 'package:json_api/src/document/resource.dart';
47

58
/// A sever-to-client document.

lib/src/document/relationship.dart

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import 'dart:collection';
33
import 'package:json_api/src/document/identifier.dart';
44
import 'package:json_api/src/document/link.dart';
55

6-
class Relationship with IterableMixin<Identifier /*!*/ > {
6+
class Relationship with IterableMixin<Identifier> {
77
final links = <String, Link>{};
88
final meta = <String, Object?>{};
99

lib/src/document/resource_properties.dart

+1
Original file line numberDiff line numberDiff line change
@@ -26,5 +26,6 @@ mixin ResourceProperties {
2626
R? _rel<R extends Relationship>(String name) {
2727
final r = relationships[name];
2828
if (r is R) return r;
29+
return null;
2930
}
3031
}

lib/src/query/filter.dart

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ class Filter with MapMixin<String, String> {
1515

1616
static Filter fromUri(Uri uri) => Filter(uri.queryParametersAll
1717
.map((k, v) => MapEntry(_regex.firstMatch(k)?.group(1) ?? '', v.last))
18-
..removeWhere((k, v) => k.isEmpty));
18+
..removeWhere((k, v) => k.isEmpty));
1919

2020
static final _regex = RegExp(r'^filter\[(.+)\]$');
2121

lib/src/query/page.dart

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ class Page with MapMixin<String, String> {
1818

1919
static Page fromUri(Uri uri) => Page(uri.queryParametersAll
2020
.map((k, v) => MapEntry(_regex.firstMatch(k)?.group(1) ?? '', v.last))
21-
..removeWhere((k, v) => k.isEmpty));
21+
..removeWhere((k, v) => k.isEmpty));
2222
static final _regex = RegExp(r'^page\[(.+)\]$');
2323

2424
final _ = <String, String>{};

pubspec.yaml

+7-7
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
11
name: json_api
2-
version: 5.0.5
2+
version: 5.1.0
33
homepage: https://github.com/f3ath/json-api-dart
44
description: A framework-agnostic implementations of JSON:API Client and Server. Supports JSON:API v1.0 (https://jsonapi.org)
55
environment:
6-
sdk: '>=2.12.0 <3.0.0'
6+
sdk: '>=2.17.0 <3.0.0'
77

88
dependencies:
9-
http: ^0.13.0
9+
http: ^0.13.4
1010
http_parser: ^4.0.0
1111

1212
dev_dependencies:
13-
pedantic: ^1.10.0
14-
test: ^1.16.0
13+
lints: ^1.0.1
14+
test: ^1.21.1
1515
stream_channel: ^2.1.0
1616
uuid: ^3.0.0
17-
coverage: ^1.0.2
18-
check_coverage: ^0.0.2
17+
coverage: ^1.3.0
18+
check_coverage: ^0.0.4
1919

2020
cider:
2121
link_template:

test/unit/client/response.dart

-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import 'dart:convert';
22

33
import 'package:json_api/http.dart';
4-
import 'package:json_api/src/http/media_type.dart';
54

65
final collectionMin = HttpResponse(200,
76
body: jsonEncode({

test/unit/http/encoding_test.dart

+2-2
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ void main() {
1313
final stringBodyEn = 'qwerty';
1414
final bytesBodyEn = utf8.encode(stringBodyEn);
1515

16-
final buildResponse = (
16+
buildResponse(
1717
List<int> bytesBody,
1818
Encoding encoding,
1919
) async {
@@ -27,7 +27,7 @@ void main() {
2727
);
2828

2929
return dartHttp.handle(HttpRequest('get', Uri.parse('http://test.com')));
30-
};
30+
}
3131

3232
test('UTF-8 ru', () async {
3333
final response = await buildResponse(bytesBodyRu, utf8);

0 commit comments

Comments
 (0)