Class: Gitlab::GrapeOpenapi::Models::SecurityScheme
- Inherits:
-
Object
- Object
- Gitlab::GrapeOpenapi::Models::SecurityScheme
- Defined in:
- lib/gitlab/grape_openapi/models/security_scheme.rb
Overview
Constant Summary collapse
- VALID_TYPES =
%w[apiKey http oauth2 openIdConnect].freeze
- VALID_IN_VALUES =
%w[query header cookie].freeze
- VALID_HTTP_SCHEMES =
%w[basic bearer oauth].freeze
Instance Attribute Summary collapse
-
#bearer_format ⇒ Object
Returns the value of attribute bearer_format.
-
#description ⇒ Object
Returns the value of attribute description.
-
#flows ⇒ Object
Returns the value of attribute flows.
-
#in ⇒ Object
Returns the value of attribute in.
-
#name ⇒ Object
Returns the value of attribute name.
-
#open_id_connect_url ⇒ Object
Returns the value of attribute open_id_connect_url.
-
#scheme ⇒ Object
Returns the value of attribute scheme.
-
#type ⇒ Object
Returns the value of attribute type.
Instance Method Summary collapse
-
#initialize(type:, **options) ⇒ SecurityScheme
constructor
A new instance of SecurityScheme.
- #to_h ⇒ Object
Constructor Details
#initialize(type:, **options) ⇒ SecurityScheme
Returns a new instance of SecurityScheme.
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/gitlab/grape_openapi/models/security_scheme.rb', line 15 def initialize(type:, **) @type = type validate_type! @description = [:description] case @type when 'apiKey' @name = [:name] || raise(ArgumentError, "name is required for apiKey type") @in = [:in] || raise(ArgumentError, "in is required for apiKey type") validate_in! when 'http' @scheme = [:scheme] || raise(ArgumentError, "scheme is required for http type") validate_http_scheme! @bearer_format = [:bearer_format] if @scheme == 'bearer' when 'oauth2' @flows = [:flows] || raise(ArgumentError, "flows is required for oauth2 type") validate_oauth2_flows! when 'openIdConnect' @open_id_connect_url = [:open_id_connect_url] || raise(ArgumentError, "open_id_connect_url is required for openIdConnect type") end end |
Instance Attribute Details
#bearer_format ⇒ Object
Returns the value of attribute bearer_format.
12 13 14 |
# File 'lib/gitlab/grape_openapi/models/security_scheme.rb', line 12 def bearer_format @bearer_format end |
#description ⇒ Object
Returns the value of attribute description.
12 13 14 |
# File 'lib/gitlab/grape_openapi/models/security_scheme.rb', line 12 def description @description end |
#flows ⇒ Object
Returns the value of attribute flows.
12 13 14 |
# File 'lib/gitlab/grape_openapi/models/security_scheme.rb', line 12 def flows @flows end |
#in ⇒ Object
Returns the value of attribute in.
12 13 14 |
# File 'lib/gitlab/grape_openapi/models/security_scheme.rb', line 12 def in @in end |
#name ⇒ Object
Returns the value of attribute name.
12 13 14 |
# File 'lib/gitlab/grape_openapi/models/security_scheme.rb', line 12 def name @name end |
#open_id_connect_url ⇒ Object
Returns the value of attribute open_id_connect_url.
12 13 14 |
# File 'lib/gitlab/grape_openapi/models/security_scheme.rb', line 12 def open_id_connect_url @open_id_connect_url end |
#scheme ⇒ Object
Returns the value of attribute scheme.
12 13 14 |
# File 'lib/gitlab/grape_openapi/models/security_scheme.rb', line 12 def scheme @scheme end |
#type ⇒ Object
Returns the value of attribute type.
12 13 14 |
# File 'lib/gitlab/grape_openapi/models/security_scheme.rb', line 12 def type @type end |
Instance Method Details
#to_h ⇒ Object
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/gitlab/grape_openapi/models/security_scheme.rb', line 39 def to_h hash = { 'type' => @type } hash['description'] = @description if @description case @type when 'apiKey' hash['name'] = @name hash['in'] = @in when 'http' hash['scheme'] = @scheme hash['bearerFormat'] = @bearer_format if @bearer_format when 'oauth2' hash['flows'] = flows_to_hash(@flows) when 'openIdConnect' hash['openIdConnectUrl'] = @open_id_connect_url end hash end |