json_api_conformant 0.0.1 → 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/.travis.yml +12 -0
- data/README.md +13 -5
- data/lib/json_api_conformant/version.rb +1 -1
- data/lib/json_api_conformant.rb +4 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4634ddceab8a179d9c13de30a94cf8592db96bf9
|
4
|
+
data.tar.gz: 66ca7f6573f8bb44f5badf9dd29dda5de8593bd9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f5a94c9cad6f10c1c64d5e5c28e32a249b366b83a27264d6e1522056808eb5a2c68f2cfb050aaf853a7012f67c5644f82eca6d74a02636f827c07bc70d111997
|
7
|
+
data.tar.gz: 0e09e145ab952ac4eab546015bf4d3cc61397e460838a773a21f18ef4f430f00ed4c630fa9d2ce7f2df5beeda1415cd90571683bf8337eeb334fa76397271acb
|
data/.gitignore
CHANGED
data/.travis.yml
ADDED
data/README.md
CHANGED
@@ -1,4 +1,6 @@
|
|
1
1
|
# JSON API Conformant
|
2
|
+
[](https://travis-ci.org/sebasoga/json_api_conformant)
|
3
|
+
[](https://codeclimate.com/github/sebasoga/json_api_conformant)
|
2
4
|
|
3
5
|
When building an API in JSON it is important to follow conventions for the so
|
4
6
|
that your system clients know how to send a request for the available resources
|
@@ -47,20 +49,26 @@ valid_schema = {"posts" => [{"id" => "1"}]}
|
|
47
49
|
invalid_schema = {"comments" => "Nice gem!"}
|
48
50
|
|
49
51
|
JSON::API::Conformant.validate(valid_schema) # => []
|
50
|
-
JSON::API::Conformant.validate(invalid_schema) # => ["The property
|
51
|
-
'#/comments' of type String did not match the"]
|
52
|
+
JSON::API::Conformant.validate(invalid_schema) # => ["The property '#/comments' of type String did not match the..."]
|
52
53
|
```
|
53
54
|
|
54
|
-
JSON API Conformant wraps [json-schema](https://github.com/hoxworth/json-schema,
|
55
|
+
JSON API Conformant wraps [json-schema](https://github.com/hoxworth/json-schema),
|
55
56
|
so other options that validator accepts will work here too.
|
57
|
+
```ruby
|
58
|
+
schema = {"posts" => [{"id" => "1"}]}
|
59
|
+
|
60
|
+
JSON::API::Conformant.valid?(valid_schema, insert_defaults: true)
|
61
|
+
JSON::API::Conformant.validate(valid_schema, errors_as_objects: true)
|
62
|
+
```
|
63
|
+
|
56
64
|
|
57
65
|
### RSpec Matcher
|
66
|
+
Only tested with RSpec 3.
|
58
67
|
|
59
68
|
It is pretty straighword to use.
|
60
69
|
```ruby
|
61
|
-
it "
|
70
|
+
it "validates that's JSON API conformant" do
|
62
71
|
data = {"posts" => [{"id" => "1"}]}
|
63
|
-
|
64
72
|
expect(data).to be_json_api_conformant
|
65
73
|
end
|
66
74
|
```
|
data/lib/json_api_conformant.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: json_api_conformant
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sebastian Sogamoso
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-08-
|
11
|
+
date: 2014-08-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -74,6 +74,7 @@ extensions: []
|
|
74
74
|
extra_rdoc_files: []
|
75
75
|
files:
|
76
76
|
- ".gitignore"
|
77
|
+
- ".travis.yml"
|
77
78
|
- Gemfile
|
78
79
|
- LICENSE.txt
|
79
80
|
- README.md
|