Skip to content

Commit

Permalink
Migrate to 13.20.0 (#89)
Browse files Browse the repository at this point in the history
* Update README.md

* Add nswag.cmd (RicoSuter#4255)

* v13.18.1

* v13.18.2

* Remove description from OpenApiResponse when serializing for Swagger v2 (RicoSuter#4314)

* Remove description from OpenApiResponse when serializing for Swagger v2 to prevent error "Structural error at paths.somepath.get.responses.304 should NOT have additional properties additionalProperty: description" [PR].

* Remove description from OpenApiResponse when serializing for Swagger v2 to prevent error "Structural error at paths.somepath.get.responses.304 should NOT have additional properties additionalProperty: description" [PR].

* Add check for IsBindingAllowed so that BindNever attribute works correctly

* Add CS0612 to the File.Header.liquid (RicoSuter#4409)

OpenApi which contains deprecated schemas correctly generates `[Obsolete]` attribute. If the API document does not propagate `deprecate` all the way to path/method resulting c# code produce warning CS0612: '...' is obsolete

* Update Client.Class.liquid (RicoSuter#4402)

Fix Newtonsoft.Json being used instead of System.Text.Json

* Descriptive exception for duplicate XML doc line (RicoSuter#2863) (RicoSuter#4388)

Duplicate response code in XML documentation response xml tag causes
somewhat hard to debug exception, which is now made more descriptive.

Did not yet figure out how to make an unit test for this one or if some
other other exception type would be more suitable than
InvalidOperationException.

Bug: Duplicate return code declaration causes nasty exception
id: RicoSuter#2863

Co-authored-by: Antti Viita <antti.viita@vividworks.com>

* Revert PR RicoSuter#4314

* v13.18.3

* Improve NRT support for API parameters

* Required path parameters are not nullable (when NRT is off)

* v13.18.4

* Add enforceNotNull parameter and use for required path parameters

* v13.18.5

* Add File.Footer.liquid (RicoSuter#4411)

* Swagger UI v4.18.3, closes RicoSuter#4311 and RicoSuter#4387 (v13.18.5)

* add axios abort signal (RicoSuter#4282)

* add axios abort signal

* unit test

* Add support for MSBuild transitive dependency flow RicoSuter#4026 (RicoSuter#4338)

* Use GNU tar for cache and install .NET in single step (RicoSuter#4251)

* Unwrap ValueTask<T> return types (RicoSuter#4374)

* Unwrap ValueTask<T> return types, same as Task<T>, unwrap (Value)Task<ActionResult<T>> and unify unwrapping for consistency RicoSuter#4373

* lahma suggestion for performance

* cleanup

* NJsonSchema v10.9.0

* Fix build

* Revert "Fix build"

This reverts commit 21bf926.

* Fix build

* Fix dep

* Add .NET 5 SDK

* Improve build

* v13.19.0

* fix default value docs of SerializeTypeInformation, closes RicoSuter#4480

* Add SwaggerRoutesFactory to SwaggerUi3Settings

* Disable warning CS8604 "Possible null reference argument for parameter" in generated code (RicoSuter#4422)

* Disable warning CS8604 "Possible null reference argument for parameter" in code generation file header template

* Restore warning in file footer

* Update Client.Class.liquid (RicoSuter#4471)

* Update Client.Class.liquid

fix RicoSuter#4466

* Update Client.Class.liquid

---------

Co-authored-by: Rico Suter <mail@rsuter.com>

* install .net 3.1 sdk

* v13.20.0

* Set ChocolateyPush source

* Post-merge adjustments

* Updated more Newtonsoft.Json versions, for consistency

---------

Co-authored-by: Rico Suter <mail@rsuter.com>
Co-authored-by: Patrick Hofman <PatrickHofman@users.noreply.github.com>
Co-authored-by: Jan Trejbal <jan@trejbal.land>
Co-authored-by: Jean-Luc <jeanluc1@live.de>
Co-authored-by: Antti Viita <aviita@gmail.com>
Co-authored-by: Antti Viita <antti.viita@vividworks.com>
Co-authored-by: Rico Suter <rico.suter@buhlergroup.com>
Co-authored-by: Lydon Chandra <104476360+fmg-lydonchandra@users.noreply.github.com>
Co-authored-by: Daniel Sack <danielthecoder@outlook.com>
Co-authored-by: Marko Lahma <marko.lahma@gmail.com>
Co-authored-by: Alasdair <alasdaircs@gmail.com>
Co-authored-by: Noah Stolk <noah.stolk@gmail.com>
Co-authored-by: Alireza Mahdavi <alireza.mahdavi2125@outlook.com>
  • Loading branch information
14 people committed Nov 16, 2023
1 parent 5cf27cf commit 459583a
Show file tree
Hide file tree
Showing 73 changed files with 842 additions and 222 deletions.
28 changes: 12 additions & 16 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,24 +34,20 @@ jobs:
steps:
- name: 'Allow long file path'
run: git config --system core.longpaths true
- uses: actions/checkout@v1
- if: ${{ runner.os == 'Windows' }}
name: 'Use GNU tar'
shell: cmd
run: |
echo "Adding GNU tar to PATH"
echo C:\Program Files\Git\usr\bin>>"%GITHUB_PATH%"
- uses: actions/setup-dotnet@v3
with:
dotnet-version: 2.1.*
- uses: actions/setup-dotnet@v3
with:
dotnet-version: 3.1.*
- uses: actions/setup-dotnet@v3
with:
dotnet-version: 5.0.*
- uses: actions/setup-dotnet@v3
with:
dotnet-version: 6.0.*
- uses: actions/setup-dotnet@v3
with:
dotnet-version: 7.0.*
dotnet-version: |
2.1.*
5.0.*
- uses: actions/checkout@v3
- name: Cache .nuke/temp, ~/.nuget/packages
uses: actions/cache@v2
uses: actions/cache@v3
with:
path: |
.nuke/temp
Expand All @@ -64,7 +60,7 @@ jobs:
MYGET_API_KEY: ${{ secrets.MYGET_API_KEY }}
CHOCO_API_KEY: ${{ secrets.CHOCO_API_KEY }}
NPM_AUTH_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }}
- uses: actions/upload-artifact@v1
- uses: actions/upload-artifact@v3
with:
name: artifacts
path: artifacts
26 changes: 11 additions & 15 deletions .github/workflows/pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,24 +32,20 @@ jobs:
steps:
- name: 'Allow long file path'
run: git config --system core.longpaths true
- uses: actions/checkout@v1
- if: ${{ runner.os == 'Windows' }}
name: 'Use GNU tar'
shell: cmd
run: |
echo "Adding GNU tar to PATH"
echo C:\Program Files\Git\usr\bin>>"%GITHUB_PATH%"
- uses: actions/setup-dotnet@v3
with:
dotnet-version: 2.1.*
- uses: actions/setup-dotnet@v3
with:
dotnet-version: 3.1.*
- uses: actions/setup-dotnet@v3
with:
dotnet-version: 5.0.*
- uses: actions/setup-dotnet@v3
with:
dotnet-version: 6.0.*
- uses: actions/setup-dotnet@v3
with:
dotnet-version: 7.0.*
dotnet-version: |
2.1.*
5.0.*
- uses: actions/checkout@v3
- name: Cache .nuke/temp, ~/.nuget/packages
uses: actions/cache@v2
uses: actions/cache@v3
with:
path: |
.nuke/temp
Expand Down
9 changes: 5 additions & 4 deletions .nuke/build.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"properties": {
"ChocoApiKey": {
"type": "string",
"default": "Secrets must be entered via 'nuke :secret [profile]'"
"default": "Secrets must be entered via 'nuke :secrets [profile]'"
},
"Configuration": {
"type": "string",
Expand All @@ -33,6 +33,7 @@
"AppVeyor",
"AzurePipelines",
"Bamboo",
"Bitbucket",
"Bitrise",
"GitHubActions",
"GitLab",
Expand All @@ -48,19 +49,19 @@
},
"MyGetApiKey": {
"type": "string",
"default": "Secrets must be entered via 'nuke :secret [profile]'"
"default": "Secrets must be entered via 'nuke :secrets [profile]'"
},
"NoLogo": {
"type": "boolean",
"description": "Disables displaying the NUKE logo"
},
"NpmAuthToken": {
"type": "string",
"default": "Secrets must be entered via 'nuke :secret [profile]'"
"default": "Secrets must be entered via 'nuke :secrets [profile]'"
},
"NuGetApiKey": {
"type": "string",
"default": "Secrets must be entered via 'nuke :secret [profile]'"
"default": "Secrets must be entered via 'nuke :secrets [profile]'"
},
"Partition": {
"type": "string",
Expand Down
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@ NSwag | [NJsonSchema](http://njsonschema.org) | [Apimundo](https://apimundo.com)
[![npm](https://img.shields.io/npm/v/nswag.svg)](https://www.npmjs.com/package/nswag)
[![MyGet](https://img.shields.io/myget/nswag/v/NSwag.Core.svg?label=preview%20nuget)](https://www.myget.org/feed/Packages/nswag)
[![build](https://github.com/RicoSuter/NSwag/actions/workflows/build.yml/badge.svg)](https://github.com/RicoSuter/NSwag/actions/workflows/build.yml)
[![Gitter](https://img.shields.io/badge/gitter-join%20chat-1dce73.svg)](https://gitter.im/NSwag/NSwag)
[![Discord](https://img.shields.io/badge/Discord-join%20chat-1dce73.svg)](https://discord.gg/4x48JjUT)
[![Discord](https://img.shields.io/badge/Discord-join%20chat-1dce73.svg)](https://discord.gg/BxQNy25WF6)
[![StackOverflow](https://img.shields.io/badge/questions-on%20StackOverflow-orange.svg?style=flat)](http://stackoverflow.com/questions/tagged/nswag)
[![Wiki](https://img.shields.io/badge/docs-in%20wiki-orange.svg?style=flat)](https://github.com/RicoSuter/nswag/wiki)
[![Backers on Open Collective](https://opencollective.com/NSwag/backers/badge.svg)](#backers)
Expand Down
2 changes: 1 addition & 1 deletion build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ else {
$env:DOTNET_EXE = "$DotNetDirectory\dotnet.exe"
}

Write-Output "Microsoft (R) .NET Core SDK version $(& $env:DOTNET_EXE --version)"
Write-Output "Microsoft (R) .NET SDK version $(& $env:DOTNET_EXE --version)"

ExecSafe { & $env:DOTNET_EXE build $BuildProjectFile /nodeReuse:false /p:UseSharedCompilation=false -nologo -clp:NoSummary --verbosity quiet }
ExecSafe { & $env:DOTNET_EXE run --project $BuildProjectFile --no-build -- $BuildArguments }
2 changes: 1 addition & 1 deletion build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ else
export DOTNET_EXE="$DOTNET_DIRECTORY/dotnet"
fi

echo "Microsoft (R) .NET Core SDK version $("$DOTNET_EXE" --version)"
echo "Microsoft (R) .NET SDK version $("$DOTNET_EXE" --version)"

"$DOTNET_EXE" build "$BUILD_PROJECT_FILE" /nodeReuse:false /p:UseSharedCompilation=false -nologo -clp:NoSummary --verbosity quiet
"$DOTNET_EXE" run --project "$BUILD_PROJECT_FILE" --no-build -- "$@"
55 changes: 44 additions & 11 deletions build/Build.CI.GitHubActions.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
using System.Collections.Generic;
using System.Linq;
using Nuke.Common.CI.GitHubActions;
using Nuke.Common.CI.GitHubActions.Configuration;
using Nuke.Common.Execution;
using Nuke.Common.Utilities;

[CustomGitHubActionsAttribute(
[CustomGitHubActions(
"pr",
GitHubActionsImage.WindowsServer2022,
// GitHubActionsImage.UbuntuLatest,
Expand All @@ -16,7 +17,7 @@
InvokedTargets = new[] { nameof(InstallDependencies), nameof(Compile), nameof(Test), nameof(Pack) },
CacheKeyFiles = new[] { "global.json", "src/**/*.csproj", "src/**/package.json" }),
]
[CustomGitHubActionsAttribute(
[CustomGitHubActions(
"build",
GitHubActionsImage.WindowsServer2022,
// GitHubActionsImage.UbuntuLatest,
Expand Down Expand Up @@ -45,14 +46,15 @@ protected override GitHubActionsJob GetJobs(GitHubActionsImage image, IReadOnlyC
var job = base.GetJobs(image, relevantTargets);

var newSteps = new List<GitHubActionsStep>(job.Steps);
foreach (var version in new[] { "7.0.*", "6.0.*", "5.0.*", "3.1.*", "2.1.*" })

// only need to list the ones that are missing from default image
newSteps.Insert(0, new GitHubActionsSetupDotNetStep(new[]
{
newSteps.Insert(1, new GitHubActionsSetupDotNetStep
{
Version = version
});
}

"2.1.*",
"5.0.*"
}));

newSteps.Insert(0, new GitHubActionsUseGnuTarStep());
newSteps.Insert(0, new GitHubActionsConfigureLongPathsStep());

job.Steps = newSteps.ToArray();
Expand All @@ -74,7 +76,12 @@ public override void Write(CustomFileWriter writer)

class GitHubActionsSetupDotNetStep : GitHubActionsStep
{
public string Version { get; init; }
public GitHubActionsSetupDotNetStep(string[] versions)
{
Versions = versions;
}

string[] Versions { get; }

public override void Write(CustomFileWriter writer)
{
Expand All @@ -85,8 +92,34 @@ public override void Write(CustomFileWriter writer)
writer.WriteLine("with:");
using (writer.Indent())
{
writer.WriteLine($"dotnet-version: {Version}");
writer.WriteLine("dotnet-version: |");
using (writer.Indent())
{
foreach (var version in Versions)
{
writer.WriteLine(version);
}
}
}
}
}
}

class GitHubActionsUseGnuTarStep : GitHubActionsStep
{
public override void Write(CustomFileWriter writer)
{
writer.WriteLine("- if: ${{ runner.os == 'Windows' }}");
using (writer.Indent())
{
writer.WriteLine("name: 'Use GNU tar'");
writer.WriteLine("shell: cmd");
writer.WriteLine("run: |");
using (writer.Indent())
{
writer.WriteLine("echo \"Adding GNU tar to PATH\"");
writer.WriteLine("echo C:\\Program Files\\Git\\usr\\bin>>\"%GITHUB_PATH%\"");
}
}
}
}
1 change: 1 addition & 0 deletions build/Build.Publish.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ public partial class Build
ChocolateyPush(_ => _
.SetApiKey(ChocoApiKey)
.SetPathToNuGetPackage(ArtifactsDirectory.GlobFiles("NSwagStudio.*.nupkg").Single())
.SetSource("https://push.chocolatey.org/")
);
try
Expand Down
4 changes: 1 addition & 3 deletions build/Build.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
using Microsoft.Build.Evaluation;
using Microsoft.Build.Locator;
using Nuke.Common;
using Nuke.Common.Execution;
using Nuke.Common.Git;
using Nuke.Common.IO;
using Nuke.Common.ProjectModel;
Expand All @@ -18,7 +17,6 @@
using Nuke.Common.Utilities.Collections;

using static Nuke.Common.IO.FileSystemTasks;
using static Nuke.Common.Logger;
using static Nuke.Common.Tooling.ProcessTasks;
using static Nuke.Common.Tools.Chocolatey.ChocolateyTasks;
using static Nuke.Common.Tools.DotNet.DotNetTasks;
Expand All @@ -27,7 +25,6 @@
using static Nuke.Common.Tools.VSTest.VSTestTasks;
using Project = Nuke.Common.ProjectModel.Project;

[CheckBuildProjectConfigurations]
partial class Build : NukeBuild
{
public Build()
Expand Down Expand Up @@ -125,6 +122,7 @@ protected override void OnBuildInitialized()
{
Chocolatey("install wixtoolset -y");
Chocolatey("install netfx-4.6.1-devpack -y");
Chocolatey("install dotnetcore-3.1-sdk -y");
NpmInstall(x => x
.EnableGlobal()
.AddPackages("dotnettools")
Expand Down
2 changes: 1 addition & 1 deletion build/_build.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Nuke.Common" Version="6.0.1" />
<PackageReference Include="Nuke.Common" Version="6.3.0" />
</ItemGroup>

<ItemGroup>
Expand Down
4 changes: 2 additions & 2 deletions src/Directory.Build.props
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<Project>
<PropertyGroup>
<VersionPrefix>13.18.0</VersionPrefix>
<VersionPrefix>13.20.0</VersionPrefix>

<Authors>Rico Suter</Authors>
<Copyright>Copyright © Rico Suter, 2021</Copyright>
<Copyright>Copyright © Rico Suter, 2023</Copyright>

<Description>NSwag: The OpenAPI/Swagger API toolchain for .NET and TypeScript</Description>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System;
using System.IO;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.Owin;
using NSwag.Generation;
Expand Down Expand Up @@ -30,7 +31,7 @@ public override async Task Invoke(IOwinContext context)
{
context.Response.Headers["Content-Type"] = "text/html; charset=utf-8";
context.Response.StatusCode = 200;
context.Response.Write(_settings.TransformHtml(reader.ReadToEnd(), context.Request));
context.Response.Write(await _settings.TransformHtmlAsync(reader.ReadToEnd(), context.Request, CancellationToken.None));
}
}
else
Expand Down
2 changes: 1 addition & 1 deletion src/NSwag.AspNet.Owin/SwaggerUi3/swagger-ui-bundle.js

Large diffs are not rendered by default.

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/NSwag.AspNet.Owin/SwaggerUi3/swagger-ui-es-bundle.js

Large diffs are not rendered by default.

Large diffs are not rendered by default.

3 changes: 1 addition & 2 deletions src/NSwag.AspNet.Owin/SwaggerUi3/swagger-ui.css

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/NSwag.AspNet.Owin/SwaggerUi3/swagger-ui.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/NSwag.AspNet.WebApi/NSwag.AspNet.WebApi.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<ItemGroup>
<PackageReference Include="Microsoft.AspNet.WebApi.Core" Version="5.2.3" />
<PackageReference Include="Microsoft.AspNet.WebApi.Client" Version="5.2.3" />
<PackageReference Include="NJsonSchema" Version="10.8.0" />
<PackageReference Include="NJsonSchema" Version="10.9.0" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\NSwag.Annotations\NSwag.Annotations.csproj" />
Expand Down
6 changes: 4 additions & 2 deletions src/NSwag.AspNetCore/ApiverseUiSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
//-----------------------------------------------------------------------

using Microsoft.AspNetCore.Http;
using System.Threading;
using System.Threading.Tasks;

namespace NSwag.AspNetCore
{
Expand All @@ -31,9 +33,9 @@ public ApimundoUiSettings()
/// </summary>
public string ApimundoUrl { get; set; } = "https://apimundo.com";

internal override string TransformHtml(string html, HttpRequest request)
internal override Task<string> TransformHtmlAsync(string html, HttpRequest request, CancellationToken cancellationToken)
{
return html;
return Task.FromResult(html);
}
}
}
6 changes: 5 additions & 1 deletion src/NSwag.AspNetCore/Middlewares/SwaggerUiIndexMiddleware.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,11 @@ public async Task Invoke(HttpContext context)
{
context.Response.Headers["Content-Type"] = "text/html; charset=utf-8";
context.Response.StatusCode = 200;
await context.Response.WriteAsync(_settings.TransformHtml(await reader.ReadToEndAsync(), context.Request));
await context.Response.WriteAsync(
await _settings.TransformHtmlAsync(
await reader.ReadToEndAsync(),
context.Request,
context.RequestAborted));
}
}
else
Expand Down
8 changes: 5 additions & 3 deletions src/NSwag.AspNetCore/ReDocSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@

using NSwag.Generation;
using System.Collections.Generic;
using System.Threading.Tasks;
using System.Threading;
#if AspNetOwin
using Microsoft.Owin;

Expand All @@ -30,15 +32,15 @@ public class ReDocSettings : SwaggerUiSettingsBase
public IDictionary<string, object> AdditionalSettings { get; } = new Dictionary<string, object>();

#if AspNetOwin
internal override string TransformHtml(string html, IOwinRequest request)
internal override Task<string> TransformHtmlAsync(string html, IOwinRequest request, CancellationToken cancellationToken)
#else
internal override string TransformHtml(string html, HttpRequest request)
internal override Task<string> TransformHtmlAsync(string html, HttpRequest request, CancellationToken cancellationToken)
#endif
{
html = html.Replace("{AdditionalSettings}", GenerateAdditionalSettings(AdditionalSettings));
html = html.Replace("{CustomStyle}", GetCustomStyleHtml(request));
html = html.Replace("{CustomScript}", GetCustomScriptHtml(request));
return html;
return Task.FromResult(html);
}
}
}
2 changes: 1 addition & 1 deletion src/NSwag.AspNetCore/SwaggerUi3/swagger-ui-bundle.js

Large diffs are not rendered by default.

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/NSwag.AspNetCore/SwaggerUi3/swagger-ui-es-bundle.js

Large diffs are not rendered by default.

Large diffs are not rendered by default.

3 changes: 1 addition & 2 deletions src/NSwag.AspNetCore/SwaggerUi3/swagger-ui.css

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/NSwag.AspNetCore/SwaggerUi3/swagger-ui.js

Large diffs are not rendered by default.

Loading

0 comments on commit 459583a

Please sign in to comment.