Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion app/controllers/api_docs_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,19 @@
#++

class APIDocsController < ApplicationController
before_action :require_login
before_action :require_login,
:check_if_api_docs_enabled
no_authorization_required! :index

helper API::APIDocsHelper

def index
render locals: { turbo_opt_out: true }
end

private

def check_if_api_docs_enabled
render_404 unless Setting.apiv3_docs_enabled?
end
end
31 changes: 23 additions & 8 deletions app/views/api_docs/index.html.erb
Original file line number Diff line number Diff line change
@@ -1,9 +1,24 @@
<%= nonced_javascript_include_tag "openapi-explorer.min.js" %>
<%= nonced_javascript_include_tag variable_asset_path("openapi-explorer.js"), skip_pipeline: true %>

<%= content_tag(
"openapi-explorer",
"",
"spec-url": api_v3_paths.api_spec,
"server-url": api_v3_paths.root_path,
"nav-bg-color": color_by_variable("main-menu-bg-color")
) %>
<%= nonced_javascript_tag do %>
(function() {
// set openapi-explorer parent width and height explicitly to prevent them being set to 100vw/100vh by the script
// which leads to double scroll bars
// https://github.com/Authress-Engineering/openapi-explorer/blob/49d4d32de6fd7b14a8f5f95fbfefa8cd72e72587/src/openapi-explorer.js#L191-L196
const contentBody = document.getElementById('content-body');
if (contentBody) {
contentBody.style.width = 'auto';
contentBody.style.height = 'auto';
}
})();
<% end %>

<%=
content_tag(
"openapi-explorer",
"",
"spec-url": api_v3_paths.api_spec,
"server-url": api_v3_paths.root_path,
"nav-bg-color": color_by_variable("main-menu-bg-color")
)
%>
5 changes: 5 additions & 0 deletions frontend/angular.json
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,11 @@
"input": "node_modules/jquery/dist/jquery.min.js",
"inject": false,
"bundleName": "jquery"
},
{
"input": "node_modules/openapi-explorer/dist/browser/openapi-explorer.min.js",
"inject": false,
"bundleName": "openapi-explorer"
}
]
},
Expand Down
Loading
Loading