Module: Jsapi::Meta::OpenAPI::SecurityScheme
- Defined in:
- lib/jsapi/meta/openapi/security_scheme.rb,
lib/jsapi/meta/openapi/security_scheme/base.rb,
lib/jsapi/meta/openapi/security_scheme/http.rb,
lib/jsapi/meta/openapi/security_scheme/oauth2.rb,
lib/jsapi/meta/openapi/security_scheme/api_key.rb,
lib/jsapi/meta/openapi/security_scheme/http/basic.rb,
lib/jsapi/meta/openapi/security_scheme/http/other.rb,
lib/jsapi/meta/openapi/security_scheme/http/bearer.rb,
lib/jsapi/meta/openapi/security_scheme/open_id_connect.rb
Defined Under Namespace
Modules: HTTP Classes: APIKey, Base, OAuth2, OpenIDConnect
Class Method Summary collapse
-
.new(keywords = {}) ⇒ Object
Creates a security scheme.
Class Method Details
.new(keywords = {}) ⇒ Object
Creates a security scheme. The :type keyword specifies the type of the security scheme to be created. Possible types are:
-
"api_key" -
"basic" -
"http" -
"oauth2" -
"open_id_connect"
Raises an InvalidArgumentError if the given type is invalid.
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/jsapi/meta/openapi/security_scheme.rb', line 24 def new(keywords = {}) type = keywords[:type] keywords = keywords.except(:type) case type&.to_s when 'api_key' APIKey.new(keywords) when 'basic' # OpenAPI 2.0 HTTP.new(keywords.merge(scheme: 'basic')) when 'http' # OpenAPI 3.x HTTP.new(keywords) when 'oauth2' OAuth2.new(keywords) when 'open_id_connect' # OpenAPI 3.x OpenIDConnect.new(keywords) else raise InvalidArgumentError.new( 'type', type, %w[api_key basic http oauth2 open_id_connect] ) end end |