active_model_serializers_validator 0.1.3 → 0.1.4

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # ActiveModel::Serializer::Validator
2
2
 
3
- This gem adds JSON schema validations for output generated by an `ActiveModel::Serializer`.
3
+ This gem adds JSON schema validations for the JSON output generated by an `ActiveModel::Serializer`.
4
4
 
5
5
  ## Installation
6
6
 
@@ -12,16 +12,37 @@ gem 'active_model_serializers_validator'
12
12
 
13
13
  ## Usage
14
14
 
15
- The gem adds one instance method and one class method to the `ActiveModel::Serializer` class, `#valid?` and `.json_schema`:
15
+ The gem adds two instance methods (`#valid?` and `#errors`) and one class method (`.json_schema`) to the `ActiveModel::Serializer` class.
16
+
17
+ ### A JSON schema
18
+
19
+ ```json
20
+ {
21
+ "type": "object",
22
+ "$schema": "http://json-schema.org/draft-03/schema",
23
+ "id": "#",
24
+ "required": false,
25
+ "additionalProperties": false,
26
+ "properties": {
27
+ "favorite_number": {
28
+ "type": "integer",
29
+ "id": "favorite_number",
30
+ "required": true
31
+ },
32
+ }
33
+ }
34
+ ```
35
+
36
+ ### A serializer
16
37
 
17
38
  ```ruby
18
39
  class MySerializer < ActiveModel::Serializer
19
40
  json_schema '/path/to/my/schema.jsonschema'
20
-
21
- attribute :foo
41
+ attribute :favorite_number
22
42
  end
23
43
 
24
- serializer = MySerializer.new(OpenStruct.new(foo: 'bla'))
44
+ object = OpenStruct.new(favorite_number: 'what?')
45
+ serializer = MySerializer.new(object)
25
46
 
26
47
  serializer.valid?
27
48
  # => false
@@ -30,10 +51,6 @@ serializer.errors
30
51
  # => [The property '#/foo' of type String did not match the following type: integer in schema /path/to/my/schema.jsonschema]
31
52
  ```
32
53
 
33
- ## Todo
34
-
35
- * Add more features! :smile:
36
-
37
54
  ## License
38
55
 
39
56
  `ActiveModel::Serializer::Validator` is © 2013 [Mirego](http://www.mirego.com) and may be freely distributed under the [New BSD license](http://opensource.org/licenses/BSD-3-Clause). See the [`LICENSE.md`](https://github.com/mirego/active_model_serializers_validator/blob/master/LICENSE.md) file.
@@ -11,7 +11,7 @@ Gem::Specification.new do |spec|
11
11
  spec.description = 'An extension to ActiveModel::Serializer that validates serializers output against a JSON schema'
12
12
  spec.summary = 'An extension to ActiveModel::Serializer that validates serializers output against a JSON schema'
13
13
  spec.homepage = 'https://github.com/mirego/active_model_serializers_validator'
14
- spec.license = 'New BSD'
14
+ spec.license = 'BSD 3-Clause'
15
15
 
16
16
  spec.files = `git ls-files`.split($/)
17
17
  spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
@@ -1,7 +1,7 @@
1
1
  module ActiveModel
2
2
  class Serializer
3
3
  module Validator
4
- VERSION = '0.1.3'
4
+ VERSION = '0.1.4'
5
5
  end
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: active_model_serializers_validator
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.4
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-06-22 00:00:00.000000000 Z
12
+ date: 2013-07-09 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler
@@ -148,7 +148,7 @@ files:
148
148
  - spec/validator_spec.rb
149
149
  homepage: https://github.com/mirego/active_model_serializers_validator
150
150
  licenses:
151
- - New BSD
151
+ - BSD 3-Clause
152
152
  post_install_message:
153
153
  rdoc_options: []
154
154
  require_paths:
@@ -161,7 +161,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
161
161
  version: '0'
162
162
  segments:
163
163
  - 0
164
- hash: 199562626635737587
164
+ hash: 1033799192214177102
165
165
  required_rubygems_version: !ruby/object:Gem::Requirement
166
166
  none: false
167
167
  requirements:
@@ -170,7 +170,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
170
170
  version: '0'
171
171
  segments:
172
172
  - 0
173
- hash: 199562626635737587
173
+ hash: 1033799192214177102
174
174
  requirements: []
175
175
  rubyforge_project:
176
176
  rubygems_version: 1.8.23