|
|
|
@ -1,6 +1,5 @@ |
|
|
|
using System; |
|
|
|
using System.Collections.Generic; |
|
|
|
using System.Diagnostics; |
|
|
|
using System.Linq; |
|
|
|
using System.Reflection; |
|
|
|
using System.Text; |
|
|
|
@ -283,21 +282,21 @@ namespace Volo.Abp.AspNetCore.Mvc |
|
|
|
return; |
|
|
|
} |
|
|
|
|
|
|
|
/* |
|
|
|
* --- bug report --- |
|
|
|
ArrayMatcher.Match has the following bug: |
|
|
|
sourceArray: [ "test1", "test2", "test3" ], |
|
|
|
destinationArray: [ "test2", "test3" ], |
|
|
|
expectedResult: [ "test2", "test3" ], |
|
|
|
result: [ "test1", "test1" ] |
|
|
|
*/ |
|
|
|
/*Because of ArrayMatcher.Match bug parameters that are |
|
|
|
* service provided by FromServicesAttribute must be excluded |
|
|
|
* because Microsoft's API Explorer does not include them |
|
|
|
*/ |
|
|
|
var parameterDescriptionNames = apiDescription.ParameterDescriptions.Select(p => p.Name).ToArray(); |
|
|
|
var methodParameterNames = method.GetParameters().Where(NotServiceProvidedParam).Select(GetMethodParamName).ToArray(); |
|
|
|
var matchedMethodParamNames = ArrayMatcher.Match(parameterDescriptionNames, methodParameterNames); |
|
|
|
var parameterDescriptionNames = apiDescription |
|
|
|
.ParameterDescriptions |
|
|
|
.Select(p => p.Name) |
|
|
|
.ToArray(); |
|
|
|
|
|
|
|
var methodParameterNames = method |
|
|
|
.GetParameters() |
|
|
|
.Where(IsNotFromServicesParameter) |
|
|
|
.Select(GetMethodParamName) |
|
|
|
.ToArray(); |
|
|
|
|
|
|
|
var matchedMethodParamNames = ArrayMatcher.Match( |
|
|
|
parameterDescriptionNames, |
|
|
|
methodParameterNames |
|
|
|
); |
|
|
|
|
|
|
|
for (var i = 0; i < apiDescription.ParameterDescriptions.Count; i++) |
|
|
|
{ |
|
|
|
@ -322,10 +321,9 @@ namespace Volo.Abp.AspNetCore.Mvc |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
private bool NotServiceProvidedParam(ParameterInfo parameterInfo) |
|
|
|
private static bool IsNotFromServicesParameter(ParameterInfo parameterInfo) |
|
|
|
{ |
|
|
|
var fromServicesAttribute = parameterInfo.GetCustomAttribute<FromServicesAttribute>(); |
|
|
|
return fromServicesAttribute == null; |
|
|
|
return !parameterInfo.IsDefined(typeof(FromServicesAttribute), true); |
|
|
|
} |
|
|
|
|
|
|
|
public string GetMethodParamName(ParameterInfo parameterInfo) |
|
|
|
|