Class: Dox::RedoclyAdapter

Inherits:
Object
  • Object
show all
Defined in:
lib/dox/redocly_adapter.rb

Constant Summary collapse

DEFAULT_REDOC_VERSION =
'2.5.1'.freeze

Instance Method Summary collapse

Instance Method Details

#build_html(title, spec) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/dox/redocly_adapter.rb', line 5

def build_html(title, spec)
  <<~HTML
    <!DOCTYPE html>
    <html>
    <head>
      <meta charset="utf-8"/>
      <title>#{title}</title>
      <meta name="viewport" content="width=device-width, initial-scale=1">
      <style>body { margin: 0; padding: 0; }</style>
    </head>
    <body>
      <div id="redoc"></div>
      <script src="https://cdn.redocly.com/redoc/v#{redoc_version}/bundles/redoc.standalone.js"></script>
      <script>
        Redoc.init(#{JSON.generate(spec)}, {}, document.getElementById('redoc'));
      </script>
    </body>
    </html>
  HTML
end