diff --git a/Apps/Api/Controllers/AccountsController.cs b/Apps/Api/Controllers/AccountsController.cs
index 4a29fb9..4f5fba0 100644
--- a/Apps/Api/Controllers/AccountsController.cs
+++ b/Apps/Api/Controllers/AccountsController.cs
@@ -26,6 +26,11 @@ namespace Api.Controllers
_tokenParameters = tokenParameters;
}
+ ///
+ /// Récupère un jeton d'accès pour un utilisateur particulier.
+ ///
+ ///
+ ///
[HttpPost("login")]
[AllowAnonymous]
public async Task Login(LoginViewModel command)
diff --git a/Apps/Api/Controllers/CommentsController.cs b/Apps/Api/Controllers/CommentsController.cs
new file mode 100644
index 0000000..4db8c37
--- /dev/null
+++ b/Apps/Api/Controllers/CommentsController.cs
@@ -0,0 +1,48 @@
+using System;
+using System.Threading.Tasks;
+using HN.Application;
+using HN.Domain;
+using MediatR;
+using Microsoft.AspNetCore.Http;
+using Microsoft.AspNetCore.Mvc;
+
+namespace Api.Controllers
+{
+ [ApiController]
+ [Route("api/[controller]")]
+ public sealed class CommentsController : ControllerBase
+ {
+ private readonly IMediator _bus;
+
+ public CommentsController(IMediator bus)
+ {
+ _bus = bus;
+ }
+
+ ///
+ /// Upvote un commentaire particulier.
+ ///
+ ///
+ ///
+ [HttpPut("{id}/upvote")]
+ [ProducesResponseType(StatusCodes.Status204NoContent)]
+ public async Task Upvote(Guid id)
+ {
+ await _bus.Send(new VoteForCommentCommand(id, VoteType.Up));
+ return NoContent();
+ }
+
+ ///
+ /// Downvote un commentaire particulier.
+ ///
+ ///
+ ///
+ [HttpPut("{id}/downvote")]
+ [ProducesResponseType(StatusCodes.Status204NoContent)]
+ public async Task Downvote(Guid id)
+ {
+ await _bus.Send(new VoteForCommentCommand(id, VoteType.Down));
+ return NoContent();
+ }
+ }
+}
\ No newline at end of file
diff --git a/Apps/Api/Startup.cs b/Apps/Api/Startup.cs
index 06439a3..f6570a8 100644
--- a/Apps/Api/Startup.cs
+++ b/Apps/Api/Startup.cs
@@ -71,7 +71,7 @@ namespace Api
o.Filters.Add(new AuthorizeFilter()); // Ou MapControllers().RequireAuthentication()
});
- services.AddSwaggerDocument(d =>
+ services.AddOpenApiDocument(d =>
{
// cf. https://github.com/RicoSuter/NSwag/wiki/AspNetCore-Middleware#enable-authentication-in-generator-and-swagger-ui
@@ -100,8 +100,6 @@ namespace Api
{
od.Info.Title = "Hacker news like API in .Net";
};
-
- d.SchemaType = NJsonSchema.SchemaType.OpenApi3;
});
}
diff --git a/Apps/Api/swagger.json b/Apps/Api/swagger.json
index d16fda3..4a56ec2 100644
--- a/Apps/Api/swagger.json
+++ b/Apps/Api/swagger.json
@@ -11,6 +11,7 @@
"tags": [
"Accounts"
],
+ "summary": "Récupère un jeton d'accès pour un utilisateur particulier.",
"operationId": "Accounts_Login",
"requestBody": {
"x-name": "command",
@@ -39,6 +40,58 @@
}
}
},
+ "/api/comments/{id}/upvote": {
+ "put": {
+ "tags": [
+ "Comments"
+ ],
+ "summary": "Upvote un commentaire particulier.",
+ "operationId": "Comments_Upvote",
+ "parameters": [
+ {
+ "name": "id",
+ "in": "path",
+ "required": true,
+ "schema": {
+ "type": "string",
+ "format": "guid"
+ },
+ "x-position": 1
+ }
+ ],
+ "responses": {
+ "204": {
+ "description": ""
+ }
+ }
+ }
+ },
+ "/api/comments/{id}/downvote": {
+ "put": {
+ "tags": [
+ "Comments"
+ ],
+ "summary": "Downvote un commentaire particulier.",
+ "operationId": "Comments_Downvote",
+ "parameters": [
+ {
+ "name": "id",
+ "in": "path",
+ "required": true,
+ "schema": {
+ "type": "string",
+ "format": "guid"
+ },
+ "x-position": 1
+ }
+ ],
+ "responses": {
+ "204": {
+ "description": ""
+ }
+ }
+ }
+ },
"/api/links": {
"get": {
"tags": [