Skip to content

Commit 9445465

Browse files
committed
fix: update version to 1.0.12 and enhance OpenAPI UI middleware with base URL configuration
1 parent 2652e21 commit 9445465

File tree

4 files changed

+8
-5
lines changed

4 files changed

+8
-5
lines changed

src/c-sharp/JakubKozera.OpenApiUi/JakubKozera.OpenApiUi.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<PropertyGroup>
33
<TargetFrameworks>net6.0;net8.0;net9.0</TargetFrameworks>
44
<PackageId>JakubKozera.OpenApiUi</PackageId>
5-
<Version>1.0.11</Version>
5+
<Version>1.0.12</Version>
66
<Authors>Jakub Kozera</Authors>
77
<Description>A .NET library serving OpenAPI UI with HTML/CSS</Description>
88
<PackageTags>openapi;ui;html;css;dotnet</PackageTags>

src/c-sharp/JakubKozera.OpenApiUi/Lib/OpenApiUiMiddleware.cs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,11 +51,13 @@ public static IApplicationBuilder UseOpenApiUi(this IApplicationBuilder app, Ope
5151
{
5252
using var stream = fileInfo.CreateReadStream();
5353
using var reader = new StreamReader(stream);
54-
var content = await reader.ReadToEndAsync();
55-
56-
// Replace the placeholder with the actual OpenAPI spec path
54+
var content = await reader.ReadToEndAsync(); // Replace the placeholder with the actual OpenAPI spec path
5755
content = content.Replace("#swagger_path#", configuration.OpenApiSpecPath);
5856

57+
// Replace the base URL placeholder with the current host
58+
var baseUrl = $"{context.Request.Scheme}://{context.Request.Host}";
59+
content = content.Replace("#base_url#", baseUrl);
60+
5961
// Update resource paths to use the configurable UI path
6062
var uiPath = configuration.OpenApiUiPath.TrimStart('/');
6163
content = content.Replace("bundle.css", $"{uiPath}/bundle.css");

src/core/index.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -567,6 +567,7 @@ <h2 class="text-xl font-semibold text-gray-800 dark:text-white">Code Snippet</h2
567567
<!-- Core/config first -->
568568
<script>
569569
window.swaggerPath = "swagger.json";
570+
window.baseUrl = "#base_url#";
570571
</script>
571572
<script src="js/config.js"></script>
572573
<script src="js/themeManager.js"></script>

src/core/js/config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// Global configuration and state variables
22

33
// API Base URL and other state variables
4-
let baseUrl = "https://localhost:7030/";
4+
let baseUrl = window.baseUrl;
55
window.swaggerData = null;
66
let currentPath = null; // Store the current path
77
let currentMethod = null; // Store the current method

0 commit comments

Comments
 (0)