Class: Docit::Configuration
- Inherits:
-
Object
- Object
- Docit::Configuration
- Defined in:
- lib/docit/configuration.rb
Overview
Holds global API documentation settings: metadata, authentication, tags, and servers.
Instance Attribute Summary collapse
-
#base_url ⇒ Object
Returns the value of attribute base_url.
-
#description ⇒ Object
Returns the value of attribute description.
-
#title ⇒ Object
Returns the value of attribute title.
-
#version ⇒ Object
Returns the value of attribute version.
Instance Method Summary collapse
- #auth(type, **options) ⇒ Object
-
#initialize ⇒ Configuration
constructor
A new instance of Configuration.
- #security_schemes ⇒ Object
- #server(url, description: nil) ⇒ Object
- #servers ⇒ Object
- #tag(name, description: nil) ⇒ Object
- #tags ⇒ Object
Constructor Details
#initialize ⇒ Configuration
Returns a new instance of Configuration.
8 9 10 11 12 13 14 15 16 |
# File 'lib/docit/configuration.rb', line 8 def initialize @title = "API Documentation" @version = "1.0.0" @description = "" @base_url = "/" @security_schemes = {} @tags = [] @servers = [] end |
Instance Attribute Details
#base_url ⇒ Object
Returns the value of attribute base_url.
6 7 8 |
# File 'lib/docit/configuration.rb', line 6 def base_url @base_url end |
#description ⇒ Object
Returns the value of attribute description.
6 7 8 |
# File 'lib/docit/configuration.rb', line 6 def description @description end |
#title ⇒ Object
Returns the value of attribute title.
6 7 8 |
# File 'lib/docit/configuration.rb', line 6 def title @title end |
#version ⇒ Object
Returns the value of attribute version.
6 7 8 |
# File 'lib/docit/configuration.rb', line 6 def version @version end |
Instance Method Details
#auth(type, **options) ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/docit/configuration.rb', line 18 def auth(type, **) case type.to_s.downcase when "basic" @security_schemes[:basic_auth] = { type: "http", scheme: "basic" } when "bearer" @security_schemes[:bearer_auth] = { type: "http", scheme: "bearer", bearerFormat: [:bearer_format] || "JWT" } when "api_key" @security_schemes[:api_key] = { type: "apiKey", name: [:name] || "X-API-Key", in: [:location] || "header" } else raise ArgumentError, "Unsupported auth type: #{type}" end end |
#security_schemes ⇒ Object
42 43 44 |
# File 'lib/docit/configuration.rb', line 42 def security_schemes @security_schemes.dup end |
#server(url, description: nil) ⇒ Object
56 57 58 59 60 |
# File 'lib/docit/configuration.rb', line 56 def server(url, description: nil) entry = { url: url.to_s } entry[:description] = description if description @servers << entry end |
#servers ⇒ Object
62 63 64 |
# File 'lib/docit/configuration.rb', line 62 def servers @servers.dup end |
#tag(name, description: nil) ⇒ Object
46 47 48 49 50 |
# File 'lib/docit/configuration.rb', line 46 def tag(name, description: nil) entry = { name: name.to_s } entry[:description] = description if description @tags << entry end |
#tags ⇒ Object
52 53 54 |
# File 'lib/docit/configuration.rb', line 52 def @tags.dup end |