Class: Rack::JsonSchema::SchemaProvider
- Inherits:
-
Object
- Object
- Rack::JsonSchema::SchemaProvider
- Defined in:
- lib/rack/json_schema/schema_provider.rb
Constant Summary collapse
- DEFAULT_PATH =
"/schema"
Instance Method Summary collapse
-
#call(env) ⇒ Array
Returns rendered document for document request.
-
#initialize(app, path: nil, schema: nil) ⇒ SchemaProvider
constructor
Behaves as a rack-middleware.
Constructor Details
#initialize(app, path: nil, schema: nil) ⇒ SchemaProvider
Behaves as a rack-middleware
11 12 13 14 15 |
# File 'lib/rack/json_schema/schema_provider.rb', line 11 def initialize(app, path: nil, schema: nil) @app = app @path = path @schema = schema end |
Instance Method Details
#call(env) ⇒ Array
Returns rendered document for document request
20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/rack/json_schema/schema_provider.rb', line 20 def call(env) if env["REQUEST_METHOD"] == "GET" && env["PATH_INFO"] == path [ 200, { "Content-Type" => "application/json" }, [rendered_schema], ] else @app.call(env) end end |