maliming
1 month ago
No known key found for this signature in database
GPG Key ID: A646B9CB645ECEA4
1 changed files with
23 additions and
1 deletions
-
framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/AspNetCoreApiDescriptionModelProvider.cs
|
|
|
@ -175,7 +175,8 @@ public class AspNetCoreApiDescriptionModelProvider : IApiDescriptionModelProvide |
|
|
|
GetSupportedVersions(controllerType, method, setting), |
|
|
|
allowAnonymous, |
|
|
|
authorizeModels, |
|
|
|
implementFrom |
|
|
|
implementFrom, |
|
|
|
GetReturnValueContentTypes(apiDescription) |
|
|
|
) |
|
|
|
); |
|
|
|
|
|
|
|
@ -199,6 +200,27 @@ public class AspNetCoreApiDescriptionModelProvider : IApiDescriptionModelProvide |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
private static List<string>? GetReturnValueContentTypes(ApiDescription apiDescription) |
|
|
|
{ |
|
|
|
var preferred = apiDescription.SupportedResponseTypes |
|
|
|
.FirstOrDefault(x => x.StatusCode == 200 && x.ApiResponseFormats.Any()) |
|
|
|
?? apiDescription.SupportedResponseTypes |
|
|
|
.FirstOrDefault(x => x.StatusCode is >= 200 and < 300 && x.ApiResponseFormats.Any()); |
|
|
|
|
|
|
|
if (preferred == null) |
|
|
|
{ |
|
|
|
return null; |
|
|
|
} |
|
|
|
|
|
|
|
var contentTypes = preferred.ApiResponseFormats |
|
|
|
.Select(f => f.MediaType) |
|
|
|
.Where(m => !string.IsNullOrWhiteSpace(m)) |
|
|
|
.Distinct() |
|
|
|
.ToList(); |
|
|
|
|
|
|
|
return contentTypes.Count > 0 ? contentTypes : null; |
|
|
|
} |
|
|
|
|
|
|
|
private static List<string> GetSupportedVersions(Type controllerType, MethodInfo method, |
|
|
|
ConventionalControllerSetting? setting) |
|
|
|
{ |
|
|
|
|