Skip to content

Commit

Permalink
Fix #12
Browse files Browse the repository at this point in the history
  • Loading branch information
unchase committed Jul 28, 2020
1 parent ece9b53 commit a3d1193
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 10 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@

These are the changes to each version that has been released on the [nuget](https://www.nuget.org/packages/Unchase.Swashbuckle.AspNetCore.Extensions/).

## v2.3.9 `(2020-07-11)`

- [x] Update nuget dependencies for sample WebAPI
- [x] Fix [issue #12](https://github.com/unchase/Unchase.Swashbuckle.AspNetCore.Extensions/issues/12)

## v2.3.8 `(2020-07-06)`

- [x] Fix bug with missed required definitions in `HidePathsAndDefinitionsByRolesDocumentFilter`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ private static string GetFieldAttributeDescription(this Type enumType, object en
if (!enumType.IsEnum)
return string.Empty;
var memInfo = enumType.GetMember(enumField.ToString());
var attributes = memInfo[0].GetCustomAttributes(typeof(DescriptionAttribute), false);
var attributes = memInfo[0].GetCustomAttributes(typeof(DescriptionAttribute), true);
if (attributes.Length > 0)
return (attributes[attributeNumber] as DescriptionAttribute)?.Description ?? string.Empty;
return string.Empty;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ internal static ApiDescription Create(

var actionDescriptor = CreateActionDescriptor(methodInfo);

var routAttr = controllerType.GetCustomAttributes().OfType<RouteAttribute>().LastOrDefault();
var routAttr = controllerType.GetCustomAttributes(true).OfType<RouteAttribute>().LastOrDefault();

if (string.IsNullOrWhiteSpace(actionDescriptor?.AttributeRouteInfo?.Template))
return null;
Expand All @@ -62,7 +62,7 @@ internal static ApiDescription Create(
actionDescriptor.AttributeRouteInfo.Template.Replace($"[{routeValue.Key}]", routeValue.Value);
}

httpMethod = httpMethod ?? methodInfo?.GetCustomAttributes().OfType<HttpMethodAttribute>().FirstOrDefault()?.HttpMethods?.FirstOrDefault();
httpMethod = httpMethod ?? methodInfo?.GetCustomAttributes(true).OfType<HttpMethodAttribute>().FirstOrDefault()?.HttpMethods?.FirstOrDefault();

var apiDescription = new ApiDescription
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ internal static void RemovePathsAndComponents(

foreach (var path in paths)
{
var authorizeAttributes = path.Key.ActionMethodInfo.GetCustomAttributes<AuthorizeAttribute>(false);
var authorizeAttributes = path.Key.ActionMethodInfo.GetCustomAttributes<AuthorizeAttribute>(true);
foreach (var authorizeAttribute in authorizeAttributes)
{
var authorizeAttributeRoles = authorizeAttribute?.Roles?.Split(',').Select(r => r.Trim()).ToList();
Expand All @@ -180,7 +180,7 @@ internal static void RemovePathsAndComponents(
}
}

var controllerAuthorizeAttributes = path.Key.ControllerType.GetCustomAttributes<AuthorizeAttribute>(false);
var controllerAuthorizeAttributes = path.Key.ControllerType.GetCustomAttributes<AuthorizeAttribute>(true);
foreach (var controllerAuthorizeAttribute in controllerAuthorizeAttributes)
{
var authorizeAttributeRoles = controllerAuthorizeAttribute?.Roles?.Split(',').Select(r => r.Trim()).ToList();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@
<NeutralLanguage></NeutralLanguage>
<LangVersion>7.3</LangVersion>
<PackageIconUrl>https://github.com/unchase/Unchase.Swashbuckle.AspNetCore.Extensions/blob/master/assets/icon.png?raw=true</PackageIconUrl>
<Version>2.3.8</Version>
<AssemblyVersion>2.3.8.0</AssemblyVersion>
<FileVersion>2.3.8.0</FileVersion>
<Version>2.3.9</Version>
<AssemblyVersion>2.3.9.0</AssemblyVersion>
<FileVersion>2.3.9.0</FileVersion>
<GeneratePackageOnBuild>false</GeneratePackageOnBuild>
<DocumentationFile>Unchase.Swashbuckle.AspNetCore.Extensions.xml</DocumentationFile>
</PropertyGroup>
Expand Down
4 changes: 2 additions & 2 deletions test/WebApi3.1-Swashbuckle/WebApi3.1-Swashbuckle.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Swashbuckle.AspNetCore" Version="5.0.0" />
<PackageReference Include="Swashbuckle.AspNetCore.Annotations" Version="5.0.0" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="5.5.1" />
<PackageReference Include="Swashbuckle.AspNetCore.Annotations" Version="5.5.1" />
</ItemGroup>

<ItemGroup>
Expand Down

0 comments on commit a3d1193

Please sign in to comment.