Skip to content

Commit

Permalink
Close #6
Browse files Browse the repository at this point in the history
  • Loading branch information
unchase committed Mar 22, 2020
1 parent 2ec5dd1 commit 5744333
Show file tree
Hide file tree
Showing 4 changed files with 20 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.2.6 `(2020-03-22)`

- [x] Fix bug: add fix #6 to `options.AddEnumsWithValuesFixFilters(true);` when using `JsonStringEnumConverter()`

## v2.2.5 `(2020-03-02)`

- [x] Fix bug: hide Paths and Components with `AuthorizeAttribute` applied to the Controller
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,17 @@ internal static string AddEnumValuesDescription(this OpenApiSchema schema, bool
var sb = new StringBuilder();
for (int i = 0; i < schema.Enum.Count; i++)
{
var value = ((OpenApiInteger)schema.Enum[i]).Value;
var name = ((OpenApiString)((OpenApiArray)schema.Extensions["x-enumNames"])[i]).Value;
sb.Append($"{Environment.NewLine}{Environment.NewLine}{value} = {name}");
if (schema.Enum[i] is OpenApiInteger schemaEnumInt)
{
var value = schemaEnumInt.Value;
var name = ((OpenApiString)((OpenApiArray)schema.Extensions["x-enumNames"])[i]).Value;
sb.Append($"{Environment.NewLine}{Environment.NewLine}{value} = {name}");
}
else if (schema.Enum[i] is OpenApiString schemaEnumString)
{
var value = schemaEnumString.Value;
sb.Append($"{Environment.NewLine}{Environment.NewLine}{value}");
}

// add description from DescriptionAttribute
if (includeDescriptionFromAttribute)
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.2.5</Version>
<AssemblyVersion>2.2.5.0</AssemblyVersion>
<FileVersion>2.2.5.0</FileVersion>
<Version>2.2.6</Version>
<AssemblyVersion>2.2.6.0</AssemblyVersion>
<FileVersion>2.2.6.0</FileVersion>
<GeneratePackageOnBuild>false</GeneratePackageOnBuild>
<DocumentationFile>Unchase.Swashbuckle.AspNetCore.Extensions.xml</DocumentationFile>
</PropertyGroup>
Expand Down
2 changes: 2 additions & 0 deletions test/WebApi3.1-Swashbuckle/Startup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
using System.Collections.Generic;
using System.IO;
using System.Net;
using System.Text.Json.Serialization;
using TodoApi.Models;
using Unchase.Swashbuckle.AspNetCore.Extensions.Extensions;
using Unchase.Swashbuckle.AspNetCore.Extensions.Filters;
Expand All @@ -24,6 +25,7 @@ public class Startup
public void ConfigureServices(IServiceCollection services)
{
services.AddControllers();
//.AddJsonOptions(options => options.JsonSerializerOptions.Converters.Add(new JsonStringEnumConverter()));

// Register the Swagger generator, defining 1 or more Swagger documents
services.AddSwaggerGen(options =>
Expand Down

0 comments on commit 5744333

Please sign in to comment.