Class: Rack::JsonSchema::Docs::DocumentGenerator

Inherits:
Object
  • Object
show all
Defined in:
lib/rack/json_schema/docs.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(app: nil, env: nil, html: nil, markdown: nil, path: nil) ⇒ DocumentGenerator

Returns a new instance of DocumentGenerator.

Parameters:

  • app (Object) (defaults to: nil)

    Rack application

  • env (Hash) (defaults to: nil)

    Rack env

  • html (String) (defaults to: nil)

    HTML rendered docs

  • markdown (String) (defaults to: nil)

    Markdown rendered docs

  • path (String) (defaults to: nil)

    Route for docs



46
47
48
49
50
51
52
# File 'lib/rack/json_schema/docs.rb', line 46

def initialize(app: nil, env: nil, html: nil, markdown: nil, path: nil)
  @app = app
  @env = env
  @html = html
  @markdown = markdown
  @path = path
end

Class Method Details

.call(*args) ⇒ Object



37
38
39
# File 'lib/rack/json_schema/docs.rb', line 37

def self.call(*args)
  new(*args).call
end

Instance Method Details

#callArray

Generates suited response body from given env & document to docs request

Returns:

  • (Array)

    Rack response



56
57
58
59
60
61
62
63
64
65
66
# File 'lib/rack/json_schema/docs.rb', line 56

def call
  if has_docs_request?
    if has_markdown_request?
      markdown_response
    else
      html_response
    end
  else
    delegate
  end
end