Class: OpenapiFirst::Router
- Inherits:
-
Object
- Object
- OpenapiFirst::Router
- Defined in:
- lib/openapi_first/router.rb
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app, options) ⇒ Router
constructor
A new instance of Router.
Constructor Details
#initialize(app, options) ⇒ Router
Returns a new instance of Router.
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/openapi_first/router.rb', line 10 def initialize( app, ) @app = app @raise = .fetch(:raise_error, false) @not_found = .fetch(:not_found, :halt) spec = .fetch(:spec) raise "You have to pass spec: when initializing #{self.class}" unless spec spec = OpenapiFirst.load(spec) unless spec.is_a?(Definition) @filepath = spec.filepath @router = build_router(spec.operations) end |