Class: Fakeit::App::Routes::OpenapiRoute

Inherits:
Object
  • Object
show all
Defined in:
lib/fakeit/app/routes/openapi_route.rb

Instance Method Summary collapse

Constructor Details

#initialize(spec_file) ⇒ OpenapiRoute



5
6
7
# File 'lib/fakeit/app/routes/openapi_route.rb', line 5

def initialize(spec_file)
  @specification = Fakeit::Openapi::Specification.new(spec_file)
end

Instance Method Details

#call(request, options) ⇒ Object



9
10
11
12
13
# File 'lib/fakeit/app/routes/openapi_route.rb', line 9

def call(request, options)
  @specification
    .operation(request.request_method.downcase.to_sym, request.path_info, options)
    .then { _1 ? handle(_1, request, options) : Fakeit::App::Helpers::ResponseBuilder.not_found }
end