json_schema 0.1.9 → 0.2.0
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/lib/commands/validate_schema.rb +0 -1
- data/lib/json_schema/parser.rb +1 -0
- data/lib/json_schema/schema.rb +5 -8
- data/lib/json_schema/schema_error.rb +1 -2
- data/test/json_schema/parser_test.rb +2 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c09e98d77f8312b241a686e9754c64868f3168cd
|
4
|
+
data.tar.gz: 37c8aa03c7b3c20f1297521e1ad028450ef1dbe9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c4eaccae952cb463de80492d3e5903e0f597dfed795ccdd2929c253ba4efd27a4b97b07527f6eef6b9f4ba3a0c943ab6c305ada987586f4d52c9a47d8adfb9b4
|
7
|
+
data.tar.gz: c126e71608055b4747d7556548a268021ba388fbccf77893408e5b6e166d9c9d53ca25a1e4da4a78416a4893f6797bf81a56c73795097302a776528679cae2ca
|
data/lib/json_schema/parser.rb
CHANGED
@@ -175,6 +175,7 @@ module JsonSchema
|
|
175
175
|
link.method = l["method"] ? l["method"].downcase.to_sym : nil
|
176
176
|
link.rel = l["rel"]
|
177
177
|
link.title = l["title"]
|
178
|
+
link.media_type = l["mediaType"]
|
178
179
|
|
179
180
|
if l["schema"]
|
180
181
|
link.schema = parse_data(l["schema"], schema, "links/#{i}/schema")
|
data/lib/json_schema/schema.rb
CHANGED
@@ -261,14 +261,6 @@ module JsonSchema
|
|
261
261
|
!clones.include?(self)
|
262
262
|
end
|
263
263
|
|
264
|
-
def depth
|
265
|
-
if parent
|
266
|
-
parent.depth + 1
|
267
|
-
else
|
268
|
-
0
|
269
|
-
end
|
270
|
-
end
|
271
|
-
|
272
264
|
def pointer
|
273
265
|
if parent
|
274
266
|
parent.pointer + "/" + fragment
|
@@ -297,6 +289,7 @@ module JsonSchema
|
|
297
289
|
attr_accessor :href
|
298
290
|
attr_accessor :method
|
299
291
|
attr_accessor :rel
|
292
|
+
attr_accessor :media_type
|
300
293
|
attr_accessor :schema
|
301
294
|
attr_accessor :target_schema
|
302
295
|
attr_accessor :title
|
@@ -304,6 +297,10 @@ module JsonSchema
|
|
304
297
|
def enc_type
|
305
298
|
@enc_type || "application/json"
|
306
299
|
end
|
300
|
+
|
301
|
+
def media_type
|
302
|
+
@media_type || "application/json"
|
303
|
+
end
|
307
304
|
end
|
308
305
|
|
309
306
|
# Media type subobject for a hyperschema.
|
@@ -160,6 +160,7 @@ describe JsonSchema::Parser do
|
|
160
160
|
"href" => "/apps",
|
161
161
|
"method" => "POST",
|
162
162
|
"rel" => "create",
|
163
|
+
"mediaType" => "application/json",
|
163
164
|
"schema" => {
|
164
165
|
"properties" => {
|
165
166
|
"name" => {
|
@@ -180,6 +181,7 @@ describe JsonSchema::Parser do
|
|
180
181
|
assert_equal "/apps", link.href
|
181
182
|
assert_equal :post, link.method
|
182
183
|
assert_equal "create", link.rel
|
184
|
+
assert_equal "application/json", link.media_type
|
183
185
|
assert_equal "#/definitions/app/definitions/name",
|
184
186
|
link.schema.properties["name"].reference.pointer
|
185
187
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: json_schema
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Brandur
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-08-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: minitest
|