openapi_parser 0.10.0 → 0.11.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +4 -3
- data/CHANGELOG.md +5 -0
- data/lib/openapi_parser.rb +16 -4
- data/lib/openapi_parser/concerns/findable.rb +3 -0
- data/lib/openapi_parser/schema_validators/base.rb +1 -1
- data/lib/openapi_parser/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: c94d0bbb5e44314e9cde71c23587355496214b1fdf6ca2e3bf43f404087b6220
|
4
|
+
data.tar.gz: be8205b97559da91e85613df31c2ac0e060116046532e4285eb01127c0303eae
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a844336ca5d80573478d7e35d6978881c8d0581e2757584e227781c5b523e1f181f5403c4efb4047df3a9c519043ab0513bbaf5df83acff12d54f0d2c19874a2
|
7
|
+
data.tar.gz: 406ad0fc2ad51af48b56ba1bf2ace1cac8b920adb85615e160e901aacbacf58c94a02cf4c737cf0601a6bab120bc2c51b3d7cd3f9da0295138edbc63bf7cf8ae
|
data/.travis.yml
CHANGED
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,10 @@
|
|
1
1
|
## Unreleased
|
2
2
|
|
3
|
+
## 0.11.0 (2020-05-09)
|
4
|
+
* Add committee friendly interface to use remote references. #74
|
5
|
+
* Prevent SystemStackError on recursive schema reference #76
|
6
|
+
* support newest ruby versions #78
|
7
|
+
|
3
8
|
## 0.10.0 (2020-04-01)
|
4
9
|
* Support $ref to objects in other OpenAPI yaml files #66
|
5
10
|
* Allow $ref for path item objects #71
|
data/lib/openapi_parser.rb
CHANGED
@@ -18,18 +18,24 @@ require 'openapi_parser/reference_expander'
|
|
18
18
|
|
19
19
|
module OpenAPIParser
|
20
20
|
class << self
|
21
|
-
# Load schema
|
21
|
+
# Load schema hash object. Uri is not set for returned schema.
|
22
22
|
# @return [OpenAPIParser::Schemas::OpenAPI]
|
23
23
|
def parse(schema, config = {})
|
24
24
|
load_hash(schema, config: Config.new(config), uri: nil, schema_registry: {})
|
25
25
|
end
|
26
26
|
|
27
|
+
# @param filepath [String] Path of the file containing the passed schema.
|
28
|
+
# Used for resolving remote $ref if provided.
|
29
|
+
# If file path is relative, it is resolved using working directory.
|
30
|
+
# @return [OpenAPIParser::Schemas::OpenAPI]
|
31
|
+
def parse_with_filepath(schema, filepath, config = {})
|
32
|
+
load_hash(schema, config: Config.new(config), uri: filepath && file_uri(filepath), schema_registry: {})
|
33
|
+
end
|
34
|
+
|
27
35
|
# Load schema in specified filepath. If file path is relative, it is resolved using working directory.
|
28
36
|
# @return [OpenAPIParser::Schemas::OpenAPI]
|
29
37
|
def load(filepath, config = {})
|
30
|
-
|
31
|
-
path = Pathname.getwd + path if path.relative?
|
32
|
-
load_uri(URI.join("file:///", path.to_s), config: Config.new(config), schema_registry: {})
|
38
|
+
load_uri(file_uri(filepath), config: Config.new(config), schema_registry: {})
|
33
39
|
end
|
34
40
|
|
35
41
|
# Load schema located by the passed uri. Uri must be absolute.
|
@@ -49,6 +55,12 @@ module OpenAPIParser
|
|
49
55
|
|
50
56
|
private
|
51
57
|
|
58
|
+
def file_uri(filepath)
|
59
|
+
path = Pathname.new(filepath)
|
60
|
+
path = Pathname.getwd + path if path.relative?
|
61
|
+
URI.join("file:///", path.to_s)
|
62
|
+
end
|
63
|
+
|
52
64
|
def parse_file(content, extension)
|
53
65
|
case extension.downcase
|
54
66
|
when '.yaml', '.yml'
|
@@ -34,7 +34,7 @@ class OpenAPIParser::SchemaValidator
|
|
34
34
|
unless resolved_schema
|
35
35
|
return [nil, OpenAPIParser::NotExistDiscriminatorMappedSchema.new(mapping_target, discriminator.object_reference)]
|
36
36
|
end
|
37
|
-
validatable.validate_schema(value, resolved_schema, {discriminator_property_name: discriminator.property_name})
|
37
|
+
validatable.validate_schema(value, resolved_schema, **{discriminator_property_name: discriminator.property_name})
|
38
38
|
end
|
39
39
|
end
|
40
40
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: openapi_parser
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.11.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- ota42y
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-05-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -222,7 +222,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
222
222
|
- !ruby/object:Gem::Version
|
223
223
|
version: '0'
|
224
224
|
requirements: []
|
225
|
-
rubygems_version: 3.
|
225
|
+
rubygems_version: 3.1.2
|
226
226
|
signing_key:
|
227
227
|
specification_version: 4
|
228
228
|
summary: OpenAPI3 parser
|