File tree Expand file tree Collapse file tree 5 files changed +28
-4
lines changed Expand file tree Collapse file tree 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.
44The format is based on [ Keep a Changelog] ( https://keepachangelog.com/en/1.0.0/ ) ,
55and this project adheres to [ Semantic Versioning] ( https://semver.org/spec/v2.0.0.html ) .
66
7+ ## [ 5.0.5] - 2021-07-19
8+ ### Fixed
9+ - Pagination with null values crashes json parser (#123 )
10+
711## [ 5.0.4] - 2021-05-20
812### Fixed
913- Missing meta properties in responses
@@ -204,6 +208,7 @@ the Document model.
204208### Added
205209- Client: fetch resources, collections, related resources and relationships
206210
211+ [ 5.0.5 ] : https://github.com/f3ath/json-api-dart/compare/5.0.4...5.0.5
207212[ 5.0.4 ] : https://github.com/f3ath/json-api-dart/compare/5.0.3...5.0.4
208213[ 5.0.3 ] : https://github.com/f3ath/json-api-dart/compare/5.0.2...5.0.3
209214[ 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 {
6767 Map <String , Object ?> meta (Map json) =>
6868 json.get <Map <String , Object ?>>('meta' , orGet: () => {});
6969
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+ }
7375
7476 Relationship relationship (Map json) {
7577 final rel = json.containsKey ('data' ) ? _rel (json['data' ]) : Relationship ();
Original file line number Diff line number Diff line change 11name : json_api
2- version : 5.0.4
2+ version : 5.0.5
33homepage : https://github.com/f3ath/json-api-dart
44description : A framework-agnostic implementations of JSON:API Client and Server. Supports JSON:API v1.0 (https://jsonapi.org)
55environment :
Original file line number Diff line number Diff line change @@ -78,6 +78,14 @@ void main() {
7878 expect (doc.meta (), isEmpty);
7979 });
8080
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+
8189 test ('can parse primary resource' , () {
8290 final doc = InboundDocument (payload.resource);
8391 final article = doc.dataAsResource ();
Original file line number Diff line number Diff line change @@ -67,6 +67,15 @@ final example = {
6767 ]
6868};
6969
70+ final nullLink = {
71+ 'links' : {
72+ 'self' : 'http://example.com/articles' ,
73+ 'next' : null ,
74+ 'last' : null ,
75+ },
76+ 'data' : []
77+ };
78+
7079final newResource = {
7180 'data' : {
7281 'type' : 'articles' ,
You can’t perform that action at this time.
0 commit comments