Class: SwaggerYard::Authorization
- Inherits:
-
Object
- Object
- SwaggerYard::Authorization
- Defined in:
- lib/swagger_yard/authorization.rb
Instance Attribute Summary collapse
-
#key ⇒ Object
readonly
Returns the value of attribute key.
-
#name ⇒ Object
the spec suggests most auth names are just the type of auth.
-
#pass_as ⇒ Object
readonly
Returns the value of attribute pass_as.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(type, pass_as, key) ⇒ Authorization
constructor
A new instance of Authorization.
- #to_h ⇒ Object
- #type ⇒ Object
Constructor Details
#initialize(type, pass_as, key) ⇒ Authorization
Returns a new instance of Authorization.
10 11 12 |
# File 'lib/swagger_yard/authorization.rb', line 10 def initialize(type, pass_as, key) @type, @pass_as, @key = type, pass_as, key end |
Instance Attribute Details
#key ⇒ Object (readonly)
Returns the value of attribute key.
3 4 5 |
# File 'lib/swagger_yard/authorization.rb', line 3 def key @key end |
#name ⇒ Object
the spec suggests most auth names are just the type of auth
15 16 17 |
# File 'lib/swagger_yard/authorization.rb', line 15 def name @name ||= [@pass_as, @key].join('_').downcase.gsub('-', '_') end |
#pass_as ⇒ Object (readonly)
Returns the value of attribute pass_as.
3 4 5 |
# File 'lib/swagger_yard/authorization.rb', line 3 def pass_as @pass_as end |
Class Method Details
.from_yard_object(yard_object) ⇒ Object
6 7 8 |
# File 'lib/swagger_yard/authorization.rb', line 6 def self.from_yard_object(yard_object) new(yard_object.types.first, yard_object.name, yard_object.text) end |
Instance Method Details
#to_h ⇒ Object
28 29 30 31 32 |
# File 'lib/swagger_yard/authorization.rb', line 28 def to_h { "type" => type, "name" => @key, "in" => @pass_as } end |
#type ⇒ Object
19 20 21 22 23 24 25 26 |
# File 'lib/swagger_yard/authorization.rb', line 19 def type case @type when "api_key" "apiKey" when "basic_auth" "basicAuth" end end |