This commit is contained in:
Natlinux81
2025-04-21 16:55:15 +02:00
commit d5f6034a28
39 changed files with 15372 additions and 0 deletions

53
src/API/Program.cs Normal file
View File

@@ -0,0 +1,53 @@
using API.Extension;
using Microsoft.OpenApi.Models;
using Swashbuckle.AspNetCore.SwaggerGen;
var builder = WebApplication.CreateBuilder(args);
// Add services to the container.
builder.Services.AddEndpointsApiExplorer();
builder.Services.AddControllers();
builder.Services.AddWebServices();
builder.Services.AddCors(options =>
{
options.AddPolicy("AllowLocalhost",
policy =>
{
policy.WithOrigins("http://localhost:44492")
.AllowAnyHeader()
.AllowAnyMethod();
});
});
var app = builder.Build();
// Configure the HTTP request pipeline.
if (app.Environment.IsDevelopment() || app.Environment.IsEnvironment("Test"))
{
app.UseSwagger();
app.UseSwaggerUI();
}
app.UseHttpsRedirection();
app.UseCors("AllowLocalhost");
app.UseAuthentication();
app.UseAuthorization();
app.MapControllers();
app.UseStaticFiles();
app.Run();
public class LowerCaseDocumentFilter : IDocumentFilter
{
public void Apply(OpenApiDocument swaggerDoc, DocumentFilterContext context)
{
// get the paths
var paths = swaggerDoc.Paths.ToDictionary(
path => path.Key.ToLowerInvariant(),
path => swaggerDoc.Paths[path.Key]);
// add the paths
swaggerDoc.Paths = new OpenApiPaths();
foreach (var pathItem in paths) swaggerDoc.Paths.Add(pathItem.Key, pathItem.Value);
}
}