Class: Docit::UI::SwaggerRenderer
- Inherits:
-
BaseRenderer
- Object
- BaseRenderer
- Docit::UI::SwaggerRenderer
- Defined in:
- lib/docit/ui/swagger_renderer.rb
Constant Summary collapse
- VERSION =
"5.32.2"
Instance Attribute Summary
Attributes inherited from BaseRenderer
Instance Method Summary collapse
Methods inherited from BaseRenderer
Constructor Details
This class inherits a constructor from Docit::UI::BaseRenderer
Instance Method Details
#render ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/docit/ui/swagger_renderer.rb', line 8 def render <<~HTML <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>#{title}</title> <link rel="stylesheet" href="https://unpkg.com/swagger-ui-dist@#{VERSION}/swagger-ui.css" /> <style> html { box-sizing: border-box; overflow-y: scroll; } *, *:before, *:after { box-sizing: inherit; } body { margin: 0; background: #fafafa; } </style> </head> <body> #{(active: :swagger)} <div id="swagger-ui"></div> <script src="https://unpkg.com/swagger-ui-dist@#{VERSION}/swagger-ui-bundle.js"></script> <script> SwaggerUIBundle({ url: #{spec_url_json}, dom_id: '#swagger-ui', presets: [ SwaggerUIBundle.presets.apis, SwaggerUIBundle.SwaggerUIStandalonePreset ], layout: "BaseLayout", deepLinking: true, showExtensions: true, showCommonExtensions: true, requestInterceptor: function(req) { var url = new URL(req.url); url.protocol = window.location.protocol; url.host = window.location.host; req.url = url.toString(); return req; } }) </script> </body> </html> HTML end |