diff options
author | crupest <crupest@outlook.com> | 2020-08-20 00:39:09 +0800 |
---|---|---|
committer | crupest <crupest@outlook.com> | 2020-08-20 00:39:09 +0800 |
commit | 32fdf425e6b4f4edfb727fb3c0cbebe2c87fd663 (patch) | |
tree | ba373b6b022d96cc0b3723d693296b42374ec465 /Timeline/Startup.cs | |
parent | 44b410f359f64e6cb69d506b5689d2b3df715c74 (diff) | |
download | timeline-32fdf425e6b4f4edfb727fb3c0cbebe2c87fd663.tar.gz timeline-32fdf425e6b4f4edfb727fb3c0cbebe2c87fd663.tar.bz2 timeline-32fdf425e6b4f4edfb727fb3c0cbebe2c87fd663.zip |
...
Diffstat (limited to 'Timeline/Startup.cs')
-rw-r--r-- | Timeline/Startup.cs | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/Timeline/Startup.cs b/Timeline/Startup.cs index be2377b9..3e5dd24d 100644 --- a/Timeline/Startup.cs +++ b/Timeline/Startup.cs @@ -7,6 +7,8 @@ using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.DependencyInjection.Extensions;
using Microsoft.Extensions.Hosting;
+using NSwag;
+using NSwag.Generation.Processors.Security;
using System;
using System.ComponentModel;
using System.Text.Json.Serialization;
@@ -95,6 +97,23 @@ namespace Timeline options.UseSqlite($"Data Source={pathProvider.GetDatabaseFilePath()}");
});
+ services.AddSwaggerDocument(document =>
+ {
+ document.DocumentName = "Timeline";
+ document.Title = "Timeline REST API Reference";
+ document.Version = typeof(Startup).Assembly.GetName().Version?.ToString() ?? "unknown version";
+ document.DocumentProcessors.Add(
+ new SecurityDefinitionAppender("JWT",
+ new OpenApiSecurityScheme
+ {
+ Type = OpenApiSecuritySchemeType.ApiKey,
+ Name = "Authorization",
+ In = OpenApiSecurityApiKeyLocation.Header,
+ Description = "Type into the textbox: Bearer {your JWT token}."
+ }));
+ document.OperationProcessors.Add(new AspNetCoreOperationSecurityScopeProcessor("JWT"));
+ });
+
if (!disableFrontEnd)
{
if (useMockFrontEnd)
@@ -129,6 +148,9 @@ namespace Timeline });
}
+ app.UseOpenApi();
+ app.UseSwaggerUi3();
+
app.UseAuthentication();
app.UseAuthorization();
|