Skip to content

Commit

Permalink
Merge pull request #404 from DFE-Digital/trusts-v3-swagger
Browse files Browse the repository at this point in the history
Trust endpoints annotations
  • Loading branch information
dneed-nimble authored Oct 25, 2023
2 parents e82d22e + 8fc2a64 commit f068091
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions TramsDataApi/Controllers/V3/TrustsController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,19 @@
using System.Text.Json;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Logging;
using Swashbuckle.AspNetCore.Annotations;
using TramsDataApi.ResponseModels;
using TramsDataApi.UseCases;

namespace TramsDataApi.Controllers.V3
{
/// <summary>
/// Manages operations related to trusts using the Master schema.
/// </summary>
[ApiVersion("3.0")]
[ApiController]
[Route("v{version:apiVersion}/")]
[SwaggerTag("Operations related to Trusts using the Master schema")]
public class TrustsController : ControllerBase
{
private readonly IGetMstrTrustByUkprn _getMstrTrustByUkPrn;
Expand All @@ -23,8 +28,16 @@ public TrustsController(IGetMstrTrustByUkprn getMstrTrustByUkPrn, IMstrSearchTru
_logger = logger;
}

/// <summary>
/// Searches for trusts based on given criteria.
/// </summary>
/// <remarks>
/// Search can be performed using the groupName, ukPrn, and companiesHouseNumber parameters.
/// </remarks>
[HttpGet("trusts")]
[MapToApiVersion("3.0")]
[SwaggerOperation(Summary = "Search Trusts", Description = "Search for trusts using the specified parameters, within the Master schema.")]
[SwaggerResponse(200, "Successfully found and returned the list of trusts.")]
public ActionResult<ApiResponseV2<TrustSummaryResponse>> SearchTrusts(string groupName, string ukPrn, string companiesHouseNumber,
int page = 1, int count = 50, bool includeEstablishments = true)
{
Expand All @@ -50,9 +63,15 @@ public ActionResult<ApiResponseV2<TrustSummaryResponse>> SearchTrusts(string gro
return new OkObjectResult(response);
}

/// <summary>
/// Retrieves a specific trust by UKPRN.
/// </summary>
[HttpGet]
[Route("trust/{ukprn}")]
[MapToApiVersion("3.0")]
[SwaggerOperation(Summary = "Get Trust By UKPRN", Description = "Retrieve a single trust by its UKPRN.")]
[SwaggerResponse(200, "Successfully retrieved the trust.")]
[SwaggerResponse(404, "The trust was not found.")]
public ActionResult<ApiSingleResponseV2<MasterTrustResponse>> GetTrustByUkPrn(string ukprn)
{
_logger.LogInformation("Attempting to get trust by UKPRN {prn}", ukprn);
Expand Down

0 comments on commit f068091

Please sign in to comment.