class Fakeit::Openapi::Specification
Public Class Methods
new(spec_file)
click to toggle source
# File lib/fakeit/openapi/specification.rb, line 4 def initialize(spec_file) @spec_file = spec_file @mtime = File.mtime(spec_file) if File.exist?(spec_file) @doc = Fakeit::Openapi.load(spec_file) end
Public Instance Methods
operation(method, path, options)
click to toggle source
# File lib/fakeit/openapi/specification.rb, line 10 def operation(method, path, options) reload_spec if @mtime @doc .request_operation(method, path) &.then { Operation.new(_1, options) } end
Private Instance Methods
reload_spec()
click to toggle source
# File lib/fakeit/openapi/specification.rb, line 20 def reload_spec new_mtime = File.mtime(@spec_file) return if @mtime == new_mtime @mtime = new_mtime @doc = Fakeit::Openapi.load(@spec_file) rescue StandardError => _e Logger.warn(Rainbow('Invalid spec file, use previous snapshot instead').red) end