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
30 changes: 5 additions & 25 deletions Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -92,17 +92,6 @@ Follow this example to set up your project with all the features provided by thi
"Url": "https://pandatech.it",
"Email": "info@pandatech.it"
}
},
"SwaggerUi": {
"InjectedCssPaths": [
"/assets/css/panda-style.css"
],
"InjectedJsPaths": [
"/assets/js/docs.js"
]
},
"ScalarUi": {
"FaviconPath": "/assets/images/favicon.svg"
}
}
```
Expand Down Expand Up @@ -186,7 +175,6 @@ of Swashbuckle for generating OpenAPI definitions. Along with this new library,
- **Multiple API Documents:** Easily define and organize multiple API documentation groups.
- **Enum String Values:** Enum string values are automatically displayed in the documentation, simplifying integration
for external partners.
- **Customizable SwaggerUI:** Add custom styles and JavaScript to tailor the UI.
- **Security Schemes:** Configure security headers directly in your OpenAPI settings.

### Adding OpenAPI to Your Project
Expand Down Expand Up @@ -247,17 +235,6 @@ Add the following configuration to your `appsettings.json` file:
"Url": "https://pandatech.it",
"Email": "info@pandatech.it"
}
},
"SwaggerUi": {
"InjectedCssPaths": [
"/assets/css/panda-style.css"
],
"InjectedJsPaths": [
"/assets/js/docs.js"
]
},
"ScalarUi": {
"FaviconPath": "/assets/images/favicon.svg"
}
}
```
Expand Down Expand Up @@ -549,6 +526,7 @@ app.Run();
## Telemetry Integration

Integrate OpenTelemetry for observability, including metrics, traces, and logging:

1. Setup:
```csharp
var builder = WebApplication.CreateBuilder(args);
Expand All @@ -568,14 +546,16 @@ Integrate OpenTelemetry for observability, including metrics, traces, and loggin
- Prometheus exporter

## HealthChecks

- **Startup Validation:** `app.EnsureHealthy()` performs a health check at startup and terminates the application if it
is not healthy.
- **Endpoints Mapping:** `app.MapHealthCheckEndpoints()` maps default health check endpoints to the application.
- **Mapped Endpoints:**
- Ping Endpoint: `url/above-board/ping`
- Health Check Endpoint: `url/above-board/health`
- Ping Endpoint: `url/above-board/ping`
- Health Check Endpoint: `url/above-board/health`

Example:

```csharp
var app = builder.Build();

Expand Down
11 changes: 0 additions & 11 deletions Shared.Kernel.Demo/appsettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -69,16 +69,5 @@
"Url": "https://pandatech.it",
"Email": "info@pandatech.it"
}
},
"SwaggerUi": {
"InjectedCssPaths": [
"/assets/css/panda-style.css"
],
"InjectedJsPaths": [
"/assets/js/docs.js"
]
},
"ScalarUi": {
"FaviconPath": "/assets/images/favicon.svg"
}
}
6 changes: 0 additions & 6 deletions src/SharedKernel/OpenApi/Options/ScalarUiConfig.cs

This file was deleted.

7 changes: 0 additions & 7 deletions src/SharedKernel/OpenApi/Options/SwaggerUiConfig.cs

This file was deleted.

26 changes: 6 additions & 20 deletions src/SharedKernel/OpenApi/UiExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,6 @@ internal static class UiExtensions
{
internal static WebApplication MapSwaggerUi(this WebApplication app, OpenApiConfig openApiConfigConfiguration)
{
var swaggerUiConfig = app.Configuration
.GetSection("SwaggerUi")
.Get<SwaggerUiConfig>();

app.UseSwaggerUI(options =>
{
foreach (var document in openApiConfigConfiguration.Documents)
Expand All @@ -24,7 +20,7 @@ internal static WebApplication MapSwaggerUi(this WebApplication app, OpenApiConf
}

options.RoutePrefix = "swagger";
options.AddPandaOptions(swaggerUiConfig);
options.AddPandaOptions();
});


Expand All @@ -34,7 +30,7 @@ internal static WebApplication MapSwaggerUi(this WebApplication app, OpenApiConf
{
options.SwaggerEndpoint($"{document.GetEndpointUrl()}", document.Title);
options.RoutePrefix = $"doc/{document.GroupName}";
options.AddPandaOptions(swaggerUiConfig);
options.AddPandaOptions();
});
}

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

internal static WebApplication MapScalarUi(this WebApplication app)
{
var scalarConfig = app.Configuration
.GetSection("ScalarUi")
.Get<ScalarUiConfig>();

app.MapScalarApiReference(options =>
{
options.Theme = ScalarTheme.Kepler;
if (scalarConfig?.FaviconPath is not null)
{
options.Favicon = "/swagger-resources/favicon.svg";
}

options.Favicon = "/swagger-resources/favicon.svg";
});
return app;
}
Expand All @@ -63,14 +53,10 @@ private static string GetEndpointUrl(this Document document)
return $"/openapi/{document.GroupName}.json";
}

private static SwaggerUIOptions AddPandaOptions(this SwaggerUIOptions options, SwaggerUiConfig? swaggerUiConfig)
private static SwaggerUIOptions AddPandaOptions(this SwaggerUIOptions options)
{
options.DocExpansion(DocExpansion.None);
if (swaggerUiConfig is null)
{
return options;
}


options.InjectStylesheet("/swagger-resources/panda-style.css");
options.InjectJavascript("/swagger-resources/panda-style.js");

Expand Down
2 changes: 1 addition & 1 deletion src/SharedKernel/SharedKernel.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<PackageReadmeFile>Readme.md</PackageReadmeFile>
<Authors>Pandatech</Authors>
<Copyright>MIT</Copyright>
<Version>1.0.5</Version>
<Version>1.0.6</Version>
<PackageId>Pandatech.SharedKernel</PackageId>
<Title>Pandatech Shared Kernel Library</Title>
<PackageTags>Pandatech, shared kernel, library, OpenAPI, Swagger, utilities, scalar</PackageTags>
Expand Down