MSHelper.Swagger
1.0.0
dotnet add package MSHelper.Swagger --version 1.0.0
NuGet\Install-Package MSHelper.Swagger -Version 1.0.0
<PackageReference Include="MSHelper.Swagger" Version="1.0.0" />
paket add MSHelper.Swagger --version 1.0.0
#r "nuget: MSHelper.Swagger, 1.0.0"
// Install MSHelper.Swagger as a Cake Addin #addin nuget:?package=MSHelper.Swagger&version=1.0.0 // Install MSHelper.Swagger as a Cake Tool #tool nuget:?package=MSHelper.Swagger&version=1.0.0
MSHelper.Swagger : Autogenerated docs with Swagger
⭐ Star us on GitHub � it motivates us a lot!
Overview
Adds API documentation using Swagger or ReDoc.
Installation
This document is for the latest MSHelper.Swagger 1.0.0 release and later.
dotnet add package MSHelper.Swagger
Dependencies
-- MSHelper
Usage
Extend IMSHelperBuilder
with AddHttpClient()
that will register the required services.
public static IMSHelperBuilder RegisterMSHelper(this IMSHelperBuilder builder)
{
builder.AddHttpClient();
// Other services.
return builder;
}
Then, simply inject IHttpClient
(and optionally HttpClientOptions
to resolve services URLS) to execute HTTP requests.
public class SomeService
{
private readonly string _webService1Url;
private readonly IHttpClient _client;
public SomeService(IHttpClient _client, HttpClientOptions options)
{
_client = _client;
_webService1Url = options.Services["web-service1"];
}
public async Task FooAsync()
{
var dto = await _client.GetAsync<Dto>($"{_webService1Url}/data");
}
}
Options
--- Enabled - determines whether documentation is enabled --- ReDocEnabled - if false SwaggerUI is used to render documentation. Otherwise uses ReDoc --- Name - name of the documentation --- Title - title of the documentation --- Version - version of the documentation --- RoutePrefix - endpoint at which the documentation is going to be available --- IncludeSecurity - determines whether documentation security (via JWT) is going to be activated
appsettings.json
"swagger": {
"enabled": true,
"reDocEnabled": false,
"name": "v1",
"title": "API",
"version": "v1",
"routePrefix": "docs",
"includeSecurity": true
},
Usage
Inside Startup.cs extend IMSHelperBuilder
with AddSwaggerDocs()
and IApplicationBuilder
with UseSwaggerDocs()
:
public IServiceProvider ConfigureServices(this IServiceCollection services)
{
var builder = services.AddMSHelper()
.AddSwaggerDocs();
//other registrations
return builder.Build();
}
public void Configure(this IApplicationBuilder app)
{
app.UseSwaggerDocs();
}
Having this done your docs should be available at http://{host}:{port}/{routePrefix}
Important Note:
All the MSHelper packages are for self learning purposes inspired by Devmentors.io
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net6.0 is compatible. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
-
net6.0
- MSHelper (>= 1.0.0)
- Swashbuckle.AspNetCore (>= 6.4.0)
- Swashbuckle.AspNetCore.Annotations (>= 6.4.0)
- Swashbuckle.AspNetCore.ReDoc (>= 6.4.0)
- Swashbuckle.AspNetCore.Swagger (>= 6.4.0)
- Swashbuckle.AspNetCore.SwaggerGen (>= 6.4.0)
- Swashbuckle.AspNetCore.SwaggerUI (>= 6.4.0)
NuGet packages (1)
Showing the top 1 NuGet packages that depend on MSHelper.Swagger:
Package | Downloads |
---|---|
MSHelper.WebApi.Swagger
MSHelper.WebApi.Swagger - Swagger Integration. |
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|---|---|
1.0.0 | 261 | 10/25/2022 |