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.
C# aspnet-corecsharpdockerdotnetecommerceecommerce-platformmongodbmulti-storemulti-vendornosqlonline-shopshoppingcart
Further changes with Swagger for frontend
support3eb6aeac1ac8
diff --git a/src/Web/Grand.Web.Common/ApiExplorer/ApiResponseTypeProvider.cs b/src/Web/Grand.Web.Common/ApiExplorer/ApiResponseTypeProvider.csindex 9bd822a2a..45e9039ce 100644--- a/src/Web/Grand.Web.Common/ApiExplorer/ApiResponseTypeProvider.cs+++ b/src/Web/Grand.Web.Common/ApiExplorer/ApiResponseTypeProvider.cs@@ -76,7 +76,7 @@ public class ApiResponseTypeProviderType defaultErrorType){var contentTypes = new MediaTypeCollection();- var responseTypeMetadataProviders = _mvcOptions.OutputFormatters.OfType<IApiResponseTypeMetadataProvider>();+ var responseTypeMetadataProviders = _mvcOptions.OutputFormatters.OfType<NewtonsoftJsonOutputFormatter>();var responseTypes = ReadResponseMetadata(responseMetadataAttributes,@@ -158,8 +158,7 @@ public class ApiResponseTypeProviderif (apiResponseType.Type == typeof(void)){- if (type != null && (statusCode == StatusCodes.Status200OK ||- statusCode == StatusCodes.Status201Created))+ if (type != null && statusCode is StatusCodes.Status200OK or StatusCodes.Status201Created){// ProducesResponseTypeAttribute's constructor defaults to setting "Type" to void when no value is specified.// In this event, use the action's return type for 200 or 201 status codes. This lets you decorate an action with a@@ -315,17 +314,7 @@ public class ApiResponseTypeProvider// We've already excluded Task, void, and IActionResult at this point.//// If the action might return any object, then assume we don't know anything about it.- if (declaredReturnType == typeof(object))- {- return null;- }-- return declaredReturnType;- }-- private static bool IsClientError(int statusCode)- {- return statusCode >= 400 && statusCode < 500;+ return declaredReturnType == typeof(object) ? null : declaredReturnType;}private static bool HasSignificantMetadataProvider(IReadOnlyList<IApiResponseMetadataProvider> providers)diff --git a/src/Web/Grand.Web.Common/ApiExplorer/MetadataApiDescriptionProvider.cs b/src/Web/Grand.Web.Common/ApiExplorer/MetadataApiDescriptionProvider.csindex 48960ecdf..14a3ea3fa 100644--- a/src/Web/Grand.Web.Common/ApiExplorer/MetadataApiDescriptionProvider.cs+++ b/src/Web/Grand.Web.Common/ApiExplorer/MetadataApiDescriptionProvider.cs@@ -1,4 +1,5 @@//https://github.com/dotnet/aspnetcore/blob/main/src/Mvc/Mvc.ApiExplorer/src/DefaultApiDescriptionProvider.cs+using Grand.SharedKernel.Attributes;using Grand.SharedKernel.Extensions;using Grand.Web.Common.Controllers;@@ -104,8 +105,8 @@ public class MetadataApiDescriptionProvider : IApiDescriptionProvidervar templateParameters = parsedTemplate?.Parameters?.ToList() ?? new List<TemplatePart>();var parameterContext = new ApiParameterContext(_modelMetadataProvider, action, templateParameters);-- foreach (var parameter in GetParameters(parameterContext))+ foreach (var parameter in GetParameters(parameterContext,+ httpMethod.Equals("GET", StringComparison.CurrentCultureIgnoreCase))){apiDescription.ParameterDescriptions.Add(parameter);}@@ -125,8 +126,8 @@ public class MetadataApiDescriptionProvider : IApiDescriptionProvidervar contentTypes = GetDeclaredContentTypes(requestMetadataAttributes);foreach (var parameter in apiDescription.ParameterDescriptions){- if (parameter.Source == BindingSource.Body ||- parameter.Source == BindingSource.Form )+ if (parameter.Source == BindingSource.Body ||+ parameter.Source == BindingSource.Form){// For request body bound parameters, determine the content types supported// by input formatters.@@ -152,7 +153,7 @@ public class MetadataApiDescriptionProvider : IApiDescriptionProviderreturn apiDescription;}- private IList<ApiParameterDescription> GetParameters(ApiParameterContext context)+ private IList<ApiParameterDescription> GetParameters(ApiParameterContext context, bool httpGet){// First, get parameters from the model-binding/parameter-binding side of the world.if (context.ActionDescriptor.Parameters != null)@@ -178,15 +179,15 @@ public class MetadataApiDescriptionProvider : IApiDescriptionProvidermetadata = _modelMetadataProvider.GetMetadataForType(actionParameter.ParameterType);}- if (actionParameter.BindingInfo == null &&+ if (!httpGet &&+ actionParameter.BindingInfo == null &&!CommonHelper.IsSimpleType(actionParameter.ParameterType)){- actionParameter.BindingInfo = new BindingInfo- {+ actionParameter.BindingInfo = new BindingInfo {BindingSource = new BindingSource("Body", "Body", true, true)};}-+var bindingContext = new ApiParameterDescriptionContext(metadata,actionParameter.BindingInfo,@@ -421,7 +422,7 @@ public class MetadataApiDescriptionProvider : IApiDescriptionProviderif (supportedTypes != null){- foreach (var supportedType in supportedTypes.Where(x=>x == "application/json"))+ foreach (var supportedType in supportedTypes.Where(x => x == "application/json")){results.Add(new ApiRequestFormat() {Formatter = formatter,