Class: Minitest::OpenAPI::Configuration

Inherits:
Object
  • Object
show all
Defined in:
lib/minitest/openapi/configuration.rb

Overview

Per-suite settings. Configure in test_helper.rb:

Minitest::OpenAPI.configure do |c|
  c.output_path = "openapi/v1/openapi.json"
  c.base = "openapi/base.json"   # or a Hash
end

Constant Summary collapse

DEFAULT_BASE =
{
  "openapi" => "3.0.3",
  "info" => {"title" => "API", "version" => "1.0.0"},
  "components" => {"schemas" => {}}
}.freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfiguration

Returns a new instance of Configuration.



27
28
29
30
31
# File 'lib/minitest/openapi/configuration.rb', line 27

def initialize
  @output_path = "openapi/openapi.json"
  @validate_responses = true
  @base = deep_dup(DEFAULT_BASE)
end

Instance Attribute Details

#baseObject

The base document — everything not derived from tests (info, servers, security schemes, reusable component schemas). A Hash, or a path to a JSON/YAML file. Test-recorded operations are merged into ‘paths`.



36
37
38
# File 'lib/minitest/openapi/configuration.rb', line 36

def base
  @base
end

#output_pathObject

Where openapi:generate writes the document (relative to Rails.root).



16
17
18
# File 'lib/minitest/openapi/configuration.rb', line 16

def output_path
  @output_path
end

#validate_responsesObject

Validate each response body against its declared schema as tests run.



19
20
21
# File 'lib/minitest/openapi/configuration.rb', line 19

def validate_responses
  @validate_responses
end

Instance Method Details

#base_documentObject



47
48
49
# File 'lib/minitest/openapi/configuration.rb', line 47

def base_document
  deep_dup(@base)
end