Skip to content

Commit 956f39c

Browse files
authored
Merge pull request #391 from DFE-Digital/v1-establishment-documentation
V1 establishment endpoints documentation
2 parents 1f2135d + ba12030 commit 956f39c

File tree

1 file changed

+44
-0
lines changed

1 file changed

+44
-0
lines changed

TramsDataApi/Controllers/EstablishmentsController.cs

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,19 @@
22
using System.Text.Json;
33
using Microsoft.AspNetCore.Mvc;
44
using Microsoft.Extensions.Logging;
5+
using Swashbuckle.AspNetCore.Annotations;
56
using TramsDataApi.RequestModels;
67
using TramsDataApi.ResponseModels;
78
using TramsDataApi.UseCases;
89

910
namespace TramsDataApi.Controllers
1011
{
12+
/// <summary>
13+
/// Manages establishment-related operations.
14+
/// </summary>
1115
[ApiController]
1216
[ApiVersion("1.0")]
17+
[SwaggerTag("Establishment Endpoints")]
1318
public class EstablishmentsController : ControllerBase
1419
{
1520
private readonly IGetEstablishmentByUkprn _getEstablishmentByUkprn;
@@ -35,8 +40,16 @@ public EstablishmentsController(
3540
_logger = logger;
3641
}
3742

43+
/// <summary>
44+
/// Retrieves an establishment by its UKPRN.
45+
/// </summary>
46+
/// <param name="ukprn">The UKPRN of the establishment.</param>
47+
/// <returns>An establishment or NotFound if not available.</returns>
3848
[HttpGet]
3949
[Route("establishment/{ukprn}")]
50+
[SwaggerOperation(Summary = "Get Establishment by UKPRN", Description = "Returns an establishment specified by UKPRN.")]
51+
[SwaggerResponse(200, "Successfully found and returned the establishment.")]
52+
[SwaggerResponse(404, "Establishment with specified UKPRN not found.")]
4053
public ActionResult<EstablishmentResponse> GetByUkprn(string ukprn)
4154
{
4255
_logger.LogInformation($"Attempting to get Establishment by UKPRN {ukprn}");
@@ -51,8 +64,16 @@ public ActionResult<EstablishmentResponse> GetByUkprn(string ukprn)
5164
_logger.LogDebug(JsonSerializer.Serialize<EstablishmentResponse>(establishment));
5265
return Ok(establishment);
5366
}
67+
/// <summary>
68+
/// Retrieves a list of establishment URNs by region.
69+
/// </summary>
70+
/// <param name="regions">Array of regions.</param>
71+
/// <returns>List of establishment URNs or NotFound if none are available.</returns>
5472
[HttpGet]
5573
[Route("establishment/regions")]
74+
[SwaggerOperation(Summary = "Get Establishment URNs by Region", Description = "Returns a list of establishment URNs by specified regions.")]
75+
[SwaggerResponse(200, "Successfully found and returned the establishment URNs.")]
76+
[SwaggerResponse(404, "No establishments found for specified regions.")]
5677
public ActionResult<IEnumerable<int>> GetURNsByRegion([FromQuery] string[] regions)
5778
{
5879
_logger.LogInformation($"Attempting to get Establishment URNs by Region {regions}");
@@ -68,8 +89,16 @@ public ActionResult<IEnumerable<int>> GetURNsByRegion([FromQuery] string[] regio
6889
return Ok(establishment);
6990
}
7091

92+
/// <summary>
93+
/// Retrieves an establishment by its URN.
94+
/// </summary>
95+
/// <param name="urn">The URN of the establishment.</param>
96+
/// <returns>An establishment or NotFound if not available.</returns>
7197
[HttpGet]
7298
[Route("establishment/urn/{urn}")]
99+
[SwaggerOperation(Summary = "Get Establishment by URN", Description = "Returns an establishment specified by URN.")]
100+
[SwaggerResponse(200, "Successfully found and returned the establishment.")]
101+
[SwaggerResponse(404, "Establishment with specified URN not found.")]
73102
public ActionResult<EstablishmentResponse> GetByUrn(int urn)
74103
{
75104
var establishment = _getEstablishmentByUrn.Execute(new GetEstablishmentByUrnRequest { URN = urn });
@@ -85,8 +114,15 @@ public ActionResult<EstablishmentResponse> GetByUrn(int urn)
85114
return Ok(establishment);
86115
}
87116

117+
/// <summary>
118+
/// Searches for establishments based on a query.
119+
/// </summary>
120+
/// <param name="request">Search criteria.</param>
121+
/// <returns>List of establishments that meet the search criteria.</returns>
88122
[HttpGet]
89123
[Route("establishments")]
124+
[SwaggerOperation(Summary = "Search for Establishments", Description = "Returns a list of establishments based on search criteria.")]
125+
[SwaggerResponse(200, "Successfully executed the search and returned establishments.")]
90126
public ActionResult<List<EstablishmentSummaryResponse>> SearchEstablishments([FromQuery] SearchEstablishmentsRequest request)
91127
{
92128
_logger.LogInformation($"Searching for Establishments");
@@ -95,8 +131,16 @@ public ActionResult<List<EstablishmentSummaryResponse>> SearchEstablishments([Fr
95131
return Ok(establishments);
96132
}
97133

134+
/// <summary>
135+
/// Retrieves a list of establishments by their URNs.
136+
/// </summary>
137+
/// <param name="request">Contains URNs of the establishments.</param>
138+
/// <returns>List of establishments or NotFound if none are available.</returns>
98139
[HttpGet]
99140
[Route("establishments/bulk")]
141+
[SwaggerOperation(Summary = "Get Establishments by URNs", Description = "Returns a list of establishments specified by URNs.")]
142+
[SwaggerResponse(200, "Successfully found and returned the establishments.")]
143+
[SwaggerResponse(404, "Establishments with specified URNs not found.")]
100144
public ActionResult<List<EstablishmentResponse>> GetByUrns([FromQuery] GetEstablishmentsByUrnsRequest request)
101145
{
102146
var commaSeparatedRequestUrns = string.Join(",", request.Urns);

0 commit comments

Comments
 (0)