json_api 3.2.2

  • Readme
  • Changelog
  • Example
  • Installing
  • 90

JSON:API is a specification for building APIs in JSON.

This package consists of several libraries:

  • The Client to make requests to JSON:API servers
  • The Server which is still under development
  • The Document model for resources, relationships, identifiers, etc
  • The Query to build and parse the query parameters (pagination, sorting, etc)
  • The URL Design to build and match URLs for resources, collections, and relationships

Changelog #

All notable changes to this project will be documented in this file.

The format is based on Keep a Changelog, and this project adheres to Semantic Versioning.

3.2.2 - 2020-01-07

Fixed #

  • Can not decode related resource which is null (#77)

3.2.1 - 2020-01-01

Fixed #

  • Incorrect URL in the example in the Client documentation (#74)

3.2.0 - 2019-12-30

Added #

  • matchBase option to PathBasedUrlDesign.
  • Resource.toIdentifier()method.

Changed #

  • (Server, BC-breaking) JsonApiController made generic.

Removed #

  • The package does not depend on collection anymore.

3.1.0 - 2019-12-19

Added #

  • (Server) Routing is exposed via server library.

Changed #

  • (Server, BC-breaking) Controller renamed to JsonApiController.
  • (Server, BC-breaking) Response renamed to JsonApiResponse.

Fixed #

  • (Server) Response classes had included member initialized to [] by default. Now the default is null.

3.0.0 - 2019-12-17

Added #

  • Support for custom non-standard links (#61)
  • Client supports jsonapi key in outgoing requests.
  • Document.contentType constant.
  • IdentifierObject.fromIdentifier factory method

Changed #

Most of the changes are BC-BREAKING.

  • URLBuilder was renamed to UrlFactory.
  • DocumentBuilder was split into ServerDocumentFactory and ClientDocumentFactory. Some methods were renamed.
  • Static decodeJson methods were renamed to fromJson.
  • Identifier.equals now requires the runtime type to be exactly the same.
  • Link.decodeJsonMap was renamed to mapFromJson.
  • The signature of TargetMatcher.
  • The signature of Controller.
  • Server was renamed to JsonApiServer.
  • Pagination was renamed to PaginationStrategy.

Removed #

  • (Server) ResourceTarget, CollectionTarget, RelationshipTarget classes.
  • QueryParameters interface.
  • Router class.
  • Query class.

2.1.0 - 2019-12-04

Added #

  • onHttpCall hook to enable raw http request/response logging (#60).

2.0.3 - 2019-09-29

Fixed #

  • Documentation links got broken due to pub.dev update.

2.0.2 - 2019-08-01

Fixed #

  • Meta members have incorrect type (#54).

2.0.1 - 2019-07-12

Fixed #

  • Readme example was outdated.

2.0.0 - 2019-07-12

Changed #

  • This package now consolidates the Client, the Server and the Document in one single library. It does not depend on json_api_document and json_api_server anymore, please remove these packages from your pubspec.yaml.
  • The min Dart SDK version bumped to 2.3.0
  • The Client requires an instance of HttpClient to be passed to the constructor explicitly.
  • Both the Document and the Server have been refactored with lots of BREAKING CHANGES. See the examples and the functional tests for details.
  • Meta properties are not defensively copied, but set directly. Meta property behavior is unified across the Document model.

Removed #

  • JsonApiParser is removed. Use the static decodeJson methods in the corresponding classes instead.

1.0.1 - 2019-04-05

Fixed #

  • Bumped the dependencies versions due to a bug in json_api_document.

1.0.0 - 2019-03-20

Changed #

  • JSON:API Server moved out

0.6.0 - 2019-03-25

Changed #

  • JSON:API Document moved out
  • Renamed client.removeToOne(...) to client.deleteToOne(...)

0.5.0 - 2019-03-21

Changed #

  • More BC-breaking changes in the Server

Fixed #

  • Location headers were incorrectly generated by Server

Added #

  • Related collection pagination
  • Async operations support

0.4.0 - 2019-03-17

Changed #

  • Parsing logic moved out
  • Some other BC-breaking changes in the Document
  • Huge changes in the Server

Added #

  • Compound documents support in Client (Server-side support is still very limited)

Fixed #

  • Server was not setting links for resources and relationships

0.3.0 - 2019-03-16

Changed #

  • Huge BC-breaking refactoring in the Document model which propagated everywhere

Added #

  • Resource attributes update
  • Resource relationships update

0.2.0 - 2019-03-01

Added #

  • Improved ResourceController error handling
  • Resource creation
  • Resource deletion

0.1.0 - 2019-02-27 #

Added #

  • Client: fetch resources, collections, related resources and relationships

example/README.md

JSON:API examples #

Cars Server #

This is a simple JSON:API server which is used in the tests. It provides an API to a collection to car companies and models. You can run it locally to play around.

Fetch example #

With the server running, call

dart example/fetch_collection.dart

This will make a fetchCollection() call and print the response.

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:


dependencies:
  json_api: ^3.2.2

2. Install it

You can install packages from the command line:

with pub:


$ pub get

with Flutter:


$ flutter pub get

Alternatively, your editor might support pub get or flutter pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:


import 'package:json_api/client.dart';
import 'package:json_api/document.dart';
import 'package:json_api/query.dart';
import 'package:json_api/server.dart';
import 'package:json_api/url_design.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
80
Health:
Code health derived from static analysis. [more]
100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
100
Overall:
Weighted score of the above. [more]
90
Learn more about scoring.

We analyzed this package on Jan 24, 2020, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.7.0
  • pana: 0.13.4

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.6.0 <3.0.0
http ^0.12.0 0.12.0+4
Transitive dependencies
async 2.4.0
charcode 1.1.2
collection 1.14.12
http_parser 3.1.3
meta 1.1.8
path 1.6.4
source_span 1.6.0
string_scanner 1.0.5
term_glyph 1.1.0
typed_data 1.1.6
Dev dependencies
json_matcher ^0.2.3
pedantic ^1.9.0 1.9.0
stream_channel ^2.0.0
test ^1.9.2
uuid ^2.0.1