Refactor controller OpenAPI tags

This commit is contained in:
Laura Hausmann 2024-01-27 23:26:31 +01:00
parent 6de8ea12e6
commit 3c72d50459
No known key found for this signature in database
GPG key ID: D044E84C5BE01605
7 changed files with 27 additions and 0 deletions

View file

@ -15,6 +15,7 @@ using Newtonsoft.Json.Linq;
namespace Iceshrimp.Backend.Controllers;
[ApiController]
[Tags("ActivityPub")]
[UseNewtonsoftJson]
public class ActivityPubController : Controller {
[HttpGet("/notes/{id}")]

View file

@ -12,6 +12,7 @@ using Microsoft.EntityFrameworkCore;
namespace Iceshrimp.Backend.Controllers;
[ApiController]
[Tags("Authentication")]
[EnableRateLimiting("sliding")]
[Produces("application/json")]
[Route("/api/iceshrimp/v1/auth")]

View file

@ -0,0 +1,21 @@
using System.Net;
using System.Net.Mime;
using Iceshrimp.Backend.Controllers.Schemas;
using Iceshrimp.Backend.Core.Database;
using Iceshrimp.Backend.Core.Database.Tables;
using Iceshrimp.Backend.Core.Helpers;
using Iceshrimp.Backend.Core.Services;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.RateLimiting;
using Microsoft.EntityFrameworkCore;
namespace Iceshrimp.Backend.Controllers.Mastodon;
[ApiController]
[Tags("Mastodon")]
[EnableRateLimiting("sliding")]
[Produces("application/json")]
[Route("/api/v1")]
public class MastodonAuthController() : Controller {
}

View file

@ -6,6 +6,7 @@ using Microsoft.Extensions.Options;
namespace Iceshrimp.Backend.Controllers;
[ApiController]
[Tags("Federation")]
[Route("/nodeinfo")]
public class NodeInfoController(IOptions<Config.InstanceSection> config) : Controller {
[HttpGet("2.1")]

View file

@ -8,6 +8,7 @@ using Microsoft.EntityFrameworkCore;
namespace Iceshrimp.Backend.Controllers;
[ApiController]
[Tags("User")]
[Produces("application/json")]
[EnableRateLimiting("sliding")]
[Route("/api/iceshrimp/v1/user/{id}")]

View file

@ -10,6 +10,7 @@ using Microsoft.Extensions.Options;
namespace Iceshrimp.Backend.Controllers;
[ApiController]
[Tags("Federation")]
[Route("/.well-known")]
public class WellKnownController(IOptions<Config.InstanceSection> config, DatabaseContext db) : Controller {
[HttpGet("webfinger")]

View file

@ -83,6 +83,7 @@ public static class ServiceExtensions {
//TODO: separate limiter for authenticated users, partitioned by user id
//TODO: ipv6 /64 subnet buckets
//TODO: rate limit status headers - maybe switch to https://github.com/stefanprodan/AspNetCoreRateLimit?
//TODO: alternatively just write our own
services.AddRateLimiter(options => {
options.AddSlidingWindowLimiter("sliding", limiterOptions => {
limiterOptions.PermitLimit = 500;