Skip to content

Commit

Permalink
Fix openApi response content schema in "ChangeResponseByHttpStatusCod…
Browse files Browse the repository at this point in the history
…eDocumentFilter".
  • Loading branch information
Chebotov Nikolay committed Feb 21, 2020
1 parent 0b601b6 commit 2fd559e
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 6 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.1.5 `(2020-02-21)`

- [x] Fix bug: fix openApi response content schema in `ChangeResponseByHttpStatusCodeDocumentFilter`

## v2.1.4 `(2020-02-20)`

- [x] Add xml-comments to nuget package
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,14 @@ public void Apply(OpenApiDocument swaggerDoc, DocumentFilterContext context)

jsonContent.Example = jsonExample;
}
jsonContent.Schema = schema;
jsonContent.Schema = new OpenApiSchema
{
Reference = new OpenApiReference
{
Id = typeof(T).Name,
Type = ReferenceType.Schema
}
};
break;
case ResponseExampleOptions.None:
default:
Expand All @@ -122,10 +129,17 @@ public void Apply(OpenApiDocument swaggerDoc, DocumentFilterContext context)
WriteIndented = true,
Encoder = System.Text.Encodings.Web.JavaScriptEncoder.UnsafeRelaxedJsonEscaping
}));
response.Value.Content.Add("application/json", new OpenApiMediaType()
response.Value.Content.Add("application/json", new OpenApiMediaType
{
Example = jsonExample,
Schema = schema
Schema = new OpenApiSchema
{
Reference = new OpenApiReference
{
Id = typeof(T).Name,
Type = ReferenceType.Schema
}
}
});
}
break;
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.1.4</Version>
<AssemblyVersion>2.1.4.0</AssemblyVersion>
<FileVersion>2.1.4.0</FileVersion>
<Version>2.1.5</Version>
<AssemblyVersion>2.1.5.0</AssemblyVersion>
<FileVersion>2.1.5.0</FileVersion>
<GeneratePackageOnBuild>false</GeneratePackageOnBuild>
<DocumentationFile>Unchase.Swashbuckle.AspNetCore.Extensions.xml</DocumentationFile>
</PropertyGroup>
Expand Down

0 comments on commit 2fd559e

Please sign in to comment.