Skip to content

Open-source eCommerce platform for C# and ASP.NET Core 10 with MongoDB. Build multi-store shops and multi-vendor marketplaces with B2B/B2C, REST API, plugins, Vue 3 and Docker.

API - Brand - add ProducesResponseType

KrzysztofPajak54b7d16f9652
diff --git a/src/API/Grand.Api/Controllers/OData/BrandController.cs b/src/API/Grand.Api/Controllers/OData/BrandController.cs
index 544b09063..343e4f9ad 100644
--- a/src/API/Grand.Api/Controllers/OData/BrandController.cs
+++ b/src/API/Grand.Api/Controllers/OData/BrandController.cs
@@ -10,6 +10,7 @@ using Microsoft.AspNetCore.OData.Formatter;
using Microsoft.AspNetCore.OData.Query;
using Swashbuckle.AspNetCore.Annotations;
using System.Linq;
+using System.Net;
using System.Threading.Tasks;
namespace Grand.Api.Controllers.OData
@@ -27,6 +28,8 @@ namespace Grand.Api.Controllers.OData
[SwaggerOperation(summary: "Get entities from Brand", OperationId = "GetBrands")]
[HttpGet]
[EnableQuery]
+ [ProducesResponseType((int)HttpStatusCode.Forbidden)]
+ [ProducesResponseType((int)HttpStatusCode.OK)]
public async Task<IActionResult> Get()
{
if (!await _permissionService.Authorize(PermissionSystemName.Brands))
@@ -37,6 +40,9 @@ namespace Grand.Api.Controllers.OData
[SwaggerOperation(summary: "Get entity from Brand by key", OperationId = "GetBrandById")]
[HttpGet("{key}")]
+ [ProducesResponseType((int)HttpStatusCode.Forbidden)]
+ [ProducesResponseType((int)HttpStatusCode.NotFound)]
+ [ProducesResponseType((int)HttpStatusCode.OK)]
public async Task<IActionResult> Get(string key)
{
if (!await _permissionService.Authorize(PermissionSystemName.Brands))
@@ -46,13 +52,16 @@ namespace Grand.Api.Controllers.OData
if (!brand.Any())
return NotFound();
- return Ok(brand);
+ return Ok(brand.FirstOrDefault());
}
[SwaggerOperation(summary: "Add new entity to Brand", OperationId = "InsertBrand")]
[HttpPost]
+ [ProducesResponseType((int)HttpStatusCode.Forbidden)]
+ [ProducesResponseType((int)HttpStatusCode.OK)]
+ [ProducesResponseType((int)HttpStatusCode.BadRequest)]
public async Task<IActionResult> Post([FromBody] BrandDto model)
{
if (!await _permissionService.Authorize(PermissionSystemName.Brands))
@@ -68,6 +77,10 @@ namespace Grand.Api.Controllers.OData
[SwaggerOperation(summary: "Update entity in Brand", OperationId = "UpdateBrand")]
[HttpPut]
+ [ProducesResponseType((int)HttpStatusCode.Forbidden)]
+ [ProducesResponseType((int)HttpStatusCode.OK)]
+ [ProducesResponseType((int)HttpStatusCode.BadRequest)]
+ [ProducesResponseType((int)HttpStatusCode.NotFound)]
public async Task<IActionResult> Put([FromBody] BrandDto model)
{
if (!await _permissionService.Authorize(PermissionSystemName.Brands))
@@ -91,6 +104,10 @@ namespace Grand.Api.Controllers.OData
[SwaggerOperation(summary: "Partially update entity in Brand", OperationId = "PartiallyUpdateBrand")]
[HttpPatch]
+ [ProducesResponseType((int)HttpStatusCode.Forbidden)]
+ [ProducesResponseType((int)HttpStatusCode.OK)]
+ [ProducesResponseType((int)HttpStatusCode.BadRequest)]
+ [ProducesResponseType((int)HttpStatusCode.NotFound)]
public async Task<IActionResult> Patch([FromODataUri] string key, [FromBody] JsonPatchDocument<BrandDto> model)
{
if (!await _permissionService.Authorize(PermissionSystemName.Brands))
@@ -115,6 +132,9 @@ namespace Grand.Api.Controllers.OData
[SwaggerOperation(summary: "Delete entity in Brand", OperationId = "DeleteBrand")]
[HttpDelete]
+ [ProducesResponseType((int)HttpStatusCode.Forbidden)]
+ [ProducesResponseType((int)HttpStatusCode.OK)]
+ [ProducesResponseType((int)HttpStatusCode.NotFound)]
public async Task<IActionResult> Delete(string key)
{
if (!await _permissionService.Authorize(PermissionSystemName.Brands))