Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,21 @@

<ItemGroup>
<!-- Main application packages -->
<PackageVersion Include="Microsoft.AspNetCore.OpenApi" Version="9.0.6" />
<PackageVersion Include="Swashbuckle.AspNetCore" Version="9.0.3" />
<PackageVersion Include="Swashbuckle.AspNetCore.Annotations" Version="9.0.3" />
<PackageVersion Include="Microsoft.AspNetCore.OpenApi" Version="10.0.3" />
<PackageVersion Include="Swashbuckle.AspNetCore" Version="10.1.2" />
<PackageVersion Include="Swashbuckle.AspNetCore.Annotations" Version="10.1.2" />

<!-- Test framework packages -->
<PackageVersion Include="Allure.Xunit" Version="2.14.1" />
<PackageVersion Include="coverlet.collector" Version="6.0.2" />
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="17.12.0" />
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="18.0.1" />
<PackageVersion Include="Moq" Version="4.20.72" />
<PackageVersion Include="xunit" Version="2.9.2" />
<PackageVersion Include="xunit.runner.visualstudio" Version="2.8.2" />

<!-- ASP.NET Core test packages -->
<PackageVersion Include="Microsoft.AspNetCore.Mvc.Testing" Version="9.0.11" />
<PackageVersion Include="Microsoft.Extensions.Hosting.Abstractions" Version="9.0.11" />
<PackageVersion Include="Microsoft.Extensions.Options" Version="9.0.11" />
<PackageVersion Include="Microsoft.AspNetCore.Mvc.Testing" Version="10.0.2" />
<PackageVersion Include="Microsoft.Extensions.Hosting.Abstractions" Version="10.0.3" />
<PackageVersion Include="Microsoft.Extensions.Options" Version="10.0.3" />
</ItemGroup>
</Project>
5 changes: 3 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Build stage
FROM mcr.microsoft.com/dotnet/sdk:9.0 AS build
FROM mcr.microsoft.com/dotnet/sdk:10.0 AS build
WORKDIR /app

# Copy solution and all .csproj files
Expand All @@ -14,6 +14,7 @@ COPY tests/TheOfficeAPI.Level2.Tests.Integration/*.csproj ./tests/TheOfficeAPI.L
COPY tests/TheOfficeAPI.Level3.Tests.Unit/*.csproj ./tests/TheOfficeAPI.Level3.Tests.Unit/
COPY tests/TheOfficeAPI.Level3.Tests.Integration/*.csproj ./tests/TheOfficeAPI.Level3.Tests.Integration/
COPY tests/TheOfficeAPI.Tests.E2E/*.csproj ./tests/TheOfficeAPI.Tests.E2E/
COPY tests/TheOfficeAPI.Common.Tests.Unit/*.csproj ./tests/TheOfficeAPI.Common.Tests.Unit/

# Restore dependencies
RUN dotnet restore TheOfficeAPI.sln
Expand All @@ -28,7 +29,7 @@ RUN dotnet publish src/TheOfficeAPI/TheOfficeAPI.csproj \
--no-restore

# Runtime stage
FROM mcr.microsoft.com/dotnet/aspnet:9.0
FROM mcr.microsoft.com/dotnet/aspnet:10.0
WORKDIR /app

# Copy compiled files
Expand Down
34 changes: 26 additions & 8 deletions TheOfficeAPI.sln
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@


Microsoft Visual Studio Solution File, Format Version 12.00
#
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TheOfficeAPI", "src/TheOfficeAPI/TheOfficeAPI.csproj", "{B1D1A596-0809-4313-8A9F-AFBC87A87458}"
Expand All @@ -13,15 +13,15 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TheOfficeAPI.Level1.Tests.I
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TheOfficeAPI.Level2.Tests.Unit", "tests/TheOfficeAPI.Level2.Tests.Unit/TheOfficeAPI.Level2.Tests.Unit.csproj", "{E3FA0913-3456-7890-1234-D362FE48FE0D}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TheOfficeAPI.Level2.Tests.Integration", "tests/TheOfficeAPI.Level2.Tests.Integration/TheOfficeAPI.Level2.Tests.Integration.csproj", "{00000000-0000-0000-0000-000000000000}"
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TheOfficeAPI.Level2.Tests.Integration", "tests/TheOfficeAPI.Level2.Tests.Integration/TheOfficeAPI.Level2.Tests.Integration.csproj", "{9078F4DA-6AD0-4024-8764-679B805E0C28}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TheOfficeAPI.Level3.Tests.Unit", "tests/TheOfficeAPI.Level3.Tests.Unit/TheOfficeAPI.Level3.Tests.Unit.csproj", "{00000000-0000-0000-0000-000000000000}"
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TheOfficeAPI.Level3.Tests.Unit", "tests/TheOfficeAPI.Level3.Tests.Unit/TheOfficeAPI.Level3.Tests.Unit.csproj", "{DB0B4A87-CBA6-4B04-98FD-479E0E4A1E84}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TheOfficeAPI.Level3.Tests.Integration", "tests/TheOfficeAPI.Level3.Tests.Integration/TheOfficeAPI.Level3.Tests.Integration.csproj", "{00000000-0000-0000-0000-000000000000}"
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TheOfficeAPI.Level3.Tests.Integration", "tests/TheOfficeAPI.Level3.Tests.Integration/TheOfficeAPI.Level3.Tests.Integration.csproj", "{3586BC66-210E-47DD-ABCE-8DC3D0638291}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TheOfficeAPI.Tests.E2E", "tests/TheOfficeAPI.Tests.E2E/TheOfficeAPI.Tests.E2E.csproj", "{00000000-0000-0000-0000-000000000000}"
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TheOfficeAPI.Tests.E2E", "tests/TheOfficeAPI.Tests.E2E/TheOfficeAPI.Tests.E2E.csproj", "{EDE0ED8F-C286-4FFC-80BC-1972BE240130}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TheOfficeAPI.Common.Tests.Unit", "tests/TheOfficeAPI.Common.Tests.Unit/TheOfficeAPI.Common.Tests.Unit.csproj", "{00000000-0000-0000-0000-000000000000}"
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TheOfficeAPI.Common.Tests.Unit", "tests/TheOfficeAPI.Common.Tests.Unit/TheOfficeAPI.Common.Tests.Unit.csproj", "{91D7F9AC-B773-4409-90BB-C743351DB612}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Expand Down Expand Up @@ -53,7 +53,25 @@ Global
{E3FA0913-3456-7890-1234-D362FE48FE0D}.Debug|Any CPU.Build.0 = Debug|Any CPU
{E3FA0913-3456-7890-1234-D362FE48FE0D}.Release|Any CPU.ActiveCfg = Release|Any CPU
{E3FA0913-3456-7890-1234-D362FE48FE0D}.Release|Any CPU.Build.0 = Release|Any CPU
{00000000-0000-0000-0000-000000000000}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{00000000-0000-0000-0000-000000000000}.Debug|Any CPU.Build.0 = Debug|Any CPU
{9078F4DA-6AD0-4024-8764-679B805E0C28}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{9078F4DA-6AD0-4024-8764-679B805E0C28}.Debug|Any CPU.Build.0 = Debug|Any CPU
{9078F4DA-6AD0-4024-8764-679B805E0C28}.Release|Any CPU.ActiveCfg = Release|Any CPU
{9078F4DA-6AD0-4024-8764-679B805E0C28}.Release|Any CPU.Build.0 = Release|Any CPU
{DB0B4A87-CBA6-4B04-98FD-479E0E4A1E84}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{DB0B4A87-CBA6-4B04-98FD-479E0E4A1E84}.Debug|Any CPU.Build.0 = Debug|Any CPU
{DB0B4A87-CBA6-4B04-98FD-479E0E4A1E84}.Release|Any CPU.ActiveCfg = Release|Any CPU
{DB0B4A87-CBA6-4B04-98FD-479E0E4A1E84}.Release|Any CPU.Build.0 = Release|Any CPU
{3586BC66-210E-47DD-ABCE-8DC3D0638291}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{3586BC66-210E-47DD-ABCE-8DC3D0638291}.Debug|Any CPU.Build.0 = Debug|Any CPU
{3586BC66-210E-47DD-ABCE-8DC3D0638291}.Release|Any CPU.ActiveCfg = Release|Any CPU
{3586BC66-210E-47DD-ABCE-8DC3D0638291}.Release|Any CPU.Build.0 = Release|Any CPU
{EDE0ED8F-C286-4FFC-80BC-1972BE240130}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{EDE0ED8F-C286-4FFC-80BC-1972BE240130}.Debug|Any CPU.Build.0 = Debug|Any CPU
{EDE0ED8F-C286-4FFC-80BC-1972BE240130}.Release|Any CPU.ActiveCfg = Release|Any CPU
{EDE0ED8F-C286-4FFC-80BC-1972BE240130}.Release|Any CPU.Build.0 = Release|Any CPU
{91D7F9AC-B773-4409-90BB-C743351DB612}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{91D7F9AC-B773-4409-90BB-C743351DB612}.Debug|Any CPU.Build.0 = Debug|Any CPU
{91D7F9AC-B773-4409-90BB-C743351DB612}.Release|Any CPU.ActiveCfg = Release|Any CPU
{91D7F9AC-B773-4409-90BB-C743351DB612}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
EndGlobal
12 changes: 7 additions & 5 deletions src/TheOfficeAPI/Common/Services/HealthCheckService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ namespace TheOfficeAPI.Common.Services;
/// </summary>
public class HealthCheckService
{
private const string HealthyStatus = "Healthy";

private readonly DateTime _startTime;
private readonly string _version;

Expand All @@ -24,7 +26,7 @@ public HealthCheckResponse GetLivenessStatus()
{
return new HealthCheckResponse
{
Status = "Healthy",
Status = HealthyStatus,
Timestamp = DateTime.UtcNow,
Message = "Application is alive"
};
Expand All @@ -37,7 +39,7 @@ public DetailedHealthCheckResponse GetReadinessStatus()
{
var response = new DetailedHealthCheckResponse
{
Status = "Healthy",
Status = HealthyStatus,
Timestamp = DateTime.UtcNow,
Message = "Application is ready to serve traffic",
Uptime = DateTime.UtcNow - _startTime,
Expand All @@ -46,7 +48,7 @@ public DetailedHealthCheckResponse GetReadinessStatus()
{
["application"] = new ComponentHealth
{
Status = "Healthy",
Status = HealthyStatus,
Description = "Application is running normally",
Data = new Dictionary<string, object>
{
Expand All @@ -56,7 +58,7 @@ public DetailedHealthCheckResponse GetReadinessStatus()
},
["dataService"] = new ComponentHealth
{
Status = "Healthy",
Status = HealthyStatus,
Description = "In-memory data service is available",
Data = new Dictionary<string, object>
{
Expand All @@ -77,7 +79,7 @@ public HealthCheckResponse GetHealthStatus()
{
return new HealthCheckResponse
{
Status = "Healthy",
Status = HealthyStatus,
Timestamp = DateTime.UtcNow,
Message = "OK"
};
Expand Down
7 changes: 4 additions & 3 deletions src/TheOfficeAPI/Level0/Controllers/HealthController.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Microsoft.AspNetCore.Mvc;
using TheOfficeAPI.Common.Models;
using TheOfficeAPI.Common.Services;

namespace TheOfficeAPI.Level0.Controllers;
Expand All @@ -23,7 +24,7 @@ public HealthController(HealthCheckService healthCheckService)
/// <returns>Health status</returns>
/// <response code="200">Service is healthy</response>
[HttpGet]
[ProducesResponseType(StatusCodes.Status200OK)]
[ProducesResponseType(typeof(HealthCheckResponse), StatusCodes.Status200OK)]
public IActionResult Get()
{
var health = _healthCheckService.GetHealthStatus();
Expand All @@ -40,7 +41,7 @@ public IActionResult Get()
/// is still running. If this fails, the container should be restarted.
/// </remarks>
[HttpGet("live")]
[ProducesResponseType(StatusCodes.Status200OK)]
[ProducesResponseType(typeof(HealthCheckResponse), StatusCodes.Status200OK)]
public IActionResult GetLiveness()
{
var health = _healthCheckService.GetLivenessStatus();
Expand All @@ -57,7 +58,7 @@ public IActionResult GetLiveness()
/// is ready to receive traffic. If this fails, traffic should not be routed to this instance.
/// </remarks>
[HttpGet("ready")]
[ProducesResponseType(StatusCodes.Status200OK)]
[ProducesResponseType(typeof(DetailedHealthCheckResponse), StatusCodes.Status200OK)]
public IActionResult GetReadiness()
{
var health = _healthCheckService.GetReadinessStatus();
Expand Down
1 change: 1 addition & 0 deletions src/TheOfficeAPI/Level0/Controllers/OfficeApiController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ public Level0Controller(TheOfficeService theOfficeService)
/// </code>
/// </example>
[HttpPost("theOffice")]
[ProducesResponseType(typeof(ApiResponse<object>), StatusCodes.Status200OK)]
public IActionResult HandleRequest([FromBody] ApiRequest request)
{
// Level 0: Always return 200 OK, put actual status in response body
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using System.Reflection;
using Microsoft.OpenApi.Models;
using Microsoft.OpenApi;

namespace TheOfficeAPI.Level0.Extensions
{
Expand Down
2 changes: 2 additions & 0 deletions src/TheOfficeAPI/Level1/Controllers/EpisodesController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ public EpisodesController(TheOfficeService theOfficeService)
/// </code>
/// </example>
[HttpPost]
[ProducesResponseType(typeof(ApiResponse<List<Episode>>), StatusCodes.Status200OK)]
public IActionResult GetSeasonEpisodes([FromRoute] int seasonNumber)
{
try
Expand Down Expand Up @@ -108,6 +109,7 @@ public IActionResult GetSeasonEpisodes([FromRoute] int seasonNumber)
/// </code>
/// </example>
[HttpPost("{episodeNumber}")]
[ProducesResponseType(typeof(ApiResponse<Episode>), StatusCodes.Status200OK)]
public IActionResult GetEpisode([FromRoute] int seasonNumber, [FromRoute] int episodeNumber)
{
try
Expand Down
7 changes: 4 additions & 3 deletions src/TheOfficeAPI/Level1/Controllers/HealthController.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Microsoft.AspNetCore.Mvc;
using TheOfficeAPI.Common.Models;
using TheOfficeAPI.Common.Services;

namespace TheOfficeAPI.Level1.Controllers;
Expand All @@ -23,7 +24,7 @@ public HealthController(HealthCheckService healthCheckService)
/// <returns>Health status</returns>
/// <response code="200">Service is healthy</response>
[HttpGet]
[ProducesResponseType(StatusCodes.Status200OK)]
[ProducesResponseType(typeof(HealthCheckResponse), StatusCodes.Status200OK)]
public IActionResult Get()
{
var health = _healthCheckService.GetHealthStatus();
Expand All @@ -40,7 +41,7 @@ public IActionResult Get()
/// is still running. If this fails, the container should be restarted.
/// </remarks>
[HttpGet("live")]
[ProducesResponseType(StatusCodes.Status200OK)]
[ProducesResponseType(typeof(HealthCheckResponse), StatusCodes.Status200OK)]
public IActionResult GetLiveness()
{
var health = _healthCheckService.GetLivenessStatus();
Expand All @@ -57,7 +58,7 @@ public IActionResult GetLiveness()
/// is ready to receive traffic. If this fails, traffic should not be routed to this instance.
/// </remarks>
[HttpGet("ready")]
[ProducesResponseType(StatusCodes.Status200OK)]
[ProducesResponseType(typeof(DetailedHealthCheckResponse), StatusCodes.Status200OK)]
public IActionResult GetReadiness()
{
var health = _healthCheckService.GetReadinessStatus();
Expand Down
1 change: 1 addition & 0 deletions src/TheOfficeAPI/Level1/Controllers/SeasonsController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ public SeasonsController(TheOfficeService theOfficeService)
/// </code>
/// </example>
[HttpPost]
[ProducesResponseType(typeof(ApiResponse<List<Season>>), StatusCodes.Status200OK)]
public IActionResult GetAllSeasons()
{
try
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using System.Reflection;
using Microsoft.OpenApi.Models;
using Microsoft.OpenApi;

namespace TheOfficeAPI.Level1.Extensions
{
Expand Down
7 changes: 4 additions & 3 deletions src/TheOfficeAPI/Level2/Controllers/HealthController.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Microsoft.AspNetCore.Mvc;
using TheOfficeAPI.Common.Models;
using TheOfficeAPI.Common.Services;

namespace TheOfficeAPI.Level2.Controllers;
Expand All @@ -23,7 +24,7 @@ public HealthController(HealthCheckService healthCheckService)
/// <returns>Health status</returns>
/// <response code="200">Service is healthy</response>
[HttpGet]
[ProducesResponseType(StatusCodes.Status200OK)]
[ProducesResponseType(typeof(HealthCheckResponse), StatusCodes.Status200OK)]
public IActionResult Get()
{
var health = _healthCheckService.GetHealthStatus();
Expand All @@ -40,7 +41,7 @@ public IActionResult Get()
/// is still running. If this fails, the container should be restarted.
/// </remarks>
[HttpGet("live")]
[ProducesResponseType(StatusCodes.Status200OK)]
[ProducesResponseType(typeof(HealthCheckResponse), StatusCodes.Status200OK)]
public IActionResult GetLiveness()
{
var health = _healthCheckService.GetLivenessStatus();
Expand All @@ -57,7 +58,7 @@ public IActionResult GetLiveness()
/// is ready to receive traffic. If this fails, traffic should not be routed to this instance.
/// </remarks>
[HttpGet("ready")]
[ProducesResponseType(StatusCodes.Status200OK)]
[ProducesResponseType(typeof(DetailedHealthCheckResponse), StatusCodes.Status200OK)]
public IActionResult GetReadiness()
{
var health = _healthCheckService.GetReadinessStatus();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using System.Reflection;
using Microsoft.OpenApi.Models;
using Microsoft.OpenApi;

namespace TheOfficeAPI.Level2.Extensions
{
Expand Down
Loading
Loading