diff --git a/Iceshrimp.Backend/Controllers/ActivityPubController.cs b/Iceshrimp.Backend/Controllers/ActivityPubController.cs index 72c0bfd3..5b572a2e 100644 --- a/Iceshrimp.Backend/Controllers/ActivityPubController.cs +++ b/Iceshrimp.Backend/Controllers/ActivityPubController.cs @@ -1,4 +1,3 @@ -using System.Net.Mime; using System.Text; using Iceshrimp.Backend.Controllers.Attributes; using Iceshrimp.Backend.Controllers.Schemas; @@ -17,12 +16,12 @@ namespace Iceshrimp.Backend.Controllers; [ApiController] [Tags("ActivityPub")] [UseNewtonsoftJson] +[Produces("application/activity+json", "application/ld+json; profile=\"https://www.w3.org/ns/activitystreams\"")] public class ActivityPubController : Controller { [HttpGet("/notes/{id}")] [AuthorizedFetch] [MediaTypeRouteFilter("application/activity+json", "application/ld+json")] - [Produces("application/activity+json", "application/ld+json; profile=\"https://www.w3.org/ns/activitystreams\"")] [ProducesResponseType(StatusCodes.Status200OK, Type = typeof(ASNote))] [ProducesResponseType(StatusCodes.Status401Unauthorized, Type = typeof(ErrorResponse))] [ProducesResponseType(StatusCodes.Status404NotFound, Type = typeof(ErrorResponse))] @@ -45,7 +44,6 @@ public class ActivityPubController : Controller [HttpGet("/users/{id}")] [AuthorizedFetch] [MediaTypeRouteFilter("application/activity+json", "application/ld+json")] - [Produces("application/activity+json", "application/ld+json; profile=\"https://www.w3.org/ns/activitystreams\"")] [ProducesResponseType(StatusCodes.Status200OK, Type = typeof(ASActor))] [ProducesResponseType(StatusCodes.Status404NotFound, Type = typeof(ErrorResponse))] public async Task GetUser( @@ -63,7 +61,6 @@ public class ActivityPubController : Controller [HttpGet("/@{acct}")] [AuthorizedFetch] [MediaTypeRouteFilter("application/activity+json", "application/ld+json")] - [Produces("application/activity+json", "application/ld+json; profile=\"https://www.w3.org/ns/activitystreams\"")] [ProducesResponseType(StatusCodes.Status200OK, Type = typeof(ASActor))] [ProducesResponseType(StatusCodes.Status404NotFound, Type = typeof(ErrorResponse))] public async Task GetUserByUsername( @@ -93,7 +90,7 @@ public class ActivityPubController : Controller [AuthorizedFetch(true)] [EnableRequestBuffering(1024 * 1024)] [Produces("text/plain")] - [Consumes(MediaTypeNames.Application.Json)] + [Consumes("application/activity+json", "application/ld+json; profile=\"https://www.w3.org/ns/activitystreams\"")] public async Task Inbox(string? id, [FromServices] QueueService queues) { using var reader = new StreamReader(Request.Body, Encoding.UTF8, true, 1024, true); diff --git a/Iceshrimp.Backend/Controllers/AdminController.cs b/Iceshrimp.Backend/Controllers/AdminController.cs index 8db04350..8cb33254 100644 --- a/Iceshrimp.Backend/Controllers/AdminController.cs +++ b/Iceshrimp.Backend/Controllers/AdminController.cs @@ -1,4 +1,5 @@ using System.Diagnostics.CodeAnalysis; +using System.Net.Mime; using Iceshrimp.Backend.Controllers.Schemas; using Iceshrimp.Backend.Core.Database; using Iceshrimp.Backend.Core.Database.Tables; @@ -16,6 +17,7 @@ namespace Iceshrimp.Backend.Controllers; [ProducesResponseType(StatusCodes.Status403Forbidden, Type = typeof(ErrorResponse))] [SuppressMessage("ReSharper", "SuggestBaseTypeForParameterInConstructor", Justification = "We only have a DatabaseContext in our DI pool, not the base type")] +[Produces(MediaTypeNames.Application.Json)] public class AdminController(DatabaseContext db) : Controller { [HttpPost("invites/generate")] diff --git a/Iceshrimp.Backend/Controllers/AuthController.cs b/Iceshrimp.Backend/Controllers/AuthController.cs index d2cd1b68..f282956d 100644 --- a/Iceshrimp.Backend/Controllers/AuthController.cs +++ b/Iceshrimp.Backend/Controllers/AuthController.cs @@ -15,7 +15,7 @@ namespace Iceshrimp.Backend.Controllers; [ApiController] [Tags("Authentication")] [EnableRateLimiting("sliding")] -[Produces("application/json")] +[Produces(MediaTypeNames.Application.Json)] [Route("/api/iceshrimp/v1/auth")] public class AuthController(DatabaseContext db, UserService userSvc) : Controller { diff --git a/Iceshrimp.Backend/Controllers/FallbackController.cs b/Iceshrimp.Backend/Controllers/FallbackController.cs index 15e874b3..8e44bae9 100644 --- a/Iceshrimp.Backend/Controllers/FallbackController.cs +++ b/Iceshrimp.Backend/Controllers/FallbackController.cs @@ -1,11 +1,12 @@ using System.Net; +using System.Net.Mime; using Iceshrimp.Backend.Controllers.Schemas; using Iceshrimp.Backend.Core.Middleware; using Microsoft.AspNetCore.Mvc; namespace Iceshrimp.Backend.Controllers; -[Produces("application/json")] +[Produces(MediaTypeNames.Application.Json)] public class FallbackController : Controller { [ProducesResponseType(StatusCodes.Status501NotImplemented, Type = typeof(ErrorResponse))] diff --git a/Iceshrimp.Backend/Controllers/IdenticonController.cs b/Iceshrimp.Backend/Controllers/IdenticonController.cs index 3fdc3f29..d4bb1c75 100644 --- a/Iceshrimp.Backend/Controllers/IdenticonController.cs +++ b/Iceshrimp.Backend/Controllers/IdenticonController.cs @@ -1,4 +1,5 @@ using System.IO.Hashing; +using System.Net.Mime; using System.Text; using Microsoft.AspNetCore.Cors; using Microsoft.AspNetCore.Mvc; @@ -12,6 +13,8 @@ namespace Iceshrimp.Backend.Controllers; [ApiController] [EnableCors("drive")] [Route("/identicon/{id}")] +[Produces(MediaTypeNames.Image.Png)] +[ProducesResponseType(StatusCodes.Status200OK, Type = typeof(object))] public class IdenticonController : Controller { [HttpGet] diff --git a/Iceshrimp.Backend/Controllers/Mastodon/AccountController.cs b/Iceshrimp.Backend/Controllers/Mastodon/AccountController.cs index f81297cf..88b53f5f 100644 --- a/Iceshrimp.Backend/Controllers/Mastodon/AccountController.cs +++ b/Iceshrimp.Backend/Controllers/Mastodon/AccountController.cs @@ -1,3 +1,4 @@ +using System.Net.Mime; using Iceshrimp.Backend.Controllers.Attributes; using Iceshrimp.Backend.Controllers.Mastodon.Attributes; using Iceshrimp.Backend.Controllers.Mastodon.Renderers; @@ -21,7 +22,7 @@ namespace Iceshrimp.Backend.Controllers.Mastodon; [EnableCors("mastodon")] [Authenticate] [EnableRateLimiting("sliding")] -[Produces("application/json")] +[Produces(MediaTypeNames.Application.Json)] public class AccountController( DatabaseContext db, UserRenderer userRenderer, @@ -273,7 +274,6 @@ public class AccountController( [HttpGet("{id}/statuses")] [Authorize("read:statuses")] [LinkPagination(20, 40)] - [Produces("application/json")] [ProducesResponseType(StatusCodes.Status200OK, Type = typeof(IEnumerable))] [ProducesResponseType(StatusCodes.Status401Unauthorized, Type = typeof(MastodonErrorResponse))] [ProducesResponseType(StatusCodes.Status403Forbidden, Type = typeof(MastodonErrorResponse))] diff --git a/Iceshrimp.Backend/Controllers/Mastodon/AuthController.cs b/Iceshrimp.Backend/Controllers/Mastodon/AuthController.cs index 8516cffb..5ffced68 100644 --- a/Iceshrimp.Backend/Controllers/Mastodon/AuthController.cs +++ b/Iceshrimp.Backend/Controllers/Mastodon/AuthController.cs @@ -1,3 +1,4 @@ +using System.Net.Mime; using Iceshrimp.Backend.Controllers.Mastodon.Attributes; using Iceshrimp.Backend.Controllers.Mastodon.Schemas; using Iceshrimp.Backend.Core.Database; @@ -15,12 +16,11 @@ namespace Iceshrimp.Backend.Controllers.Mastodon; [MastodonApiController] [EnableRateLimiting("sliding")] [EnableCors("mastodon")] -[Produces("application/json")] +[Produces(MediaTypeNames.Application.Json)] public class AuthController(DatabaseContext db) : Controller { [HttpGet("/api/v1/apps/verify_credentials")] [Authenticate] - [Produces("application/json")] [ProducesResponseType(StatusCodes.Status200OK, Type = typeof(AuthSchemas.VerifyAppCredentialsResponse))] [ProducesResponseType(StatusCodes.Status401Unauthorized, Type = typeof(MastodonErrorResponse))] public IActionResult VerifyAppCredentials() @@ -39,7 +39,6 @@ public class AuthController(DatabaseContext db) : Controller [HttpPost("/api/v1/apps")] [EnableRateLimiting("strict")] [ConsumesHybrid] - [Produces("application/json")] [ProducesResponseType(StatusCodes.Status200OK, Type = typeof(AuthSchemas.RegisterAppResponse))] [ProducesResponseType(StatusCodes.Status400BadRequest, Type = typeof(MastodonErrorResponse))] public async Task RegisterApp([FromHybrid] AuthSchemas.RegisterAppRequest request) @@ -90,7 +89,6 @@ public class AuthController(DatabaseContext db) : Controller [HttpPost("/oauth/token")] [ConsumesHybrid] - [Produces("application/json")] [ProducesResponseType(StatusCodes.Status200OK, Type = typeof(AuthSchemas.OauthTokenResponse))] [ProducesResponseType(StatusCodes.Status400BadRequest, Type = typeof(MastodonErrorResponse))] public async Task GetOauthToken([FromHybrid] AuthSchemas.OauthTokenRequest request) @@ -128,7 +126,6 @@ public class AuthController(DatabaseContext db) : Controller [HttpPost("/oauth/revoke")] [ConsumesHybrid] - [Produces("application/json")] [ProducesResponseType(StatusCodes.Status200OK, Type = typeof(object))] [ProducesResponseType(StatusCodes.Status400BadRequest, Type = typeof(MastodonErrorResponse))] [ProducesResponseType(StatusCodes.Status403Forbidden, Type = typeof(MastodonErrorResponse))] diff --git a/Iceshrimp.Backend/Controllers/Mastodon/InstanceController.cs b/Iceshrimp.Backend/Controllers/Mastodon/InstanceController.cs index fa8e5dfb..3d4cd6bb 100644 --- a/Iceshrimp.Backend/Controllers/Mastodon/InstanceController.cs +++ b/Iceshrimp.Backend/Controllers/Mastodon/InstanceController.cs @@ -1,3 +1,4 @@ +using System.Net.Mime; using Iceshrimp.Backend.Controllers.Mastodon.Attributes; using Iceshrimp.Backend.Controllers.Mastodon.Schemas; using Iceshrimp.Backend.Core.Configuration; @@ -13,11 +14,10 @@ namespace Iceshrimp.Backend.Controllers.Mastodon; [MastodonApiController] [EnableCors("mastodon")] [EnableRateLimiting("sliding")] -[Produces("application/json")] +[Produces(MediaTypeNames.Application.Json)] public class InstanceController(DatabaseContext db) : Controller { [HttpGet("/api/v1/instance")] - [Produces("application/json")] public async Task GetInstanceInfo([FromServices] IOptionsSnapshot config) { var userCount = await db.Users.LongCountAsync(p => p.Host == null); diff --git a/Iceshrimp.Backend/Controllers/Mastodon/MediaController.cs b/Iceshrimp.Backend/Controllers/Mastodon/MediaController.cs index 90234fe1..45b16757 100644 --- a/Iceshrimp.Backend/Controllers/Mastodon/MediaController.cs +++ b/Iceshrimp.Backend/Controllers/Mastodon/MediaController.cs @@ -1,3 +1,4 @@ +using System.Net.Mime; using Iceshrimp.Backend.Controllers.Mastodon.Attributes; using Iceshrimp.Backend.Controllers.Mastodon.Schemas; using Iceshrimp.Backend.Controllers.Mastodon.Schemas.Entities; @@ -14,7 +15,7 @@ namespace Iceshrimp.Backend.Controllers.Mastodon; [Authorize("write:media")] [EnableCors("mastodon")] [EnableRateLimiting("sliding")] -[Produces("application/json")] +[Produces(MediaTypeNames.Application.Json)] [ProducesResponseType(StatusCodes.Status200OK, Type = typeof(AttachmentEntity))] [ProducesResponseType(StatusCodes.Status401Unauthorized, Type = typeof(MastodonErrorResponse))] [ProducesResponseType(StatusCodes.Status403Forbidden, Type = typeof(MastodonErrorResponse))] diff --git a/Iceshrimp.Backend/Controllers/Mastodon/NotificationController.cs b/Iceshrimp.Backend/Controllers/Mastodon/NotificationController.cs index 0c1d9069..68072417 100644 --- a/Iceshrimp.Backend/Controllers/Mastodon/NotificationController.cs +++ b/Iceshrimp.Backend/Controllers/Mastodon/NotificationController.cs @@ -1,3 +1,4 @@ +using System.Net.Mime; using Iceshrimp.Backend.Controllers.Attributes; using Iceshrimp.Backend.Controllers.Mastodon.Attributes; using Iceshrimp.Backend.Controllers.Mastodon.Renderers; @@ -18,13 +19,12 @@ namespace Iceshrimp.Backend.Controllers.Mastodon; [Authenticate] [EnableCors("mastodon")] [EnableRateLimiting("sliding")] -[Produces("application/json")] +[Produces(MediaTypeNames.Application.Json)] public class NotificationController(DatabaseContext db, NotificationRenderer notificationRenderer) : Controller { [HttpGet] [Authorize("read:notifications")] [LinkPagination(40, 80)] - [Produces("application/json")] [ProducesResponseType(StatusCodes.Status200OK, Type = typeof(List))] [ProducesResponseType(StatusCodes.Status404NotFound, Type = typeof(MastodonErrorResponse))] public async Task GetNotifications(MastodonPaginationQuery query) diff --git a/Iceshrimp.Backend/Controllers/Mastodon/SearchController.cs b/Iceshrimp.Backend/Controllers/Mastodon/SearchController.cs index 4b9fce70..05e21e18 100644 --- a/Iceshrimp.Backend/Controllers/Mastodon/SearchController.cs +++ b/Iceshrimp.Backend/Controllers/Mastodon/SearchController.cs @@ -1,4 +1,5 @@ using System.Diagnostics.CodeAnalysis; +using System.Net.Mime; using System.Text.RegularExpressions; using Iceshrimp.Backend.Controllers.Attributes; using Iceshrimp.Backend.Controllers.Mastodon.Attributes; @@ -20,7 +21,7 @@ namespace Iceshrimp.Backend.Controllers.Mastodon; [Authenticate] [EnableCors("mastodon")] [EnableRateLimiting("sliding")] -[Produces("application/json")] +[Produces(MediaTypeNames.Application.Json)] public class SearchController( DatabaseContext db, NoteRenderer noteRenderer, @@ -32,7 +33,6 @@ public class SearchController( [HttpGet("/api/v2/search")] [Authorize("read:search")] [LinkPagination(20, 40)] - [Produces("application/json")] [ProducesResponseType(StatusCodes.Status200OK, Type = typeof(SearchSchemas.SearchResponse))] [ProducesResponseType(StatusCodes.Status404NotFound, Type = typeof(MastodonErrorResponse))] public async Task Search(SearchSchemas.SearchRequest search, MastodonPaginationQuery pagination) diff --git a/Iceshrimp.Backend/Controllers/Mastodon/StatusController.cs b/Iceshrimp.Backend/Controllers/Mastodon/StatusController.cs index ea9117e1..310c5133 100644 --- a/Iceshrimp.Backend/Controllers/Mastodon/StatusController.cs +++ b/Iceshrimp.Backend/Controllers/Mastodon/StatusController.cs @@ -1,3 +1,4 @@ +using System.Net.Mime; using Iceshrimp.Backend.Controllers.Mastodon.Attributes; using Iceshrimp.Backend.Controllers.Mastodon.Renderers; using Iceshrimp.Backend.Controllers.Mastodon.Schemas; @@ -19,7 +20,7 @@ namespace Iceshrimp.Backend.Controllers.Mastodon; [Authenticate] [EnableCors("mastodon")] [EnableRateLimiting("sliding")] -[Produces("application/json")] +[Produces(MediaTypeNames.Application.Json)] public class StatusController( DatabaseContext db, NoteRenderer noteRenderer, @@ -29,7 +30,6 @@ public class StatusController( { [HttpGet("{id}")] [Authenticate("read:statuses")] - [Produces("application/json")] [ProducesResponseType(StatusCodes.Status200OK, Type = typeof(StatusEntity))] [ProducesResponseType(StatusCodes.Status404NotFound, Type = typeof(MastodonErrorResponse))] public async Task GetNote(string id) @@ -48,7 +48,6 @@ public class StatusController( [HttpGet("{id}/context")] [Authenticate("read:statuses")] - [Produces("application/json")] [ProducesResponseType(StatusCodes.Status200OK, Type = typeof(StatusEntity))] [ProducesResponseType(StatusCodes.Status404NotFound, Type = typeof(MastodonErrorResponse))] public async Task GetStatusContext(string id) @@ -80,7 +79,6 @@ public class StatusController( [HttpPost("{id}/favourite")] [Authorize("write:favourites")] - [Produces("application/json")] [ProducesResponseType(StatusCodes.Status200OK, Type = typeof(StatusEntity))] [ProducesResponseType(StatusCodes.Status401Unauthorized, Type = typeof(MastodonErrorResponse))] [ProducesResponseType(StatusCodes.Status403Forbidden, Type = typeof(MastodonErrorResponse))] @@ -100,7 +98,6 @@ public class StatusController( [HttpPost("{id}/unfavourite")] [Authorize("write:favourites")] - [Produces("application/json")] [ProducesResponseType(StatusCodes.Status200OK, Type = typeof(StatusEntity))] [ProducesResponseType(StatusCodes.Status401Unauthorized, Type = typeof(MastodonErrorResponse))] [ProducesResponseType(StatusCodes.Status403Forbidden, Type = typeof(MastodonErrorResponse))] @@ -120,7 +117,6 @@ public class StatusController( [HttpPost] [Authorize("write:statuses")] - [Produces("application/json")] [ProducesResponseType(StatusCodes.Status200OK, Type = typeof(StatusEntity))] [ProducesResponseType(StatusCodes.Status400BadRequest, Type = typeof(MastodonErrorResponse))] public async Task PostNote([FromHybrid] StatusSchemas.PostStatusRequest request) @@ -183,7 +179,6 @@ public class StatusController( [HttpPut("{id}")] [Authorize("write:statuses")] - [Produces("application/json")] [ProducesResponseType(StatusCodes.Status200OK, Type = typeof(StatusEntity))] [ProducesResponseType(StatusCodes.Status400BadRequest, Type = typeof(MastodonErrorResponse))] public async Task EditNote(string id, [FromHybrid] StatusSchemas.EditStatusRequest request) diff --git a/Iceshrimp.Backend/Controllers/Mastodon/TimelineController.cs b/Iceshrimp.Backend/Controllers/Mastodon/TimelineController.cs index 66fe331b..e2a48034 100644 --- a/Iceshrimp.Backend/Controllers/Mastodon/TimelineController.cs +++ b/Iceshrimp.Backend/Controllers/Mastodon/TimelineController.cs @@ -1,3 +1,4 @@ +using System.Net.Mime; using Iceshrimp.Backend.Controllers.Attributes; using Iceshrimp.Backend.Controllers.Mastodon.Attributes; using Iceshrimp.Backend.Controllers.Mastodon.Renderers; @@ -20,14 +21,13 @@ namespace Iceshrimp.Backend.Controllers.Mastodon; [LinkPagination(20, 40)] [EnableRateLimiting("sliding")] [EnableCors("mastodon")] -[Produces("application/json")] +[Produces(MediaTypeNames.Application.Json)] [ProducesResponseType(StatusCodes.Status401Unauthorized, Type = typeof(MastodonErrorResponse))] [ProducesResponseType(StatusCodes.Status403Forbidden, Type = typeof(MastodonErrorResponse))] public class TimelineController(DatabaseContext db, NoteRenderer noteRenderer, IDistributedCache cache) : Controller { [Authorize("read:statuses")] [HttpGet("home")] - [Produces("application/json")] [ProducesResponseType(StatusCodes.Status200OK, Type = typeof(IEnumerable))] public async Task GetHomeTimeline(MastodonPaginationQuery query) { @@ -50,7 +50,6 @@ public class TimelineController(DatabaseContext db, NoteRenderer noteRenderer, I [Authorize("read:statuses")] [HttpGet("public")] - [Produces("application/json")] [ProducesResponseType(StatusCodes.Status200OK, Type = typeof(IEnumerable))] public async Task GetPublicTimeline(MastodonPaginationQuery query) { diff --git a/Iceshrimp.Backend/Controllers/NodeInfoController.cs b/Iceshrimp.Backend/Controllers/NodeInfoController.cs index 34149ab7..6cfce531 100644 --- a/Iceshrimp.Backend/Controllers/NodeInfoController.cs +++ b/Iceshrimp.Backend/Controllers/NodeInfoController.cs @@ -1,3 +1,4 @@ +using System.Net.Mime; using Iceshrimp.Backend.Core.Configuration; using Iceshrimp.Backend.Core.Database; using Iceshrimp.Backend.Core.Federation.WebFinger; @@ -12,11 +13,11 @@ namespace Iceshrimp.Backend.Controllers; [Tags("Federation")] [Route("/nodeinfo")] [EnableCors("well-known")] +[Produces(MediaTypeNames.Application.Json)] public class NodeInfoController(IOptions config, DatabaseContext db) : Controller { [HttpGet("2.1")] [HttpGet("2.0")] - [Produces("application/json")] [ProducesResponseType(StatusCodes.Status200OK, Type = typeof(WebFingerResponse))] public async Task GetNodeInfo() { diff --git a/Iceshrimp.Backend/Controllers/NoteController.cs b/Iceshrimp.Backend/Controllers/NoteController.cs index cd4146cb..20fe859c 100644 --- a/Iceshrimp.Backend/Controllers/NoteController.cs +++ b/Iceshrimp.Backend/Controllers/NoteController.cs @@ -1,3 +1,4 @@ +using System.Net.Mime; using Iceshrimp.Backend.Controllers.Renderers; using Iceshrimp.Backend.Controllers.Schemas; using Iceshrimp.Backend.Core.Database; @@ -12,13 +13,14 @@ using Microsoft.EntityFrameworkCore; namespace Iceshrimp.Backend.Controllers; [ApiController] -[Produces("application/json")] [EnableRateLimiting("sliding")] [Route("/api/iceshrimp/v1/note")] +[Produces(MediaTypeNames.Application.Json)] public class NoteController(DatabaseContext db, NoteService noteSvc) : Controller { [HttpGet("{id}")] [Authenticate] + [Produces(MediaTypeNames.Application.Json)] [ProducesResponseType(StatusCodes.Status200OK, Type = typeof(NoteResponse))] [ProducesResponseType(StatusCodes.Status404NotFound, Type = typeof(ErrorResponse))] public async Task GetNote(string id) @@ -36,10 +38,11 @@ public class NoteController(DatabaseContext db, NoteService noteSvc) : Controlle [HttpPost] [Authenticate, Authorize] + [Consumes(MediaTypeNames.Application.Json)] [ProducesResponseType(StatusCodes.Status200OK, Type = typeof(NoteResponse))] [ProducesResponseType(StatusCodes.Status401Unauthorized, Type = typeof(ErrorResponse))] [ProducesResponseType(StatusCodes.Status403Forbidden, Type = typeof(ErrorResponse))] - public async Task CreateNote([FromBody] NoteCreateRequest request) + public async Task CreateNote(NoteCreateRequest request) { var user = HttpContext.GetUserOrFail(); diff --git a/Iceshrimp.Backend/Controllers/Schemas/NoteCreateRequest.cs b/Iceshrimp.Backend/Controllers/Schemas/NoteCreateRequest.cs index 7b9e4029..6474db9f 100644 --- a/Iceshrimp.Backend/Controllers/Schemas/NoteCreateRequest.cs +++ b/Iceshrimp.Backend/Controllers/Schemas/NoteCreateRequest.cs @@ -4,7 +4,7 @@ namespace Iceshrimp.Backend.Controllers.Schemas; public class NoteCreateRequest { - [J("text")] public required string Text; - [J("cw")] public string? Cw; - [J("replyId")] public string? ReplyId; + [J("text")] public required string Text { get; set; } + [J("cw")] public string? Cw { get; set; } + [J("replyId")] public string? ReplyId { get; set; } } \ No newline at end of file diff --git a/Iceshrimp.Backend/Controllers/TimelineController.cs b/Iceshrimp.Backend/Controllers/TimelineController.cs index ac994586..4fda144b 100644 --- a/Iceshrimp.Backend/Controllers/TimelineController.cs +++ b/Iceshrimp.Backend/Controllers/TimelineController.cs @@ -1,3 +1,4 @@ +using System.Net.Mime; using Iceshrimp.Backend.Controllers.Renderers; using Iceshrimp.Backend.Controllers.Schemas; using Iceshrimp.Backend.Core.Database; @@ -11,9 +12,9 @@ using Microsoft.Extensions.Caching.Distributed; namespace Iceshrimp.Backend.Controllers; [ApiController] -[Produces("application/json")] [EnableRateLimiting("sliding")] [Route("/api/iceshrimp/v1/timeline")] +[Produces(MediaTypeNames.Application.Json)] public class TimelineController(DatabaseContext db, IDistributedCache cache) : Controller { [HttpGet("home")] diff --git a/Iceshrimp.Backend/Controllers/UserController.cs b/Iceshrimp.Backend/Controllers/UserController.cs index 6a389b07..8317711f 100644 --- a/Iceshrimp.Backend/Controllers/UserController.cs +++ b/Iceshrimp.Backend/Controllers/UserController.cs @@ -1,3 +1,4 @@ +using System.Net.Mime; using Iceshrimp.Backend.Controllers.Attributes; using Iceshrimp.Backend.Controllers.Renderers; using Iceshrimp.Backend.Controllers.Schemas; @@ -11,9 +12,9 @@ using Microsoft.EntityFrameworkCore; namespace Iceshrimp.Backend.Controllers; [ApiController] -[Produces("application/json")] [EnableRateLimiting("sliding")] [Route("/api/iceshrimp/v1/user/{id}")] +[Produces(MediaTypeNames.Application.Json)] public class UserController(DatabaseContext db) : Controller { [HttpGet] diff --git a/Iceshrimp.Backend/Controllers/WellKnownController.cs b/Iceshrimp.Backend/Controllers/WellKnownController.cs index e3bf095d..5fa6a1ef 100644 --- a/Iceshrimp.Backend/Controllers/WellKnownController.cs +++ b/Iceshrimp.Backend/Controllers/WellKnownController.cs @@ -1,3 +1,4 @@ +using System.Net.Mime; using Iceshrimp.Backend.Controllers.Schemas; using Iceshrimp.Backend.Core.Configuration; using Iceshrimp.Backend.Core.Database; @@ -17,7 +18,7 @@ namespace Iceshrimp.Backend.Controllers; public class WellKnownController(IOptions config, DatabaseContext db) : Controller { [HttpGet("webfinger")] - [Produces("application/json")] + [Produces(MediaTypeNames.Application.Json)] [ProducesResponseType(StatusCodes.Status200OK, Type = typeof(WebFingerResponse))] [ProducesResponseType(StatusCodes.Status404NotFound, Type = typeof(ErrorResponse))] public async Task WebFinger([FromQuery] string resource) @@ -76,7 +77,7 @@ public class WellKnownController(IOptions config, Databa } [HttpGet("nodeinfo")] - [Produces("application/json")] + [Produces(MediaTypeNames.Application.Json)] [ProducesResponseType(StatusCodes.Status200OK, Type = typeof(NodeInfoIndexResponse))] public IActionResult NodeInfo() { @@ -102,11 +103,12 @@ public class WellKnownController(IOptions config, Databa [HttpGet("host-meta")] [Produces("application/xrd+xml")] - [ProducesResponseType(StatusCodes.Status200OK)] + [ProducesResponseType(StatusCodes.Status200OK, Type = typeof(object))] public IActionResult HostMeta() { //TODO: use a proper xml serializer for this return - Content($$""""""); + Content($$"""""", + "application/xrd+xml"); } } \ No newline at end of file