Skip to content

Commit 9b8a003

Browse files
committed
Release 0.1
1 parent 7df2587 commit 9b8a003

File tree

3 files changed

+32
-3
lines changed

3 files changed

+32
-3
lines changed

CHANGELOG.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,13 @@
33
All notable changes to this project will be documented in this file.
44
This project adheres to [Semantic Versioning](http://semver.org/).
55

6-
## Unreleased
6+
## [Unreleased][]
7+
8+
## 0.1 - 2015-08-11
9+
10+
### Added
11+
12+
- Validator fits nearly 100% specification
13+
- Full test coverage
714

815
[Unreleased]: https://github.com/Art4/json-api-client/compare/0.1...HEAD

README.md

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,12 @@ $ composer require art4/json-api-client
1818

1919
## Usage
2020

21+
Todo: Documentation
22+
23+
### Using as reader
24+
2125
```php
26+
// The Response body from a JSON API server
2227
$jsonapi_string = '{"meta":{"info":"Testing the JSON API Client."}}';
2328

2429
$document = \Art4\JsonApiClient\Utils\Helper::parse($jsonapi_string);
@@ -28,7 +33,24 @@ if ($document->hasMeta() and $document->getMeta()->hasInfo())
2833
echo $document->getMeta()->getInfo();
2934
}
3035

31-
// Testing the JSON API Client.
36+
// "Testing the JSON API Client."
37+
```
38+
39+
### Using as validator
40+
41+
JSON API Client can be used as a validator for JSON API contents:
42+
43+
```php
44+
$wrong_jsonapi = '{"data":{},"meta":{"info":"This is wrong JSON API. `data` has to be `null` or containing at least `type` and `id`."}}';
45+
46+
try
47+
{
48+
$document = \Art4\JsonApiClient\Utils\Helper::parse($jsonapi_string);
49+
}
50+
catch (\InvalidArgumentException $e)
51+
{
52+
echo $e->getMessage(); // "A resource object MUST contain a type"
53+
}
3254
```
3355

3456
## Change log

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"type": "library",
44
"description": "JSON API client",
55
"homepage": "https://github.com/Art4/json-api-client",
6-
"keywords": ["json", "api", "json-api", "client", "reader"],
6+
"keywords": ["json", "api", "json-api", "client", "reader", "validator"],
77
"license": "GPL2",
88
"authors": [
99
{

0 commit comments

Comments
 (0)