Skip to content

Commit

Permalink
Merge pull request #3725 from RicoSuter/master
Browse files Browse the repository at this point in the history
Release v13.14.4
  • Loading branch information
RicoSuter authored Nov 15, 2021
2 parents 4bb1593 + fa49a5d commit 7e78409
Show file tree
Hide file tree
Showing 64 changed files with 753 additions and 228 deletions.
1 change: 1 addition & 0 deletions build/Build.cs
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,7 @@ partial class Build : NukeBuild
("NSwag.Sample.NETCore31", "NetCore31"),
("NSwag.Sample.NET50", "Net50"),
("NSwag.Sample.NET60", "Net60"),
("NSwag.Sample.NET60Minimal", "Net60")
};
foreach (var (projectName, runtime) in dotnetTargets)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@

<ItemGroup>
<!-- ## NSwag -->
<PackageReference Include="NSwag.AspNetCore" Version="13.14.3" />
<PackageReference Include="NSwag.MSBuild" Version="13.14.3">
<PackageReference Include="NSwag.AspNetCore" Version="13.14.4" />
<PackageReference Include="NSwag.MSBuild" Version="13.14.4">
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,18 +62,18 @@
<Reference Include="NJsonSchema, Version=10.5.2.0, Culture=neutral, PublicKeyToken=c2f9c3bdfae56102, processorArchitecture=MSIL">
<HintPath>..\..\packages\NJsonSchema.10.5.2\lib\net45\NJsonSchema.dll</HintPath>
</Reference>
<Reference Include="NSwag.AspNet.Owin, Version=13.14.3.0, Culture=neutral, PublicKeyToken=c2d88086e098d109, processorArchitecture=MSIL">
<HintPath>..\..\packages\NSwag.AspNet.Owin.13.14.3\lib\net45\NSwag.AspNet.Owin.dll</HintPath>
<Reference Include="NSwag.AspNet.Owin, Version=13.14.4.0, Culture=neutral, PublicKeyToken=c2d88086e098d109, processorArchitecture=MSIL">
<HintPath>..\..\packages\NSwag.AspNet.Owin.13.14.4\lib\net45\NSwag.AspNet.Owin.dll</HintPath>
</Reference>
<Reference Include="NSwag.Core, Version=13.14.3.0, Culture=neutral, PublicKeyToken=c2d88086e098d109, processorArchitecture=MSIL">
<HintPath>..\..\packages\NSwag.Core.13.14.3\lib\net45\NSwag.Core.dll</HintPath>
<Reference Include="NSwag.Core, Version=13.14.4.0, Culture=neutral, PublicKeyToken=c2d88086e098d109, processorArchitecture=MSIL">
<HintPath>..\..\packages\NSwag.Core.13.14.4\lib\net45\NSwag.Core.dll</HintPath>
</Reference>
<Reference Include="NSwag.Generation, Version=13.14.3.0, Culture=neutral, PublicKeyToken=c2d88086e098d109, processorArchitecture=MSIL">
<HintPath>..\..\packages\NSwag.Generation.13.14.3\lib\net45\NSwag.Generation.dll</HintPath>
<Reference Include="NSwag.Generation, Version=13.14.4.0, Culture=neutral, PublicKeyToken=c2d88086e098d109, processorArchitecture=MSIL">
<HintPath>..\..\packages\NSwag.Generation.13.14.4\lib\net45\NSwag.Generation.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="NSwag.Generation.WebApi, Version=13.14.3.0, Culture=neutral, PublicKeyToken=c2d88086e098d109, processorArchitecture=MSIL">
<HintPath>..\..\packages\NSwag.Generation.WebApi.13.14.3\lib\net45\NSwag.Generation.WebApi.dll</HintPath>
<Reference Include="NSwag.Generation.WebApi, Version=13.14.4.0, Culture=neutral, PublicKeyToken=c2d88086e098d109, processorArchitecture=MSIL">
<HintPath>..\..\packages\NSwag.Generation.WebApi.13.14.4\lib\net45\NSwag.Generation.WebApi.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Owin, Version=1.0.0.0, Culture=neutral, PublicKeyToken=f0ebd12fd5e55cc5, processorArchitecture=MSIL">
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"x-generator": "NSwag v13.14.3.0 (NJsonSchema v10.5.2.0 (Newtonsoft.Json v11.0.0.0))",
"x-generator": "NSwag v13.14.4.0 (NJsonSchema v10.5.2.0 (Newtonsoft.Json v11.0.0.0))",
"swagger": "2.0",
"info": {
"title": "My Title",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"x-generator": "NSwag v13.14.3.0 (NJsonSchema v10.5.2.0 (Newtonsoft.Json v11.0.0.0))",
"x-generator": "NSwag v13.14.4.0 (NJsonSchema v10.5.2.0 (Newtonsoft.Json v11.0.0.0))",
"swagger": "2.0",
"info": {
"title": "My Title",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"x-generator": "NSwag v13.14.3.0 (NJsonSchema v10.5.2.0 (Newtonsoft.Json v11.0.0.0))",
"x-generator": "NSwag v13.14.4.0 (NJsonSchema v10.5.2.0 (Newtonsoft.Json v11.0.0.0))",
"swagger": "2.0",
"info": {
"title": "My Title",
Expand Down
2 changes: 1 addition & 1 deletion src/NSwag.Annotations/NSwag.Annotations.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<PropertyGroup>
<TargetFrameworks>netstandard1.0;net45;netstandard2.0</TargetFrameworks>
<Description>NSwag: The OpenAPI/Swagger API toolchain for .NET and TypeScript</Description>
<Version>13.14.3</Version>
<Version>13.14.4</Version>
<PackageTags>OpenAPI Swagger AspNetCore Documentation CodeGen TypeScript WebApi AspNet</PackageTags>
<Copyright>Copyright © Rico Suter, 2020</Copyright>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<package xmlns="http://schemas.microsoft.com/packaging/2011/08/nuspec.xsd">
<metadata>
<id>NSwag.ApiDescription.Client</id>
<version>13.14.3</version>
<version>13.14.4</version>
<authors>Rico Suter</authors>
<owners>Rico Suter</owners>
<requireLicenseAcceptance>false</requireLicenseAcceptance>
Expand All @@ -16,7 +16,7 @@
<developmentDependency>true</developmentDependency>
<dependencies>
<dependency id="Microsoft.Extensions.ApiDescription.Client" version="3.0.0" />
<dependency id="NSwag.MSBuild" version="13.14.3" />
<dependency id="NSwag.MSBuild" version="13.14.4" />
</dependencies>
<references />
</metadata>
Expand Down
2 changes: 1 addition & 1 deletion src/NSwag.AspNet.Owin/NSwag.AspNet.Owin.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<PropertyGroup>
<TargetFrameworks>net45</TargetFrameworks>
<Description>NSwag: The OpenAPI/Swagger API toolchain for .NET and TypeScript</Description>
<Version>13.14.3</Version>
<Version>13.14.4</Version>
<PackageTags>OpenAPI Swagger AspNetCore Documentation CodeGen TypeScript WebApi AspNet</PackageTags>
<Copyright>Copyright © Rico Suter, 2020</Copyright>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
Expand Down
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 @@ -2,7 +2,7 @@
<PropertyGroup>
<TargetFrameworks>net45</TargetFrameworks>
<Description>NSwag: The OpenAPI/Swagger API toolchain for .NET and TypeScript</Description>
<Version>13.14.3</Version>
<Version>13.14.4</Version>
<PackageTags>OpenAPI Swagger AspNetCore Documentation CodeGen TypeScript WebApi AspNet</PackageTags>
<Copyright>Copyright © Rico Suter, 2020</Copyright>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<PlatformTarget>x86</PlatformTarget>
<OutputType>Exe</OutputType>
<IsPackable>false</IsPackable>
<Version>13.14.3</Version>
<Version>13.14.4</Version>
<Authors>Rico Suter</Authors>
<Company>Rico Suter</Company>
<Description>NSwag: The OpenAPI/Swagger API toolchain for .NET and TypeScript</Description>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<PlatformTarget Condition="'$(TargetFramework)'=='net461'">x64</PlatformTarget>
<OutputType>Exe</OutputType>
<IsPackable>false</IsPackable>
<Version>13.14.3</Version>
<Version>13.14.4</Version>
<Authors>Rico Suter</Authors>
<Company>Rico Suter</Company>
<Description>NSwag: The OpenAPI/Swagger API toolchain for .NET and TypeScript</Description>
Expand Down
2 changes: 1 addition & 1 deletion src/NSwag.AspNetCore/NSwag.AspNetCore.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<PropertyGroup>
<TargetFrameworks>net451;netstandard1.6;netstandard2.0;netcoreapp3.1;net5.0;net6.0</TargetFrameworks>
<Description>NSwag: The OpenAPI/Swagger API toolchain for .NET and TypeScript</Description>
<Version>13.14.3</Version>
<Version>13.14.4</Version>
<PackageTags>Swagger Documentation AspNetCore NetCore TypeScript CodeGen</PackageTags>
<Copyright>Copyright © Rico Suter, 2020</Copyright>
<PackageLicenseUrl>https://github.com/RicoSuter/NSwag/blob/master/LICENSE.md</PackageLicenseUrl>
Expand Down
2 changes: 1 addition & 1 deletion src/NSwag.AssemblyLoader/NSwag.AssemblyLoader.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<PropertyGroup>
<TargetFrameworks>netstandard1.6;net461;netstandard2.0</TargetFrameworks>
<Description>NSwag: The OpenAPI/Swagger API toolchain for .NET and TypeScript</Description>
<Version>13.14.3</Version>
<Version>13.14.4</Version>
<PackageTags>OpenAPI Swagger AspNetCore Documentation CodeGen TypeScript WebApi AspNet</PackageTags>
<Copyright>Copyright © Rico Suter, 2020</Copyright>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<PropertyGroup>
<TargetFrameworks>netstandard1.3;net451;netstandard2.0</TargetFrameworks>
<Description>NSwag: The OpenAPI/Swagger API toolchain for .NET and TypeScript</Description>
<Version>13.14.3</Version>
<Version>13.14.4</Version>
<PackageTags>OpenAPI Swagger AspNetCore Documentation CodeGen TypeScript WebApi AspNet</PackageTags>
<Copyright>Copyright © Rico Suter, 2020</Copyright>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,9 @@ public IEnumerable<string> ResponseClassNames
/// <summary>Gets a value indicating whether to call 'transformOptions' on the base class or extension class.</summary>
public bool UseTransformOptionsMethod => _settings.UseTransformOptionsMethod;

/// <summary>Gets a value indicating whether to include the httpContext parameter (Angular template only, default: false).</summary>
public bool IncludeHttpContext => _settings.IncludeHttpContext;

/// <summary>Gets the clients code.</summary>
public string Clients => _settings.GenerateClientClasses ? _clientCode : string.Empty;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<PropertyGroup>
<TargetFrameworks>netstandard1.3;net451;netstandard2.0</TargetFrameworks>
<Description>NSwag: The OpenAPI/Swagger API toolchain for .NET and TypeScript</Description>
<Version>13.14.3</Version>
<Version>13.14.4</Version>
<PackageTags>OpenAPI Swagger AspNetCore Documentation CodeGen TypeScript WebApi AspNet</PackageTags>
<Copyright>Copyright © Rico Suter, 2020</Copyright>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
Expand Down
2 changes: 1 addition & 1 deletion src/NSwag.CodeGeneration/NSwag.CodeGeneration.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<PropertyGroup>
<TargetFrameworks>netstandard1.3;net451;netstandard2.0</TargetFrameworks>
<Description>NSwag: The OpenAPI/Swagger API toolchain for .NET and TypeScript</Description>
<Version>13.14.3</Version>
<Version>13.14.4</Version>
<PackageTags>OpenAPI Swagger AspNetCore Documentation CodeGen TypeScript WebApi AspNet</PackageTags>
<Copyright>Copyright © Rico Suter, 2020</Copyright>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -320,11 +320,8 @@ private async Task<OpenApiDocument> GenerateDocumentWithApiDescriptionAsync(Asse
protected override async Task<string> RunIsolatedAsync(AssemblyLoader.AssemblyLoader assemblyLoader)
{
var currentWorkingDirectory = ChangeWorkingDirectoryAndSetAspNetCoreEnvironment();
using (var webHost = await CreateWebHostAsync(assemblyLoader))
{
var document = await GenerateDocumentAsync(assemblyLoader, webHost.TryGetPropertyValue<IServiceProvider>("Services"), currentWorkingDirectory);
return UseDocumentProvider ? document.ToJson() : document.ToJson(OutputType);
}
var document = await GenerateDocumentAsync(assemblyLoader, GetServiceProvider(assemblyLoader), currentWorkingDirectory);
return UseDocumentProvider ? document.ToJson() : document.ToJson(OutputType);
}

private static void TryDeleteFiles(List<string> files)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@
// <author>Rico Suter, [email protected]</author>
//-----------------------------------------------------------------------

using System;
using System.IO;
using System.Reflection;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Hosting;
using Newtonsoft.Json;

#pragma warning disable CS0618

namespace NSwag.Commands.Generation.AspNetCore
{
/// <summary>In-process entry point for the aspnetcore2swagger command.</summary>
Expand All @@ -21,9 +21,11 @@ internal class AspNetCoreToOpenApiGeneratorCommandEntryPoint
public static void Process(string commandContent, string outputFile, string applicationName)
{
var command = JsonConvert.DeserializeObject<AspNetCoreToSwaggerCommand>(commandContent);

var previousWorkingDirectory = command.ChangeWorkingDirectoryAndSetAspNetCoreEnvironment();
var serviceProvider = GetServiceProvider(applicationName);

var assemblyName = new AssemblyName(applicationName);
var assembly = Assembly.Load(assemblyName);
var serviceProvider = ServiceProviderResolver.GetServiceProvider(assembly);

var assemblyLoader = new AssemblyLoader.AssemblyLoader();
var document = Task.Run(async () =>
Expand All @@ -35,65 +37,5 @@ public static void Process(string commandContent, string outputFile, string appl
Directory.CreateDirectory(outputPathDirectory);
File.WriteAllText(outputFile, json);
}

private static IServiceProvider GetServiceProvider(string applicationName)
{
var assemblyName = new AssemblyName(applicationName);
var assembly = Assembly.Load(assemblyName);

if (assembly.EntryPoint == null)
{
throw new InvalidOperationException($"Unable to locate the program entry point for {assemblyName}.");
}

var entryPointType = assembly.EntryPoint.DeclaringType;
var buildWebHostMethod = entryPointType.GetMethod("BuildWebHost");
var args = new string[0];

IServiceProvider serviceProvider = null;
if (buildWebHostMethod != null)
{
var result = buildWebHostMethod.Invoke(null, new object[] { args });
serviceProvider = ((IWebHost)result).Services;
}
else
{
var createWebHostMethod =
entryPointType?.GetRuntimeMethod("CreateWebHostBuilder", new[] { typeof(string[]) }) ??
entryPointType?.GetRuntimeMethod("CreateWebHostBuilder", new Type[0]);

if (createWebHostMethod != null)
{
var webHostBuilder = (IWebHostBuilder)createWebHostMethod.Invoke(
null, createWebHostMethod.GetParameters().Length > 0 ? new object[] { args } : new object[0]);
serviceProvider = webHostBuilder.Build().Services;
}
#if NET6_0 || NET5_0 || NETCOREAPP3_1 || NETCOREAPP3_0
else
{
var createHostMethod =
entryPointType?.GetRuntimeMethod("CreateHostBuilder", new[] { typeof(string[]) }) ??
entryPointType?.GetRuntimeMethod("CreateHostBuilder", new Type[0]);

if (createHostMethod != null)
{
var webHostBuilder = (Microsoft.Extensions.Hosting.IHostBuilder)createHostMethod.Invoke(
null, createHostMethod.GetParameters().Length > 0 ? new object[] { args } : new object[0]);
serviceProvider = webHostBuilder.Build().Services;
}
}
#endif
}

if (serviceProvider != null)
{
return serviceProvider;
}

throw new InvalidOperationException($"NSwag requires the entry point type {entryPointType.FullName} to have " +
$"either an BuildWebHost or CreateWebHostBuilder/CreateHostBuilder method. " +
$"See https://docs.microsoft.com/en-us/aspnet/core/fundamentals/hosting?tabs=aspnetcore2x " +
$"for suggestions on ways to refactor your startup type.");
}
}
}
Loading

0 comments on commit 7e78409

Please sign in to comment.