diff --git a/lib/rspec/openapi.rb b/lib/rspec/openapi.rb index 911e407..780b4c3 100644 --- a/lib/rspec/openapi.rb +++ b/lib/rspec/openapi.rb @@ -31,6 +31,9 @@ module RSpec::OpenAPI @path_records = Hash.new { |h, k| h[k] = [] } @ignored_path_params = %i[controller action format] + # This is the configuraion override file name we look for within each path. + @config_filename = 'rspec_openapi.rb' + class << self attr_accessor :path, :title, @@ -48,5 +51,7 @@ class << self :response_headers, :path_records, :ignored_path_params + + attr_reader :config_filename end end diff --git a/lib/rspec/openapi/result_recorder.rb b/lib/rspec/openapi/result_recorder.rb index 418ba3f..440b841 100644 --- a/lib/rspec/openapi/result_recorder.rb +++ b/lib/rspec/openapi/result_recorder.rb @@ -9,6 +9,10 @@ def initialize(path_records) def record_results! title = RSpec::OpenAPI.title @path_records.each do |path, records| + # Look for a path-specific config file and run it. + config_file = File.join(File.dirname(path), RSpec::OpenAPI.config_filename) + eval(File.read(config_file)) if File.exist?(config_file) + RSpec::OpenAPI::SchemaFile.new(path).edit do |spec| schema = RSpec::OpenAPI::DefaultSchema.build(title) schema[:info].merge!(RSpec::OpenAPI.info)