refactor: move files
Some checks failed
.NET Test Pipeline / build-and-test (pull_request) Failing after 1m13s
Some checks failed
.NET Test Pipeline / build-and-test (pull_request) Failing after 1m13s
This commit is contained in:
36
Endpoint/Configuration/ConfigureSwaggerOptions.cs
Normal file
36
Endpoint/Configuration/ConfigureSwaggerOptions.cs
Normal file
@ -0,0 +1,36 @@
|
||||
using Microsoft.AspNetCore.Mvc.ApiExplorer;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Options;
|
||||
using Microsoft.OpenApi.Models;
|
||||
using Swashbuckle.AspNetCore.SwaggerGen;
|
||||
using System;
|
||||
|
||||
namespace Mirea.Api.Endpoint.Configuration;
|
||||
|
||||
public class ConfigureSwaggerOptions(IApiVersionDescriptionProvider provider) : IConfigureOptions<SwaggerGenOptions>
|
||||
{
|
||||
public void Configure(SwaggerGenOptions options)
|
||||
{
|
||||
foreach (var description in provider.ApiVersionDescriptions)
|
||||
{
|
||||
options.SwaggerDoc(description.GroupName, CreateInfoForApiVersion(description));
|
||||
}
|
||||
}
|
||||
|
||||
private static OpenApiInfo CreateInfoForApiVersion(ApiVersionDescription description)
|
||||
{
|
||||
var info = new OpenApiInfo()
|
||||
{
|
||||
Title = "MIREA Schedule Web API",
|
||||
Version = description.ApiVersion.ToString(),
|
||||
Description = "This API provides a convenient interface for retrieving data stored in the database. Special attention was paid to the lightweight and easy transfer of all necessary data. Made by the Winsomnia team.",
|
||||
Contact = new OpenApiContact { Name = "Author name", Email = "support@winsomnia.net" },
|
||||
License = new OpenApiLicense { Name = "MIT", Url = new Uri("https://opensource.org/licenses/MIT") }
|
||||
};
|
||||
|
||||
if (description.IsDeprecated)
|
||||
info.Description += " This API version has been deprecated.";
|
||||
|
||||
return info;
|
||||
}
|
||||
}
|
24
Endpoint/Configuration/EnvironmentManager.cs
Normal file
24
Endpoint/Configuration/EnvironmentManager.cs
Normal file
@ -0,0 +1,24 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
|
||||
namespace Mirea.Api.Endpoint.Configuration;
|
||||
|
||||
internal static class EnvironmentManager
|
||||
{
|
||||
public static void LoadEnvironment(string filePath)
|
||||
{
|
||||
if (!File.Exists(filePath)) return;
|
||||
|
||||
foreach (var line in File.ReadAllLines(filePath))
|
||||
{
|
||||
var parts = line.Split(
|
||||
'=',
|
||||
StringSplitOptions.RemoveEmptyEntries);
|
||||
|
||||
if (parts.Length != 2)
|
||||
continue;
|
||||
|
||||
Environment.SetEnvironmentVariable(parts[0].Trim(), parts[1][..(parts[1].Contains('#') ? parts[1].IndexOf('#') : parts[1].Length)].Trim());
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user