Class: Swagger::Blocks::ApiAuthorizationNode

Inherits:
Node
  • Object
show all
Defined in:
lib/swagger/blocks.rb

Overview

v1.2: NOTE: in the spec this is different than Resource Listing’s authorization. v1.2: goo.gl/PvwUXj#515-authorization-object

Instance Attribute Summary

Attributes inherited from Node

#name, #version

Instance Method Summary collapse

Methods inherited from Node

call, #data, #is_swagger_1_2?, #is_swagger_2_0?, #key, #keys

Instance Method Details

#as_jsonObject



587
588
589
590
591
592
# File 'lib/swagger/blocks.rb', line 587

def as_json
  # Special case: the API Authorization object is weirdly the only array of hashes.
  # Override the default hash behavior and return an array.
  self.data[:_scopes] ||= []
  self.data[:_scopes].map { |s| s.as_json }
end

#scope(inline_keys = nil, &block) ⇒ Object



594
595
596
597
# File 'lib/swagger/blocks.rb', line 594

def scope(inline_keys = nil, &block)
  self.data[:_scopes] ||= []
  self.data[:_scopes] << Swagger::Blocks::ApiAuthorizationScopeNode.call(version: version, inline_keys: inline_keys, &block)
end