reynard 0.2.0 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 95ca8eb7744c1550bfcf705a92d97331d9c558b08dec5f2369b166b285b38edc
4
- data.tar.gz: a140a0dbe5f74c95f43d2aa785dd3c96a322eab2893b2d8a629abd3b9859724e
3
+ metadata.gz: bb3f70f5fd68cbe19747d08687715165595d29a6b81da3329a975cac30bd3cbe
4
+ data.tar.gz: 73020e57c19507af7ac13b9bc509d3a4b7ac3ae9b74866d7f783cc816436039f
5
5
  SHA512:
6
- metadata.gz: 77148ca6897e1e7b0479348cfe536ff94afc5c1741b6fe59afea7940b442d7c46a71914868f572f3588b7d85d95f38446bd8d28885a22a032c91a86e71e3da28
7
- data.tar.gz: eab59f1738c99af0f2c8fba6a4fb09f15a5a26f31f86de91125d9f299d2d50844060bd3c13db33b260f267a82e269175e0c69d2cdeb4f32d397e99bca74e9694
6
+ metadata.gz: d5289ec587b945a0a858537569a4543e9bbfb3daa6dcb8e11cc409d620b89c1d85406d4a1fa0d20dcccc4c00eddcc6ff4b03f5ae24feff865f4cb62661f09638
7
+ data.tar.gz: af30bf905849a2589e091b0b9655e52375db08ea00f0b28365029900b4101c5d4b94822b30a17b3a1b8e35329886b61cf857fa6d8de1ff6a16fd56ca0dc2a904
@@ -46,7 +46,7 @@ class Reynard
46
46
 
47
47
  def build_object_without_media_type
48
48
  # Try to parse the response as JSON and give up otherwise.
49
- OpenStruct.new(MultiJson.load(@http_response.body))
49
+ Reynard::Model.new(MultiJson.load(@http_response.body))
50
50
  rescue StandardError
51
51
  @http_response.body
52
52
  end
@@ -15,7 +15,7 @@ class Reynard
15
15
  if @media_type.schema_name
16
16
  self.class.model_class(@media_type.schema_name, @schema.object_type)
17
17
  else
18
- OpenStruct
18
+ Reynard::Model
19
19
  end
20
20
  end
21
21
 
@@ -23,7 +23,7 @@ class Reynard
23
23
  if @schema.item_schema_name
24
24
  self.class.model_class(@schema.item_schema_name, 'object')
25
25
  else
26
- OpenStruct
26
+ Reynard::Model
27
27
  end
28
28
  end
29
29
 
@@ -5,6 +5,8 @@ require 'rack'
5
5
  class Reynard
6
6
  # Wraps the YAML representation of an OpenAPI specification.
7
7
  class Specification
8
+ VERBS = %w[get put post delete options head patch trace].freeze
9
+
8
10
  def initialize(filename:)
9
11
  @filename = filename
10
12
  @data = read
@@ -32,7 +34,15 @@ class Reynard
32
34
  def build_grouped_params(operation_node, params)
33
35
  return {} unless params
34
36
 
35
- GroupedParameters.new(dig(*operation_node, 'parameters'), params).to_h
37
+ GroupedParameters.new(
38
+ [
39
+ # Parameters can be shared between methods on a path or be specific to an operation. The
40
+ # parameters on the operation level override those at the path level.
41
+ dig(*operation_node, 'parameters'),
42
+ dig(*operation_node[..-2], 'parameters')
43
+ ].compact.flatten,
44
+ params
45
+ ).to_h
36
46
  end
37
47
 
38
48
  # Returns a serialized body instance to serialize a request body and figure out the request
@@ -43,7 +53,7 @@ class Reynard
43
53
 
44
54
  def operation(operation_name)
45
55
  dig('paths').each do |path, operations|
46
- operations.each do |verb, operation|
56
+ operations.slice(*VERBS).each do |verb, operation|
47
57
  return Operation.new(node: ['paths', path, verb]) if operation_name == operation['operationId']
48
58
  end
49
59
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  class Reynard
4
- VERSION = '0.2.0'
4
+ VERSION = '0.3.0'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: reynard
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Manfred Stienstra
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-11-16 00:00:00.000000000 Z
11
+ date: 2021-11-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: multi_json