json_skooma 0.2.2 → 0.2.3

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: dce896a1a7c67eef175462387309d5635c989b6dc73feefe0b9e298008f3fe00
4
- data.tar.gz: f072c2ff39c2231a7505aebc78d1825f6d1da203062c9611f5ada1dea4dc76ac
3
+ metadata.gz: b477f1320adcfae0e544129fd0c7cf7423221582a4914df84e2b685bbc3d3407
4
+ data.tar.gz: 33be1f69264fa10de07b4391850945343996832b3f0b534fbc4ea34f125dee28
5
5
  SHA512:
6
- metadata.gz: fa5e600b9a45004f9fd4fd980a2290e7fc0d4e1920e81a843b2888f26f860bfb2b4cdce2ae953f4e319ab42c6dd89eddddaf17184dd56a37e4d50f4b2dde0d8e
7
- data.tar.gz: d9dde950d0fc71f0e0f5a9a8d4876ffe042cc96fc0fc801eb45f185d740de8505a551b98ddad65af60bad0421929e4f04c369a6ac88cb5bf97a93fd6ecf836cf
6
+ metadata.gz: 4fd6ad6cf954c7b5cd9886691280e334b49332a51b74beba483a2041e00c36ce0b9662a52cdc1ba8ee310fc979117ee3a08f8df05f1f6291c5e501215149dd2a
7
+ data.tar.gz: 5d428bce4e4e1979cf908d4efc9cdf397d60449fde95742df5df7d18084ced68cacc9169d6e4ee1517a152bb990ebce9a38f48221968cfa1633dc14503b3b31a
data/CHANGELOG.md CHANGED
@@ -7,7 +7,13 @@ and this project adheres to [Semantic Versioning].
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
- ## [0.2.2] - 2023-04-09
10
+ ## [0.2.3] - 2024-04-28
11
+
12
+ ### Fixed
13
+
14
+ - Fix `JSONSkooma::Sources::Remote` to allow remote refs. ([@killondark])
15
+
16
+ ## [0.2.2] - 2024-04-09
11
17
 
12
18
  ### Fixed
13
19
 
@@ -42,8 +48,10 @@ and this project adheres to [Semantic Versioning].
42
48
  - Initial implementation. ([@skryukov])
43
49
 
44
50
  [@skryukov]: https://github.com/skryukov
51
+ [@killondark]: https://github.com/killondark
45
52
 
46
- [Unreleased]: https://github.com/skryukov/json_skooma/compare/v0.2.2...HEAD
53
+ [Unreleased]: https://github.com/skryukov/json_skooma/compare/v0.2.3...HEAD
54
+ [0.2.3]: https://github.com/skryukov/json_skooma/compare/v0.2.2...v0.2.3
47
55
  [0.2.2]: https://github.com/skryukov/json_skooma/compare/v0.2.1...v0.2.2
48
56
  [0.2.1]: https://github.com/skryukov/json_skooma/compare/v0.2.0...v0.2.1
49
57
  [0.2.0]: https://github.com/skryukov/json_skooma/compare/v0.1.0...v0.2.0
data/README.md CHANGED
@@ -14,7 +14,7 @@ JSONSkooma is a Ruby library for validating JSONs against JSON Schemas.
14
14
  - Supports custom schema resolvers
15
15
 
16
16
  <a href="https://evilmartians.com/?utm_source=json_skooma&utm_campaign=project_page">
17
- <img src="https://evilmartians.com/badges/sponsored-by-evil-martians.svg" alt="Sponsored by Evil Martians" width="236" height="54">
17
+ <img src="https://evilmartians.com/badges/sponsored-by-evil-martians.svg" alt="Built by Evil Martians" width="236" height="54">
18
18
  </a>
19
19
 
20
20
  ## Installation
@@ -117,6 +117,45 @@ result.output(:basic)
117
117
  # "error"=>"The instance value \"bar\" must be equal to one of the elements in the defined enumeration: [\"baz\"]"}]}
118
118
  ```
119
119
 
120
+ ### Handling External `$ref`s in JSON Schemas
121
+
122
+ In `JSONSkooma`, you can map `$ref` identifiers in your JSON schemas to local or remote sources.
123
+
124
+ This configuration allows `JSONSkooma` to automatically link `$ref` URIs to their corresponding schemas from specified sources:
125
+
126
+ ```yaml
127
+ # schema.yml
128
+ $schema: https://json-schema.org/draft/2020-12/schema
129
+ type: object
130
+ properties:
131
+ user:
132
+ $ref: http://local.example/user_definition.yaml
133
+ product:
134
+ $ref: http://remote.example/product_definition.yaml
135
+ ```
136
+
137
+ ```ruby
138
+ # Initialize the JSONSkooma registry
139
+ schema_registry = JSONSkooma.create_registry("2020-12")
140
+
141
+ # Add a local source for user definitions
142
+ local_schemas_path = File.join(__dir__, "schemas", "local")
143
+ schema_registry.add_source(
144
+ "http://local.example/",
145
+ JSONSkooma::Sources::Local.new(local_schemas_path)
146
+ )
147
+
148
+ # Add a remote source for product definitions
149
+ schema_registry.add_source(
150
+ "http://remote.example/",
151
+ JSONSkooma::Sources::Remote.new("http://example.com/schemas/")
152
+ )
153
+
154
+ # JSONSkooma now automatically resolves `$refs` to the appropriate schemas:
155
+ # - http://local.example/user_definition.yaml -> ./schemas/local/user_definition.yaml
156
+ # - http://remote.example/product_definition.yaml -> http://example.com/schemas/product_definition.yaml
157
+ ```
158
+
120
159
  ## Alternatives
121
160
 
122
161
  - [json_schemer](https://github.com/davishmcclurg/json_schemer) – Draft 4, 6, 7, 2019-09 and 2020-12 compliant
@@ -46,7 +46,7 @@ module JSONSkooma
46
46
  def read(relative_path)
47
47
  path = suffix ? relative_path + suffix : relative_path
48
48
  url = URI.join(base, path)
49
- URI.parse(url).open.read
49
+ url.read
50
50
  rescue OpenURI::HTTPError, SocketError
51
51
  raise Error, "Could not fetch #{url}"
52
52
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module JSONSkooma
4
- VERSION = "0.2.2"
4
+ VERSION = "0.2.3"
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.2
4
+ version: 0.2.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Svyatoslav Kryukov
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-04-09 00:00:00.000000000 Z
11
+ date: 2024-04-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: zeitwerk
@@ -237,7 +237,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
237
237
  - !ruby/object:Gem::Version
238
238
  version: '0'
239
239
  requirements: []
240
- rubygems_version: 3.3.7
240
+ rubygems_version: 3.5.7
241
241
  signing_key:
242
242
  specification_version: 4
243
243
  summary: I bring some sugar for your JSONs.