|
3 | 3 | using Microsoft.AspNetCore.Mvc; |
4 | 4 | using Microsoft.EntityFrameworkCore; |
5 | 5 | using OpenShock.Internal.Common; |
| 6 | +using OpenShock.Internal.Common.Problems; |
6 | 7 | using OpenShock.RepositoryServer.Config; |
7 | | -using OpenShock.RepositoryServer.Problems; |
| 8 | +using OpenShock.RepositoryServer.Errors; |
8 | 9 | using OpenShock.RepositoryServer.RepoServerDb; |
9 | 10 | using OpenShock.RepositoryServer.Services; |
10 | 11 | using Semver; |
@@ -41,9 +42,19 @@ public CiCdController(RepoServerContext db, IStorageService storage, ApiConfig a |
41 | 42 | /// Publishes a desktop module version by uploading a zip file. |
42 | 43 | /// The file is hashed server-side, uploaded to storage, and recorded in the database. |
43 | 44 | /// </summary> |
| 45 | + /// <response code="201">The version was published.</response> |
| 46 | + /// <response code="400">The version is not valid semver, or the uploaded zip is missing or rejected.</response> |
| 47 | + /// <response code="403">The calling repository does not own this module.</response> |
| 48 | + /// <response code="404">The module does not exist.</response> |
| 49 | + /// <response code="409">This version has already been published.</response> |
44 | 50 | [HttpPut("modules/{moduleId}/versions/{moduleVersion}")] |
45 | 51 | [Consumes("multipart/form-data")] |
46 | 52 | [RequestSizeLimit(256 * 1024 * 1024)] // 256 MB |
| 53 | + [ProducesResponseType(StatusCodes.Status201Created)] |
| 54 | + [ProducesResponseType<OpenShockProblem>(StatusCodes.Status400BadRequest, MediaTypeNames.Application.ProblemJson)] // VersionInvalidSemver, ZipMissing, ZipInvalid, ZipEmpty, ZipPathTraversal, ZipDisallowedDirectory, ZipDisallowedRootFile |
| 55 | + [ProducesResponseType<OpenShockProblem>(StatusCodes.Status403Forbidden, MediaTypeNames.Application.ProblemJson)] // ModuleNotOwned |
| 56 | + [ProducesResponseType<OpenShockProblem>(StatusCodes.Status404NotFound, MediaTypeNames.Application.ProblemJson)] // ModuleNotFound |
| 57 | + [ProducesResponseType<OpenShockProblem>(StatusCodes.Status409Conflict, MediaTypeNames.Application.ProblemJson)] // VersionAlreadyExists |
47 | 58 | public async Task<IActionResult> PublishVersion( |
48 | 59 | [FromRoute] string moduleId, |
49 | 60 | [FromRoute] string moduleVersion, |
@@ -86,7 +97,7 @@ public async Task<IActionResult> PublishVersion( |
86 | 97 | var file = Request.Form.Files.GetFile("zip"); |
87 | 98 | if (file == null) |
88 | 99 | { |
89 | | - return BadRequest(new { error = "No file uploaded. Expected a file field named 'zip'." }); |
| 100 | + return Problem(ModuleError.ZipMissing); |
90 | 101 | } |
91 | 102 |
|
92 | 103 | // Read file into memory for validation + hashing + storage upload |
|
0 commit comments