From 87a2e6f64160994f8d0c2ab63f29647a1aa57ef5 Mon Sep 17 00:00:00 2001 From: Phil Chen <06fahchen@gmail.com> Date: Wed, 8 Jan 2025 14:31:11 +0800 Subject: [PATCH] fix: supports setting a relative path for the API definition URL --- lib/open_api_spex/plug/swagger_ui.ex | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/lib/open_api_spex/plug/swagger_ui.ex b/lib/open_api_spex/plug/swagger_ui.ex index 9fb72986..d1fafb44 100644 --- a/lib/open_api_spex/plug/swagger_ui.ex +++ b/lib/open_api_spex/plug/swagger_ui.ex @@ -90,8 +90,7 @@ defmodule OpenApiSpex.Plug.SwaggerUI do <% end %> window.onload = function() { // Begin Swagger UI call region - const api_spec_url = new URL(window.location); - api_spec_url.pathname = "<%= config.path %>"; + const api_spec_url = new URL("<%= config.path %>", window.location); api_spec_url.hash = ""; const ui = SwaggerUIBundle({ url: api_spec_url.href,