json_world 0.1.4 → 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/CHANGELOG.md +3 -0
- data/lib/json_world/property_definition.rb +25 -12
- data/lib/json_world/version.rb +1 -1
- 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: a5aef48228e4c1d49717c2f834412ea45ddc98ae
|
4
|
+
data.tar.gz: c1ce06838c98f6a6b18c4dbf834619879b44eb7f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3db2e0a659ba8b9c559e8862eab6a88f76de7a87f49961743b9b19d54b7eef854d15a52acaae6c5da9220345f1a2d0cc7855fcf8c34744d948ab7c76d3a3bdea
|
7
|
+
data.tar.gz: 70522ff96af036d7ab5b20c6e830173e3e4ca68613ce70bce2d5ef7532148738401a184a72f2fce98daecb18d6595c2f425fb344115dd85c5f589b7515505ed2
|
data/CHANGELOG.md
CHANGED
@@ -14,18 +14,26 @@ module JsonWorld
|
|
14
14
|
|
15
15
|
# @return [Hash{Symbol => Object}]
|
16
16
|
def as_json_schema
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
17
|
+
if has_json_schema_compatible_type?
|
18
|
+
if @options[:links]
|
19
|
+
@options[:type].as_json_schema
|
20
|
+
else
|
21
|
+
@options[:type].as_json_schema_without_links
|
22
|
+
end
|
23
|
+
else
|
24
|
+
{
|
25
|
+
description: description,
|
26
|
+
example: example,
|
27
|
+
format: format_type,
|
28
|
+
items: items_as_json_schema,
|
29
|
+
pattern: pattern_in_string,
|
30
|
+
properties: properties_as_json_schema,
|
31
|
+
required: required_property_names,
|
32
|
+
type: type,
|
33
|
+
uniqueItems: unique_flag,
|
34
|
+
}.reject do |_key, value|
|
35
|
+
value.nil? || value.respond_to?(:empty?) && value.empty?
|
36
|
+
end
|
29
37
|
end
|
30
38
|
end
|
31
39
|
|
@@ -59,6 +67,11 @@ module JsonWorld
|
|
59
67
|
end
|
60
68
|
end
|
61
69
|
|
70
|
+
# @return [false, true]
|
71
|
+
def has_json_schema_compatible_type?
|
72
|
+
@options[:type].respond_to?(:as_json_schema)
|
73
|
+
end
|
74
|
+
|
62
75
|
# @note Tuple validation is not supported yet
|
63
76
|
# @return [Array<Hash>, nil]
|
64
77
|
def items_as_json_schema
|
data/lib/json_world/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: json_world
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ryo Nakamura
|
@@ -122,7 +122,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
122
122
|
version: '0'
|
123
123
|
requirements: []
|
124
124
|
rubyforge_project:
|
125
|
-
rubygems_version: 2.
|
125
|
+
rubygems_version: 2.4.5
|
126
126
|
signing_key:
|
127
127
|
specification_version: 4
|
128
128
|
summary: Provides DSL to define JSON Schema representation of your class.
|