json_schema_tools 0.3.3 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/CHANGELOG.md +5 -1
- data/README.md +7 -7
- data/lib/schema_tools/modules/as_schema.rb +0 -1
- data/lib/schema_tools/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
MzY3ZTE3OTFiYzg5OTY5MDQ4ZmRjNTE2MjIzNmE3ZjA5MDg0MTA3YQ==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
MGQ4NjQ2MmQ3NWY0NGI1MWM3MjFjMjY0YjQxMWM1ODc1YmNiZGY2OQ==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
NjMwMGI3ZTY4YzdiZDFmMzA2NzQ2MWRjZjIzN2E4NDNjMzM1ODljZGFhNDM4
|
10
|
+
NjU0MjM2YjM0NWE3NTg0MmQ5MWI2OGI1OGFhMDNjMjA2ODQ4M2I5NjIzYWZj
|
11
|
+
MTUyY2Y5N2ZkOWUzZTZlNzY5MGI2MGZjNzI0YTY1YWVmNTAwMWY=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
ZDE5YTA5NmE1NWQwNWNmOWRkN2FjNmJhODI3MGFhMWZkNDY2NzhjYzliM2E3
|
14
|
+
MmVhY2FlMDg0NTczYzgzZjE2OTlmNmZjMWU3NDExYzU5M2RmMzBlY2ZlYjY4
|
15
|
+
ZjQyYzk0NmM0ZmM5N2M5Y2Y1ZDI2MDFjY2M4NzM4YWM0MWQwZWQ=
|
data/CHANGELOG.md
CHANGED
@@ -1,9 +1,12 @@
|
|
1
1
|
# Changelog JSON Schema Tools
|
2
2
|
|
3
|
+
2014-11
|
4
|
+
|
5
|
+
* remove as_json method(alias of as_schema_json) conflicting with active_resource/active_record. Nothing stops one from using/aliasing it in his own code.
|
3
6
|
|
4
7
|
2014-10
|
5
8
|
|
6
|
-
* handle circular dependencies in $ref arguments, so schema.to_h always resolves $refs properly
|
9
|
+
* handle circular dependencies in $ref arguments, so schema.to_h always resolves $refs properly
|
7
10
|
|
8
11
|
2014-09
|
9
12
|
|
@@ -22,6 +25,7 @@
|
|
22
25
|
* add $ref resolver to merge property definitions from another file
|
23
26
|
|
24
27
|
2013-10
|
28
|
+
|
25
29
|
* allow all object properties in link href placeholders => contacts/{id}/{number}
|
26
30
|
* add base_url option to schema hash creation. Prepends an url to all links of a rendered object
|
27
31
|
* add to_schema_json for simpler model to json conversion
|
data/README.md
CHANGED
@@ -5,7 +5,7 @@
|
|
5
5
|
Toolbox to work with JSON Schema in Ruby:
|
6
6
|
|
7
7
|
* blow up classes from schema
|
8
|
-
* object.
|
8
|
+
* object.as_schema_json conversion
|
9
9
|
* object.valid? validations with object.errors
|
10
10
|
|
11
11
|
Simply use full blown classes or customize the bits and pieces:
|
@@ -123,7 +123,7 @@ class Client < ActiveRecord::Base
|
|
123
123
|
end
|
124
124
|
|
125
125
|
peter = Client.new name: 'Peter'
|
126
|
-
peter.
|
126
|
+
peter.as_schema_json
|
127
127
|
#=> "client":{"id":12, "name": "Peter", "email":"",..}
|
128
128
|
|
129
129
|
peter.as_hash
|
@@ -147,7 +147,7 @@ course they can be combined.
|
|
147
147
|
Only use some fields e.g. to save bandwidth
|
148
148
|
|
149
149
|
```ruby
|
150
|
-
peter.
|
150
|
+
peter.as_schema_json(fields:['id', 'name'])
|
151
151
|
#=> "client":{"id":12, "name": "Peter"}
|
152
152
|
```
|
153
153
|
|
@@ -155,13 +155,13 @@ Use a custom schema name e.g. to represent a client as contact. Assumes you also
|
|
155
155
|
have a schema named contact.json
|
156
156
|
|
157
157
|
```ruby
|
158
|
-
peter.
|
158
|
+
peter.as_schema_json(class_name: 'contact')
|
159
159
|
```
|
160
160
|
|
161
161
|
Set a custom schema path
|
162
162
|
|
163
163
|
```ruby
|
164
|
-
peter.
|
164
|
+
peter.as_schema_json( path: 'path-to/json-files/')
|
165
165
|
```
|
166
166
|
|
167
167
|
By default the object hash has the class name (client) and the link-section on
|
@@ -173,7 +173,7 @@ inline:
|
|
173
173
|
|
174
174
|
```ruby
|
175
175
|
|
176
|
-
peter.
|
176
|
+
peter.as_schema_json( exclude_root: true )
|
177
177
|
|
178
178
|
#=> {"id":12, "name"=> "Peter",
|
179
179
|
# "_class_name":"client",
|
@@ -218,7 +218,7 @@ contact.last_name = 'Rambo'
|
|
218
218
|
# raw access
|
219
219
|
contact.schema_attrs
|
220
220
|
# to json
|
221
|
-
contact.
|
221
|
+
contact.as_schema_json
|
222
222
|
```
|
223
223
|
|
224
224
|
## Classes from Schema - KlassFactory
|
data/lib/schema_tools/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: json_schema_tools
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Georg Leciejewski
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-11-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: json
|