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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 98afa3c7fb754859a594373659d18ebb81483581c948621d0ea050c360da38ec
4
- data.tar.gz: 9cf7b695875b6ca55a89a3d5e1a288381d39e203c5fbb469beeb7465232ff0a5
3
+ metadata.gz: c94d0bbb5e44314e9cde71c23587355496214b1fdf6ca2e3bf43f404087b6220
4
+ data.tar.gz: be8205b97559da91e85613df31c2ac0e060116046532e4285eb01127c0303eae
5
5
  SHA512:
6
- metadata.gz: ddc32d47e0072b78f4790a6b6fa031eab103bb4665d5c0cfe4e7ac2ac9b2e04a048a82f4ddefd40fd112221e389cd86568ac67c3ca9db6f46ae4b9f8ece23c8a
7
- data.tar.gz: bdd2fdeaec224eaecdde6088abc7eb69513a4ab9e2afffbf23a6a21f9e13a640bddaf6bd7fbbaab16dff588c021bc12296aefd01b1efcb28908f33f8b263f9ad
6
+ metadata.gz: a844336ca5d80573478d7e35d6978881c8d0581e2757584e227781c5b523e1f181f5403c4efb4047df3a9c519043ab0513bbaf5df83acff12d54f0d2c19874a2
7
+ data.tar.gz: 406ad0fc2ad51af48b56ba1bf2ace1cac8b920adb85615e160e901aacbacf58c94a02cf4c737cf0601a6bab120bc2c51b3d7cd3f9da0295138edbc63bf7cf8ae
data/.travis.yml CHANGED
@@ -6,9 +6,10 @@ language: ruby
6
6
 
7
7
  rvm:
8
8
  - 2.3.8
9
- - 2.4.6
10
- - 2.5.5
11
- - 2.6.3
9
+ - 2.4.10
10
+ - 2.5.8
11
+ - 2.6.6
12
+ - 2.7.1
12
13
  - ruby-head
13
14
 
14
15
  cache: bundler
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
@@ -18,18 +18,24 @@ require 'openapi_parser/reference_expander'
18
18
 
19
19
  module OpenAPIParser
20
20
  class << self
21
- # Load schema yaml object. Uri is not set for returned 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
- path = Pathname.new(filepath)
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'
@@ -30,7 +30,10 @@ module OpenAPIParser::Findable
30
30
  end
31
31
 
32
32
  def purge_object_cache
33
+ return if @purged
34
+
33
35
  @find_object_cache = {}
36
+ @purged = true
34
37
 
35
38
  _openapi_all_child_objects.values.each(&:purge_object_cache)
36
39
  end
@@ -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
@@ -1,3 +1,3 @@
1
1
  module OpenAPIParser
2
- VERSION = '0.10.0'.freeze
2
+ VERSION = '0.11.0'.freeze
3
3
  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.10.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-04-01 00:00:00.000000000 Z
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.0.3
225
+ rubygems_version: 3.1.2
226
226
  signing_key:
227
227
  specification_version: 4
228
228
  summary: OpenAPI3 parser