diff --git a/Applications/AdminApi/src/AdminApi/Controllers/ClientsController.cs b/Applications/AdminApi/src/AdminApi/Controllers/ClientsController.cs index a3d6932ae4..33aeec3804 100644 --- a/Applications/AdminApi/src/AdminApi/Controllers/ClientsController.cs +++ b/Applications/AdminApi/src/AdminApi/Controllers/ClientsController.cs @@ -37,7 +37,7 @@ public async Task GetAllClients(CancellationToken cancellationTok } [HttpGet("{id}")] - [ProducesResponseType(typeof(ClientDTO), StatusCodes.Status200OK)] + [ProducesResponseType(typeof(HttpResponseEnvelopeResult), StatusCodes.Status200OK)] [ProducesError(StatusCodes.Status404NotFound)] public async Task GetClient([FromRoute] string id, CancellationToken cancellationToken) { diff --git a/Applications/AdminApi/src/AdminApi/Controllers/IdentitiesController.cs b/Applications/AdminApi/src/AdminApi/Controllers/IdentitiesController.cs index 722c8e9750..48c4924779 100644 --- a/Applications/AdminApi/src/AdminApi/Controllers/IdentitiesController.cs +++ b/Applications/AdminApi/src/AdminApi/Controllers/IdentitiesController.cs @@ -31,7 +31,7 @@ public IdentitiesController(IMediator mediator) : base(mediator) } [HttpPost("{identityAddress}/Quotas")] - [ProducesResponseType(typeof(IndividualQuotaDTO), StatusCodes.Status201Created)] + [ProducesResponseType(typeof(HttpResponseEnvelopeResult), StatusCodes.Status201Created)] [ProducesError(StatusCodes.Status404NotFound)] [ProducesError(StatusCodes.Status400BadRequest)] public async Task CreateIndividualQuota([FromRoute] string identityAddress, [FromBody] CreateQuotaForIdentityRequest request, CancellationToken cancellationToken) @@ -51,7 +51,7 @@ public async Task DeleteIndividualQuota([FromRoute] string identi } [HttpGet("{address}")] - [ProducesResponseType(typeof(GetIdentityResponse), StatusCodes.Status200OK)] + [ProducesResponseType(typeof(HttpResponseEnvelopeResult), StatusCodes.Status200OK)] [ProducesError(StatusCodes.Status404NotFound)] public async Task GetIdentityByAddress([FromRoute] string address, CancellationToken cancellationToken) { @@ -119,7 +119,7 @@ public async Task StartDeletionProcess([FromRoute] string address } [HttpGet("{identityAddress}/DeletionProcesses")] - [ProducesResponseType(typeof(GetDeletionProcessesAsSupportResponse), StatusCodes.Status200OK)] + [ProducesResponseType(typeof(HttpResponseEnvelopeResult), StatusCodes.Status200OK)] [ProducesError(StatusCodes.Status400BadRequest)] public async Task GetDeletionProcessesAsSupport([FromRoute] string identityAddress, CancellationToken cancellationToken) { @@ -128,7 +128,7 @@ public async Task GetDeletionProcessesAsSupport([FromRoute] strin } [HttpGet("{identityAddress}/DeletionProcesses/AuditLogs")] - [ProducesResponseType(typeof(GetDeletionProcessesAuditLogsResponse), StatusCodes.Status200OK)] + [ProducesResponseType(typeof(HttpResponseEnvelopeResult), StatusCodes.Status200OK)] [ProducesError(StatusCodes.Status400BadRequest)] public async Task GetDeletionProcessesAuditLogs([FromRoute] string identityAddress, CancellationToken cancellationToken) { @@ -146,7 +146,7 @@ public async Task CancelDeletionProcessAsSupport([FromRoute] stri } [HttpGet("{identityAddress}/DeletionProcesses/{deletionProcessId}")] - [ProducesResponseType(typeof(IdentityDeletionProcessDetailsDTO), StatusCodes.Status200OK)] + [ProducesResponseType(typeof(HttpResponseEnvelopeResult), StatusCodes.Status200OK)] [ProducesError(StatusCodes.Status404NotFound)] public async Task GetDeletionProcessAsSupport([FromRoute] string identityAddress, [FromRoute] string deletionProcessId, CancellationToken cancellationToken) { diff --git a/Applications/AdminApi/src/AdminApi/Controllers/TiersController.cs b/Applications/AdminApi/src/AdminApi/Controllers/TiersController.cs index 2f4059fa99..3944e780dc 100644 --- a/Applications/AdminApi/src/AdminApi/Controllers/TiersController.cs +++ b/Applications/AdminApi/src/AdminApi/Controllers/TiersController.cs @@ -37,7 +37,7 @@ public async Task GetTiers(CancellationToken cancellationToken) } [HttpGet("{tierId}")] - [ProducesResponseType(typeof(TierDetailsDTO), StatusCodes.Status200OK)] + [ProducesResponseType(typeof(HttpResponseEnvelopeResult), StatusCodes.Status200OK)] [ProducesError(StatusCodes.Status404NotFound)] public async Task GetTierByIdAsync([FromRoute] string tierId, CancellationToken cancellationToken) { @@ -46,7 +46,7 @@ public async Task GetTierByIdAsync([FromRoute] string tierId, Can } [HttpPost] - [ProducesResponseType(typeof(CreateTierResponse), StatusCodes.Status201Created)] + [ProducesResponseType(typeof(HttpResponseEnvelopeResult), StatusCodes.Status201Created)] [ProducesError(StatusCodes.Status400BadRequest)] public async Task PostTiers([FromBody] CreateTierCommand command, CancellationToken cancellationToken) { @@ -66,7 +66,7 @@ public async Task DeleteTier([FromRoute] string tierId, Cancellat } [HttpPost("{tierId}/Quotas")] - [ProducesResponseType(typeof(TierQuotaDefinitionDTO), StatusCodes.Status201Created)] + [ProducesResponseType(typeof(HttpResponseEnvelopeResult), StatusCodes.Status201Created)] [ProducesError(StatusCodes.Status404NotFound)] [ProducesError(StatusCodes.Status400BadRequest)] public async Task CreateTierQuota([FromRoute] string tierId, [FromBody] CreateQuotaForTierRequest request, CancellationToken cancellationToken) diff --git a/Applications/AdminApi/src/AdminApi/Controllers/TokensController.cs b/Applications/AdminApi/src/AdminApi/Controllers/TokensController.cs index 6c3c41e1cd..eb4f21a4dd 100644 --- a/Applications/AdminApi/src/AdminApi/Controllers/TokensController.cs +++ b/Applications/AdminApi/src/AdminApi/Controllers/TokensController.cs @@ -1,4 +1,5 @@ -using Backbone.BuildingBlocks.API.Mvc; +using Backbone.BuildingBlocks.API; +using Backbone.BuildingBlocks.API.Mvc; using Backbone.BuildingBlocks.Application.Abstractions.Exceptions; using Backbone.BuildingBlocks.Application.Pagination; using Backbone.Modules.Tokens.Application; @@ -17,7 +18,7 @@ namespace Backbone.AdminApi.Controllers; public class TokensController(IMediator mediator, IOptions options) : ApiControllerBase(mediator) { [HttpGet] - [ProducesResponseType(typeof(List), StatusCodes.Status200OK)] + [ProducesResponseType(typeof(HttpResponseEnvelopeResult>), StatusCodes.Status200OK)] public async Task ListTokensByIdentity([FromQuery] PaginationFilter paginationFilter, [FromQuery] string createdBy, CancellationToken cancellationToken) { if (paginationFilter.PageSize != null) diff --git a/Applications/ConsumerApi/src/Controllers/AuthorizationController.cs b/Applications/ConsumerApi/src/Controllers/AuthorizationController.cs index e30f5a06e4..714f78ada7 100644 --- a/Applications/ConsumerApi/src/Controllers/AuthorizationController.cs +++ b/Applications/ConsumerApi/src/Controllers/AuthorizationController.cs @@ -33,13 +33,17 @@ public AuthorizationController( _userManager = userManager; } - [HttpPost("~/connect/token"), IgnoreAntiforgeryToken, Produces("application/json"), - Consumes("application/x-www-form-urlencoded")] + [HttpPost("~/connect/token")] + [IgnoreAntiforgeryToken] + [Produces("application/json")] + [Consumes("application/x-www-form-urlencoded")] [AllowAnonymous] + [ApiExplorerSettings(IgnoreApi = true)] public async Task Exchange() { var request = HttpContext.GetOpenIddictServerRequest() ?? throw new OperationFailedException( ApplicationErrors.Authentication.InvalidOAuthRequest("no request was found")); + if (!request.IsPasswordGrantType()) throw new OperationFailedException( ApplicationErrors.Authentication.InvalidOAuthRequest("the specified grant type is not implemented")); diff --git a/Applications/ConsumerApi/src/Program.cs b/Applications/ConsumerApi/src/Program.cs index da4caf932e..3eb23293fa 100644 --- a/Applications/ConsumerApi/src/Program.cs +++ b/Applications/ConsumerApi/src/Program.cs @@ -201,8 +201,6 @@ static void Configure(WebApplication app) .AddCustomHeader("X-Frame-Options", "Deny") ); - var configuration = app.Services.GetRequiredService>().Value; - if (app.Environment.IsDevelopment()) IdentityModelEventSource.ShowPII = true; diff --git a/Modules/Announcements/src/Announcements.ConsumerApi/Controllers/AnnouncementsController.cs b/Modules/Announcements/src/Announcements.ConsumerApi/Controllers/AnnouncementsController.cs index e3b4f19170..6237f1ce2f 100644 --- a/Modules/Announcements/src/Announcements.ConsumerApi/Controllers/AnnouncementsController.cs +++ b/Modules/Announcements/src/Announcements.ConsumerApi/Controllers/AnnouncementsController.cs @@ -1,7 +1,10 @@ -using Backbone.BuildingBlocks.API.Mvc; +using Backbone.BuildingBlocks.API; +using Backbone.BuildingBlocks.API.Mvc; +using Backbone.BuildingBlocks.API.Mvc.ControllerAttributes; using Backbone.Modules.Announcements.Application.Announcements.Queries.GetAllAnnouncementsInLanguage; using MediatR; using Microsoft.AspNetCore.Authorization; +using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Mvc; namespace Backbone.Modules.Announcements.ConsumerApi.Controllers; @@ -15,6 +18,8 @@ public AnnouncementsController(IMediator mediator) : base(mediator) } [HttpGet] + [ProducesResponseType>(StatusCodes.Status200OK)] + [ProducesError(StatusCodes.Status400BadRequest)] public async Task GetAllAnnouncements([FromQuery] string language) { var announcements = await _mediator.Send(new GetAllAnnouncementsInLanguageQuery { Language = language }); diff --git a/Modules/Challenges/src/Challenges.ConsumerApi/Controllers/ChallengesController.cs b/Modules/Challenges/src/Challenges.ConsumerApi/Controllers/ChallengesController.cs index c41937db8f..1b12129efb 100644 --- a/Modules/Challenges/src/Challenges.ConsumerApi/Controllers/ChallengesController.cs +++ b/Modules/Challenges/src/Challenges.ConsumerApi/Controllers/ChallengesController.cs @@ -4,7 +4,6 @@ using Backbone.Modules.Challenges.Application.Challenges.Commands.CreateChallenge; using Backbone.Modules.Challenges.Application.Challenges.DTOs; using Backbone.Modules.Challenges.Application.Challenges.Queries.GetChallengeById; -using Backbone.Modules.Challenges.Domain.Ids; using MediatR; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Http; @@ -32,8 +31,9 @@ public async Task Create(CancellationToken cancellationToken) [HttpGet("{id}")] [ProducesResponseType(typeof(HttpResponseEnvelopeResult), StatusCodes.Status200OK)] + [ProducesError(StatusCodes.Status400BadRequest)] [ProducesError(StatusCodes.Status404NotFound)] - public async Task GetById([FromRoute] ChallengeId id, CancellationToken cancellationToken) + public async Task GetById([FromRoute] string id, CancellationToken cancellationToken) { var @event = await _mediator.Send(new GetChallengeByIdQuery { Id = id }, cancellationToken); return Ok(@event); diff --git a/Modules/Devices/src/Devices.ConsumerApi/Controllers/DevicesController.cs b/Modules/Devices/src/Devices.ConsumerApi/Controllers/DevicesController.cs index 2e7f7601ea..daddb2dc57 100644 --- a/Modules/Devices/src/Devices.ConsumerApi/Controllers/DevicesController.cs +++ b/Modules/Devices/src/Devices.ConsumerApi/Controllers/DevicesController.cs @@ -3,7 +3,6 @@ using Backbone.BuildingBlocks.API.Mvc.ControllerAttributes; using Backbone.BuildingBlocks.Application.Abstractions.Exceptions; using Backbone.BuildingBlocks.Application.Pagination; -using Backbone.DevelopmentKit.Identity.ValueObjects; using Backbone.Modules.Devices.Application; using Backbone.Modules.Devices.Application.Devices.Commands.ChangePassword; using Backbone.Modules.Devices.Application.Devices.Commands.DeleteDevice; @@ -74,6 +73,7 @@ public async Task ChangePassword(ChangePasswordCommand request, C [HttpGet] [ProducesResponseType(typeof(PagedHttpResponseEnvelope), StatusCodes.Status200OK)] + [ProducesError(StatusCodes.Status400BadRequest)] public async Task ListDevices([FromQuery] PaginationFilter paginationFilter, [FromQuery] IEnumerable ids, CancellationToken cancellationToken) { paginationFilter.PageSize ??= _options.Pagination.DefaultPageSize; @@ -88,7 +88,6 @@ public async Task ListDevices([FromQuery] PaginationFilter pagina [HttpGet("Self")] [ProducesResponseType(typeof(HttpResponseEnvelopeResult), StatusCodes.Status200OK)] - [ProducesResponseType(StatusCodes.Status404NotFound)] public async Task GetActiveDevice() { var response = await _mediator.Send(new GetActiveDeviceQuery()); @@ -96,10 +95,10 @@ public async Task GetActiveDevice() } [HttpDelete("{id}")] - [ProducesResponseType(StatusCodes.Status200OK)] + [ProducesResponseType(StatusCodes.Status204NoContent)] [ProducesError(StatusCodes.Status400BadRequest)] [ProducesResponseType(StatusCodes.Status404NotFound)] - public async Task DeleteDevice([FromRoute] DeviceId id, CancellationToken cancellationToken) + public async Task DeleteDevice([FromRoute] string id, CancellationToken cancellationToken) { await _mediator.Send(new DeleteDeviceCommand { DeviceId = id }, cancellationToken); return NoContent(); diff --git a/Modules/Devices/src/Devices.ConsumerApi/Controllers/IdentitiesController.cs b/Modules/Devices/src/Devices.ConsumerApi/Controllers/IdentitiesController.cs index c40ac2f343..dbceb1e52b 100644 --- a/Modules/Devices/src/Devices.ConsumerApi/Controllers/IdentitiesController.cs +++ b/Modules/Devices/src/Devices.ConsumerApi/Controllers/IdentitiesController.cs @@ -19,7 +19,6 @@ using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Mvc; -using Microsoft.Extensions.Logging; using OpenIddict.Core; using OpenIddict.Validation.AspNetCore; @@ -30,20 +29,18 @@ namespace Backbone.Modules.Devices.ConsumerApi.Controllers; public class IdentitiesController : ApiControllerBase { private readonly OpenIddictApplicationManager _applicationManager; - private readonly ILogger _logger; public IdentitiesController( IMediator mediator, - OpenIddictApplicationManager applicationManager, - ILogger logger) : base(mediator) + OpenIddictApplicationManager applicationManager) : base(mediator) { _applicationManager = applicationManager; - _logger = logger; } [HttpPost] [ProducesResponseType(typeof(HttpResponseEnvelopeResult), StatusCodes.Status201Created)] [ProducesError(StatusCodes.Status400BadRequest)] + [ProducesError(StatusCodes.Status404NotFound)] [AllowAnonymous] public async Task CreateIdentity(CreateIdentityRequest request, CancellationToken cancellationToken) { @@ -103,6 +100,7 @@ public async Task RejectDeletionProcess([FromRoute] string id, Ca [HttpGet("Self/DeletionProcesses/{id}")] [ProducesResponseType(typeof(HttpResponseEnvelopeResult), StatusCodes.Status200OK)] + [ProducesError(StatusCodes.Status400BadRequest)] [ProducesError(StatusCodes.Status404NotFound)] public async Task GetDeletionProcess([FromRoute] string id, CancellationToken cancellationToken) { @@ -138,8 +136,8 @@ public async Task GetOwnIdentity(CancellationToken cancellationTo [HttpGet("IsDeleted")] [AllowAnonymous] - [ProducesResponseType(typeof(IsIdentityOfUserDeletedResponse), StatusCodes.Status200OK)] - [ProducesError(StatusCodes.Status200OK)] + [ProducesResponseType(typeof(HttpResponseEnvelopeResult), StatusCodes.Status200OK)] + [ProducesError(StatusCodes.Status400BadRequest)] public async Task IsIdentityOfUserDeleted([FromQuery(Name = "username")] string username, CancellationToken cancellationToken) { var response = await _mediator.Send(new IsIdentityOfUserDeletedQuery { Username = username }, cancellationToken); diff --git a/Modules/Devices/src/Devices.ConsumerApi/Controllers/PushNotificationsController.cs b/Modules/Devices/src/Devices.ConsumerApi/Controllers/PushNotificationsController.cs index 070997b1b5..9d475a62ef 100644 --- a/Modules/Devices/src/Devices.ConsumerApi/Controllers/PushNotificationsController.cs +++ b/Modules/Devices/src/Devices.ConsumerApi/Controllers/PushNotificationsController.cs @@ -1,3 +1,4 @@ +using Backbone.BuildingBlocks.API; using Backbone.BuildingBlocks.API.Mvc; using Backbone.BuildingBlocks.API.Mvc.ControllerAttributes; using Backbone.Modules.Devices.Application.PushNotifications.Commands.DeleteDeviceRegistration; @@ -15,10 +16,12 @@ namespace Backbone.Modules.Devices.ConsumerApi.Controllers; [Authorize(OpenIddictValidationAspNetCoreDefaults.AuthenticationScheme)] public class PushNotificationsController : ApiControllerBase { - public PushNotificationsController(IMediator mediator) : base(mediator) { } + public PushNotificationsController(IMediator mediator) : base(mediator) + { + } [HttpPut] - [ProducesResponseType(StatusCodes.Status200OK)] + [ProducesResponseType(typeof(HttpResponseEnvelopeResult), StatusCodes.Status200OK)] [ProducesError(StatusCodes.Status400BadRequest)] public async Task RegisterForPushNotifications(UpdateDeviceRegistrationCommand request, CancellationToken cancellationToken) { @@ -35,6 +38,7 @@ public async Task UnregisterFromPushNotifications(CancellationTok } [HttpPost("SendTestNotification")] + [ApiExplorerSettings(IgnoreApi = true)] // don't show this in the API docs as it's just for internal testing [ProducesResponseType(StatusCodes.Status204NoContent)] public async Task SendTestPushNotification([FromBody] dynamic data, CancellationToken cancellationToken) { diff --git a/Modules/Files/src/Files.ConsumerApi/Controllers/FilesController.cs b/Modules/Files/src/Files.ConsumerApi/Controllers/FilesController.cs index 54799fecfe..3ebfe31d59 100644 --- a/Modules/Files/src/Files.ConsumerApi/Controllers/FilesController.cs +++ b/Modules/Files/src/Files.ConsumerApi/Controllers/FilesController.cs @@ -63,8 +63,8 @@ public async Task UploadFile([FromForm] CreateFileDTO dto, Cancel } [HttpGet("{fileId}")] - [Produces(MediaTypeNames.Application.Octet)] - [ProducesResponseType(typeof(HttpResponseEnvelopeResult), StatusCodes.Status200OK)] + [ProducesResponseType(StatusCodes.Status200OK, MediaTypeNames.Application.Octet)] + [ProducesError(StatusCodes.Status400BadRequest)] [ProducesError(StatusCodes.Status404NotFound)] public async Task DownloadFile(string fileId, CancellationToken cancellationToken) { @@ -73,8 +73,9 @@ public async Task DownloadFile(string fileId, CancellationToken c } - [HttpGet("{fileId}/metadata")] + [HttpGet("{fileId}/Metadata")] [ProducesResponseType(typeof(HttpResponseEnvelopeResult), StatusCodes.Status200OK)] + [ProducesError(StatusCodes.Status400BadRequest)] [ProducesError(StatusCodes.Status404NotFound)] public async Task GetFileMetadata(string fileId, CancellationToken cancellationToken) { @@ -84,6 +85,7 @@ public async Task GetFileMetadata(string fileId, CancellationToke [HttpDelete("{fileId}")] [ProducesResponseType(StatusCodes.Status204NoContent)] + [ProducesError(StatusCodes.Status400BadRequest)] [ProducesError(StatusCodes.Status404NotFound)] public async Task DeleteFile(string fileId, CancellationToken cancellationToken) { @@ -93,6 +95,7 @@ public async Task DeleteFile(string fileId, CancellationToken can [HttpGet] [ProducesResponseType(typeof(PagedHttpResponseEnvelope), StatusCodes.Status200OK)] + [ProducesError(StatusCodes.Status400BadRequest)] public async Task ListFileMetadata([FromQuery] PaginationFilter paginationFilter, [FromQuery] IEnumerable ids, CancellationToken cancellationToken) { diff --git a/Modules/Messages/src/Messages.ConsumerApi/Controllers/MessagesController.cs b/Modules/Messages/src/Messages.ConsumerApi/Controllers/MessagesController.cs index ce13403334..a815731b2b 100644 --- a/Modules/Messages/src/Messages.ConsumerApi/Controllers/MessagesController.cs +++ b/Modules/Messages/src/Messages.ConsumerApi/Controllers/MessagesController.cs @@ -30,6 +30,7 @@ public MessagesController(IMediator mediator, IOptions optio [HttpGet] [ProducesResponseType(typeof(PagedHttpResponseEnvelope), StatusCodes.Status200OK)] + [ProducesError(StatusCodes.Status400BadRequest)] public async Task ListMessages([FromQuery] PaginationFilter paginationFilter, [FromQuery] IEnumerable ids, CancellationToken cancellationToken) { @@ -47,6 +48,7 @@ public async Task ListMessages([FromQuery] PaginationFilter pagin [HttpGet("{id}")] [ProducesResponseType(typeof(HttpResponseEnvelopeResult), StatusCodes.Status200OK)] + [ProducesError(StatusCodes.Status400BadRequest)] [ProducesError(StatusCodes.Status404NotFound)] public async Task GetMessage(string id, [FromQuery] bool? noBody, CancellationToken cancellationToken) { diff --git a/Modules/Relationships/src/Relationships.ConsumerApi/Controllers/PublicRelationshipTemplateReferencesController.cs b/Modules/Relationships/src/Relationships.ConsumerApi/Controllers/PublicRelationshipTemplateReferencesController.cs index 28690a9e56..bc9bf7466b 100644 --- a/Modules/Relationships/src/Relationships.ConsumerApi/Controllers/PublicRelationshipTemplateReferencesController.cs +++ b/Modules/Relationships/src/Relationships.ConsumerApi/Controllers/PublicRelationshipTemplateReferencesController.cs @@ -9,6 +9,7 @@ namespace Backbone.Modules.Relationships.ConsumerApi.Controllers; [Route("api/poc/[controller]")] [Authorize("OpenIddict.Validation.AspNetCore")] +[ApiExplorerSettings(IgnoreApi = true)] // don't show this endpoints of this controller in the API docs as it's just a PoC public class PublicRelationshipTemplateReferencesController : ApiControllerBase { private readonly Configuration _options; diff --git a/Modules/Relationships/src/Relationships.ConsumerApi/Controllers/RelationshipTemplatesController.cs b/Modules/Relationships/src/Relationships.ConsumerApi/Controllers/RelationshipTemplatesController.cs index 53c332d221..4f0dcc0c5d 100644 --- a/Modules/Relationships/src/Relationships.ConsumerApi/Controllers/RelationshipTemplatesController.cs +++ b/Modules/Relationships/src/Relationships.ConsumerApi/Controllers/RelationshipTemplatesController.cs @@ -31,6 +31,7 @@ public RelationshipTemplatesController(IMediator mediator, IOptions), StatusCodes.Status200OK)] + [ProducesError(StatusCodes.Status400BadRequest)] [ProducesError(StatusCodes.Status404NotFound)] public async Task GetById(string id, [FromQuery] byte[]? password, CancellationToken cancellationToken) { @@ -39,8 +40,8 @@ public async Task GetById(string id, [FromQuery] byte[]? password } [HttpGet] - [ProducesResponseType(typeof(PagedHttpResponseEnvelope), - StatusCodes.Status200OK)] + [ProducesResponseType(typeof(PagedHttpResponseEnvelope), StatusCodes.Status200OK)] + [ProducesError(StatusCodes.Status400BadRequest)] public async Task GetAll([FromQuery] PaginationFilter paginationFilter, [FromQuery] ListRelationshipTemplatesQueryItem[]? templates, [FromQuery] IEnumerable ids, CancellationToken cancellationToken) { @@ -60,8 +61,7 @@ public async Task GetAll([FromQuery] PaginationFilter paginationF } [HttpPost] - [ProducesResponseType(typeof(HttpResponseEnvelopeResult), - StatusCodes.Status201Created)] + [ProducesResponseType(typeof(HttpResponseEnvelopeResult), StatusCodes.Status201Created)] [ProducesError(StatusCodes.Status400BadRequest)] public async Task Create(CreateRelationshipTemplateCommand request, CancellationToken cancellationToken) { @@ -71,6 +71,7 @@ public async Task Create(CreateRelationshipTemplateCommand reques [HttpDelete("{id}")] [ProducesResponseType(StatusCodes.Status204NoContent)] + [ProducesError(StatusCodes.Status400BadRequest)] [ProducesError(StatusCodes.Status404NotFound)] public async Task Delete(string id, CancellationToken cancellationToken) { diff --git a/Modules/Relationships/src/Relationships.ConsumerApi/Controllers/RelationshipsController.cs b/Modules/Relationships/src/Relationships.ConsumerApi/Controllers/RelationshipsController.cs index 8af74b0655..8af7ae99d9 100644 --- a/Modules/Relationships/src/Relationships.ConsumerApi/Controllers/RelationshipsController.cs +++ b/Modules/Relationships/src/Relationships.ConsumerApi/Controllers/RelationshipsController.cs @@ -43,6 +43,7 @@ public RelationshipsController(IMediator mediator, IOptions [HttpGet("{id}")] [ProducesResponseType(typeof(HttpResponseEnvelopeResult), StatusCodes.Status200OK)] + [ProducesError(StatusCodes.Status400BadRequest)] [ProducesError(StatusCodes.Status404NotFound)] public async Task GetRelationship(string id, CancellationToken cancellationToken) { @@ -52,23 +53,22 @@ public async Task GetRelationship(string id, CancellationToken ca [HttpGet] [ProducesResponseType(typeof(PagedHttpResponseEnvelope), StatusCodes.Status200OK)] - public async Task ListRelationships([FromQuery] PaginationFilter paginationFilter, - [FromQuery] IEnumerable ids, CancellationToken cancellationToken) + [ProducesError(StatusCodes.Status400BadRequest)] + public async Task ListRelationships([FromQuery] PaginationFilter paginationFilter, [FromQuery] IEnumerable ids, CancellationToken cancellationToken) { var request = new ListRelationshipsQuery(paginationFilter, ids); request.PaginationFilter.PageSize ??= _options.Pagination.DefaultPageSize; if (paginationFilter.PageSize > _options.Pagination.MaxPageSize) - throw new ApplicationException( - GenericApplicationErrors.Validation.InvalidPageSize(_options.Pagination.MaxPageSize)); + throw new ApplicationException(GenericApplicationErrors.Validation.InvalidPageSize(_options.Pagination.MaxPageSize)); var relationships = await _mediator.Send(request, cancellationToken); return Paged(relationships); } [HttpPost] - [ProducesResponseType(typeof(HttpResponseEnvelopeResult), StatusCodes.Status200OK)] + [ProducesResponseType(typeof(HttpResponseEnvelopeResult), StatusCodes.Status201Created)] [ProducesError(StatusCodes.Status400BadRequest)] [ProducesError(StatusCodes.Status404NotFound)] public async Task CreateRelationship(CreateRelationshipCommand request, CancellationToken cancellationToken) diff --git a/Modules/Synchronization/src/Synchronization.ConsumerApi/Controllers/DatawalletController.cs b/Modules/Synchronization/src/Synchronization.ConsumerApi/Controllers/DatawalletController.cs index 97a0f994d7..23f5278c6d 100644 --- a/Modules/Synchronization/src/Synchronization.ConsumerApi/Controllers/DatawalletController.cs +++ b/Modules/Synchronization/src/Synchronization.ConsumerApi/Controllers/DatawalletController.cs @@ -31,6 +31,7 @@ public DatawalletController(IMediator mediator, IOptions opt [HttpGet] [ProducesResponseType(typeof(HttpResponseEnvelopeResult), StatusCodes.Status200OK)] [ProducesError(StatusCodes.Status400BadRequest)] + [ProducesError(StatusCodes.Status404NotFound)] public async Task Get(CancellationToken cancellationToken) { var response = await _mediator.Send(new GetDatawalletQuery(), cancellationToken); @@ -38,7 +39,8 @@ public async Task Get(CancellationToken cancellationToken) } [HttpGet("Modifications")] - [ProducesResponseType(typeof(HttpResponseEnvelopeResult), StatusCodes.Status200OK)] + [ProducesResponseType(typeof(PagedHttpResponseEnvelope), StatusCodes.Status200OK)] + [ProducesError(StatusCodes.Status400BadRequest)] public async Task GetModifications([FromQuery] PaginationFilter paginationFilter, [FromQuery] int? localIndex, [FromHeader(Name = "X-Supported-Datawallet-Version")] @@ -58,9 +60,9 @@ public async Task GetModifications([FromQuery] PaginationFilter p } [HttpPost("Modifications")] - [ProducesResponseType(typeof(HttpResponseEnvelopeResult), - StatusCodes.Status201Created)] + [ProducesResponseType(typeof(HttpResponseEnvelopeResult), StatusCodes.Status201Created)] [ProducesError(StatusCodes.Status400BadRequest)] + [ProducesError(StatusCodes.Status404NotFound)] public async Task PushModifications(PushDatawalletModificationsRequestBody request, [FromHeader(Name = "X-Supported-Datawallet-Version")] ushort supportedDatawalletVersion, CancellationToken cancellationToken) diff --git a/Modules/Synchronization/src/Synchronization.ConsumerApi/Controllers/SyncRunsController.cs b/Modules/Synchronization/src/Synchronization.ConsumerApi/Controllers/SyncRunsController.cs index 6b348d5d99..e55e1d27fa 100644 --- a/Modules/Synchronization/src/Synchronization.ConsumerApi/Controllers/SyncRunsController.cs +++ b/Modules/Synchronization/src/Synchronization.ConsumerApi/Controllers/SyncRunsController.cs @@ -14,7 +14,6 @@ using Backbone.Modules.Synchronization.Application.SyncRuns.DTOs; using Backbone.Modules.Synchronization.Application.SyncRuns.Queries.GetExternalEventsOfSyncRun; using Backbone.Modules.Synchronization.Application.SyncRuns.Queries.GetSyncRunById; -using Backbone.Modules.Synchronization.Domain.Entities.Sync; using MediatR; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Http; @@ -39,6 +38,7 @@ public SyncRunsController(IMediator mediator, IOptions optio [HttpPost] [ProducesResponseType(typeof(HttpResponseEnvelopeResult), StatusCodes.Status200OK)] + [ProducesResponseType(typeof(HttpResponseEnvelopeResult), StatusCodes.Status201Created)] [ProducesError(StatusCodes.Status400BadRequest)] public async Task StartSyncRun(StartSyncRunRequestBody requestBody, [FromHeader(Name = "X-Supported-Datawallet-Version")] @@ -47,21 +47,16 @@ public async Task StartSyncRun(StartSyncRunRequestBody requestBod var identityResponse = await _mediator.Send(new GetIdentityQuery(_userContext.GetAddress()), cancellationToken); EnsureIdentityIsNotToBeDeleted(identityResponse); - var response = await _mediator.Send(new StartSyncRunCommand( - requestBody.Type ?? SyncRunDTO.SyncRunType.ExternalEventSync, requestBody.Duration, - supportedDatawalletVersion), cancellationToken); + var response = await _mediator.Send(new StartSyncRunCommand(requestBody.Type ?? SyncRunDTO.SyncRunType.ExternalEventSync, requestBody.Duration, supportedDatawalletVersion), cancellationToken); - if (response.Status == StartSyncRunStatus.Created) - return Created(response); - - return Ok(response); + return response.Status == StartSyncRunStatus.Created ? Created(response) : Ok(response); } [HttpPut("{id}/FinalizeExternalEventSync")] - [ProducesResponseType(typeof(HttpResponseEnvelopeResult), - StatusCodes.Status200OK)] + [ProducesResponseType(typeof(HttpResponseEnvelopeResult), StatusCodes.Status200OK)] [ProducesError(StatusCodes.Status400BadRequest)] - public async Task FinalizeExternalEventSync([FromRoute] SyncRunId id, + [ProducesError(StatusCodes.Status404NotFound)] + public async Task FinalizeExternalEventSync([FromRoute] string id, [FromBody] FinalizeExternalEventSyncRequest request, CancellationToken cancellationToken) { var response = await _mediator.Send(new FinalizeExternalEventSyncSyncRunCommand(id, @@ -71,29 +66,27 @@ public async Task FinalizeExternalEventSync([FromRoute] SyncRunId } [HttpPut("{id}/FinalizeDatawalletVersionUpgrade")] - [ProducesResponseType(typeof(HttpResponseEnvelopeResult), - StatusCodes.Status200OK)] + [ProducesResponseType(typeof(HttpResponseEnvelopeResult), StatusCodes.Status200OK)] [ProducesError(StatusCodes.Status400BadRequest)] - public async Task FinalizeDatawalletVersionUpgrade([FromRoute] SyncRunId id, - [FromBody] FinalizeDatawalletVersionUpgradeRequest request, CancellationToken cancellationToken) + [ProducesError(StatusCodes.Status404NotFound)] + public async Task FinalizeDatawalletVersionUpgrade([FromRoute] string id, [FromBody] FinalizeDatawalletVersionUpgradeRequest request, CancellationToken cancellationToken) { - var response = await _mediator.Send(new FinalizeDatawalletVersionUpgradeSyncRunCommand(id, - request.NewDatawalletVersion, request.DatawalletModifications), cancellationToken); + var response = await _mediator.Send(new FinalizeDatawalletVersionUpgradeSyncRunCommand(id, request.NewDatawalletVersion, request.DatawalletModifications), cancellationToken); return Ok(response); } [HttpGet("{id}/ExternalEvents")] - [ProducesResponseType(typeof(PagedHttpResponseEnvelope), - StatusCodes.Status200OK)] - public async Task GetExternalEventsOfSyncRun([FromRoute] SyncRunId id, + [ProducesResponseType(typeof(PagedHttpResponseEnvelope), StatusCodes.Status200OK)] + [ProducesError(StatusCodes.Status400BadRequest)] + [ProducesError(StatusCodes.Status404NotFound)] + public async Task GetExternalEventsOfSyncRun([FromRoute] string id, [FromQuery] PaginationFilter paginationFilter, CancellationToken cancellationToken) { paginationFilter.PageSize ??= _options.Pagination.DefaultPageSize; if (paginationFilter.PageSize > _options.Pagination.MaxPageSize) - throw new ApplicationException( - GenericApplicationErrors.Validation.InvalidPageSize(_options.Pagination.MaxPageSize)); + throw new ApplicationException(GenericApplicationErrors.Validation.InvalidPageSize(_options.Pagination.MaxPageSize)); var response = await _mediator.Send(new GetExternalEventsOfSyncRunQuery(id, paginationFilter), cancellationToken); @@ -102,19 +95,19 @@ public async Task GetExternalEventsOfSyncRun([FromRoute] SyncRunI [HttpGet("{id}")] [ProducesResponseType(typeof(HttpResponseEnvelopeResult), StatusCodes.Status200OK)] + [ProducesError(StatusCodes.Status400BadRequest)] [ProducesError(StatusCodes.Status404NotFound)] - public async Task GetSyncRunById(SyncRunId id, CancellationToken cancellationToken) + public async Task GetSyncRunById(string id, CancellationToken cancellationToken) { var response = await _mediator.Send(new GetSyncRunByIdQuery(id), cancellationToken); return Ok(response); } [HttpPut("{id}/RefreshExpirationTime")] - [ProducesResponseType(typeof(HttpResponseEnvelopeResult), - StatusCodes.Status200OK)] + [ProducesResponseType(typeof(HttpResponseEnvelopeResult), StatusCodes.Status200OK)] [ProducesError(StatusCodes.Status400BadRequest)] [ProducesError(StatusCodes.Status404NotFound)] - public async Task RefreshExpirationTimeOfSyncRun(SyncRunId id, CancellationToken cancellationToken) + public async Task RefreshExpirationTimeOfSyncRun(string id, CancellationToken cancellationToken) { var response = await _mediator.Send(new RefreshExpirationTimeOfSyncRunCommand(id), cancellationToken); return Ok(response); diff --git a/Modules/Tags/src/Tags.ConsumerApi/Controllers/TagsController.cs b/Modules/Tags/src/Tags.ConsumerApi/Controllers/TagsController.cs index ee28cbe550..34e99b97d5 100644 --- a/Modules/Tags/src/Tags.ConsumerApi/Controllers/TagsController.cs +++ b/Modules/Tags/src/Tags.ConsumerApi/Controllers/TagsController.cs @@ -1,7 +1,9 @@ -using Backbone.BuildingBlocks.API.Mvc; +using Backbone.BuildingBlocks.API; +using Backbone.BuildingBlocks.API.Mvc; using Backbone.Modules.Tags.Application.Tags.Queries.ListTags; using MediatR; using Microsoft.AspNetCore.Authorization; +using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Mvc; namespace Backbone.Modules.Tags.ConsumerApi.Controllers; @@ -15,6 +17,7 @@ public TagsController(IMediator mediator) : base(mediator) } [HttpGet] + [ProducesResponseType(typeof(HttpResponseEnvelopeResult), StatusCodes.Status200OK)] [AllowAnonymous] public async Task ListTags(CancellationToken cancellationToken) { diff --git a/Modules/Tokens/src/Tokens.ConsumerApi/Controllers/TokensController.cs b/Modules/Tokens/src/Tokens.ConsumerApi/Controllers/TokensController.cs index 95fefa0780..187927ed3a 100644 --- a/Modules/Tokens/src/Tokens.ConsumerApi/Controllers/TokensController.cs +++ b/Modules/Tokens/src/Tokens.ConsumerApi/Controllers/TokensController.cs @@ -39,6 +39,7 @@ public async Task CreateToken(CreateTokenCommand request, Cancell [HttpGet("{id}")] [ProducesResponseType(typeof(HttpResponseEnvelopeResult), StatusCodes.Status200OK)] + [ProducesError(StatusCodes.Status400BadRequest)] [ProducesError(StatusCodes.Status404NotFound)] [AllowAnonymous] public async Task GetToken([FromRoute] string id, [FromQuery] byte[]? password, CancellationToken cancellationToken) @@ -49,8 +50,9 @@ public async Task GetToken([FromRoute] string id, [FromQuery] byt [HttpGet] [ProducesResponseType(typeof(PagedHttpResponseEnvelope), StatusCodes.Status200OK)] - public async Task ListTokens([FromQuery] PaginationFilter paginationFilter, [FromQuery] ListTokensQueryItem[]? tokens, - [FromQuery] List ids, CancellationToken cancellationToken) + [ProducesError(StatusCodes.Status400BadRequest)] + public async Task ListTokens([FromQuery] PaginationFilter paginationFilter, [FromQuery] ListTokensQueryItem[]? tokens, [FromQuery] List ids, + CancellationToken cancellationToken) { // We keep this code for backwards compatibility reasons. In a few months the `ids` // parameter will become required again, and the fallback to `tokens` will be removed. @@ -61,8 +63,7 @@ public async Task ListTokens([FromQuery] PaginationFilter paginat paginationFilter.PageSize ??= _options.Pagination.DefaultPageSize; if (paginationFilter.PageSize > _options.Pagination.MaxPageSize) - throw new ApplicationException( - GenericApplicationErrors.Validation.InvalidPageSize(_options.Pagination.MaxPageSize)); + throw new ApplicationException(GenericApplicationErrors.Validation.InvalidPageSize(_options.Pagination.MaxPageSize)); var response = await _mediator.Send(request, cancellationToken); @@ -71,6 +72,7 @@ public async Task ListTokens([FromQuery] PaginationFilter paginat [HttpDelete("{id}")] [ProducesResponseType(StatusCodes.Status204NoContent)] + [ProducesError(StatusCodes.Status400BadRequest)] [ProducesError(StatusCodes.Status404NotFound)] public async Task DeleteToken([FromRoute] string id, CancellationToken cancellationToken) {