kwalify_to_json_schema 0.5.1 → 0.6.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b6c69311e6acfcc28fea0bcfaeb66c5378f87a6021bf51e275c55946bf6fe2f4
4
- data.tar.gz: 1424cced2ddf03ee281266745b9bc5b52a230ac2f99ba58b1cc772eb611ca100
3
+ metadata.gz: 2bbbe823e0df66f54b21956a628b2a08dad03190f4d2884ee05abe1c6362fba8
4
+ data.tar.gz: ef883dfea6e9cebcee6c0bd95d7470db46d428734dac428cd52f65230af7666a
5
5
  SHA512:
6
- metadata.gz: 4e517fcf1bef41d0ff88c5d1dab70c7c4322791675cf905598f06aab6320358f9375691f3123584cd9c327f7c8a023e1eaf89f3768f01b68bb801edfeefa7b87
7
- data.tar.gz: 40efd0e3eb515e9f441cc4a6a0d09bdfca4b2cd993a2a597942f921e27fc463ba72a1294788a1399370c558e66717b9a18f1856ea41b3e8908a88396f9ce806b
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
- # Ignore mapping default value
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
- new_issue path, Limitations::MAPPING_DEFAULT_VALUE_NOT_SUPPORTED
91
- next
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
- process(target["items"] = {}, sequence.first)
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::UNIQUE_NOT_SUPPORTED if kelem["unique"]
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
- UNIQUE_NOT_SUPPORTED = "Kwalify 'unique' is not supported by JSON Schema and is ignored"
8
- MAPPING_DEFAULT_VALUE_NOT_SUPPORTED = "Kwalify mapping default value is not supported by JSON Schema and is ignored"
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.5.1
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: 2020-07-23 00:00:00.000000000 Z
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
- rubyforge_project:
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