json_skooma 0.2.0 → 0.2.1

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: 41c787af86379c5c95a01c3180116d12854d11ca7def23569967d35352998da2
4
- data.tar.gz: 4f3fbca4d35931fe884598c1c827e4434102c25b76973293af31b2af5ce62371
3
+ metadata.gz: 9da78d5df937e93b851e37daf72770aeb62c61a09922232a2dc308533a4c5e36
4
+ data.tar.gz: 13759edb9c18994d8f315f740b37a5e32c4935415c0262292f77f6f52e648a30
5
5
  SHA512:
6
- metadata.gz: bef3119c2f4de1880ebde8036ad6517154b82373c80896b7d3d97ce70cb0d39f5b4c458ca2836d8f23439dcde2965b62a61e02586d7d2dfc12892e1f64fef815
7
- data.tar.gz: 5aadc6b0af540a0d7d5eacae5959f5051a7b932ce9d92bd049bd5348f6d67e1740bba94a9b51be325aace1cdd1c28bf0521a8d325f137f5207afa79b1dd4c0c3
6
+ metadata.gz: b5b8b57d54a71b2c75f85c4f4964757cce15acedbbc49d967ebcea2447a17dfd0acbd36441aafb647f4e744ae91b78e84917ff0a7964b584a157602797210655
7
+ data.tar.gz: 8435cc06b0e079f1980797b0b2cbf3a7d635bb78bcbab8431f7c4408b54e871ee2dd79bd37bf948653f5d9c1f87626618135894e54fef24135e162aca046f7e3
data/CHANGELOG.md CHANGED
@@ -7,6 +7,13 @@ and this project adheres to [Semantic Versioning].
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ## [0.2.1] - 2023-12-03
11
+
12
+ ### Fixed
13
+
14
+ - Make `unevaluated*` keyword respect reference keywords. ([@skryukov])
15
+ - Fix `:basic` output. ([@skryukov])
16
+
10
17
  ## [0.2.0] - 2023-10-23
11
18
 
12
19
  ### Added
@@ -30,7 +37,8 @@ and this project adheres to [Semantic Versioning].
30
37
 
31
38
  [@skryukov]: https://github.com/skryukov
32
39
 
33
- [Unreleased]: https://github.com/skryukov/json_skooma/compare/v0.2.0...HEAD
40
+ [Unreleased]: https://github.com/skryukov/json_skooma/compare/v0.2.1...HEAD
41
+ [0.2.1]: https://github.com/skryukov/json_skooma/compare/v0.2.0...v0.2.1
34
42
  [0.2.0]: https://github.com/skryukov/json_skooma/compare/v0.1.0...v0.2.0
35
43
  [0.1.0]: https://github.com/skryukov/json_skooma/commits/v0.1.0
36
44
 
@@ -1,9 +1,6 @@
1
1
  {
2
2
  "$schema": "https://json-schema.org/draft/2019-09/schema",
3
3
  "$id": "https://json-schema.org/draft/2019-09/meta/applicator",
4
- "$vocabulary": {
5
- "https://json-schema.org/draft/2019-09/vocab/applicator": true
6
- },
7
4
  "$recursiveAnchor": true,
8
5
 
9
6
  "title": "Applicator vocabulary meta-schema",
@@ -1,9 +1,6 @@
1
1
  {
2
2
  "$schema": "https://json-schema.org/draft/2019-09/schema",
3
3
  "$id": "https://json-schema.org/draft/2019-09/meta/content",
4
- "$vocabulary": {
5
- "https://json-schema.org/draft/2019-09/vocab/content": true
6
- },
7
4
  "$recursiveAnchor": true,
8
5
 
9
6
  "title": "Content vocabulary meta-schema",
@@ -1,9 +1,6 @@
1
1
  {
2
2
  "$schema": "https://json-schema.org/draft/2019-09/schema",
3
3
  "$id": "https://json-schema.org/draft/2019-09/meta/core",
4
- "$vocabulary": {
5
- "https://json-schema.org/draft/2019-09/vocab/core": true
6
- },
7
4
  "$recursiveAnchor": true,
8
5
 
9
6
  "title": "Core vocabulary meta-schema",
@@ -1,9 +1,6 @@
1
1
  {
2
2
  "$schema": "https://json-schema.org/draft/2019-09/schema",
3
3
  "$id": "https://json-schema.org/draft/2019-09/meta/format",
4
- "$vocabulary": {
5
- "https://json-schema.org/draft/2019-09/vocab/format": true
6
- },
7
4
  "$recursiveAnchor": true,
8
5
 
9
6
  "title": "Format vocabulary meta-schema",
@@ -1,9 +1,6 @@
1
1
  {
2
2
  "$schema": "https://json-schema.org/draft/2019-09/hyper-schema",
3
3
  "$id": "https://json-schema.org/draft/2019-09/meta/hyper-schema",
4
- "$vocabulary": {
5
- "https://json-schema.org/draft/2019-09/vocab/hyper-schema": true
6
- },
7
4
  "$recursiveAnchor": true,
8
5
 
9
6
  "title": "JSON Hyper-Schema Vocabulary Schema",
@@ -1,9 +1,6 @@
1
1
  {
2
2
  "$schema": "https://json-schema.org/draft/2019-09/schema",
3
3
  "$id": "https://json-schema.org/draft/2019-09/meta/meta-data",
4
- "$vocabulary": {
5
- "https://json-schema.org/draft/2019-09/vocab/meta-data": true
6
- },
7
4
  "$recursiveAnchor": true,
8
5
 
9
6
  "title": "Meta-data vocabulary meta-schema",
@@ -1,9 +1,6 @@
1
1
  {
2
2
  "$schema": "https://json-schema.org/draft/2019-09/schema",
3
3
  "$id": "https://json-schema.org/draft/2019-09/meta/validation",
4
- "$vocabulary": {
5
- "https://json-schema.org/draft/2019-09/vocab/validation": true
6
- },
7
4
  "$recursiveAnchor": true,
8
5
 
9
6
  "title": "Validation vocabulary meta-schema",
@@ -1,9 +1,6 @@
1
1
  {
2
2
  "$schema": "https://json-schema.org/draft/2020-12/schema",
3
3
  "$id": "https://json-schema.org/draft/2020-12/meta/applicator",
4
- "$vocabulary": {
5
- "https://json-schema.org/draft/2020-12/vocab/applicator": true
6
- },
7
4
  "$dynamicAnchor": "meta",
8
5
 
9
6
  "title": "Applicator vocabulary meta-schema",
@@ -1,9 +1,6 @@
1
1
  {
2
2
  "$schema": "https://json-schema.org/draft/2020-12/schema",
3
3
  "$id": "https://json-schema.org/draft/2020-12/meta/content",
4
- "$vocabulary": {
5
- "https://json-schema.org/draft/2020-12/vocab/content": true
6
- },
7
4
  "$dynamicAnchor": "meta",
8
5
 
9
6
  "title": "Content vocabulary meta-schema",
@@ -1,9 +1,6 @@
1
1
  {
2
2
  "$schema": "https://json-schema.org/draft/2020-12/schema",
3
3
  "$id": "https://json-schema.org/draft/2020-12/meta/core",
4
- "$vocabulary": {
5
- "https://json-schema.org/draft/2020-12/vocab/core": true
6
- },
7
4
  "$dynamicAnchor": "meta",
8
5
 
9
6
  "title": "Core vocabulary meta-schema",
@@ -1,9 +1,6 @@
1
1
  {
2
2
  "$schema": "https://json-schema.org/draft/2020-12/schema",
3
3
  "$id": "https://json-schema.org/draft/2020-12/meta/format-annotation",
4
- "$vocabulary": {
5
- "https://json-schema.org/draft/2020-12/vocab/format-annotation": true
6
- },
7
4
  "$dynamicAnchor": "meta",
8
5
 
9
6
  "title": "Format vocabulary meta-schema for annotation results",
@@ -1,9 +1,6 @@
1
1
  {
2
2
  "$schema": "https://json-schema.org/draft/2020-12/schema",
3
3
  "$id": "https://json-schema.org/draft/2020-12/meta/format-assertion",
4
- "$vocabulary": {
5
- "https://json-schema.org/draft/2020-12/vocab/format-assertion": true
6
- },
7
4
  "$dynamicAnchor": "meta",
8
5
 
9
6
  "title": "Format vocabulary meta-schema for assertion results",
@@ -1,9 +1,6 @@
1
1
  {
2
2
  "$schema": "https://json-schema.org/draft/2020-12/hyper-schema",
3
3
  "$id": "https://json-schema.org/draft/2020-12/meta/hyper-schema",
4
- "$vocabulary": {
5
- "https://json-schema.org/draft/2019-09/vocab/hyper-schema": true
6
- },
7
4
  "$dynamicAnchor": "meta",
8
5
 
9
6
  "title": "JSON Hyper-Schema Vocabulary Schema",
@@ -1,9 +1,6 @@
1
1
  {
2
2
  "$schema": "https://json-schema.org/draft/2020-12/schema",
3
3
  "$id": "https://json-schema.org/draft/2020-12/meta/meta-data",
4
- "$vocabulary": {
5
- "https://json-schema.org/draft/2020-12/vocab/meta-data": true
6
- },
7
4
  "$dynamicAnchor": "meta",
8
5
 
9
6
  "title": "Meta-data vocabulary meta-schema",
@@ -1,9 +1,6 @@
1
1
  {
2
2
  "$schema": "https://json-schema.org/draft/2020-12/schema",
3
3
  "$id": "https://json-schema.org/draft/2020-12/meta/unevaluated",
4
- "$vocabulary": {
5
- "https://json-schema.org/draft/2020-12/vocab/unevaluated": true
6
- },
7
4
  "$dynamicAnchor": "meta",
8
5
 
9
6
  "title": "Unevaluated applicator vocabulary meta-schema",
@@ -1,9 +1,6 @@
1
1
  {
2
2
  "$schema": "https://json-schema.org/draft/2020-12/schema",
3
3
  "$id": "https://json-schema.org/draft/2020-12/meta/validation",
4
- "$vocabulary": {
5
- "https://json-schema.org/draft/2020-12/vocab/validation": true
6
- },
7
4
  "$dynamicAnchor": "meta",
8
5
 
9
6
  "title": "Validation vocabulary meta-schema",
@@ -36,11 +36,11 @@ module JSONSkooma
36
36
  Keywords::Draft201909::Items,
37
37
  Keywords::Draft201909::AdditionalItems,
38
38
  Keywords::Draft201909::UnevaluatedItems,
39
+ Keywords::Draft201909::UnevaluatedProperties,
39
40
  Keywords::Applicator::Contains,
40
41
  Keywords::Applicator::Properties,
41
42
  Keywords::Applicator::PatternProperties,
42
43
  Keywords::Applicator::AdditionalProperties,
43
- Keywords::Unevaluated::UnevaluatedProperties,
44
44
  Keywords::Applicator::PropertyNames
45
45
  )
46
46
 
@@ -43,7 +43,7 @@ module JSONSkooma
43
43
  key = valid ? "annotation" : "error"
44
44
  result << node_data(node, key) if node.public_send(key)
45
45
 
46
- node.children.each_children do |child|
46
+ node.each_children do |child|
47
47
  collect_nodes(child, valid, result)
48
48
  end
49
49
 
@@ -10,6 +10,7 @@ module JSONSkooma
10
10
  self.depends_on = %w[
11
11
  items additionalItems
12
12
  if then else allOf anyOf oneOf not
13
+ $ref $dynamicRef $recursiveRef
13
14
  ]
14
15
 
15
16
  LOOKUP_KEYWORDS = %w[items additionalItems unevaluatedItems].freeze
@@ -0,0 +1,45 @@
1
+ # frozen_string_literal: true
2
+
3
+ module JSONSkooma
4
+ module Keywords
5
+ module Draft201909
6
+ class UnevaluatedProperties < Base
7
+ self.key = "unevaluatedProperties"
8
+ self.instance_types = %w[object]
9
+ self.value_schema = :schema
10
+ self.depends_on = %w[
11
+ properties patternProperties additionalProperties
12
+ if then else dependentSchemas allOf anyOf oneOf not
13
+ $ref $dynamicRef $recursiveRef
14
+ ]
15
+
16
+ LOOKUP_KEYWORDS = %w[properties patternProperties additionalProperties unevaluatedProperties].freeze
17
+
18
+ def evaluate(instance, result)
19
+ evaluated_names = Set.new
20
+ result.parent.collect_annotations(instance, keys: LOOKUP_KEYWORDS) do |node|
21
+ evaluated_names += node.annotation
22
+ end
23
+
24
+ annotation = []
25
+ error = []
26
+ instance.each do |name, item|
27
+ next if evaluated_names.include?(name)
28
+
29
+ if json.evaluate(item, result).passed?
30
+ annotation << name
31
+ else
32
+ error << name
33
+ # reset to success for the next iteration
34
+ result.success
35
+ end
36
+ end
37
+
38
+ return result.failure(error) if error.any?
39
+
40
+ result.annotate(annotation)
41
+ end
42
+ end
43
+ end
44
+ end
45
+ end
@@ -10,6 +10,7 @@ module JSONSkooma
10
10
  self.depends_on = %w[
11
11
  prefixItems items contains
12
12
  if then else allOf anyOf oneOf not
13
+ $ref $dynamicRef
13
14
  ]
14
15
 
15
16
  LOOKUP_KEYWORDS = %w[items unevaluatedItems prefixItems contains].freeze
@@ -10,6 +10,7 @@ module JSONSkooma
10
10
  self.depends_on = %w[
11
11
  properties patternProperties additionalProperties
12
12
  if then else dependentSchemas allOf anyOf oneOf not
13
+ $ref $dynamicRef
13
14
  ]
14
15
 
15
16
  LOOKUP_KEYWORDS = %w[properties patternProperties additionalProperties unevaluatedProperties].freeze
@@ -6,7 +6,8 @@ module JSONSkooma
6
6
  module Validators
7
7
  class IdnHostname < Base
8
8
  def call(data)
9
- URI::IDNA.register(ulabel: data.value)
9
+ register_opts = data.value.ascii_only? ? {alabel: data.value} : {ulabel: data.value}
10
+ URI::IDNA.register(**register_opts)
10
11
  rescue URI::IDNA::Error => e
11
12
  raise FormatError, "#{data} is not a valid IDN hostname: #{e.message}"
12
13
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module JSONSkooma
4
- VERSION = "0.2.0"
4
+ VERSION = "0.2.1"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: json_skooma
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Svyatoslav Kryukov
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-10-22 00:00:00.000000000 Z
11
+ date: 2023-12-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: zeitwerk
@@ -58,14 +58,14 @@ dependencies:
58
58
  requirements:
59
59
  - - "~>"
60
60
  - !ruby/object:Gem::Version
61
- version: '0.1'
61
+ version: '0.2'
62
62
  type: :runtime
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
66
  - - "~>"
67
67
  - !ruby/object:Gem::Version
68
- version: '0.1'
68
+ version: '0.2'
69
69
  description: I bring some sugar for your JSONs.
70
70
  email:
71
71
  - me@skryukov.dev
@@ -152,6 +152,7 @@ files:
152
152
  - lib/json_skooma/keywords/draft_2019_09/recursive_anchor.rb
153
153
  - lib/json_skooma/keywords/draft_2019_09/recursive_ref.rb
154
154
  - lib/json_skooma/keywords/draft_2019_09/unevaluated_items.rb
155
+ - lib/json_skooma/keywords/draft_2019_09/unevaluated_properties.rb
155
156
  - lib/json_skooma/keywords/format_annotation/format.rb
156
157
  - lib/json_skooma/keywords/meta_data/default.rb
157
158
  - lib/json_skooma/keywords/meta_data/deprecated.rb