json_skooma 0.2.1 → 0.2.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +16 -1
- data/README.md +40 -1
- data/data/draft-2019-09/README.md +1 -1
- data/data/draft-2020-12/README.md +1 -1
- data/lib/json_skooma/json_pointer.rb +1 -1
- data/lib/json_skooma/keywords/core/dynamic_ref.rb +1 -1
- data/lib/json_skooma/sources.rb +1 -1
- data/lib/json_skooma/validators/time.rb +1 -1
- data/lib/json_skooma/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b477f1320adcfae0e544129fd0c7cf7423221582a4914df84e2b685bbc3d3407
|
4
|
+
data.tar.gz: 33be1f69264fa10de07b4391850945343996832b3f0b534fbc4ea34f125dee28
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4fd6ad6cf954c7b5cd9886691280e334b49332a51b74beba483a2041e00c36ce0b9662a52cdc1ba8ee310fc979117ee3a08f8df05f1f6291c5e501215149dd2a
|
7
|
+
data.tar.gz: 5d428bce4e4e1979cf908d4efc9cdf397d60449fde95742df5df7d18084ced68cacc9169d6e4ee1517a152bb990ebce9a38f48221968cfa1633dc14503b3b31a
|
data/CHANGELOG.md
CHANGED
@@ -7,6 +7,18 @@ and this project adheres to [Semantic Versioning].
|
|
7
7
|
|
8
8
|
## [Unreleased]
|
9
9
|
|
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
|
17
|
+
|
18
|
+
### Fixed
|
19
|
+
|
20
|
+
- Fix `$dynamicAnchor` boolean evaluation. ([@skryukov])
|
21
|
+
|
10
22
|
## [0.2.1] - 2023-12-03
|
11
23
|
|
12
24
|
### Fixed
|
@@ -36,8 +48,11 @@ and this project adheres to [Semantic Versioning].
|
|
36
48
|
- Initial implementation. ([@skryukov])
|
37
49
|
|
38
50
|
[@skryukov]: https://github.com/skryukov
|
51
|
+
[@killondark]: https://github.com/killondark
|
39
52
|
|
40
|
-
[Unreleased]: https://github.com/skryukov/json_skooma/compare/v0.2.
|
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
|
55
|
+
[0.2.2]: https://github.com/skryukov/json_skooma/compare/v0.2.1...v0.2.2
|
41
56
|
[0.2.1]: https://github.com/skryukov/json_skooma/compare/v0.2.0...v0.2.1
|
42
57
|
[0.2.0]: https://github.com/skryukov/json_skooma/compare/v0.1.0...v0.2.0
|
43
58
|
[0.1.0]: https://github.com/skryukov/json_skooma/commits/v0.1.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="
|
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
|
@@ -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/
|
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
|
|
@@ -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/
|
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
|
|
@@ -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
|
|
data/lib/json_skooma/sources.rb
CHANGED
@@ -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
|
-
|
49
|
+
url.read
|
50
50
|
rescue OpenURI::HTTPError, SocketError
|
51
51
|
raise Error, "Could not fetch #{url}"
|
52
52
|
end
|
data/lib/json_skooma/version.rb
CHANGED
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.
|
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:
|
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.
|
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.
|