Class: SwaggerDocsRails::Configuration
- Inherits:
-
Object
- Object
- SwaggerDocsRails::Configuration
- Defined in:
- lib/swagger_docs_rails/configuration.rb
Instance Attribute Summary collapse
-
#additional_controller_paths ⇒ Object
Returns the value of attribute additional_controller_paths.
-
#description ⇒ Object
Returns the value of attribute description.
-
#enabled ⇒ Object
Returns the value of attribute enabled.
-
#global_security ⇒ Object
Returns the value of attribute global_security.
-
#live_reload ⇒ Object
Returns the value of attribute live_reload.
-
#output_path ⇒ Object
Returns the value of attribute output_path.
-
#password ⇒ Object
Returns the value of attribute password.
-
#security_schemes ⇒ Object
Returns the value of attribute security_schemes.
-
#server_url ⇒ Object
Returns the value of attribute server_url.
-
#title ⇒ Object
Returns the value of attribute title.
-
#username ⇒ Object
Returns the value of attribute username.
-
#version ⇒ Object
Returns the value of attribute version.
Instance Method Summary collapse
- #esquemas_seguranca_padrao ⇒ Object
-
#initialize ⇒ Configuration
constructor
A new instance of Configuration.
- #openapi_global_security ⇒ Object
- #openapi_security_schemes ⇒ Object
- #to_generator_config ⇒ Object
Constructor Details
#initialize ⇒ Configuration
Returns a new instance of Configuration.
10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/swagger_docs_rails/configuration.rb', line 10 def initialize @enabled = !Rails.env.production? @title = Rails.application.class.module_parent_name @version = "1.0.0" @description = "Documentação OpenAPI gerada automaticamente" @server_url = ENV.fetch("HOST_URL", "/") @live_reload = Rails.env.development? @username = ENV.fetch("SWAGGER_USER", "admin") @password = ENV.fetch("SWAGGER_PASSWORD", "") @additional_controller_paths = [] @output_path = Rails.root.join("public", "swagger", "openapi.json") @security_schemes = esquemas_seguranca_padrao @global_security = [{ BearerAuth: [] }] end |
Instance Attribute Details
#additional_controller_paths ⇒ Object
Returns the value of attribute additional_controller_paths.
5 6 7 |
# File 'lib/swagger_docs_rails/configuration.rb', line 5 def additional_controller_paths @additional_controller_paths end |
#description ⇒ Object
Returns the value of attribute description.
5 6 7 |
# File 'lib/swagger_docs_rails/configuration.rb', line 5 def description @description end |
#enabled ⇒ Object
Returns the value of attribute enabled.
5 6 7 |
# File 'lib/swagger_docs_rails/configuration.rb', line 5 def enabled @enabled end |
#global_security ⇒ Object
Returns the value of attribute global_security.
5 6 7 |
# File 'lib/swagger_docs_rails/configuration.rb', line 5 def global_security @global_security end |
#live_reload ⇒ Object
Returns the value of attribute live_reload.
5 6 7 |
# File 'lib/swagger_docs_rails/configuration.rb', line 5 def live_reload @live_reload end |
#output_path ⇒ Object
Returns the value of attribute output_path.
5 6 7 |
# File 'lib/swagger_docs_rails/configuration.rb', line 5 def output_path @output_path end |
#password ⇒ Object
Returns the value of attribute password.
5 6 7 |
# File 'lib/swagger_docs_rails/configuration.rb', line 5 def password @password end |
#security_schemes ⇒ Object
Returns the value of attribute security_schemes.
5 6 7 |
# File 'lib/swagger_docs_rails/configuration.rb', line 5 def security_schemes @security_schemes end |
#server_url ⇒ Object
Returns the value of attribute server_url.
5 6 7 |
# File 'lib/swagger_docs_rails/configuration.rb', line 5 def server_url @server_url end |
#title ⇒ Object
Returns the value of attribute title.
5 6 7 |
# File 'lib/swagger_docs_rails/configuration.rb', line 5 def title @title end |
#username ⇒ Object
Returns the value of attribute username.
5 6 7 |
# File 'lib/swagger_docs_rails/configuration.rb', line 5 def username @username end |
#version ⇒ Object
Returns the value of attribute version.
5 6 7 |
# File 'lib/swagger_docs_rails/configuration.rb', line 5 def version @version end |
Instance Method Details
#esquemas_seguranca_padrao ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/swagger_docs_rails/configuration.rb', line 25 def esquemas_seguranca_padrao [ { name: "BearerAuth", type: :http, scheme: "bearer", bearer_format: "JWT", description: "Token JWT (header Authorization: Bearer <token>)" } ] end |
#openapi_global_security ⇒ Object
41 42 43 |
# File 'lib/swagger_docs_rails/configuration.rb', line 41 def openapi_global_security SecuritySchemeBuilder.build_global_security(global_security) end |
#openapi_security_schemes ⇒ Object
37 38 39 |
# File 'lib/swagger_docs_rails/configuration.rb', line 37 def openapi_security_schemes SecuritySchemeBuilder.build_all(security_schemes) end |
#to_generator_config ⇒ Object
45 46 47 48 49 50 51 52 53 54 |
# File 'lib/swagger_docs_rails/configuration.rb', line 45 def to_generator_config { title: title, version: version, description: description, server_url: server_url, security_schemes: openapi_security_schemes, global_security: openapi_global_security } end |