AP.NET/Program.cs
Gordon Pedersen 2f152a656e Added dbcontext and reference model deps
Reference KristofferStrube.ActivityStreams for models.
His models are very similar to mine, if I put the work in I was planning to for the JSON converters and stuff. Why duplicate efforts when I can just submit PRs to the existing nuget package?
2024-04-22 09:40:14 +10:00

48 lines
1.2 KiB
C#

using Microsoft.OpenApi.Models;
using System.Reflection;
using System.Text.Json.Serialization;
var builder = WebApplication.CreateBuilder(args);
// Add services to the container.
builder.Services.AddControllers().AddJsonOptions(options =>
{
options.JsonSerializerOptions.DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull;
});
// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
builder.Services.AddEndpointsApiExplorer();
builder.Services.AddSwaggerGen(options =>
{
options.SwaggerDoc("v1", new OpenApiInfo
{
Version = "v0.0.1",
Title = "ActivityPub API",
Description = "An ASP.NET Core Web API for ActivityPub C2S and S2S Protocols"
});
var xmlFilename = $"{Assembly.GetExecutingAssembly().GetName().Name}.xml";
options.IncludeXmlComments(Path.Combine(AppContext.BaseDirectory, xmlFilename));
});
var app = builder.Build();
// Configure the HTTP request pipeline.
if (app.Environment.IsDevelopment())
{
app.UseSwagger();
app.UseSwaggerUI(options =>
{
options.SwaggerEndpoint("/swagger/v1/swagger.json", "v1");
options.RoutePrefix = string.Empty;
}); ;
}
app.UseHttpsRedirection();
app.UseAuthorization();
app.MapControllers();
app.Run();