scorpio 0.4.3 → 0.4.4
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 +4 -0
- data/lib/scorpio/openapi/document.rb +5 -11
- data/lib/scorpio/openapi/operation.rb +8 -7
- data/lib/scorpio/resource_base.rb +18 -19
- data/lib/scorpio/response.rb +1 -1
- data/lib/scorpio/version.rb +1 -1
- data/scorpio.gemspec +2 -2
- metadata +6 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d8e4b8a415bbb35c491e9a563c438916a33049e596e879d022f6435e5a7c7ec1
|
4
|
+
data.tar.gz: ca3d1b9b6539e9c0351c51bee08ed18667eabae3038514ecbe4a375ae246066f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 89b3da10d085ab62755defca0457f9dc1d8e9c1db8699e2727efecdd9d12f5d09c3dbeca309afe283ac7ed5f25e3f92368969434a789c334a4897627bf7cd64d
|
7
|
+
data.tar.gz: 3dc9d5722372386ec1040c3ad6707d8aed251882ab31d8f26ad559edf517f3fbd001178b94de78987d849ba285808dc5f27b7414b78ad34a437a7b08fe73e899
|
data/CHANGELOG.md
CHANGED
@@ -12,10 +12,11 @@ module Scorpio
|
|
12
12
|
# @param instance [#to_hash] the document to represent as a Scorpio OpenAPI Document
|
13
13
|
# @return [Scorpio::OpenAPI::V2::Document, Scorpio::OpenAPI::V3::Document]
|
14
14
|
def from_instance(instance)
|
15
|
-
if instance.is_a?(
|
16
|
-
instance
|
17
|
-
|
18
|
-
|
15
|
+
if instance.is_a?(Scorpio::OpenAPI::Document)
|
16
|
+
instance
|
17
|
+
elsif instance.is_a?(JSI::Base)
|
18
|
+
raise(TypeError, "instance is unexpected JSI type: #{instance.class.inspect}")
|
19
|
+
elsif instance.respond_to?(:to_hash)
|
19
20
|
if instance['swagger'] =~ /\A2(\.|\z)/
|
20
21
|
instance = Scorpio::OpenAPI::V2::Document.new(instance)
|
21
22
|
elsif instance['openapi'] =~ /\A3(\.|\z)/
|
@@ -23,13 +24,6 @@ module Scorpio
|
|
23
24
|
else
|
24
25
|
raise(ArgumentError, "instance does not look like a recognized openapi document")
|
25
26
|
end
|
26
|
-
end
|
27
|
-
if instance.is_a?(Scorpio::OpenAPI::Document)
|
28
|
-
instance
|
29
|
-
elsif instance.is_a?(JSI::Base)
|
30
|
-
raise(TypeError, "instance is unexpected JSI type: #{instance.class.inspect}")
|
31
|
-
elsif instance.respond_to?(:to_hash)
|
32
|
-
from_instance(instance.to_hash)
|
33
27
|
else
|
34
28
|
raise(TypeError, "instance does not look like a hash (json object)")
|
35
29
|
end
|
@@ -55,16 +55,16 @@ module Scorpio
|
|
55
55
|
|
56
56
|
# @return [Scorpio::OpenAPI::Document] the document whence this operation came
|
57
57
|
def openapi_document
|
58
|
-
|
58
|
+
parent_jsis.detect { |p| p.is_a?(Scorpio::OpenAPI::Document) }
|
59
59
|
end
|
60
60
|
|
61
61
|
def path_template_str
|
62
62
|
return @path_template_str if instance_variable_defined?(:@path_template_str)
|
63
63
|
@path_template_str = begin
|
64
|
-
parent_is_pathitem =
|
65
|
-
parent_parent_is_paths =
|
64
|
+
parent_is_pathitem = parent_jsi.is_a?(Scorpio::OpenAPI::V2::PathItem) || parent_jsi.is_a?(Scorpio::OpenAPI::V3::PathItem)
|
65
|
+
parent_parent_is_paths = parent_jsi.parent_jsi.is_a?(Scorpio::OpenAPI::V2::Paths) || parent_jsi.parent_jsi.is_a?(Scorpio::OpenAPI::V3::Paths)
|
66
66
|
if parent_is_pathitem && parent_parent_is_paths
|
67
|
-
|
67
|
+
parent_jsi.jsi_ptr.reference_tokens.last
|
68
68
|
end
|
69
69
|
end
|
70
70
|
end
|
@@ -92,9 +92,9 @@ module Scorpio
|
|
92
92
|
def http_method
|
93
93
|
return @http_method if instance_variable_defined?(:@http_method)
|
94
94
|
@http_method = begin
|
95
|
-
parent_is_pathitem =
|
95
|
+
parent_is_pathitem = parent_jsi.is_a?(Scorpio::OpenAPI::V2::PathItem) || parent_jsi.is_a?(Scorpio::OpenAPI::V3::PathItem)
|
96
96
|
if parent_is_pathitem
|
97
|
-
|
97
|
+
jsi_ptr.reference_tokens.last
|
98
98
|
end
|
99
99
|
end
|
100
100
|
end
|
@@ -272,7 +272,8 @@ module Scorpio
|
|
272
272
|
end
|
273
273
|
include Configurables
|
274
274
|
|
275
|
-
#
|
275
|
+
# @return [#to_hash] the body parameter
|
276
|
+
# @raise [Scorpio::OpenAPI::SemanticError] if there's more than one body param
|
276
277
|
def body_parameter
|
277
278
|
body_parameters = (parameters || []).select { |parameter| parameter['in'] == 'body' }
|
278
279
|
if body_parameters.size == 0
|
@@ -6,18 +6,20 @@ module Scorpio
|
|
6
6
|
|
7
7
|
class ResourceBase
|
8
8
|
class << self
|
9
|
-
# a hash of accessor names (Symbol)
|
10
|
-
# what accessors have been
|
9
|
+
# ResourceBase.inheritable_accessor_defaults is a hash of accessor names (Symbol) mapped
|
10
|
+
# to default getter methods (UnboundMethod), used to determine what accessors have been
|
11
|
+
# overridden from their defaults.
|
11
12
|
(-> (x) { define_method(:inheritable_accessor_defaults) { x } }).({})
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
13
|
+
|
14
|
+
# @param accessor [String, Symbol] the name of the accessor
|
15
|
+
# @param default_getter [#to_proc] a proc to provide a default value when no value
|
16
|
+
# has been explicitly set
|
17
|
+
# @param default_value [Object] a default value to return when no value has been
|
18
|
+
# explicitly set. do not pass both :default_getter and :default_value.
|
19
|
+
# @param on_set [#to_proc] callback proc, invoked when a value is assigned
|
20
|
+
def define_inheritable_accessor(accessor, default_value: nil, default_getter: -> { default_value }, on_set: nil)
|
21
|
+
# the value before the field is set (overwritten) is the result of the default_getter proc
|
22
|
+
define_singleton_method(accessor, &default_getter)
|
21
23
|
inheritable_accessor_defaults[accessor] = self.singleton_class.instance_method(accessor)
|
22
24
|
# field setter method. redefines the getter, replacing the method with one that returns the
|
23
25
|
# setter's argument (that being inherited to the scope of the define_method(accessor) block
|
@@ -33,8 +35,8 @@ module Scorpio
|
|
33
35
|
# getter method
|
34
36
|
define_method(accessor) { value_ }
|
35
37
|
# invoke on_set callback defined on the class
|
36
|
-
if
|
37
|
-
klass.instance_exec(&
|
38
|
+
if on_set
|
39
|
+
klass.instance_exec(&on_set)
|
38
40
|
end
|
39
41
|
end
|
40
42
|
end
|
@@ -349,10 +351,8 @@ module Scorpio
|
|
349
351
|
if object.is_a?(Scorpio::ResourceBase)
|
350
352
|
# TODO request_schema_fail unless schema is for given model type
|
351
353
|
request_body_for_schema(object.attributes, schema)
|
352
|
-
elsif object.is_a?(JSI::
|
353
|
-
request_body_for_schema(object.
|
354
|
-
elsif object.is_a?(JSI::JSON::Node)
|
355
|
-
request_body_for_schema(object.content, schema)
|
354
|
+
elsif object.is_a?(JSI::PathedNode)
|
355
|
+
request_body_for_schema(object.node_content, schema)
|
356
356
|
else
|
357
357
|
if object.respond_to?(:to_hash)
|
358
358
|
object.map do |key, value|
|
@@ -431,8 +431,7 @@ module Scorpio
|
|
431
431
|
mod = object.map do |key, value|
|
432
432
|
{key => response_object_to_instances(value, initialize_options)}
|
433
433
|
end.inject({}, &:update)
|
434
|
-
mod = mod.
|
435
|
-
mod = mod.content if mod.is_a?(JSI::JSON::Node)
|
434
|
+
mod = mod.node_content if mod.is_a?(JSI::PathedNode)
|
436
435
|
mod
|
437
436
|
end
|
438
437
|
if model
|
data/lib/scorpio/response.rb
CHANGED
@@ -23,7 +23,7 @@ module Scorpio
|
|
23
23
|
end
|
24
24
|
|
25
25
|
if response_schema && (body_object.respond_to?(:to_hash) || body_object.respond_to?(:to_ary))
|
26
|
-
body_object = JSI.class_for_schema(response_schema).new(
|
26
|
+
body_object = JSI.class_for_schema(response_schema).new(body_object)
|
27
27
|
end
|
28
28
|
|
29
29
|
body_object
|
data/lib/scorpio/version.rb
CHANGED
data/scorpio.gemspec
CHANGED
@@ -20,8 +20,8 @@ Gem::Specification.new do |spec|
|
|
20
20
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
21
21
|
spec.require_paths = ["lib"]
|
22
22
|
|
23
|
-
spec.add_dependency "jsi", "~> 0.
|
24
|
-
spec.add_dependency "ur", "~> 0.0.
|
23
|
+
spec.add_dependency "jsi", "~> 0.2.0"
|
24
|
+
spec.add_dependency "ur", "~> 0.0.4"
|
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.4
|
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-
|
11
|
+
date: 2019-11-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: jsi
|
@@ -16,28 +16,28 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 0.
|
19
|
+
version: 0.2.0
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: 0.
|
26
|
+
version: 0.2.0
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: ur
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
31
|
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: 0.0.
|
33
|
+
version: 0.0.4
|
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.0.4
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: faraday
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|