Class: Miniswag::Configuration
- Inherits:
-
Object
- Object
- Miniswag::Configuration
- Defined in:
- lib/miniswag/configuration.rb
Instance Attribute Summary collapse
-
#dry_run ⇒ Object
Returns the value of attribute dry_run.
-
#openapi_all_properties_required ⇒ Object
Returns the value of attribute openapi_all_properties_required.
-
#openapi_format ⇒ Object
Returns the value of attribute openapi_format.
-
#openapi_no_additional_properties ⇒ Object
Returns the value of attribute openapi_no_additional_properties.
-
#openapi_root ⇒ Object
Returns the value of attribute openapi_root.
-
#openapi_specs ⇒ Object
Returns the value of attribute openapi_specs.
Instance Method Summary collapse
- #get_openapi_spec(name) ⇒ Object
-
#initialize ⇒ Configuration
constructor
A new instance of Configuration.
- #validate! ⇒ Object
Constructor Details
#initialize ⇒ Configuration
Returns a new instance of Configuration.
9 10 11 12 13 14 15 16 |
# File 'lib/miniswag/configuration.rb', line 9 def initialize @openapi_root = nil @openapi_specs = {} @openapi_format = :json @openapi_all_properties_required = false @openapi_no_additional_properties = false @dry_run = ENV.key?('MINISWAG_DRY_RUN') ? ENV['MINISWAG_DRY_RUN'] == '1' : true end |
Instance Attribute Details
#dry_run ⇒ Object
Returns the value of attribute dry_run.
5 6 7 |
# File 'lib/miniswag/configuration.rb', line 5 def dry_run @dry_run end |
#openapi_all_properties_required ⇒ Object
Returns the value of attribute openapi_all_properties_required.
5 6 7 |
# File 'lib/miniswag/configuration.rb', line 5 def openapi_all_properties_required @openapi_all_properties_required end |
#openapi_format ⇒ Object
Returns the value of attribute openapi_format.
5 6 7 |
# File 'lib/miniswag/configuration.rb', line 5 def openapi_format @openapi_format end |
#openapi_no_additional_properties ⇒ Object
Returns the value of attribute openapi_no_additional_properties.
5 6 7 |
# File 'lib/miniswag/configuration.rb', line 5 def openapi_no_additional_properties @openapi_no_additional_properties end |
#openapi_root ⇒ Object
Returns the value of attribute openapi_root.
5 6 7 |
# File 'lib/miniswag/configuration.rb', line 5 def openapi_root @openapi_root end |
#openapi_specs ⇒ Object
Returns the value of attribute openapi_specs.
5 6 7 |
# File 'lib/miniswag/configuration.rb', line 5 def openapi_specs @openapi_specs end |
Instance Method Details
#get_openapi_spec(name) ⇒ Object
18 19 20 21 22 23 |
# File 'lib/miniswag/configuration.rb', line 18 def get_openapi_spec(name) return openapi_specs.values.first if name.nil? raise ConfigurationError, "Unknown openapi_spec '#{name}'" unless openapi_specs[name] openapi_specs[name] end |
#validate! ⇒ Object
25 26 27 28 29 30 31 32 33 |
# File 'lib/miniswag/configuration.rb', line 25 def validate! raise ConfigurationError, 'No openapi_root provided. See openapi_helper.rb' if openapi_root.nil? if openapi_specs.nil? || openapi_specs.empty? raise ConfigurationError, 'No openapi_specs defined. See openapi_helper.rb' end return if %i[json yaml].include?(openapi_format) raise ConfigurationError, "Unknown openapi_format '#{openapi_format}'" end |