blob: bfa44b007e59975348b58547e9ada60a23cbdc10 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
|
using System;
using System.IO;
using System.Linq;
using System.Reflection;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.OpenApi.Models;
using Swashbuckle.AspNetCore.SwaggerGen;
namespace DevHive.Web.Configurations.Extensions
{
public static class SwaggerExtensions
{
#pragma warning disable S1075
private const string LicenseName = "GPL-3.0 License";
private const string LicenseUri = "https://github.com/Team-Kaleidoscope/DevHive/blob/main/LICENSE";
private const string TermsOfServiceUri = "https://example.com/terms";
#pragma warning restore S1075
public static void SwaggerConfiguration(this IServiceCollection services)
{
services.AddSwaggerGen(c =>
{
c.SwaggerDoc("v0.1", new OpenApiInfo
{
Version = "v0.1",
Title = "API",
Description = "DevHive Social Media's first official API release",
TermsOfService = new Uri(TermsOfServiceUri),
License = new OpenApiLicense
{
Name = LicenseName,
Url = new Uri(LicenseUri)
}
});
string xmlFile = $"{Assembly.GetExecutingAssembly().GetName().Name}.xml";
string xmlPath = Path.Combine(AppContext.BaseDirectory, xmlFile);
c.IncludeXmlComments(xmlPath);
});
}
public static void UseSwaggerConfiguration(this IApplicationBuilder app)
{
app.UseSwagger();
app.UseSwaggerUI(c =>
{
c.SwaggerEndpoint("/swagger/v0.1/swagger.json", "v0.1");
});
}
}
}
|