diff --git a/CHANGELOG.md b/CHANGELOG.md index c25a44c..06b967e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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` diff --git a/src/Unchase.Swashbuckle.AspNetCore.Extensions/Filters/HidePathsAndDefinitionsByRolesDocumentFilter.cs b/src/Unchase.Swashbuckle.AspNetCore.Extensions/Filters/HidePathsAndDefinitionsByRolesDocumentFilter.cs index cd15647..9338fba 100644 --- a/src/Unchase.Swashbuckle.AspNetCore.Extensions/Filters/HidePathsAndDefinitionsByRolesDocumentFilter.cs +++ b/src/Unchase.Swashbuckle.AspNetCore.Extensions/Filters/HidePathsAndDefinitionsByRolesDocumentFilter.cs @@ -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)) diff --git a/src/Unchase.Swashbuckle.AspNetCore.Extensions/Unchase.Swashbuckle.AspNetCore.Extensions.csproj b/src/Unchase.Swashbuckle.AspNetCore.Extensions/Unchase.Swashbuckle.AspNetCore.Extensions.csproj index 0bd6262..d7dead7 100644 --- a/src/Unchase.Swashbuckle.AspNetCore.Extensions/Unchase.Swashbuckle.AspNetCore.Extensions.csproj +++ b/src/Unchase.Swashbuckle.AspNetCore.Extensions/Unchase.Swashbuckle.AspNetCore.Extensions.csproj @@ -14,9 +14,9 @@ 7.3 https://github.com/unchase/Unchase.Swashbuckle.AspNetCore.Extensions/blob/master/assets/icon.png?raw=true - 2.3.4 - 2.3.4.0 - 2.3.4.0 + 2.3.6 + 2.3.6.0 + 2.3.6.0 false Unchase.Swashbuckle.AspNetCore.Extensions.xml