cicd
This commit is contained in:
47
PARR.API/Installers/SwaggerInstaller.cs
Normal file
47
PARR.API/Installers/SwaggerInstaller.cs
Normal file
@@ -0,0 +1,47 @@
|
||||
using Microsoft.OpenApi.Models;
|
||||
using System.Reflection;
|
||||
|
||||
namespace PARR.API.Installers
|
||||
{
|
||||
public static class SwaggerInstaller
|
||||
{
|
||||
public static void InstallSwaggerService(this IServiceCollection services, IConfiguration configuration)
|
||||
{
|
||||
// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
|
||||
services.AddEndpointsApiExplorer();
|
||||
|
||||
var version = Assembly.GetEntryAssembly()?.GetCustomAttribute<AssemblyInformationalVersionAttribute>()?.InformationalVersion ?? "1.0.0";
|
||||
|
||||
services.AddSwaggerGen(x =>
|
||||
{
|
||||
//TODO:
|
||||
x.SwaggerDoc(
|
||||
"v1",
|
||||
new OpenApiInfo
|
||||
{
|
||||
Title = "GEO API",
|
||||
Version = $"v{version}",
|
||||
Description = "API for the project \"GEO DVGD\"",
|
||||
Contact = new OpenApiContact { Email = "IVC_TrubnikovME@dvgd.rzd;IVC_KuznetsovMV@dvgd.rzd", Name = "Trubnikov M.E., Kuznetsov M.V." },
|
||||
License = new OpenApiLicense { Name = "© PTK-DVGD Software LLC" }
|
||||
});
|
||||
|
||||
// Set the comments path for the Swagger JSON and UI.
|
||||
var xmlFile = $"{Assembly.GetExecutingAssembly().GetName().Name}.xml";
|
||||
var xmlPath = Path.Combine(AppContext.BaseDirectory, xmlFile);
|
||||
x.IncludeXmlComments(xmlPath);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
public static void InstallSwagger(this WebApplication app)
|
||||
{
|
||||
// Configure the HTTP request pipeline.
|
||||
if (app.Environment.IsDevelopment())
|
||||
{
|
||||
app.UseSwagger();
|
||||
app.UseSwaggerUI();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user