GM.Documentation
1.3.0
dotnet add package GM.Documentation --version 1.3.0
NuGet\Install-Package GM.Documentation -Version 1.3.0
<PackageReference Include="GM.Documentation" Version="1.3.0" />
<PackageVersion Include="GM.Documentation" Version="1.3.0" />
<PackageReference Include="GM.Documentation" />
paket add GM.Documentation --version 1.3.0
#r "nuget: GM.Documentation, 1.3.0"
#:package GM.Documentation@1.3.0
#addin nuget:?package=GM.Documentation&version=1.3.0
#tool nuget:?package=GM.Documentation&version=1.3.0
<p align="center"> <img src="https://raw.githubusercontent.com/gmetskhvarishvili/GM.Documentation/master/icon.png" alt="GM.Documentation" width="140" height="140" /> </p>
GM.Documentation
A lightweight, configuration-driven Swagger/OpenAPI setup for ASP.NET Core. Two calls give you a
fully configured Swagger UI — API versioning, FluentValidation rules in the schema, OAuth2 security,
required-header parameters, custom date formatting, and custom CSS/JS — all driven from
configuration. Part of the GM.* family of packages. Targets net10.0.
It builds on Swashbuckle, Asp.Versioning, and MicroElements.Swashbuckle.FluentValidation.
Install
dotnet add package GM.Documentation
Register
using GM.Documentation;
builder.Services.AddGMDocumentation(builder.Configuration, "Swagger");
Use
var app = builder.Build();
app.UseGMDocumentation();
That serves the UI at the app root (/), wires one Swagger document per discovered API version,
and injects Assets/swagger.css + Assets/swagger.js if present.
Configure
Everything comes from the configuration section you name (shape matches SwaggerDocOptions);
every value is optional and falls back to a sensible default:
{
"Swagger": {
"Enabled": true,
"Title": "My API",
"Description": "My API description",
"DateTimeFormat": "dd/MM/yyyy HH:mm",
"Headers": [ "X-Tenant-Id" ],
"Contact": { "Name": "Team", "Email": "team@example.com", "Url": "https://example.com" },
"License": { "Name": "MIT", "Url": "https://opensource.org/licenses/MIT" },
"Authorization": {
"Scheme": "oauth2",
"Name": "Authorization",
"Authority": "https://identity.example.com",
"TokenEndpoint": "https://identity.example.com/connect/token",
"RequiredScopes": "api openid profile",
"Flows": [ "authorizationCode", "clientCredentials" ],
"ClientName": "swagger",
"ClientSecret": "secret"
}
}
}
You can also override options in code — values passed here win over configuration:
builder.Services.AddGMDocumentation(builder.Configuration, "Swagger", new SwaggerDocOptions
{
Title = "Overridden Title"
});
What you get
- API versioning — one Swagger document per
IApiVersionDescriptionProvidergroup (falls back tov1). - FluentValidation in the schema — validators are reflected into the OpenAPI schema.
- OAuth2 security — authorization code, client credentials, password, and implicit flows from config.
- Required headers — headers listed in config are added to every operation.
- Custom date formatting —
DateTime/DateTime?render with your configured format. - Custom UI assets —
Assets/swagger.cssandAssets/swagger.jsare injected when present. - XML comments — every
*.xmldoc file next to the app is included automatically.
Contributing & releases
Versioning is automated from Conventional Commits — see CONTRIBUTING.md.
License
MIT — see LICENSE.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net10.0
- Asp.Versioning.Mvc (>= 10.0.1)
- MicroElements.Swashbuckle.FluentValidation (>= 7.2.1)
- Swashbuckle.AspNetCore.SwaggerGen (>= 10.2.3)
- Swashbuckle.AspNetCore.SwaggerUI (>= 10.2.3)
NuGet packages (1)
Showing the top 1 NuGet packages that depend on GM.Documentation:
| Package | Downloads |
|---|---|
|
GM.API
An opinionated ASP.NET Core Web API starter for .NET. A single AddGMAPI/UseGMAPI pair wires up controllers, CORS, API versioning, Swagger docs, FluentValidation, Serilog, and middlewares for exception handling, request logging (with sensitive-data masking) and request localization. Bundles the GM.API.* companion packages. |
GitHub repositories
This package is not used by any popular GitHub repositories.