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



573
574
575
576
577
578
# File 'lib/swagger/blocks.rb', line 573

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



580
581
582
583
# File 'lib/swagger/blocks.rb', line 580

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