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 - ProductAttribute - add ProducesResponseType

KrzysztofPajak15c9a1991032
diff --git a/src/API/Grand.Api/Controllers/OData/ProductAttributeController.cs b/src/API/Grand.Api/Controllers/OData/ProductAttributeController.cs
index bcc8cd7f9..54215f02e 100644
--- a/src/API/Grand.Api/Controllers/OData/ProductAttributeController.cs
+++ b/src/API/Grand.Api/Controllers/OData/ProductAttributeController.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
@@ -29,6 +30,9 @@ namespace Grand.Api.Controllers.OData
[SwaggerOperation(summary: "Get entity from ProductAttribute by key", OperationId = "GetProductAttributeById")]
[HttpGet("{key}")]
+ [ProducesResponseType((int)HttpStatusCode.Forbidden)]
+ [ProducesResponseType((int)HttpStatusCode.OK)]
+ [ProducesResponseType((int)HttpStatusCode.NotFound)]
public async Task<IActionResult> Get(string key)
{
if (!await _permissionService.Authorize(PermissionSystemName.ProductAttributes))
@@ -44,6 +48,8 @@ namespace Grand.Api.Controllers.OData
[SwaggerOperation(summary: "Get entities from ProductAttribute", OperationId = "GetProductAttributes")]
[HttpGet]
[EnableQuery(HandleNullPropagation = HandleNullPropagationOption.False)]
+ [ProducesResponseType((int)HttpStatusCode.Forbidden)]
+ [ProducesResponseType((int)HttpStatusCode.OK)]
public async Task<IActionResult> Get()
{
if (!await _permissionService.Authorize(PermissionSystemName.ProductAttributes))
@@ -54,6 +60,9 @@ namespace Grand.Api.Controllers.OData
[SwaggerOperation(summary: "Add new entity to ProductAttribute", OperationId = "InsertProductAttribute")]
[HttpPost]
+ [ProducesResponseType((int)HttpStatusCode.Forbidden)]
+ [ProducesResponseType((int)HttpStatusCode.OK)]
+ [ProducesResponseType((int)HttpStatusCode.BadRequest)]
public async Task<IActionResult> Post([FromBody] ProductAttributeDto model)
{
if (!await _permissionService.Authorize(PermissionSystemName.ProductAttributes))
@@ -69,6 +78,9 @@ namespace Grand.Api.Controllers.OData
[SwaggerOperation(summary: "Update entity in ProductAttribute", OperationId = "UpdateProductAttribute")]
[HttpPut]
+ [ProducesResponseType((int)HttpStatusCode.Forbidden)]
+ [ProducesResponseType((int)HttpStatusCode.OK)]
+ [ProducesResponseType((int)HttpStatusCode.BadRequest)]
public async Task<IActionResult> Put([FromBody] ProductAttributeDto model)
{
if (!await _permissionService.Authorize(PermissionSystemName.ProductAttributes))
@@ -84,6 +96,10 @@ namespace Grand.Api.Controllers.OData
[SwaggerOperation(summary: "Partially update entity in ProductAttribute", OperationId = "PartiallyUpdateProductAttribute")]
[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<ProductAttributeDto> model)
{
if (!await _permissionService.Authorize(PermissionSystemName.ProductAttributes))
@@ -106,6 +122,9 @@ namespace Grand.Api.Controllers.OData
[SwaggerOperation(summary: "Delete entity from ProductAttribute", OperationId = "DeleteProductAttribute")]
[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.ProductAttributes))