Module: Scorpio::OpenAPI::Reference
- Included in:
- V2::JsonReference, V2::PathItem, V3_0::PathItem, V3_0::Reference
- Defined in:
- lib/scorpio/openapi/reference.rb
Defined Under Namespace
Modules: Derefable
Instance Method Summary collapse
-
#[](token, **kw) ⇒ Object
overrides JSI::Base#[] to implicitly resolve this Reference, except when the given token is present in this Reference's instance.
- #has_ref? ⇒ Boolean
-
#resolve {|JSI::Base| ... } ⇒ JSI::Base?
yields or returns the target of this reference.
Instance Method Details
#[](token, **kw) ⇒ Object
overrides JSI::Base#[] to implicitly resolve this Reference, except when the given token is present in this Reference's instance. the token '$ref' will always come from this reference, not its resolution. tokens 'summary' and 'description' may also be in some references.
79 80 81 82 83 84 85 86 |
# File 'lib/scorpio/openapi/reference.rb', line 79 def [](token, **kw) if respond_to?(:to_hash) && !key?(token) resolve do |resolved| return(resolved[token, **kw]) end end return super end |
#has_ref? ⇒ Boolean
89 90 91 |
# File 'lib/scorpio/openapi/reference.rb', line 89 def has_ref? jsi_child_token_present?('$ref') end |
#resolve {|JSI::Base| ... } ⇒ JSI::Base?
yields or returns the target of this reference. returns nil and does not yield if $ref is not present.
96 97 98 99 100 101 102 103 104 105 106 |
# File 'lib/scorpio/openapi/reference.rb', line 96 def resolve return unless has_ref? ref = @memos.fetch(:oa_ref) { @memos[:oa_ref] = JSI::Ref.new(jsi_node_content['$ref'], referrer: self) } # TODO type check resolved yield ref.resolve if block_given? ref.resolve end |