Skip to content

Commit

Permalink
Fix bug with OpenAPI operation RequestBody in "HidePathsAndDefinition…
Browse files Browse the repository at this point in the history
…sByRolesDocumentFilter"
  • Loading branch information
unchase authored and Chebotov Nikolay committed Jul 6, 2020
1 parent c92b506 commit 9629b29
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 3 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@

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.6 `(2020-07-06)`

- [x] Fix bug with OpenAPI operation RequestBody in `HidePathsAndDefinitionsByRolesDocumentFilter`

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

- [x] Fix bug in `HidePathsAndDefinitionsByRolesDocumentFilter`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,19 @@ internal static void RemovePathsAndComponents(
}
}

if (operation.Value?.RequestBody != null)
{
var operationRequestBody = operation.Value?.RequestBody;
foreach (var operationRequestBodyContentSchema in operationRequestBody?.Content?.Select(rc => rc.Value?.Schema))
{
if (operationRequestBodyContentSchema?.Reference?.Id != null && !requiredRefs.Contains(operationRequestBodyContentSchema?.Reference?.Id))
{
requiredRefs.AddRange(GetRequiredDefinitions(schemas, operationRequestBodyContentSchema?.Reference));
requiredRefs = requiredRefs.Distinct().ToList();
}
}
}

foreach (var parameter in openApiDoc.Paths?.Where(p => p.Value?.Parameters != null).SelectMany(p => p.Value?.Operations?.SelectMany(o => o.Value?.Parameters)))
{
if (parameter?.Schema?.Reference?.Id != null && !requiredRefs.Contains(parameter.Schema.Reference.Id))
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.4</Version>
<AssemblyVersion>2.3.4.0</AssemblyVersion>
<FileVersion>2.3.4.0</FileVersion>
<Version>2.3.6</Version>
<AssemblyVersion>2.3.6.0</AssemblyVersion>
<FileVersion>2.3.6.0</FileVersion>
<GeneratePackageOnBuild>false</GeneratePackageOnBuild>
<DocumentationFile>Unchase.Swashbuckle.AspNetCore.Extensions.xml</DocumentationFile>
</PropertyGroup>
Expand Down

0 comments on commit 9629b29

Please sign in to comment.