0

I want to integrate swagger UI into my ruby based slate generated API docs , for that I looked up here

and did the directed changes to the layout.erb file adding the required head and body sections but upon building the webpage nothing shows up , these are the modified head and body section.

<head>
<meta charset="utf-8">
<meta content="IE=edge,chrome=1" http-equiv="X-UA-Compatible">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
<title><%= current_page.data.title || "API Documentation" %></title>

<link rel="stylesheet" type="text/css" href="swagger-ui.css">

<style>
  <%= Rouge::Themes::MonokaiSublime.render(:scope => '.highlight') %>
</style>
<%= stylesheet_link_tag :screen, media: :screen %>
<%= stylesheet_link_tag :print, media: :print %>
<% if current_page.data.search %>
  <%= javascript_include_tag  "all" %>
<% else %>
  <%= javascript_include_tag  "all_nosearch" %>
<% end %>
<body class="<%= page_classes %>" data-languages="<%=h language_tabs.map{ |lang| lang.is_a?(Hash) ? lang.keys.first : lang }.to_json %>">




<div id="swagger-ui"></div>

<script src="swagger-ui-bundle.js"></script>
<script src="swagger-ui-standalone-preset.js"></script>

<script>
  window.onload = function() {
    const ui = SwaggerUIBundle({
      url: "https://qa-refapp.openmrs.org/openmrs/module/webservices/rest/swagger.json",
      dom_id: '#swagger-ui',
      presets: [
        SwaggerUIBundle.presets.apis,
        SwaggerUIStandalonePreset
      ]
    })

    window.ui = ui
   }
</script>

I added the complete layout.erb file here

Saurabh Kumar
  • 437
  • 1
  • 5
  • 18
  • Is there any error in browser console? – Klio Jun 25 '20 at 13:03
  • no error is there just a warning about wdm polling changes – Saurabh Kumar Jun 25 '20 at 13:12
  • what is html page source generated for this file? – Klio Jun 25 '20 at 20:43
  • I dont have any idea how to check it. do I just need to lookup the developers console?? – Saurabh Kumar Jun 26 '20 at 06:24
  • 1
    Right click in browser window and select something like View page source in the context menu – Klio Jun 26 '20 at 11:50
  • https://pastebin.com/XUZthJE4 here is the pasteBin its quite long though!! – Saurabh Kumar Jun 26 '20 at 13:27
  • I put this file you show along with swagger ui js\css files, in my site directory and all works. Probably your swagger document is not available because of CORS? try to copy this file "https://qa-refapp.openmrs.org/openmrs/module/webservices/rest/swagger.json" into the folder you put everything and use it from there, just for test. – Klio Jun 28 '20 at 02:35
  • and how do I replace the url mentioned above should I replace it with the file directory address? – Saurabh Kumar Jun 28 '20 at 14:57

0 Answers0