chore: add API documentation to swagger

This commit is contained in:
2025-07-15 20:08:23 +02:00
parent 1da5e47b88
commit 934b69b11b
7 changed files with 107 additions and 16 deletions

View File

@@ -1,8 +1,10 @@
using Microsoft.AspNetCore.Authentication.JwtBearer;
using Microsoft.EntityFrameworkCore;
using Microsoft.IdentityModel.Tokens;
using Microsoft.OpenApi.Models;
using QuotifyBE.Controllers;
using QuotifyBE.Data;
using System.Reflection;
using System.Text;
var builder = WebApplication.CreateBuilder(args);
@@ -46,7 +48,29 @@ builder.Services.AddScoped<GeneralUseHelpers>();
builder.Services.AddControllers();
// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
builder.Services.AddEndpointsApiExplorer();
builder.Services.AddSwaggerGen();
builder.Services.AddSwaggerGen(options =>
{
options.SwaggerDoc("v1", new OpenApiInfo
{
Version = "v1",
Title = "Quotify API",
Description = "An ASP.NET Core Web API for managing quotes",
Contact = new OpenApiContact
{
Name = "Quotify project's production branch",
Url = new Uri("https://quotify.7o7.cx")
},
License = new OpenApiLicense
{
Name = "AGPLv3",
Url = new Uri("https://www.gnu.org/licenses/agpl-3.0.en.html")
}
});
// using System.Reflection;
var xmlFilename = $"{Assembly.GetExecutingAssembly().GetName().Name}.xml";
options.IncludeXmlComments(Path.Combine(AppContext.BaseDirectory, xmlFilename));
});
var app = builder.Build();