From 1c459c147d3e93216d6a88300e54765e78fefa7c Mon Sep 17 00:00:00 2001 From: KrzysztofPajak Date: Tue, 10 Aug 2021 09:55:30 +0200 Subject: [PATCH 1/7] Upgrade oData to version 8.0 --- .../Controllers/BaseODataController.cs | 4 +- .../Controllers/OData/BrandController.cs | 26 +++--- .../OData/BrandLayoutController.cs | 3 +- .../Controllers/OData/CategoryController.cs | 4 +- .../OData/CategoryLayoutController.cs | 3 +- .../Controllers/OData/CollectionController.cs | 4 +- .../OData/CollectionLayoutController.cs | 3 +- .../Controllers/OData/CountryController.cs | 3 +- .../Controllers/OData/CurrencyController.cs | 3 +- .../Controllers/OData/CustomerController.cs | 2 +- .../OData/CustomerGroupController.cs | 4 +- .../OData/DeliveryDateController.cs | 3 +- .../Controllers/OData/LanguageController.cs | 3 +- .../OData/PickupPointController.cs | 3 +- .../OData/ProductAttributeController.cs | 4 +- .../Controllers/OData/ProductController.cs | 4 +- .../OData/ProductLayoutController.cs | 3 +- .../OData/ShippingMethodController.cs | 3 +- .../OData/SpecificationAttributeController.cs | 4 +- .../OData/StateProvinceController.cs | 3 +- .../Controllers/OData/StoreController.cs | 3 +- .../Controllers/OData/VendorController.cs | 3 +- .../Controllers/OData/WarehouseController.cs | 3 +- src/API/Grand.Api/Grand.Api.csproj | 7 +- .../Infrastructure/AuthenticationStartup.cs | 48 ----------- .../Infrastructure/DependencyEdmModel.cs | 32 ++----- .../IDependencyEdmModel.cs | 2 +- .../Infrastructure/ODataParamsStartup.cs | 49 ----------- .../Infrastructure/ODataRouteProvider.cs | 62 -------------- .../Grand.Api/Infrastructure/ODataStartup.cs | 83 +++++++++++++++++++ .../Infrastructure/SwaggerStartup.cs | 7 +- 31 files changed, 143 insertions(+), 245 deletions(-) delete mode 100644 src/API/Grand.Api/Infrastructure/AuthenticationStartup.cs delete mode 100644 src/API/Grand.Api/Infrastructure/ODataParamsStartup.cs delete mode 100644 src/API/Grand.Api/Infrastructure/ODataRouteProvider.cs create mode 100644 src/API/Grand.Api/Infrastructure/ODataStartup.cs diff --git a/src/API/Grand.Api/Controllers/BaseODataController.cs b/src/API/Grand.Api/Controllers/BaseODataController.cs index 2cba38fef..3929c5113 100644 --- a/src/API/Grand.Api/Controllers/BaseODataController.cs +++ b/src/API/Grand.Api/Controllers/BaseODataController.cs @@ -1,12 +1,14 @@ using Grand.Api.Filters; -using Microsoft.AspNet.OData; using Microsoft.AspNetCore.Authentication.JwtBearer; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; +using Microsoft.AspNetCore.OData.Routing.Attributes; +using Microsoft.AspNetCore.OData.Routing.Controllers; namespace Grand.Api.Controllers { [Authorize(AuthenticationSchemes = JwtBearerDefaults.AuthenticationScheme)] + [ODataRouteComponent] [Route("odata/[controller]")] [ApiExplorerSettings(IgnoreApi = false)] [AuthorizeApiAdmin] diff --git a/src/API/Grand.Api/Controllers/OData/BrandController.cs b/src/API/Grand.Api/Controllers/OData/BrandController.cs index 957990494..cf2e85c57 100644 --- a/src/API/Grand.Api/Controllers/OData/BrandController.cs +++ b/src/API/Grand.Api/Controllers/OData/BrandController.cs @@ -4,10 +4,10 @@ using Grand.Business.Common.Interfaces.Security; using Grand.Business.Common.Services.Security; using MediatR; -using Microsoft.AspNet.OData; -using Microsoft.AspNet.OData.Query; using Microsoft.AspNetCore.JsonPatch; using Microsoft.AspNetCore.Mvc; +using Microsoft.AspNetCore.OData.Formatter; +using Microsoft.AspNetCore.OData.Query; using Swashbuckle.AspNetCore.Annotations; using System.Linq; using System.Threading.Tasks; @@ -24,6 +24,17 @@ public BrandController(IMediator mediator, IPermissionService permissionService) _permissionService = permissionService; } + [SwaggerOperation(summary: "Get entities from Brand", OperationId = "GetBrands")] + [HttpGet] + [EnableQuery] + public async Task Get() + { + if (!await _permissionService.Authorize(PermissionSystemName.Brands)) + return Forbid(); + + return Ok(await _mediator.Send(new GetQuery())); + } + [SwaggerOperation(summary: "Get entity from Brand by key", OperationId = "GetBrandById")] [HttpGet("{key}")] public async Task Get(string key) @@ -38,16 +49,7 @@ public async Task Get(string key) return Ok(brand); } - [SwaggerOperation(summary: "Get entities from Brand", OperationId = "GetBrands")] - [HttpGet] - [EnableQuery(HandleNullPropagation = HandleNullPropagationOption.False)] - public async Task Get() - { - if (!await _permissionService.Authorize(PermissionSystemName.Brands)) - return Forbid(); - - return Ok(await _mediator.Send(new GetQuery())); - } + [SwaggerOperation(summary: "Add new entity to Brand", OperationId = "InsertBrand")] [HttpPost] diff --git a/src/API/Grand.Api/Controllers/OData/BrandLayoutController.cs b/src/API/Grand.Api/Controllers/OData/BrandLayoutController.cs index 2241a242b..f3677adae 100644 --- a/src/API/Grand.Api/Controllers/OData/BrandLayoutController.cs +++ b/src/API/Grand.Api/Controllers/OData/BrandLayoutController.cs @@ -2,9 +2,8 @@ using Grand.Business.Common.Interfaces.Security; using Grand.Business.Common.Services.Security; using MediatR; -using Microsoft.AspNet.OData; -using Microsoft.AspNet.OData.Query; using Microsoft.AspNetCore.Mvc; +using Microsoft.AspNetCore.OData.Query; using Swashbuckle.AspNetCore.Annotations; using System.Linq; using System.Threading.Tasks; diff --git a/src/API/Grand.Api/Controllers/OData/CategoryController.cs b/src/API/Grand.Api/Controllers/OData/CategoryController.cs index 08861ce00..9b6669779 100644 --- a/src/API/Grand.Api/Controllers/OData/CategoryController.cs +++ b/src/API/Grand.Api/Controllers/OData/CategoryController.cs @@ -4,10 +4,10 @@ using Grand.Business.Common.Interfaces.Security; using Grand.Business.Common.Services.Security; using MediatR; -using Microsoft.AspNet.OData; -using Microsoft.AspNet.OData.Query; using Microsoft.AspNetCore.JsonPatch; using Microsoft.AspNetCore.Mvc; +using Microsoft.AspNetCore.OData.Formatter; +using Microsoft.AspNetCore.OData.Query; using Swashbuckle.AspNetCore.Annotations; using System.Linq; using System.Threading.Tasks; diff --git a/src/API/Grand.Api/Controllers/OData/CategoryLayoutController.cs b/src/API/Grand.Api/Controllers/OData/CategoryLayoutController.cs index 46fb111d3..86bfe1ef6 100644 --- a/src/API/Grand.Api/Controllers/OData/CategoryLayoutController.cs +++ b/src/API/Grand.Api/Controllers/OData/CategoryLayoutController.cs @@ -2,9 +2,8 @@ using Grand.Business.Common.Interfaces.Security; using Grand.Business.Common.Services.Security; using MediatR; -using Microsoft.AspNet.OData; -using Microsoft.AspNet.OData.Query; using Microsoft.AspNetCore.Mvc; +using Microsoft.AspNetCore.OData.Query; using Swashbuckle.AspNetCore.Annotations; using System.Linq; using System.Threading.Tasks; diff --git a/src/API/Grand.Api/Controllers/OData/CollectionController.cs b/src/API/Grand.Api/Controllers/OData/CollectionController.cs index 09a654058..29506af95 100644 --- a/src/API/Grand.Api/Controllers/OData/CollectionController.cs +++ b/src/API/Grand.Api/Controllers/OData/CollectionController.cs @@ -4,10 +4,10 @@ using Grand.Business.Common.Interfaces.Security; using Grand.Business.Common.Services.Security; using MediatR; -using Microsoft.AspNet.OData; -using Microsoft.AspNet.OData.Query; using Microsoft.AspNetCore.JsonPatch; using Microsoft.AspNetCore.Mvc; +using Microsoft.AspNetCore.OData.Formatter; +using Microsoft.AspNetCore.OData.Query; using Swashbuckle.AspNetCore.Annotations; using System.Linq; using System.Threading.Tasks; diff --git a/src/API/Grand.Api/Controllers/OData/CollectionLayoutController.cs b/src/API/Grand.Api/Controllers/OData/CollectionLayoutController.cs index 4d8c40ca3..a4f2c5030 100644 --- a/src/API/Grand.Api/Controllers/OData/CollectionLayoutController.cs +++ b/src/API/Grand.Api/Controllers/OData/CollectionLayoutController.cs @@ -2,9 +2,8 @@ using Grand.Business.Common.Interfaces.Security; using Grand.Business.Common.Services.Security; using MediatR; -using Microsoft.AspNet.OData; -using Microsoft.AspNet.OData.Query; using Microsoft.AspNetCore.Mvc; +using Microsoft.AspNetCore.OData.Query; using Swashbuckle.AspNetCore.Annotations; using System.Linq; using System.Threading.Tasks; diff --git a/src/API/Grand.Api/Controllers/OData/CountryController.cs b/src/API/Grand.Api/Controllers/OData/CountryController.cs index 6b4bb19ff..579d98c9f 100644 --- a/src/API/Grand.Api/Controllers/OData/CountryController.cs +++ b/src/API/Grand.Api/Controllers/OData/CountryController.cs @@ -3,9 +3,8 @@ using Grand.Business.Common.Interfaces.Security; using Grand.Business.Common.Services.Security; using MediatR; -using Microsoft.AspNet.OData; -using Microsoft.AspNet.OData.Query; using Microsoft.AspNetCore.Mvc; +using Microsoft.AspNetCore.OData.Query; using Swashbuckle.AspNetCore.Annotations; using System.Linq; using System.Threading.Tasks; diff --git a/src/API/Grand.Api/Controllers/OData/CurrencyController.cs b/src/API/Grand.Api/Controllers/OData/CurrencyController.cs index 6f9f5952f..43233cc30 100644 --- a/src/API/Grand.Api/Controllers/OData/CurrencyController.cs +++ b/src/API/Grand.Api/Controllers/OData/CurrencyController.cs @@ -3,9 +3,8 @@ using Grand.Business.Common.Interfaces.Security; using Grand.Business.Common.Services.Security; using MediatR; -using Microsoft.AspNet.OData; -using Microsoft.AspNet.OData.Query; using Microsoft.AspNetCore.Mvc; +using Microsoft.AspNetCore.OData.Query; using Swashbuckle.AspNetCore.Annotations; using System.Linq; using System.Threading.Tasks; diff --git a/src/API/Grand.Api/Controllers/OData/CustomerController.cs b/src/API/Grand.Api/Controllers/OData/CustomerController.cs index e2f35cf5f..3de884b33 100644 --- a/src/API/Grand.Api/Controllers/OData/CustomerController.cs +++ b/src/API/Grand.Api/Controllers/OData/CustomerController.cs @@ -7,8 +7,8 @@ using Grand.Business.Customers.Utilities; using Grand.Domain.Customers; using MediatR; -using Microsoft.AspNet.OData; using Microsoft.AspNetCore.Mvc; +using Microsoft.AspNetCore.OData.Formatter; using Swashbuckle.AspNetCore.Annotations; using System.Linq; using System.Threading.Tasks; diff --git a/src/API/Grand.Api/Controllers/OData/CustomerGroupController.cs b/src/API/Grand.Api/Controllers/OData/CustomerGroupController.cs index 31168e14e..fbbfe1f8a 100644 --- a/src/API/Grand.Api/Controllers/OData/CustomerGroupController.cs +++ b/src/API/Grand.Api/Controllers/OData/CustomerGroupController.cs @@ -4,10 +4,10 @@ using Grand.Business.Common.Interfaces.Security; using Grand.Business.Common.Services.Security; using MediatR; -using Microsoft.AspNet.OData; -using Microsoft.AspNet.OData.Query; using Microsoft.AspNetCore.JsonPatch; using Microsoft.AspNetCore.Mvc; +using Microsoft.AspNetCore.OData.Formatter; +using Microsoft.AspNetCore.OData.Query; using Swashbuckle.AspNetCore.Annotations; using System.Linq; using System.Threading.Tasks; diff --git a/src/API/Grand.Api/Controllers/OData/DeliveryDateController.cs b/src/API/Grand.Api/Controllers/OData/DeliveryDateController.cs index 6df06b9a2..c2010614b 100644 --- a/src/API/Grand.Api/Controllers/OData/DeliveryDateController.cs +++ b/src/API/Grand.Api/Controllers/OData/DeliveryDateController.cs @@ -3,9 +3,8 @@ using Grand.Business.Common.Interfaces.Security; using Grand.Business.Common.Services.Security; using MediatR; -using Microsoft.AspNet.OData; -using Microsoft.AspNet.OData.Query; using Microsoft.AspNetCore.Mvc; +using Microsoft.AspNetCore.OData.Query; using Swashbuckle.AspNetCore.Annotations; using System.Linq; using System.Threading.Tasks; diff --git a/src/API/Grand.Api/Controllers/OData/LanguageController.cs b/src/API/Grand.Api/Controllers/OData/LanguageController.cs index 81d3b243e..bdc97dd51 100644 --- a/src/API/Grand.Api/Controllers/OData/LanguageController.cs +++ b/src/API/Grand.Api/Controllers/OData/LanguageController.cs @@ -3,9 +3,8 @@ using Grand.Business.Common.Interfaces.Security; using Grand.Business.Common.Services.Security; using MediatR; -using Microsoft.AspNet.OData; -using Microsoft.AspNet.OData.Query; using Microsoft.AspNetCore.Mvc; +using Microsoft.AspNetCore.OData.Query; using Swashbuckle.AspNetCore.Annotations; using System.Linq; using System.Threading.Tasks; diff --git a/src/API/Grand.Api/Controllers/OData/PickupPointController.cs b/src/API/Grand.Api/Controllers/OData/PickupPointController.cs index c6d43343c..ade52b9d1 100644 --- a/src/API/Grand.Api/Controllers/OData/PickupPointController.cs +++ b/src/API/Grand.Api/Controllers/OData/PickupPointController.cs @@ -3,9 +3,8 @@ using Grand.Business.Common.Interfaces.Security; using Grand.Business.Common.Services.Security; using MediatR; -using Microsoft.AspNet.OData; -using Microsoft.AspNet.OData.Query; using Microsoft.AspNetCore.Mvc; +using Microsoft.AspNetCore.OData.Query; using Swashbuckle.AspNetCore.Annotations; using System.Linq; using System.Threading.Tasks; diff --git a/src/API/Grand.Api/Controllers/OData/ProductAttributeController.cs b/src/API/Grand.Api/Controllers/OData/ProductAttributeController.cs index 8abf7efe3..af79ca497 100644 --- a/src/API/Grand.Api/Controllers/OData/ProductAttributeController.cs +++ b/src/API/Grand.Api/Controllers/OData/ProductAttributeController.cs @@ -4,10 +4,10 @@ using Grand.Business.Common.Interfaces.Security; using Grand.Business.Common.Services.Security; using MediatR; -using Microsoft.AspNet.OData; -using Microsoft.AspNet.OData.Query; using Microsoft.AspNetCore.JsonPatch; using Microsoft.AspNetCore.Mvc; +using Microsoft.AspNetCore.OData.Formatter; +using Microsoft.AspNetCore.OData.Query; using Swashbuckle.AspNetCore.Annotations; using System.Linq; using System.Threading.Tasks; diff --git a/src/API/Grand.Api/Controllers/OData/ProductController.cs b/src/API/Grand.Api/Controllers/OData/ProductController.cs index a07feef22..ec52d4a40 100644 --- a/src/API/Grand.Api/Controllers/OData/ProductController.cs +++ b/src/API/Grand.Api/Controllers/OData/ProductController.cs @@ -4,10 +4,10 @@ using Grand.Business.Common.Interfaces.Security; using Grand.Business.Common.Services.Security; using MediatR; -using Microsoft.AspNet.OData; -using Microsoft.AspNet.OData.Query; using Microsoft.AspNetCore.JsonPatch; using Microsoft.AspNetCore.Mvc; +using Microsoft.AspNetCore.OData.Formatter; +using Microsoft.AspNetCore.OData.Query; using Swashbuckle.AspNetCore.Annotations; using System.Linq; using System.Threading.Tasks; diff --git a/src/API/Grand.Api/Controllers/OData/ProductLayoutController.cs b/src/API/Grand.Api/Controllers/OData/ProductLayoutController.cs index 32b9654c3..757b82c49 100644 --- a/src/API/Grand.Api/Controllers/OData/ProductLayoutController.cs +++ b/src/API/Grand.Api/Controllers/OData/ProductLayoutController.cs @@ -2,9 +2,8 @@ using Grand.Business.Common.Interfaces.Security; using Grand.Business.Common.Services.Security; using MediatR; -using Microsoft.AspNet.OData; -using Microsoft.AspNet.OData.Query; using Microsoft.AspNetCore.Mvc; +using Microsoft.AspNetCore.OData.Query; using Swashbuckle.AspNetCore.Annotations; using System.Linq; using System.Threading.Tasks; diff --git a/src/API/Grand.Api/Controllers/OData/ShippingMethodController.cs b/src/API/Grand.Api/Controllers/OData/ShippingMethodController.cs index 332616887..f876658e5 100644 --- a/src/API/Grand.Api/Controllers/OData/ShippingMethodController.cs +++ b/src/API/Grand.Api/Controllers/OData/ShippingMethodController.cs @@ -3,9 +3,8 @@ using Grand.Business.Common.Interfaces.Security; using Grand.Business.Common.Services.Security; using MediatR; -using Microsoft.AspNet.OData; -using Microsoft.AspNet.OData.Query; using Microsoft.AspNetCore.Mvc; +using Microsoft.AspNetCore.OData.Query; using Swashbuckle.AspNetCore.Annotations; using System.Linq; using System.Threading.Tasks; diff --git a/src/API/Grand.Api/Controllers/OData/SpecificationAttributeController.cs b/src/API/Grand.Api/Controllers/OData/SpecificationAttributeController.cs index 1d131e800..f3b8682c2 100644 --- a/src/API/Grand.Api/Controllers/OData/SpecificationAttributeController.cs +++ b/src/API/Grand.Api/Controllers/OData/SpecificationAttributeController.cs @@ -4,10 +4,10 @@ using Grand.Business.Common.Interfaces.Security; using Grand.Business.Common.Services.Security; using MediatR; -using Microsoft.AspNet.OData; -using Microsoft.AspNet.OData.Query; using Microsoft.AspNetCore.JsonPatch; using Microsoft.AspNetCore.Mvc; +using Microsoft.AspNetCore.OData.Formatter; +using Microsoft.AspNetCore.OData.Query; using Swashbuckle.AspNetCore.Annotations; using System.Linq; using System.Threading.Tasks; diff --git a/src/API/Grand.Api/Controllers/OData/StateProvinceController.cs b/src/API/Grand.Api/Controllers/OData/StateProvinceController.cs index 7eda35cc0..b7c9641a4 100644 --- a/src/API/Grand.Api/Controllers/OData/StateProvinceController.cs +++ b/src/API/Grand.Api/Controllers/OData/StateProvinceController.cs @@ -3,9 +3,8 @@ using Grand.Business.Common.Interfaces.Security; using Grand.Business.Common.Services.Security; using MediatR; -using Microsoft.AspNet.OData; -using Microsoft.AspNet.OData.Query; using Microsoft.AspNetCore.Mvc; +using Microsoft.AspNetCore.OData.Query; using Swashbuckle.AspNetCore.Annotations; using System.Linq; using System.Threading.Tasks; diff --git a/src/API/Grand.Api/Controllers/OData/StoreController.cs b/src/API/Grand.Api/Controllers/OData/StoreController.cs index 376f68092..ebefe085e 100644 --- a/src/API/Grand.Api/Controllers/OData/StoreController.cs +++ b/src/API/Grand.Api/Controllers/OData/StoreController.cs @@ -3,9 +3,8 @@ using Grand.Business.Common.Interfaces.Security; using Grand.Business.Common.Services.Security; using MediatR; -using Microsoft.AspNet.OData; -using Microsoft.AspNet.OData.Query; using Microsoft.AspNetCore.Mvc; +using Microsoft.AspNetCore.OData.Query; using Swashbuckle.AspNetCore.Annotations; using System.Linq; using System.Threading.Tasks; diff --git a/src/API/Grand.Api/Controllers/OData/VendorController.cs b/src/API/Grand.Api/Controllers/OData/VendorController.cs index 5a118abad..1adeccecd 100644 --- a/src/API/Grand.Api/Controllers/OData/VendorController.cs +++ b/src/API/Grand.Api/Controllers/OData/VendorController.cs @@ -3,9 +3,8 @@ using Grand.Business.Common.Interfaces.Security; using Grand.Business.Common.Services.Security; using MediatR; -using Microsoft.AspNet.OData; -using Microsoft.AspNet.OData.Query; using Microsoft.AspNetCore.Mvc; +using Microsoft.AspNetCore.OData.Query; using Swashbuckle.AspNetCore.Annotations; using System.Linq; using System.Threading.Tasks; diff --git a/src/API/Grand.Api/Controllers/OData/WarehouseController.cs b/src/API/Grand.Api/Controllers/OData/WarehouseController.cs index 630502ba8..7e1bd8e8d 100644 --- a/src/API/Grand.Api/Controllers/OData/WarehouseController.cs +++ b/src/API/Grand.Api/Controllers/OData/WarehouseController.cs @@ -3,9 +3,8 @@ using Grand.Business.Common.Interfaces.Security; using Grand.Business.Common.Services.Security; using MediatR; -using Microsoft.AspNet.OData; -using Microsoft.AspNet.OData.Query; using Microsoft.AspNetCore.Mvc; +using Microsoft.AspNetCore.OData.Query; using Swashbuckle.AspNetCore.Annotations; using System.Linq; using System.Threading.Tasks; diff --git a/src/API/Grand.Api/Grand.Api.csproj b/src/API/Grand.Api/Grand.Api.csproj index cd0b45d2f..0643c233c 100644 --- a/src/API/Grand.Api/Grand.Api.csproj +++ b/src/API/Grand.Api/Grand.Api.csproj @@ -20,11 +20,10 @@ - - + - - + + diff --git a/src/API/Grand.Api/Infrastructure/AuthenticationStartup.cs b/src/API/Grand.Api/Infrastructure/AuthenticationStartup.cs deleted file mode 100644 index 4fbb90c56..000000000 --- a/src/API/Grand.Api/Infrastructure/AuthenticationStartup.cs +++ /dev/null @@ -1,48 +0,0 @@ -using Grand.Api.Constants; -using Grand.Business.Authentication.Interfaces; -using Grand.Business.Authentication.Services; -using Grand.Infrastructure; -using Grand.Infrastructure.Configuration; -using Microsoft.AspNet.OData.Extensions; -using Microsoft.AspNetCore.Builder; -using Microsoft.AspNetCore.Hosting; -using Microsoft.Extensions.Configuration; -using Microsoft.Extensions.DependencyInjection; - -namespace Grand.Api.Infrastructure -{ - public partial class AuthenticationStartup : IStartupApplication - { - public void Configure(IApplicationBuilder application, IWebHostEnvironment webHostEnvironment) - { - var apiConfig = application.ApplicationServices.GetService(); - if (apiConfig.Enabled) - { - application.UseCors(Configurations.CorsPolicyName); - } - } - - public void ConfigureServices(IServiceCollection services, - IConfiguration configuration) - { - var apiConfig = services.BuildServiceProvider().GetService(); - if (apiConfig.Enabled) - { - //cors - services.AddCors(options => - { - options.AddPolicy(Configurations.CorsPolicyName, - builder => builder.AllowAnyOrigin() - .AllowAnyMethod() - .AllowAnyHeader()); - }); - - //Add OData - services.AddOData(); - services.AddODataQueryFilter(); - } - } - public int Priority => 505; - public bool BeforeConfigure => true; - } -} diff --git a/src/API/Grand.Api/Infrastructure/DependencyEdmModel.cs b/src/API/Grand.Api/Infrastructure/DependencyEdmModel.cs index b4527e138..93be30a91 100644 --- a/src/API/Grand.Api/Infrastructure/DependencyEdmModel.cs +++ b/src/API/Grand.Api/Infrastructure/DependencyEdmModel.cs @@ -5,7 +5,7 @@ using Grand.Api.Infrastructure.DependencyManagement; using Grand.Domain.Catalog; using Grand.Infrastructure.Configuration; -using Microsoft.AspNet.OData.Builder; +using Microsoft.OData.ModelBuilder; using System; using System.Collections.Generic; @@ -18,36 +18,31 @@ protected void RegisterCommon(ODataConventionModelBuilder builder) #region Language model builder.EntitySet("Language"); - builder.EntityType().Count().Filter().OrderBy().Page(); #endregion #region Currency model builder.EntitySet("Currency"); - builder.EntityType().Count().Filter().OrderBy().Page(); #endregion #region Store model builder.EntitySet("Store"); - builder.EntityType().Count().Filter().OrderBy().Page(); - + #endregion #region Country model builder.EntitySet("Country"); - builder.EntityType().Count().Filter().OrderBy().Page(); #endregion #region State province model builder.EntitySet("StateProvince"); - builder.EntityType().Count().Filter().OrderBy().Page(); - + #endregion #region layout model @@ -56,14 +51,12 @@ protected void RegisterCommon(ODataConventionModelBuilder builder) builder.EntitySet("CollectionLayout"); builder.EntitySet("ProductlLayout"); builder.EntitySet("BrandlLayout"); - builder.EntityType().Count().Filter().OrderBy().Page(); #endregion #region Picture model builder.EntitySet("Picture"); - builder.EntityType().Count().Filter().OrderBy().Page(); #endregion } @@ -71,7 +64,6 @@ protected void RegisterProduct(ODataConventionModelBuilder builder) { builder.EntitySet("Product"); var product = builder.EntityType(); - product.Count().Filter().OrderBy().Page(); builder.ComplexType(); builder.ComplexType(); builder.ComplexType(); @@ -246,28 +238,23 @@ protected void RegisterCatalog(ODataConventionModelBuilder builder) #region Category model builder.EntitySet("Category"); - builder.EntityType().Count().Filter().OrderBy().Page(); #endregion #region Brand model builder.EntitySet("Brand"); - builder.EntityType().Count().Filter().OrderBy().Page(); #endregion #region Collection model builder.EntitySet("Collection"); - builder.EntityType().Count().Filter().OrderBy().Page(); - #endregion #region Product attribute model builder.EntitySet("ProductAttribute"); - builder.EntityType().Count().Filter().OrderBy().Page(); builder.ComplexType(); #endregion @@ -275,7 +262,6 @@ protected void RegisterCatalog(ODataConventionModelBuilder builder) #region Product attribute model builder.EntitySet("SpecificationAttribute"); - builder.EntityType().Count().Filter().OrderBy().Page(); builder.ComplexType(); #endregion @@ -341,15 +327,13 @@ protected void RegisterCustomers(ODataConventionModelBuilder builder) #region Customer group model builder.EntitySet("CustomerGroup"); - builder.EntityType().Count().Filter().OrderBy().Page(); #endregion #region Vendors builder.EntitySet("Vendor"); - builder.EntityType().Count().Filter().OrderBy().Page(); - + #endregion } @@ -358,28 +342,24 @@ protected void RegisterShipping(ODataConventionModelBuilder builder) #region Warehouse model builder.EntitySet("Warehouse"); - builder.EntityType().Count().Filter().OrderBy().Page(); - + #endregion #region Delivery date model builder.EntitySet("DeliveryDate"); - builder.EntityType().Count().Filter().OrderBy().Page(); - + #endregion #region Pickup point model builder.EntitySet("PickupPoint"); - builder.EntityType().Count().Filter().OrderBy().Page(); #endregion #region Shipping method model builder.EntitySet("ShippingMethod"); - builder.EntityType().Count().Filter().OrderBy().Page(); #endregion } diff --git a/src/API/Grand.Api/Infrastructure/DependencyManagement/IDependencyEdmModel.cs b/src/API/Grand.Api/Infrastructure/DependencyManagement/IDependencyEdmModel.cs index ad85efaec..7748b50cd 100644 --- a/src/API/Grand.Api/Infrastructure/DependencyManagement/IDependencyEdmModel.cs +++ b/src/API/Grand.Api/Infrastructure/DependencyManagement/IDependencyEdmModel.cs @@ -1,5 +1,5 @@ using Grand.Infrastructure.Configuration; -using Microsoft.AspNet.OData.Builder; +using Microsoft.OData.ModelBuilder; namespace Grand.Api.Infrastructure.DependencyManagement { diff --git a/src/API/Grand.Api/Infrastructure/ODataParamsStartup.cs b/src/API/Grand.Api/Infrastructure/ODataParamsStartup.cs deleted file mode 100644 index 5d0193e4c..000000000 --- a/src/API/Grand.Api/Infrastructure/ODataParamsStartup.cs +++ /dev/null @@ -1,49 +0,0 @@ -using Grand.Infrastructure; -using Grand.Infrastructure.Configuration; -using Microsoft.AspNet.OData.Formatter; -using Microsoft.AspNetCore.Builder; -using Microsoft.AspNetCore.Hosting; -using Microsoft.Extensions.Configuration; -using Microsoft.Extensions.DependencyInjection; -using Microsoft.Net.Http.Headers; -using System.Linq; - -namespace Grand.Api.Infrastructure -{ - public class ODataParamsStartup : IStartupApplication - { - public void Configure(IApplicationBuilder application, IWebHostEnvironment webHostEnvironment) - { - - } - - public void ConfigureServices(IServiceCollection services, IConfiguration configuration) - { - var apiConfig = services.BuildServiceProvider().GetService(); - if (apiConfig.Enabled && apiConfig.UseSwagger) - { - SetOutputFormatters(services); - } - } - - public int Priority => 900; - public bool BeforeConfigure => true; - - private void SetOutputFormatters(IServiceCollection services) - { - services.AddMvcCore(options => - { - foreach (var outputFormatter in options.OutputFormatters.OfType().Where(_ => _.SupportedMediaTypes.Count == 0)) - { - outputFormatter.SupportedMediaTypes.Add(new MediaTypeHeaderValue("application/prs.odatatestxx-odata")); - } - foreach (var inputFormatter in options.InputFormatters.OfType().Where(_ => _.SupportedMediaTypes.Count == 0)) - { - inputFormatter.SupportedMediaTypes.Add(new MediaTypeHeaderValue("application/prs.odatatestxx-odata")); - } - }); - } - - - } -} diff --git a/src/API/Grand.Api/Infrastructure/ODataRouteProvider.cs b/src/API/Grand.Api/Infrastructure/ODataRouteProvider.cs deleted file mode 100644 index 5cd09df7a..000000000 --- a/src/API/Grand.Api/Infrastructure/ODataRouteProvider.cs +++ /dev/null @@ -1,62 +0,0 @@ -using Grand.Api.Constants; -using Grand.Api.Infrastructure.DependencyManagement; -using Grand.Infrastructure.Configuration; -using Grand.Infrastructure.Endpoints; -using Grand.Infrastructure.TypeSearchers; -using Microsoft.AspNet.OData.Builder; -using Microsoft.AspNet.OData.Extensions; -using Microsoft.AspNetCore.Routing; -using Microsoft.Extensions.DependencyInjection; -using Microsoft.OData.Edm; -using System; -using System.Linq; - -namespace Grand.Api.Infrastructure -{ - public class ODataRouteProvider : IEndpointProvider - { - public int Priority => 10; - - public void RegisterEndpoint(IEndpointRouteBuilder routeBuilder) - { - var apiConfig = routeBuilder.ServiceProvider.GetRequiredService(); - if (apiConfig.Enabled) - { - //OData - var serviceProvider = routeBuilder.ServiceProvider; - IEdmModel model = GetEdmModel(serviceProvider, apiConfig); - routeBuilder.Count().Filter().OrderBy().MaxTop(Configurations.MaxLimit); - routeBuilder.MapODataRoute(Configurations.ODataRouteName, Configurations.ODataRoutePrefix, model); - routeBuilder.EnableDependencyInjection(); - } - } - - private IEdmModel GetEdmModel(IServiceProvider serviceProvider, ApiConfig apiConfig) - { - var builder = new ODataConventionModelBuilder(serviceProvider); - builder.Namespace = Configurations.ODataModelBuilderNamespace; - RegisterDependencies(builder, apiConfig); - return builder.GetEdmModel(); - } - - private void RegisterDependencies(ODataConventionModelBuilder builder, ApiConfig apiConfig) - { - var typeFinder = new AppTypeSearcher(); - - //find dependency provided by other assemblies - var dependencyInject = typeFinder.ClassesOfType(); - - //create and sort instances of dependency inject - var instances = dependencyInject - .Select(di => (IDependencyEdmModel)Activator.CreateInstance(di)) - .OrderBy(di => di.Order); - - //register all provided dependencies - foreach (var dependencyRegistrar in instances) - dependencyRegistrar.Register(builder, apiConfig); - - } - - - } -} diff --git a/src/API/Grand.Api/Infrastructure/ODataStartup.cs b/src/API/Grand.Api/Infrastructure/ODataStartup.cs new file mode 100644 index 000000000..2764ed512 --- /dev/null +++ b/src/API/Grand.Api/Infrastructure/ODataStartup.cs @@ -0,0 +1,83 @@ +using Grand.Api.Constants; +using Grand.Api.Infrastructure.DependencyManagement; +using Grand.Infrastructure; +using Grand.Infrastructure.Configuration; +using Grand.Infrastructure.TypeSearchers; +using Microsoft.AspNetCore.Builder; +using Microsoft.AspNetCore.Hosting; +using Microsoft.AspNetCore.OData; +using Microsoft.Extensions.Configuration; +using Microsoft.Extensions.DependencyInjection; +using Microsoft.OData.Edm; +using Microsoft.OData.ModelBuilder; +using System; +using System.Linq; + +namespace Grand.Api.Infrastructure +{ + public partial class ODataStartup : IStartupApplication + { + public void Configure(IApplicationBuilder application, IWebHostEnvironment webHostEnvironment) + { + var apiConfig = application.ApplicationServices.GetService(); + if (apiConfig.Enabled) + { + application.UseCors(Configurations.CorsPolicyName); + } + } + + public void ConfigureServices(IServiceCollection services, + IConfiguration configuration) + { + var apiConfig = services.BuildServiceProvider().GetService(); + if (apiConfig.Enabled) + { + //cors + services.AddCors(options => + { + options.AddPolicy(Configurations.CorsPolicyName, + builder => builder.AllowAnyOrigin() + .AllowAnyMethod() + .AllowAnyHeader()); + }); + //Add OData + services.AddControllers().AddOData(opt => + { + opt.EnableQueryFeatures(Configurations.MaxLimit); + opt.AddRouteComponents(Configurations.ODataRoutePrefix, GetEdmModel(apiConfig)); + opt.Select().Filter().Count().Expand(); + }); + } + } + public int Priority => 505; + public bool BeforeConfigure => false; + + + private IEdmModel GetEdmModel(ApiConfig apiConfig) + { + var builder = new ODataConventionModelBuilder { + Namespace = Configurations.ODataModelBuilderNamespace + }; + RegisterDependencies(builder, apiConfig); + return builder.GetEdmModel(); + } + + private void RegisterDependencies(ODataConventionModelBuilder builder, ApiConfig apiConfig) + { + var typeFinder = new AppTypeSearcher(); + + //find dependency provided by other assemblies + var dependencyInject = typeFinder.ClassesOfType(); + + //create and sort instances of dependency inject + var instances = dependencyInject + .Select(di => (IDependencyEdmModel)Activator.CreateInstance(di)) + .OrderBy(di => di.Order); + + //register all provided dependencies + foreach (var dependencyRegistrar in instances) + dependencyRegistrar.Register(builder, apiConfig); + + } + } +} diff --git a/src/API/Grand.Api/Infrastructure/SwaggerStartup.cs b/src/API/Grand.Api/Infrastructure/SwaggerStartup.cs index a612dc819..b21b833fc 100644 --- a/src/API/Grand.Api/Infrastructure/SwaggerStartup.cs +++ b/src/API/Grand.Api/Infrastructure/SwaggerStartup.cs @@ -4,6 +4,7 @@ using Microsoft.AspNetCore.Authentication.JwtBearer; using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Hosting; +using Microsoft.AspNetCore.OData; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using Microsoft.OpenApi.Models; @@ -16,6 +17,10 @@ public class SwaggerStartup : IStartupApplication public void Configure(IApplicationBuilder application, IWebHostEnvironment webHostEnvironment) { var apiConfig = application.ApplicationServices.GetService(); + + if(apiConfig.Enabled) + application.UseODataQueryRequest(); + if (apiConfig.Enabled && apiConfig.UseSwagger) { application.UseSwagger(); @@ -31,7 +36,7 @@ public void ConfigureServices(IServiceCollection services, IConfiguration config var apiConfig = services.BuildServiceProvider().GetService(); if (apiConfig.Enabled && apiConfig.UseSwagger) { - + services.AddSwaggerGen(c => { c.SwaggerDoc("v1", new OpenApiInfo { Title = "Grandnode API", Version = "v1" }); From cdfa4f5b5300d03b6b1305714aec1945c373f17a Mon Sep 17 00:00:00 2001 From: KrzysztofPajak Date: Tue, 10 Aug 2021 10:05:59 +0200 Subject: [PATCH 2/7] Remove unused package reference --- src/API/Grand.Api/Grand.Api.csproj | 1 - 1 file changed, 1 deletion(-) diff --git a/src/API/Grand.Api/Grand.Api.csproj b/src/API/Grand.Api/Grand.Api.csproj index 0643c233c..a55db3394 100644 --- a/src/API/Grand.Api/Grand.Api.csproj +++ b/src/API/Grand.Api/Grand.Api.csproj @@ -21,7 +21,6 @@ - From 1a880fe4c65859d4f3877c3d747e4a0b01100f93 Mon Sep 17 00:00:00 2001 From: KrzysztofPajak Date: Tue, 17 Aug 2021 15:53:16 +0200 Subject: [PATCH 3/7] API - change the return status for OK --- src/API/Grand.Api/Controllers/OData/BrandController.cs | 2 +- src/API/Grand.Api/Controllers/OData/CategoryController.cs | 2 +- src/API/Grand.Api/Controllers/OData/CollectionController.cs | 2 +- src/API/Grand.Api/Controllers/OData/CustomerController.cs | 2 +- .../Grand.Api/Controllers/OData/CustomerGroupController.cs | 2 +- src/API/Grand.Api/Controllers/OData/PictureController.cs | 2 +- .../Grand.Api/Controllers/OData/ProductAttributeController.cs | 2 +- src/API/Grand.Api/Controllers/OData/ProductController.cs | 4 ++-- .../Controllers/OData/SpecificationAttributeController.cs | 2 +- 9 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/API/Grand.Api/Controllers/OData/BrandController.cs b/src/API/Grand.Api/Controllers/OData/BrandController.cs index cf2e85c57..544b09063 100644 --- a/src/API/Grand.Api/Controllers/OData/BrandController.cs +++ b/src/API/Grand.Api/Controllers/OData/BrandController.cs @@ -61,7 +61,7 @@ public async Task Post([FromBody] BrandDto model) if (ModelState.IsValid) { model = await _mediator.Send(new AddBrandCommand() { Model = model }); - return Created(model); + return Ok(model); } return BadRequest(ModelState); } diff --git a/src/API/Grand.Api/Controllers/OData/CategoryController.cs b/src/API/Grand.Api/Controllers/OData/CategoryController.cs index 9b6669779..deb9de51a 100644 --- a/src/API/Grand.Api/Controllers/OData/CategoryController.cs +++ b/src/API/Grand.Api/Controllers/OData/CategoryController.cs @@ -61,7 +61,7 @@ public async Task Post([FromBody] CategoryDto model) if (ModelState.IsValid) { model = await _mediator.Send(new AddCategoryCommand() { Model = model }); - return Created(model); + return Ok(model); } return BadRequest(ModelState); } diff --git a/src/API/Grand.Api/Controllers/OData/CollectionController.cs b/src/API/Grand.Api/Controllers/OData/CollectionController.cs index 29506af95..5bebb3e43 100644 --- a/src/API/Grand.Api/Controllers/OData/CollectionController.cs +++ b/src/API/Grand.Api/Controllers/OData/CollectionController.cs @@ -59,7 +59,7 @@ public async Task Post([FromBody] CollectionDto model) if (ModelState.IsValid) { model = await _mediator.Send(new AddCollectionCommand() { Model = model }); - return Created(model); + return Ok(model); } return BadRequest(ModelState); } diff --git a/src/API/Grand.Api/Controllers/OData/CustomerController.cs b/src/API/Grand.Api/Controllers/OData/CustomerController.cs index 3de884b33..c6026d5ee 100644 --- a/src/API/Grand.Api/Controllers/OData/CustomerController.cs +++ b/src/API/Grand.Api/Controllers/OData/CustomerController.cs @@ -59,7 +59,7 @@ public async Task Post([FromBody] CustomerDto model) if (ModelState.IsValid) { model = await _mediator.Send(new AddCustomerCommand() { Model = model }); - return Created(model); + return Ok(model); } return BadRequest(ModelState); } diff --git a/src/API/Grand.Api/Controllers/OData/CustomerGroupController.cs b/src/API/Grand.Api/Controllers/OData/CustomerGroupController.cs index fbbfe1f8a..020c69b8c 100644 --- a/src/API/Grand.Api/Controllers/OData/CustomerGroupController.cs +++ b/src/API/Grand.Api/Controllers/OData/CustomerGroupController.cs @@ -60,7 +60,7 @@ public async Task Post([FromBody] CustomerGroupDto model) if (ModelState.IsValid) { model = await _mediator.Send(new AddCustomerGroupCommand() { Model = model }); - return Created(model); + return Ok(model); } return BadRequest(ModelState); } diff --git a/src/API/Grand.Api/Controllers/OData/PictureController.cs b/src/API/Grand.Api/Controllers/OData/PictureController.cs index 138f4459a..3d5a4f6a5 100644 --- a/src/API/Grand.Api/Controllers/OData/PictureController.cs +++ b/src/API/Grand.Api/Controllers/OData/PictureController.cs @@ -45,7 +45,7 @@ public async Task Post([FromBody] PictureDto model) if (ModelState.IsValid) { model = await _mediator.Send(new AddPictureCommand() { PictureDto = model }); - return Created(model); + return Ok(model); } return BadRequest(ModelState); } diff --git a/src/API/Grand.Api/Controllers/OData/ProductAttributeController.cs b/src/API/Grand.Api/Controllers/OData/ProductAttributeController.cs index af79ca497..bcc8cd7f9 100644 --- a/src/API/Grand.Api/Controllers/OData/ProductAttributeController.cs +++ b/src/API/Grand.Api/Controllers/OData/ProductAttributeController.cs @@ -62,7 +62,7 @@ public async Task Post([FromBody] ProductAttributeDto model) if (ModelState.IsValid) { model = await _mediator.Send(new AddProductAttributeCommand() { Model = model }); - return Created(model); + return Ok(model); } return BadRequest(ModelState); } diff --git a/src/API/Grand.Api/Controllers/OData/ProductController.cs b/src/API/Grand.Api/Controllers/OData/ProductController.cs index ec52d4a40..99c12f306 100644 --- a/src/API/Grand.Api/Controllers/OData/ProductController.cs +++ b/src/API/Grand.Api/Controllers/OData/ProductController.cs @@ -62,7 +62,7 @@ public async Task Post([FromBody] ProductDto model) if (ModelState.IsValid) { model = await _mediator.Send(new AddProductCommand() { Model = model }); - return Created(model); + return Ok(model); } return BadRequest(ModelState); } @@ -120,7 +120,7 @@ public async Task Delete(string key) return Ok(); } - //odata/Product(id)/UpdateStock + //odata/Product/(id)/UpdateStock //body: { "Stock": 10 } [SwaggerOperation(summary: "Invoke action UpdateStock", OperationId = "UpdateStock")] [Route("({key})/[action]")] diff --git a/src/API/Grand.Api/Controllers/OData/SpecificationAttributeController.cs b/src/API/Grand.Api/Controllers/OData/SpecificationAttributeController.cs index f3b8682c2..0154de5b8 100644 --- a/src/API/Grand.Api/Controllers/OData/SpecificationAttributeController.cs +++ b/src/API/Grand.Api/Controllers/OData/SpecificationAttributeController.cs @@ -59,7 +59,7 @@ public async Task Post([FromBody] SpecificationAttributeDto model if (ModelState.IsValid) { model = await _mediator.Send(new AddSpecificationAttributeCommand() { Model = model }); - return Created(model); + return Ok(model); } return BadRequest(ModelState); } From 85448681ec72e37904da46e9e4e44ecea6d768df Mon Sep 17 00:00:00 2001 From: KrzysztofPajak Date: Wed, 18 Aug 2021 14:02:45 +0200 Subject: [PATCH 4/7] Swagger - minor changes (priority) --- src/API/Grand.Api/Infrastructure/SwaggerStartup.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/API/Grand.Api/Infrastructure/SwaggerStartup.cs b/src/API/Grand.Api/Infrastructure/SwaggerStartup.cs index b21b833fc..75af11752 100644 --- a/src/API/Grand.Api/Infrastructure/SwaggerStartup.cs +++ b/src/API/Grand.Api/Infrastructure/SwaggerStartup.cs @@ -63,11 +63,12 @@ public void ConfigureServices(IServiceCollection services, IConfiguration config c.EnableAnnotations(); c.SchemaFilter(); }); + } } - public int Priority => 90; - public bool BeforeConfigure => true; + public int Priority => 509; + public bool BeforeConfigure => false; } } From 73f89228a77f91621f9a492d873fc254447cc531 Mon Sep 17 00:00:00 2001 From: KrzysztofPajak Date: Wed, 18 Aug 2021 14:03:54 +0200 Subject: [PATCH 5/7] Swagger - improvement for enum type in description schema --- .../Grand.Api/Infrastructure/EnumSchemaFilter.cs | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/API/Grand.Api/Infrastructure/EnumSchemaFilter.cs b/src/API/Grand.Api/Infrastructure/EnumSchemaFilter.cs index 1b12e2c1a..19a708258 100644 --- a/src/API/Grand.Api/Infrastructure/EnumSchemaFilter.cs +++ b/src/API/Grand.Api/Infrastructure/EnumSchemaFilter.cs @@ -8,14 +8,17 @@ namespace Grand.Api.Infrastructure { public class EnumSchemaFilter : ISchemaFilter { - public void Apply(OpenApiSchema model, SchemaFilterContext context) + public void Apply(OpenApiSchema schema, SchemaFilterContext context) { if (context.Type.IsEnum) { - model.Enum.Clear(); - Enum.GetNames(context.Type) - .ToList() - .ForEach(n => model.Enum.Add(new OpenApiString(n))); + var enumValues = schema.Enum.ToArray(); + foreach (var item in enumValues) + { + var value = (OpenApiPrimitive)item; + var name = Enum.GetName(context.Type, value.Value); + schema.Description += $"{value.Value} - {name}; "; + } } } } From 3e9a1be3759af314e69ecdf84453f56b49bd1d5f Mon Sep 17 00:00:00 2001 From: KrzysztofPajak Date: Fri, 20 Aug 2021 08:11:12 +0200 Subject: [PATCH 6/7] Swagger - minor changes (priority) --- src/API/Grand.Api/Infrastructure/SwaggerStartup.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/API/Grand.Api/Infrastructure/SwaggerStartup.cs b/src/API/Grand.Api/Infrastructure/SwaggerStartup.cs index 75af11752..e2d19f780 100644 --- a/src/API/Grand.Api/Infrastructure/SwaggerStartup.cs +++ b/src/API/Grand.Api/Infrastructure/SwaggerStartup.cs @@ -67,7 +67,7 @@ public void ConfigureServices(IServiceCollection services, IConfiguration config } } - public int Priority => 509; + public int Priority => 500; public bool BeforeConfigure => false; } From b2a4b8b0db6ac318c7df0d2018cbb46f879e54fc Mon Sep 17 00:00:00 2001 From: KrzysztofPajak Date: Fri, 20 Aug 2021 08:17:56 +0200 Subject: [PATCH 7/7] API - Customer - AddAddress - Add missing bracket --- src/API/Grand.Api/Controllers/OData/CustomerController.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/API/Grand.Api/Controllers/OData/CustomerController.cs b/src/API/Grand.Api/Controllers/OData/CustomerController.cs index c6026d5ee..e804d9243 100644 --- a/src/API/Grand.Api/Controllers/OData/CustomerController.cs +++ b/src/API/Grand.Api/Controllers/OData/CustomerController.cs @@ -100,7 +100,7 @@ public async Task Delete(string key) //odata/Customer(email)/AddAddress [SwaggerOperation(summary: "Invoke action AddAddress", OperationId = "AddAddress")] - [Route("({key}/[action]")] + [Route("({key})/[action]")] [HttpPost] public async Task AddAddress(string key, [FromBody] AddressDto address) {