File tree 5 files changed +28
-4
lines changed
5 files changed +28
-4
lines changed Original file line number Diff line number Diff line change @@ -4,6 +4,10 @@ All notable changes to this project will be documented in this file.
4
4
The format is based on [ Keep a Changelog] ( https://keepachangelog.com/en/1.0.0/ ) ,
5
5
and this project adheres to [ Semantic Versioning] ( https://semver.org/spec/v2.0.0.html ) .
6
6
7
+ ## [ 5.0.5] - 2021-07-19
8
+ ### Fixed
9
+ - Pagination with null values crashes json parser (#123 )
10
+
7
11
## [ 5.0.4] - 2021-05-20
8
12
### Fixed
9
13
- Missing meta properties in responses
@@ -204,6 +208,7 @@ the Document model.
204
208
### Added
205
209
- Client: fetch resources, collections, related resources and relationships
206
210
211
+ [ 5.0.5 ] : https://github.com/f3ath/json-api-dart/compare/5.0.4...5.0.5
207
212
[ 5.0.4 ] : https://github.com/f3ath/json-api-dart/compare/5.0.3...5.0.4
208
213
[ 5.0.3 ] : https://github.com/f3ath/json-api-dart/compare/5.0.2...5.0.3
209
214
[ 5.0.2 ] : https://github.com/f3ath/json-api-dart/compare/5.0.1...5.0.2
Original file line number Diff line number Diff line change @@ -67,9 +67,11 @@ class _Parser {
67
67
Map <String , Object ?> meta (Map json) =>
68
68
json.get <Map <String , Object ?>>('meta' , orGet: () => {});
69
69
70
- Map <String , Link > links (Map json) => json
71
- .get <Map >('links' , orGet: () => {})
72
- .map ((k, v) => MapEntry (k.toString (), _link (v)));
70
+ Map <String , Link > links (Map json) {
71
+ var links = json.get <Map >('links' , orGet: () => {});
72
+ links.removeWhere ((key, value) => value == null );
73
+ return links.map ((k, v) => MapEntry (k.toString (), _link (v)));
74
+ }
73
75
74
76
Relationship relationship (Map json) {
75
77
final rel = json.containsKey ('data' ) ? _rel (json['data' ]) : Relationship ();
Original file line number Diff line number Diff line change 1
1
name : json_api
2
- version : 5.0.4
2
+ version : 5.0.5
3
3
homepage : https://github.com/f3ath/json-api-dart
4
4
description : A framework-agnostic implementations of JSON:API Client and Server. Supports JSON:API v1.0 (https://jsonapi.org)
5
5
environment :
Original file line number Diff line number Diff line change @@ -78,6 +78,14 @@ void main() {
78
78
expect (doc.meta (), isEmpty);
79
79
});
80
80
81
+ test ('can parse the null link' , () {
82
+ final doc = InboundDocument (payload.nullLink);
83
+ expect (doc.links ()['self' ].toString (), 'http://example.com/articles' );
84
+ expect (doc.links ()['prev' ], isNull);
85
+ expect (doc.links ()['next' ], isNull);
86
+ expect (doc.links ()['foobar' ], isNull);
87
+ });
88
+
81
89
test ('can parse primary resource' , () {
82
90
final doc = InboundDocument (payload.resource);
83
91
final article = doc.dataAsResource ();
Original file line number Diff line number Diff line change @@ -67,6 +67,15 @@ final example = {
67
67
]
68
68
};
69
69
70
+ final nullLink = {
71
+ 'links' : {
72
+ 'self' : 'http://example.com/articles' ,
73
+ 'next' : null ,
74
+ 'last' : null ,
75
+ },
76
+ 'data' : []
77
+ };
78
+
70
79
final newResource = {
71
80
'data' : {
72
81
'type' : 'articles' ,
You can’t perform that action at this time.
0 commit comments