kwalify_to_json_schema 0.5.1 → 0.6.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/kwalify_to_json_schema/converter.rb +18 -7
- data/lib/kwalify_to_json_schema/limitations.rb +2 -2
- metadata +3 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2bbbe823e0df66f54b21956a628b2a08dad03190f4d2884ee05abe1c6362fba8
|
4
|
+
data.tar.gz: ef883dfea6e9cebcee6c0bd95d7470db46d428734dac428cd52f65230af7666a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 237ff9995ed857260b71851e3499640af68deafcbb65c8103d6e7227ce1a0c774b06d8b3d4cab7ed1f0f54bf74e4122e6dcfe543515db2dc70a2dc971e10e8a0
|
7
|
+
data.tar.gz: d30502c9942dd6039c074b3c227b3829fa8624dca103541572487659eda84386ba91f7583742183dbe1f1d8ca6e79f74b8aadfc461e65a1aac07ac576742b0e2
|
@@ -85,13 +85,18 @@ module KwalifyToJsonSchema
|
|
85
85
|
if mapping.is_a? Hash
|
86
86
|
properties = target["properties"] = {}
|
87
87
|
mapping.each_pair { |name, e|
|
88
|
-
#
|
88
|
+
# Handle partial support of mapping default value
|
89
|
+
# Only default rule is supported (see http://www.kuwata-lab.com/kwalify/ruby/users-guide.02.html#tips-default)
|
89
90
|
if name == "="
|
90
|
-
|
91
|
-
|
91
|
+
if e.is_a?(Hash)
|
92
|
+
process(target["additionalProperties"] = {}, e, path)
|
93
|
+
else
|
94
|
+
new_issue path, Limitations::ONLY_DEFAULT_RULE_SUPPORTED_FOR_DEFAULT_MAPPING
|
95
|
+
end
|
96
|
+
else
|
97
|
+
process(properties[name] = {}, e, path + [name])
|
98
|
+
required << name if e["required"] == true
|
92
99
|
end
|
93
|
-
process(properties[name] = {}, e, path + [name])
|
94
|
-
required << name if e["required"] == true
|
95
100
|
}
|
96
101
|
target["required"] = required unless required.empty?
|
97
102
|
end
|
@@ -99,7 +104,13 @@ module KwalifyToJsonSchema
|
|
99
104
|
target["type"] = "array"
|
100
105
|
sequence = kelem["sequence"]
|
101
106
|
if sequence.is_a? Array
|
102
|
-
|
107
|
+
rule = sequence.first
|
108
|
+
if rule["unique"]
|
109
|
+
target["uniqueItems"] = true
|
110
|
+
rule = rule.dup
|
111
|
+
rule.delete("unique")
|
112
|
+
end
|
113
|
+
process(target["items"] = {}, rule)
|
103
114
|
end
|
104
115
|
when "str"
|
105
116
|
target["type"] = "string"
|
@@ -166,7 +177,7 @@ module KwalifyToJsonSchema
|
|
166
177
|
end
|
167
178
|
end
|
168
179
|
|
169
|
-
new_issue path, Limitations::
|
180
|
+
new_issue path, Limitations::UNIQUE_NOT_SUPPORTED_WITHIN_MAPPING if kelem["unique"]
|
170
181
|
|
171
182
|
target
|
172
183
|
end
|
@@ -4,7 +4,7 @@ module KwalifyToJsonSchema
|
|
4
4
|
DATE_TYPE_NOT_IMPLEMENTED = "Kwalify 'date' type is not supported and is ignored"
|
5
5
|
TIME_TYPE_NOT_IMPLEMENTED = "Kwalify 'time' type is not supported and is ignored"
|
6
6
|
TIMESTAMP_TYPE_NOT_IMPLEMENTED = "Kwalify 'timestamp' type is not supported and is ignored"
|
7
|
-
|
8
|
-
|
7
|
+
UNIQUE_NOT_SUPPORTED_WITHIN_MAPPING = "Kwalify 'unique' within a mapping is not supported by JSON Schema and is ignored"
|
8
|
+
ONLY_DEFAULT_RULE_SUPPORTED_FOR_DEFAULT_MAPPING = "Kwalify mapping default value is not supported by JSON Schema and is ignored. Only default rule is supported"
|
9
9
|
end
|
10
10
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: kwalify_to_json_schema
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.6.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sylvain Gamot
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-04-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: thor
|
@@ -119,8 +119,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
119
119
|
- !ruby/object:Gem::Version
|
120
120
|
version: '0'
|
121
121
|
requirements: []
|
122
|
-
|
123
|
-
rubygems_version: 2.7.6
|
122
|
+
rubygems_version: 3.1.2
|
124
123
|
signing_key:
|
125
124
|
specification_version: 4
|
126
125
|
summary: Kwalify schemas to JSON schemas conversion
|