Skip to content

Commit f327acf

Browse files
authored
Merge pull request #6 from PandaTechAM/development
code cleanup
2 parents f43844f + 77cb09e commit f327acf

File tree

6 files changed

+12
-70
lines changed

6 files changed

+12
-70
lines changed

Readme.md

Lines changed: 5 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -92,17 +92,6 @@ Follow this example to set up your project with all the features provided by thi
9292
"Url": "https://pandatech.it",
9393
"Email": "[email protected]"
9494
}
95-
},
96-
"SwaggerUi": {
97-
"InjectedCssPaths": [
98-
"/assets/css/panda-style.css"
99-
],
100-
"InjectedJsPaths": [
101-
"/assets/js/docs.js"
102-
]
103-
},
104-
"ScalarUi": {
105-
"FaviconPath": "/assets/images/favicon.svg"
10695
}
10796
}
10897
```
@@ -186,7 +175,6 @@ of Swashbuckle for generating OpenAPI definitions. Along with this new library,
186175
- **Multiple API Documents:** Easily define and organize multiple API documentation groups.
187176
- **Enum String Values:** Enum string values are automatically displayed in the documentation, simplifying integration
188177
for external partners.
189-
- **Customizable SwaggerUI:** Add custom styles and JavaScript to tailor the UI.
190178
- **Security Schemes:** Configure security headers directly in your OpenAPI settings.
191179

192180
### Adding OpenAPI to Your Project
@@ -247,17 +235,6 @@ Add the following configuration to your `appsettings.json` file:
247235
"Url": "https://pandatech.it",
248236
"Email": "[email protected]"
249237
}
250-
},
251-
"SwaggerUi": {
252-
"InjectedCssPaths": [
253-
"/assets/css/panda-style.css"
254-
],
255-
"InjectedJsPaths": [
256-
"/assets/js/docs.js"
257-
]
258-
},
259-
"ScalarUi": {
260-
"FaviconPath": "/assets/images/favicon.svg"
261238
}
262239
}
263240
```
@@ -549,6 +526,7 @@ app.Run();
549526
## Telemetry Integration
550527

551528
Integrate OpenTelemetry for observability, including metrics, traces, and logging:
529+
552530
1. Setup:
553531
```csharp
554532
var builder = WebApplication.CreateBuilder(args);
@@ -568,14 +546,16 @@ Integrate OpenTelemetry for observability, including metrics, traces, and loggin
568546
- Prometheus exporter
569547

570548
## HealthChecks
549+
571550
- **Startup Validation:** `app.EnsureHealthy()` performs a health check at startup and terminates the application if it
572551
is not healthy.
573552
- **Endpoints Mapping:** `app.MapHealthCheckEndpoints()` maps default health check endpoints to the application.
574553
- **Mapped Endpoints:**
575-
- Ping Endpoint: `url/above-board/ping`
576-
- Health Check Endpoint: `url/above-board/health`
554+
- Ping Endpoint: `url/above-board/ping`
555+
- Health Check Endpoint: `url/above-board/health`
577556

578557
Example:
558+
579559
```csharp
580560
var app = builder.Build();
581561

Shared.Kernel.Demo/appsettings.json

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -69,16 +69,5 @@
6969
"Url": "https://pandatech.it",
7070
"Email": "[email protected]"
7171
}
72-
},
73-
"SwaggerUi": {
74-
"InjectedCssPaths": [
75-
"/assets/css/panda-style.css"
76-
],
77-
"InjectedJsPaths": [
78-
"/assets/js/docs.js"
79-
]
80-
},
81-
"ScalarUi": {
82-
"FaviconPath": "/assets/images/favicon.svg"
8372
}
8473
}

src/SharedKernel/OpenApi/Options/ScalarUiConfig.cs

Lines changed: 0 additions & 6 deletions
This file was deleted.

src/SharedKernel/OpenApi/Options/SwaggerUiConfig.cs

Lines changed: 0 additions & 7 deletions
This file was deleted.

src/SharedKernel/OpenApi/UiExtensions.cs

Lines changed: 6 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,6 @@ internal static class UiExtensions
1212
{
1313
internal static WebApplication MapSwaggerUi(this WebApplication app, OpenApiConfig openApiConfigConfiguration)
1414
{
15-
var swaggerUiConfig = app.Configuration
16-
.GetSection("SwaggerUi")
17-
.Get<SwaggerUiConfig>();
18-
1915
app.UseSwaggerUI(options =>
2016
{
2117
foreach (var document in openApiConfigConfiguration.Documents)
@@ -24,7 +20,7 @@ internal static WebApplication MapSwaggerUi(this WebApplication app, OpenApiConf
2420
}
2521

2622
options.RoutePrefix = "swagger";
27-
options.AddPandaOptions(swaggerUiConfig);
23+
options.AddPandaOptions();
2824
});
2925

3026

@@ -34,7 +30,7 @@ internal static WebApplication MapSwaggerUi(this WebApplication app, OpenApiConf
3430
{
3531
options.SwaggerEndpoint($"{document.GetEndpointUrl()}", document.Title);
3632
options.RoutePrefix = $"doc/{document.GroupName}";
37-
options.AddPandaOptions(swaggerUiConfig);
33+
options.AddPandaOptions();
3834
});
3935
}
4036

@@ -43,17 +39,11 @@ internal static WebApplication MapSwaggerUi(this WebApplication app, OpenApiConf
4339

4440
internal static WebApplication MapScalarUi(this WebApplication app)
4541
{
46-
var scalarConfig = app.Configuration
47-
.GetSection("ScalarUi")
48-
.Get<ScalarUiConfig>();
49-
5042
app.MapScalarApiReference(options =>
5143
{
5244
options.Theme = ScalarTheme.Kepler;
53-
if (scalarConfig?.FaviconPath is not null)
54-
{
55-
options.Favicon = "/swagger-resources/favicon.svg";
56-
}
45+
46+
options.Favicon = "/swagger-resources/favicon.svg";
5747
});
5848
return app;
5949
}
@@ -63,14 +53,10 @@ private static string GetEndpointUrl(this Document document)
6353
return $"/openapi/{document.GroupName}.json";
6454
}
6555

66-
private static SwaggerUIOptions AddPandaOptions(this SwaggerUIOptions options, SwaggerUiConfig? swaggerUiConfig)
56+
private static SwaggerUIOptions AddPandaOptions(this SwaggerUIOptions options)
6757
{
6858
options.DocExpansion(DocExpansion.None);
69-
if (swaggerUiConfig is null)
70-
{
71-
return options;
72-
}
73-
59+
7460
options.InjectStylesheet("/swagger-resources/panda-style.css");
7561
options.InjectJavascript("/swagger-resources/panda-style.js");
7662

src/SharedKernel/SharedKernel.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
<PackageReadmeFile>Readme.md</PackageReadmeFile>
99
<Authors>Pandatech</Authors>
1010
<Copyright>MIT</Copyright>
11-
<Version>1.0.5</Version>
11+
<Version>1.0.6</Version>
1212
<PackageId>Pandatech.SharedKernel</PackageId>
1313
<Title>Pandatech Shared Kernel Library</Title>
1414
<PackageTags>Pandatech, shared kernel, library, OpenAPI, Swagger, utilities, scalar</PackageTags>

0 commit comments

Comments
 (0)