json_skooma 0.2.0 → 0.2.2

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.
Files changed (32) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +16 -1
  3. data/data/draft-2019-09/README.md +1 -1
  4. data/data/draft-2019-09/meta/applicator.json +0 -3
  5. data/data/draft-2019-09/meta/content.json +0 -3
  6. data/data/draft-2019-09/meta/core.json +0 -3
  7. data/data/draft-2019-09/meta/format.json +0 -3
  8. data/data/draft-2019-09/meta/hyper-schema.json +0 -3
  9. data/data/draft-2019-09/meta/meta-data.json +0 -3
  10. data/data/draft-2019-09/meta/validation.json +0 -3
  11. data/data/draft-2020-12/README.md +1 -1
  12. data/data/draft-2020-12/meta/applicator.json +0 -3
  13. data/data/draft-2020-12/meta/content.json +0 -3
  14. data/data/draft-2020-12/meta/core.json +0 -3
  15. data/data/draft-2020-12/meta/format-annotation.json +0 -3
  16. data/data/draft-2020-12/meta/format-assertion.json +0 -3
  17. data/data/draft-2020-12/meta/hyper-schema.json +0 -3
  18. data/data/draft-2020-12/meta/meta-data.json +0 -3
  19. data/data/draft-2020-12/meta/unevaluated.json +0 -3
  20. data/data/draft-2020-12/meta/validation.json +0 -3
  21. data/lib/json_skooma/dialects/draft201909.rb +1 -1
  22. data/lib/json_skooma/formatters.rb +1 -1
  23. data/lib/json_skooma/json_pointer.rb +1 -1
  24. data/lib/json_skooma/keywords/core/dynamic_ref.rb +1 -1
  25. data/lib/json_skooma/keywords/draft_2019_09/unevaluated_items.rb +1 -0
  26. data/lib/json_skooma/keywords/draft_2019_09/unevaluated_properties.rb +45 -0
  27. data/lib/json_skooma/keywords/unevaluated/unevaluated_items.rb +1 -0
  28. data/lib/json_skooma/keywords/unevaluated/unevaluated_properties.rb +1 -0
  29. data/lib/json_skooma/validators/idn_hostname.rb +2 -1
  30. data/lib/json_skooma/validators/time.rb +1 -1
  31. data/lib/json_skooma/version.rb +1 -1
  32. metadata +5 -4
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 41c787af86379c5c95a01c3180116d12854d11ca7def23569967d35352998da2
4
- data.tar.gz: 4f3fbca4d35931fe884598c1c827e4434102c25b76973293af31b2af5ce62371
3
+ metadata.gz: dce896a1a7c67eef175462387309d5635c989b6dc73feefe0b9e298008f3fe00
4
+ data.tar.gz: f072c2ff39c2231a7505aebc78d1825f6d1da203062c9611f5ada1dea4dc76ac
5
5
  SHA512:
6
- metadata.gz: bef3119c2f4de1880ebde8036ad6517154b82373c80896b7d3d97ce70cb0d39f5b4c458ca2836d8f23439dcde2965b62a61e02586d7d2dfc12892e1f64fef815
7
- data.tar.gz: 5aadc6b0af540a0d7d5eacae5959f5051a7b932ce9d92bd049bd5348f6d67e1740bba94a9b51be325aace1cdd1c28bf0521a8d325f137f5207afa79b1dd4c0c3
6
+ metadata.gz: fa5e600b9a45004f9fd4fd980a2290e7fc0d4e1920e81a843b2888f26f860bfb2b4cdce2ae953f4e319ab42c6dd89eddddaf17184dd56a37e4d50f4b2dde0d8e
7
+ data.tar.gz: d9dde950d0fc71f0e0f5a9a8d4876ffe042cc96fc0fc801eb45f185d740de8505a551b98ddad65af60bad0421929e4f04c369a6ac88cb5bf97a93fd6ecf836cf
data/CHANGELOG.md CHANGED
@@ -7,6 +7,19 @@ and this project adheres to [Semantic Versioning].
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ## [0.2.2] - 2023-04-09
11
+
12
+ ### Fixed
13
+
14
+ - Fix `$dynamicAnchor` boolean evaluation. ([@skryukov])
15
+
16
+ ## [0.2.1] - 2023-12-03
17
+
18
+ ### Fixed
19
+
20
+ - Make `unevaluated*` keyword respect reference keywords. ([@skryukov])
21
+ - Fix `:basic` output. ([@skryukov])
22
+
10
23
  ## [0.2.0] - 2023-10-23
11
24
 
12
25
  ### Added
@@ -30,7 +43,9 @@ and this project adheres to [Semantic Versioning].
30
43
 
31
44
  [@skryukov]: https://github.com/skryukov
32
45
 
33
- [Unreleased]: https://github.com/skryukov/json_skooma/compare/v0.2.0...HEAD
46
+ [Unreleased]: https://github.com/skryukov/json_skooma/compare/v0.2.2...HEAD
47
+ [0.2.2]: https://github.com/skryukov/json_skooma/compare/v0.2.1...v0.2.2
48
+ [0.2.1]: https://github.com/skryukov/json_skooma/compare/v0.2.0...v0.2.1
34
49
  [0.2.0]: https://github.com/skryukov/json_skooma/compare/v0.1.0...v0.2.0
35
50
  [0.1.0]: https://github.com/skryukov/json_skooma/commits/v0.1.0
36
51
 
@@ -53,7 +53,7 @@ Conformance tests for JSON Schema and its vocabularies may be found
53
53
 
54
54
  The JSON Schema web site is at http://json-schema.org/
55
55
 
56
- The source for the website is [maintained in a separate repository](https://github.com/json-schema-org/json-schema-org.github.io).
56
+ The source for the website is [maintained in a separate repository](https://github.com/json-schema-org/website).
57
57
 
58
58
  ## License
59
59
 
@@ -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",
@@ -53,7 +53,7 @@ Conformance tests for JSON Schema and its vocabularies may be found
53
53
 
54
54
  The JSON Schema web site is at http://json-schema.org/
55
55
 
56
- The source for the website is [maintained in a separate repository](https://github.com/json-schema-org/json-schema-org.github.io).
56
+ The source for the website is [maintained in a separate repository](https://github.com/json-schema-org/website).
57
57
 
58
58
  ## Contributors
59
59
 
@@ -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
 
@@ -25,7 +25,7 @@ module JSONSkooma
25
25
  if path.is_a?(Array)
26
26
  @path = path
27
27
  else
28
- super CGI.unescape(path)
28
+ super(CGI.unescape(path))
29
29
  end
30
30
  end
31
31
 
@@ -27,7 +27,7 @@ module JSONSkooma
27
27
  metaschema_uri: parent_schema.metaschema_uri,
28
28
  cache_id: parent_schema.cache_id
29
29
  )
30
- dynamic_anchor = @ref_schema["$dynamicAnchor"]
30
+ dynamic_anchor = @ref_schema["$dynamicAnchor"] if @ref_schema.type == "object"
31
31
  @dynamic = dynamic_anchor == @fragment
32
32
  end
33
33
 
@@ -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
@@ -22,7 +22,7 @@ module JSONSkooma
22
22
  if match[:on]
23
23
  sign = (match[:on] == "+") ? -1 : 1
24
24
  time += sign * (match[:oh].to_i * 60 + match[:om].to_i)
25
- time = time % (60 * 24)
25
+ time %= (60 * 24)
26
26
  end
27
27
  leap_time = 23 * 60 + 59
28
28
  time == leap_time
@@ -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.2"
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.2
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: 2024-04-09 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