Skip to content

Commit

Permalink
fix: Fix #17 - check schema for null in `DisplayEnumsWithValuesDocume…
Browse files Browse the repository at this point in the history
…ntFilter`
  • Loading branch information
unchase committed Oct 5, 2021
1 parent cd13300 commit d710cb6
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 18 deletions.
13 changes: 1 addition & 12 deletions Build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ foreach ($src in ls src/*) {
echo "build: Packaging project in $src"

& dotnet pack -c Release -o ..\..\artifacts --version-suffix=$suffix
if($LASTEXITCODE -ne 0) { exit 1 }
if($LASTEXITCODE -ne 0) { exit 1 }

Pop-Location
}
Expand All @@ -37,15 +37,4 @@ foreach ($test in ls test/*.PerformanceTests) {
Pop-Location
}

foreach ($test in ls test/*.Tests) {
Push-Location $test

echo "build: Testing project in $test"

& dotnet test -c Release
if($LASTEXITCODE -ne 0) { exit 3 }

Pop-Location
}

Pop-Location
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.6.12 `2021-10-05`

- [x] Fix [#17](https://github.com/unchase/Unchase.Swashbuckle.AspNetCore.Extensions/issues/17): check schema for null in `DisplayEnumsWithValuesDocumentFilter`

## v2.6.11 `2021-09-29`

- [x] Fix [#18](https://github.com/unchase/Unchase.Swashbuckle.AspNetCore.Extensions/issues/18): add aliases for "x-enumNames" and "x-enumDescriptions"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,9 @@ public void Apply(OpenApiDocument openApiDoc, DocumentFilterContext context)
foreach (var parameter in openApiDoc.Paths.Values.SelectMany(v => v.Operations).SelectMany(op => op.Value.Parameters))
{
OpenApiSchema schema = null;
if (parameter.Schema.Reference == null)
if (parameter.Schema?.Reference == null)
{
if (parameter.Schema.AllOf.Count > 0)
if (parameter.Schema?.AllOf?.Count > 0)
{
schema = context.SchemaRepository.Schemas.FirstOrDefault(s => parameter.Schema.AllOf.FirstOrDefault(a => a.Reference.Id == s.Key) != null).Value;
}
Expand All @@ -89,7 +89,7 @@ public void Apply(OpenApiDocument openApiDoc, DocumentFilterContext context)
}
else
{
var componentReference = parameter.Schema.Reference.Id;
var componentReference = parameter.Schema?.Reference?.Id;
if (!string.IsNullOrWhiteSpace(componentReference))
{
schema = openApiDoc.Components.Schemas[componentReference];
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.6.11</Version>
<AssemblyVersion>2.6.11.0</AssemblyVersion>
<FileVersion>2.6.11.0</FileVersion>
<Version>2.6.12</Version>
<AssemblyVersion>2.6.12.0</AssemblyVersion>
<FileVersion>2.6.12.0</FileVersion>
<GeneratePackageOnBuild>false</GeneratePackageOnBuild>
<DocumentationFile>Unchase.Swashbuckle.AspNetCore.Extensions.xml</DocumentationFile>
</PropertyGroup>
Expand Down

0 comments on commit d710cb6

Please sign in to comment.