scorpio 0.4.4 → 0.4.5
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 +4 -4
- data/CHANGELOG.md +5 -1
- data/lib/scorpio/google_api_document.rb +1 -1
- data/lib/scorpio/openapi/operation.rb +5 -13
- data/lib/scorpio/openapi/operations_scope.rb +6 -1
- data/lib/scorpio/request.rb +8 -14
- data/lib/scorpio/response.rb +2 -3
- data/lib/scorpio/version.rb +1 -1
- data/scorpio.gemspec +1 -1
- metadata +5 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2f15434d7f81c98255a7ebb87327025e54c068bea44d4d8ba4de1e5a22b5a2e6
|
4
|
+
data.tar.gz: fa85f43ceb33e794d8ac5335f7d681ffa8897bbb6aa2f69cf1e2e15757f8e97d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2760d54f7f2c1b977192dc7244fff2f457ae293032f770482146143b14454e9896f7ff3717d9686bb02e981b854aab389a8baec76b40e6d17126b2c3446b3a45
|
7
|
+
data.tar.gz: a46a241d6bec8a531e3f76786aaa99ad335604927a3d5d4c079c7a65ebe619d1acef1a4b93c2aeb970f157a46ea8d63869d74966d5ace4e301399e2ec77a2cb9
|
data/CHANGELOG.md
CHANGED
@@ -98,7 +98,7 @@ module Scorpio
|
|
98
98
|
unused_path_params.delete(name) if op_param['in'] == 'path'
|
99
99
|
op_param['required'] = parameter.key?('required') ? parameter['required'] : op_param['in'] == 'path' ? true : false
|
100
100
|
op_param['type'] = parameter.type || 'string'
|
101
|
-
op_param['format'] = parameter
|
101
|
+
op_param['format'] = parameter['format'] if parameter['format']
|
102
102
|
end
|
103
103
|
end
|
104
104
|
end
|
@@ -60,13 +60,9 @@ module Scorpio
|
|
60
60
|
|
61
61
|
def path_template_str
|
62
62
|
return @path_template_str if instance_variable_defined?(:@path_template_str)
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
if parent_is_pathitem && parent_parent_is_paths
|
67
|
-
parent_jsi.jsi_ptr.reference_tokens.last
|
68
|
-
end
|
69
|
-
end
|
63
|
+
raise(Bug) unless parent_jsi.is_a?(Scorpio::OpenAPI::V2::PathItem) || parent_jsi.is_a?(Scorpio::OpenAPI::V3::PathItem)
|
64
|
+
raise(Bug) unless parent_jsi.parent_jsi.is_a?(Scorpio::OpenAPI::V2::Paths) || parent_jsi.parent_jsi.is_a?(Scorpio::OpenAPI::V3::Paths)
|
65
|
+
@path_template_str = parent_jsi.jsi_ptr.reference_tokens.last
|
70
66
|
end
|
71
67
|
|
72
68
|
# @return [Addressable::Template] the path as an Addressable::Template
|
@@ -91,12 +87,8 @@ module Scorpio
|
|
91
87
|
# for this operation from the parent PathItem
|
92
88
|
def http_method
|
93
89
|
return @http_method if instance_variable_defined?(:@http_method)
|
94
|
-
|
95
|
-
|
96
|
-
if parent_is_pathitem
|
97
|
-
jsi_ptr.reference_tokens.last
|
98
|
-
end
|
99
|
-
end
|
90
|
+
raise(Bug) unless parent_jsi.is_a?(Scorpio::OpenAPI::V2::PathItem) || parent_jsi.is_a?(Scorpio::OpenAPI::V3::PathItem)
|
91
|
+
@http_method = jsi_ptr.reference_tokens.last
|
100
92
|
end
|
101
93
|
|
102
94
|
# @return [String] a short identifier for this operation appropriate for an error message
|
@@ -25,9 +25,14 @@ module Scorpio
|
|
25
25
|
|
26
26
|
# @param operationId
|
27
27
|
# @return [Scorpio::OpenAPI::Operation] the operation with the given operationId
|
28
|
+
# @raise [::KeyError] if the given operationId does not exist
|
28
29
|
def [](operationId)
|
29
30
|
memoize(:[], operationId) do |operationId_|
|
30
|
-
detect { |operation| operation.operationId == operationId_ }
|
31
|
+
detect { |operation| operation.operationId == operationId_ }.tap do |op|
|
32
|
+
unless op
|
33
|
+
raise(::KeyError, "operationId not found: #{operationId_.inspect}")
|
34
|
+
end
|
35
|
+
end
|
31
36
|
end
|
32
37
|
end
|
33
38
|
end
|
data/lib/scorpio/request.rb
CHANGED
@@ -50,10 +50,9 @@ module Scorpio
|
|
50
50
|
def body
|
51
51
|
return @body if instance_variable_defined?(:@body)
|
52
52
|
if instance_variable_defined?(:@body_object)
|
53
|
-
|
54
|
-
if media_type == 'application/json'
|
53
|
+
if content_type && content_type.json?
|
55
54
|
JSON.pretty_generate(JSI::Typelike.as_json(body_object))
|
56
|
-
elsif
|
55
|
+
elsif content_type && content_type.form_urlencoded?
|
57
56
|
URI.encode_www_form(body_object)
|
58
57
|
|
59
58
|
# NOTE: the supported media types above should correspond to Request::SUPPORTED_REQUEST_MEDIA_TYPES
|
@@ -62,7 +61,7 @@ module Scorpio
|
|
62
61
|
if body_object.respond_to?(:to_str)
|
63
62
|
body_object
|
64
63
|
else
|
65
|
-
raise(NotImplementedError, "Scorpio does not know how to generate the request body with
|
64
|
+
raise(NotImplementedError, "Scorpio does not know how to generate the request body with content_type = #{content_type.respond_to?(:to_str) ? content_type : content_type.inspect} for operation: #{operation.human_id}. Scorpio supports media types: #{SUPPORTED_REQUEST_MEDIA_TYPES.join(', ')}. body_object was: #{body_object.pretty_inspect.chomp}")
|
66
65
|
end
|
67
66
|
end
|
68
67
|
else
|
@@ -81,7 +80,7 @@ module Scorpio
|
|
81
80
|
attr_writer :media_type
|
82
81
|
def media_type
|
83
82
|
return @media_type if instance_variable_defined?(:@media_type)
|
84
|
-
content_type_header ?
|
83
|
+
content_type_header ? content_type_header.media_type : operation.request_media_type
|
85
84
|
end
|
86
85
|
|
87
86
|
attr_writer :user_agent
|
@@ -190,23 +189,18 @@ module Scorpio
|
|
190
189
|
Addressable::URI.parse(File.join(base_url, path))
|
191
190
|
end
|
192
191
|
|
193
|
-
# @return [::Ur::
|
194
|
-
def content_type_attrs
|
195
|
-
Ur::ContentTypeAttrs.new(content_type)
|
196
|
-
end
|
197
|
-
|
198
|
-
# @return [String] the value of the request Content-Type header
|
192
|
+
# @return [::Ur::ContentType] the value of the request Content-Type header
|
199
193
|
def content_type_header
|
200
194
|
headers.each do |k, v|
|
201
|
-
return v if k =~ /\Acontent[-_]type\z/i
|
195
|
+
return ::Ur::ContentType.new(v) if k =~ /\Acontent[-_]type\z/i
|
202
196
|
end
|
203
197
|
nil
|
204
198
|
end
|
205
199
|
|
206
|
-
# @return [
|
200
|
+
# @return [::Ur::ContentType] Content-Type for this request, taken from request headers if
|
207
201
|
# present, or the request media_type.
|
208
202
|
def content_type
|
209
|
-
content_type_header || media_type
|
203
|
+
content_type_header || ::Ur::ContentType.new(media_type)
|
210
204
|
end
|
211
205
|
|
212
206
|
# @return [::JSI::Schema]
|
data/lib/scorpio/response.rb
CHANGED
@@ -9,8 +9,7 @@ module Scorpio
|
|
9
9
|
# if supported (only application/json is currently supported) instantiated according to
|
10
10
|
# #response_schema
|
11
11
|
def body_object
|
12
|
-
|
13
|
-
if media_type == 'application/json'
|
12
|
+
if json?
|
14
13
|
if body.empty?
|
15
14
|
# an empty body isn't valid json, of course, but we'll just return nil for it.
|
16
15
|
body_object = nil
|
@@ -27,7 +26,7 @@ module Scorpio
|
|
27
26
|
end
|
28
27
|
|
29
28
|
body_object
|
30
|
-
elsif
|
29
|
+
elsif content_type && content_type.type_text? && content_type.subtype?('plain')
|
31
30
|
body
|
32
31
|
else
|
33
32
|
# we will return the body if we do not have a supported parsing. for now.
|
data/lib/scorpio/version.rb
CHANGED
data/scorpio.gemspec
CHANGED
@@ -21,7 +21,7 @@ Gem::Specification.new do |spec|
|
|
21
21
|
spec.require_paths = ["lib"]
|
22
22
|
|
23
23
|
spec.add_dependency "jsi", "~> 0.2.0"
|
24
|
-
spec.add_dependency "ur", "~> 0.0
|
24
|
+
spec.add_dependency "ur", "~> 0.1.0"
|
25
25
|
spec.add_dependency "faraday"
|
26
26
|
spec.add_development_dependency "rake", "~> 10.0"
|
27
27
|
spec.add_development_dependency "minitest", "~> 5.0"
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: scorpio
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ethan
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-
|
11
|
+
date: 2019-12-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: jsi
|
@@ -30,14 +30,14 @@ dependencies:
|
|
30
30
|
requirements:
|
31
31
|
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: 0.0
|
33
|
+
version: 0.1.0
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: 0.0
|
40
|
+
version: 0.1.0
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: faraday
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -300,8 +300,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
300
300
|
- !ruby/object:Gem::Version
|
301
301
|
version: '0'
|
302
302
|
requirements: []
|
303
|
-
|
304
|
-
rubygems_version: 2.7.8
|
303
|
+
rubygems_version: 3.0.3
|
305
304
|
signing_key:
|
306
305
|
specification_version: 4
|
307
306
|
summary: Scorpio REST client
|