Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added link to pick button #1

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
28 changes: 28 additions & 0 deletions priv/swagger/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,20 @@
// End Swagger UI call region
window.ui = ui
};
document.getElementById("pick").onclick = function () {

windowView();
let url = window.location.search.match(/url=([^&]+)/);
if (url && url.length > 1) {
url = decodeURIComponent(url[1]);
} else {
url = window.location.origin + "/api-docs/apps/pick";
}
// Begin Swagger UI call region
const ui = swaggerBundle(url)
// End Swagger UI call region
window.ui = ui
};
document.getElementById("put-footer").onclick = function () {
windowView();
let url = window.location.search.match(/url=([^&]+)/);
Expand All @@ -174,6 +188,20 @@
// End Swagger UI call region
window.ui = ui
};
document.getElementById("pick-footer").onclick = function () {

windowView();
let url = window.location.search.match(/url=([^&]+)/);
if (url && url.length > 1) {
url = decodeURIComponent(url[1]);
} else {
url = window.location.origin + "/api-docs/apps/pick";
}
// Begin Swagger UI call region
const ui = swaggerBundle(url)
// End Swagger UI call region
window.ui = ui
};

function swaggerBundle(url) {
return SwaggerUIBundle({
Expand Down
4 changes: 3 additions & 1 deletion src/cowboy_swagger_handler.erl
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,9 @@ trails(Options) ->
"/api-docs/apps/gmc", cowboy_swagger_json_handler, Options, MD),
Handler2 = trails:trail(
"/api-docs/apps/butler_server", cowboy_swagger_json_handler, Options, MD),
[Redirect, Handler1,Handler2, Static].
Handler3 = trails:trail(
"/api-docs/apps/pick", cowboy_swagger_json_handler, Options, MD),
[Redirect, Handler1, Handler2, Handler3, Static].

%% @private
-spec cowboy_swagger_priv() -> string().
Expand Down
8 changes: 5 additions & 3 deletions src/cowboy_swagger_json_handler.erl
Original file line number Diff line number Diff line change
Expand Up @@ -49,17 +49,19 @@ handle_get(Req, State) ->
Url = cowboy_req:path(Req),
AppName =
case erlang:binary_to_list(Url) of
"/api-docs/apps/gmc" ->
"/api-docs/apps/gmc" ->
mhs;
"/api-docs/apps/butler_server" ->
application:get_env(cowboy_swagger,root_app, butler_server);
application:get_env(cowboy_swagger, root_app, butler_server);
"/api-docs/apps/pick" ->
ims;
_ ->
undefined
end,
case AppName of
undefined ->
{stop, Req, State};
AppName ->
AppName ->
Path = code:priv_dir(AppName),
{ok, YamlFile} = file:read_file(Path ++ "/swagger.yaml"),
File = unicode:characters_to_list(YamlFile),
Expand Down