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

Instance Method Details

#as_jsonObject



564
565
566
567
568
569
# File 'lib/swagger/blocks.rb', line 564

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(&block) ⇒ Object



571
572
573
574
# File 'lib/swagger/blocks.rb', line 571

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