openapi_contracts 0.12.0 → 0.13.2

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: 7fa5c81703e10335348cefdfdf14ada22c1a66a4017c71e0fd74e2499e95cd75
4
- data.tar.gz: ef6ab8b10609f9e048f9ee61cdd017883a4a9c8b7a8f3166ac3891e5e6d51e52
3
+ metadata.gz: a6ead386a672bc6da357f0686b6de4fd01e9c7a7155b65e312b04975f138a76f
4
+ data.tar.gz: cea44722316b8bb3d2bbb85f47a4794b8cdb3f143ff8cf8d65ad9a262d546127
5
5
  SHA512:
6
- metadata.gz: fb69135e230360714f93b9285efa0fa7cd1cc4b2ab524b5dac1a1bf925ef2cf98a92475b6c7d5528892f2208ba42ee0f71366280808914bb6976ec91db5d3df7
7
- data.tar.gz: 71fc02b108dae2bdcf2bcbc40ef7faca01acee5c772a57ec155426ca4aec42b5317e89f828624b2126f658f276261762ccc8eb29b6be2c1cd6f5c9f90663996f
6
+ metadata.gz: 13b0e8e63dfe4e1459d9fcca05bd82b017465ce180b4680b2a9f7464ffbef837e89810f3ba5be1b484f41619694a97bcac814787d81361be6a1c94bd96851728
7
+ data.tar.gz: 2b20b1298db18a1846f677569e7a4eb257672a6f138c0d156dbd2caf7b70097469f4baf8c9a138bf07ff68355c25dd9e7547b86d24705259b2bd1ec4435d6982
@@ -35,20 +35,20 @@ module OpenapiContracts
35
35
  end
36
36
 
37
37
  # Returns an Enumerator over all Operations
38
- def operations(&block) # rubocop:disable Naming/BlockForwarding
38
+ def operations(&block)
39
39
  return enum_for(:operations) unless block_given?
40
40
 
41
41
  paths.each do |path|
42
- path.operations.each(&block) # rubocop:disable Naming/BlockForwarding
42
+ path.operations.each(&block)
43
43
  end
44
44
  end
45
45
 
46
46
  # Returns an Enumerator over all Responses
47
- def responses(&block) # rubocop:disable Naming/BlockForwarding
47
+ def responses(&block)
48
48
  return enum_for(:responses) unless block_given?
49
49
 
50
50
  operations.each do |operation|
51
- operation.responses.each(&block) # rubocop:disable Naming/BlockForwarding
51
+ operation.responses.each(&block)
52
52
  end
53
53
  end
54
54
 
@@ -25,7 +25,9 @@ module OpenapiContracts::Parser::Transformers
25
25
  # A JSON Pointer
26
26
  generate_absolute_pointer(pointer)
27
27
  elsif %r{^(?<relpath>[^#]+)(?:#/(?<pointer>.*))?} =~ target
28
- ptr = @parser.filenesting[@cwd.join(relpath)]
28
+ ptr = @parser.filenesting[@cwd.join(relpath).cleanpath]
29
+ raise "Unknown file: #{@cwd.join(relpath).cleanpath.inspect}" unless ptr
30
+
29
31
  tgt = ptr.to_json_pointer
30
32
  tgt += "/#{pointer}" if pointer
31
33
  tgt
@@ -30,24 +30,29 @@ module OpenapiContracts
30
30
  # file list consists of
31
31
  # - root file
32
32
  # - all files in components/
33
- # - all path files referenced by the root file
33
+ # - all path & webhook files referenced by the root file
34
34
  def build_file_list
35
35
  list = {@rootfile.relative_path_from(@cwd) => Doc::Pointer[]}
36
36
  Dir[File.expand_path('components/**/*.yaml', @cwd)].each do |file|
37
- pathname = Pathname(file).relative_path_from(@cwd)
37
+ pathname = Pathname(file).relative_path_from(@cwd).cleanpath
38
38
  pointer = Doc::Pointer.from_path pathname.sub_ext('')
39
39
  list.merge! pathname => pointer
40
40
  end
41
- YAML.safe_load_file(@rootfile).fetch('paths') { {} }.each_pair do |k, v|
42
- next unless v['$ref'] && !v['$ref'].start_with?('#')
41
+ rootdata = YAML.safe_load_file(@rootfile)
42
+ %w(paths webhooks).each do |name|
43
+ rootdata.fetch(name) { {} }.each_pair do |k, v|
44
+ next unless v['$ref'] && !v['$ref'].start_with?('#')
43
45
 
44
- list.merge! Pathname(v['$ref']) => Doc::Pointer['paths', k]
46
+ list.merge! Pathname(v['$ref']).cleanpath => Doc::Pointer[name, k]
47
+ end
45
48
  end
46
49
  list
47
50
  end
48
51
 
49
52
  def file_to_data(pathname, pointer)
50
53
  YAML.safe_load_file(@cwd.join(pathname)).tap do |data|
54
+ break {} unless data.present?
55
+
51
56
  transform_objects!(data, pathname.parent, pointer)
52
57
  end
53
58
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: openapi_contracts
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.12.0
4
+ version: 0.13.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - mkon
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-01-08 00:00:00.000000000 Z
11
+ date: 2024-03-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -84,42 +84,42 @@ dependencies:
84
84
  requirements:
85
85
  - - "~>"
86
86
  - !ruby/object:Gem::Version
87
- version: 3.12.0
87
+ version: 3.13.0
88
88
  type: :development
89
89
  prerelease: false
90
90
  version_requirements: !ruby/object:Gem::Requirement
91
91
  requirements:
92
92
  - - "~>"
93
93
  - !ruby/object:Gem::Version
94
- version: 3.12.0
94
+ version: 3.13.0
95
95
  - !ruby/object:Gem::Dependency
96
96
  name: rubocop
97
97
  requirement: !ruby/object:Gem::Requirement
98
98
  requirements:
99
99
  - - '='
100
100
  - !ruby/object:Gem::Version
101
- version: 1.57.2
101
+ version: 1.60.2
102
102
  type: :development
103
103
  prerelease: false
104
104
  version_requirements: !ruby/object:Gem::Requirement
105
105
  requirements:
106
106
  - - '='
107
107
  - !ruby/object:Gem::Version
108
- version: 1.57.2
108
+ version: 1.60.2
109
109
  - !ruby/object:Gem::Dependency
110
110
  name: rubocop-rspec
111
111
  requirement: !ruby/object:Gem::Requirement
112
112
  requirements:
113
113
  - - '='
114
114
  - !ruby/object:Gem::Version
115
- version: 2.25.0
115
+ version: 2.26.1
116
116
  type: :development
117
117
  prerelease: false
118
118
  version_requirements: !ruby/object:Gem::Requirement
119
119
  requirements:
120
120
  - - '='
121
121
  - !ruby/object:Gem::Version
122
- version: 2.25.0
122
+ version: 2.26.1
123
123
  - !ruby/object:Gem::Dependency
124
124
  name: simplecov
125
125
  requirement: !ruby/object:Gem::Requirement
@@ -196,7 +196,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
196
196
  - !ruby/object:Gem::Version
197
197
  version: '0'
198
198
  requirements: []
199
- rubygems_version: 3.4.22
199
+ rubygems_version: 3.4.6
200
200
  signing_key:
201
201
  specification_version: 4
202
202
  summary: Openapi schemas as API contracts