Skip to content

Commit

Permalink
Merge pull request #3402 from RicoSuter/master
Browse files Browse the repository at this point in the history
Release v13.10.9
  • Loading branch information
RicoSuter authored Apr 9, 2021
2 parents c395916 + 621e9b6 commit 5162566
Show file tree
Hide file tree
Showing 94 changed files with 755 additions and 292 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@

<ItemGroup>
<!-- ## NSwag -->
<PackageReference Include="NSwag.AspNetCore" Version="13.10.8" />
<PackageReference Include="NSwag.MSBuild" Version="13.10.8">
<PackageReference Include="NSwag.AspNetCore" Version="13.10.9" />
<PackageReference Include="NSwag.MSBuild" Version="13.10.9">
<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.2.1.0, Culture=neutral, PublicKeyToken=c2f9c3bdfae56102, processorArchitecture=MSIL">
<HintPath>..\..\packages\NJsonSchema.10.2.1\lib\net45\NJsonSchema.dll</HintPath>
</Reference>
<Reference Include="NSwag.AspNet.Owin, Version=13.10.8.0, Culture=neutral, PublicKeyToken=c2d88086e098d109, processorArchitecture=MSIL">
<HintPath>..\..\packages\NSwag.AspNet.Owin.13.10.8\lib\net45\NSwag.AspNet.Owin.dll</HintPath>
<Reference Include="NSwag.AspNet.Owin, Version=13.10.9.0, Culture=neutral, PublicKeyToken=c2d88086e098d109, processorArchitecture=MSIL">
<HintPath>..\..\packages\NSwag.AspNet.Owin.13.10.9\lib\net45\NSwag.AspNet.Owin.dll</HintPath>
</Reference>
<Reference Include="NSwag.Core, Version=13.10.8.0, Culture=neutral, PublicKeyToken=c2d88086e098d109, processorArchitecture=MSIL">
<HintPath>..\..\packages\NSwag.Core.13.10.8\lib\net45\NSwag.Core.dll</HintPath>
<Reference Include="NSwag.Core, Version=13.10.9.0, Culture=neutral, PublicKeyToken=c2d88086e098d109, processorArchitecture=MSIL">
<HintPath>..\..\packages\NSwag.Core.13.10.9\lib\net45\NSwag.Core.dll</HintPath>
</Reference>
<Reference Include="NSwag.Generation, Version=13.10.8.0, Culture=neutral, PublicKeyToken=c2d88086e098d109, processorArchitecture=MSIL">
<HintPath>..\..\packages\NSwag.Generation.13.10.8\lib\net45\NSwag.Generation.dll</HintPath>
<Reference Include="NSwag.Generation, Version=13.10.9.0, Culture=neutral, PublicKeyToken=c2d88086e098d109, processorArchitecture=MSIL">
<HintPath>..\..\packages\NSwag.Generation.13.10.9\lib\net45\NSwag.Generation.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="NSwag.Generation.WebApi, Version=13.10.8.0, Culture=neutral, PublicKeyToken=c2d88086e098d109, processorArchitecture=MSIL">
<HintPath>..\..\packages\NSwag.Generation.WebApi.13.10.8\lib\net45\NSwag.Generation.WebApi.dll</HintPath>
<Reference Include="NSwag.Generation.WebApi, Version=13.10.9.0, Culture=neutral, PublicKeyToken=c2d88086e098d109, processorArchitecture=MSIL">
<HintPath>..\..\packages\NSwag.Generation.WebApi.13.10.9\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.10.8.0 (NJsonSchema v10.3.11.0 (Newtonsoft.Json v10.0.0.0))",
"x-generator": "NSwag v13.10.9.0 (NJsonSchema v10.4.1.0 (Newtonsoft.Json v10.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.10.8.0 (NJsonSchema v10.3.11.0 (Newtonsoft.Json v11.0.0.0))",
"x-generator": "NSwag v13.10.9.0 (NJsonSchema v10.4.1.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.10.8.0 (NJsonSchema v10.3.11.0 (Newtonsoft.Json v11.0.0.0))",
"x-generator": "NSwag v13.10.9.0 (NJsonSchema v10.4.1.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.10.8.0 (NJsonSchema v10.3.11.0 (Newtonsoft.Json v11.0.0.0))",
"x-generator": "NSwag v13.10.9.0 (NJsonSchema v10.4.1.0 (Newtonsoft.Json v11.0.0.0))",
"swagger": "2.0",
"info": {
"title": "My Title",
Expand Down
9 changes: 6 additions & 3 deletions 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.10.8</Version>
<Version>13.10.9</Version>
<PackageTags>OpenAPI Swagger AspNetCore Documentation CodeGen TypeScript WebApi AspNet</PackageTags>
<Copyright>Copyright © Rico Suter, 2020</Copyright>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
Expand All @@ -11,7 +11,7 @@
<SignAssembly>True</SignAssembly>
<AssemblyOriginatorKeyFile>../NSwag.snk</AssemblyOriginatorKeyFile>
<Authors>Rico Suter</Authors>
<PackageIconUrl>https://raw.githubusercontent.com/RicoSuter/NSwag/master/assets/NuGetIcon.png</PackageIconUrl>
<PackageIcon>NuGetIcon.png</PackageIcon>
<Company />
<RepositoryType>git</RepositoryType>
<RepositoryUrl>https://github.com/RicoSuter/NSwag.git</RepositoryUrl>
Expand All @@ -22,7 +22,10 @@
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
<DefineConstants>TRACE;DEBUG</DefineConstants>
</PropertyGroup>
<ItemGroup>
<None Include="..\..\assets\NuGetIcon.png" Pack="true" PackagePath="" />
</ItemGroup>
<ItemGroup Condition="'$(TargetFramework)' == 'net45'">
<Reference Include="Microsoft.CSharp" />
</ItemGroup>
</Project>
</Project>
2 changes: 2 additions & 0 deletions src/NSwag.Annotations/OpenApiExtensionDataAttribute.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@ namespace NSwag.Annotations
/// <remarks>Requires the SwaggerExtensionDataOperationProcessor to be used in the Swagger definition generation.</remarks>
/// <seealso cref="Attribute" />
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Method | AttributeTargets.Parameter, AllowMultiple = true)]
#pragma warning disable 618
public sealed class OpenApiExtensionDataAttribute : SwaggerExtensionDataAttribute
#pragma warning restore 618
{
/// <summary>Initializes a new instance of the <see cref="SwaggerExtensionDataAttribute"/> class.</summary>
/// <param name="key">The key.</param>
Expand Down
4 changes: 3 additions & 1 deletion src/NSwag.Annotations/OpenApiFileAttribute.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@ namespace NSwag.Annotations
{
/// <summary>Specifies a parameter or class to be handled as file.</summary>
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Parameter)]
#pragma warning disable 618
public class OpenApiFileAttribute : SwaggerFileAttribute
#pragma warning restore 618
{
}

Expand All @@ -22,4 +24,4 @@ public class OpenApiFileAttribute : SwaggerFileAttribute
public class SwaggerFileAttribute : Attribute
{
}
}
}
4 changes: 3 additions & 1 deletion src/NSwag.Annotations/OpenApiIgnoreAttribute.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@ namespace NSwag.Annotations
{
/// <summary>Excludes an action method from the generated Swagger specification.</summary>
[AttributeUsage(AttributeTargets.Property | AttributeTargets.Method | AttributeTargets.Class | AttributeTargets.Parameter)]
#pragma warning disable 618
public class OpenApiIgnoreAttribute : SwaggerIgnoreAttribute
#pragma warning restore 618
{
}

Expand All @@ -22,4 +24,4 @@ public class OpenApiIgnoreAttribute : SwaggerIgnoreAttribute
public class SwaggerIgnoreAttribute : Attribute
{
}
}
}
4 changes: 3 additions & 1 deletion src/NSwag.Annotations/OpenApiOperationAttribute.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@ namespace NSwag.Annotations
{
/// <summary>Specifies the operation id, summary and description</summary>
[AttributeUsage(AttributeTargets.Method)]
#pragma warning disable 618
public class OpenApiOperationAttribute : SwaggerOperationAttribute
#pragma warning restore 618
{
/// <summary>Initializes a new instance of the <see cref="OpenApiOperationAttribute"/> class.</summary>
/// <param name="operationId">The operation ID.</param>
Expand Down Expand Up @@ -61,4 +63,4 @@ public SwaggerOperationAttribute(string operationId)
/// <summary>Gets or sets the operation ID.</summary>
public string OperationId { get; private set; }
}
}
}
4 changes: 3 additions & 1 deletion src/NSwag.Annotations/OpenApiOperationProcessorAttribute.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@ namespace NSwag.Annotations
/// <summary>Registers an operation processor for the given method or class.</summary>
/// <seealso cref="System.Attribute" />
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Method, AllowMultiple = true)]
#pragma warning disable 618
public class OpenApiOperationProcessorAttribute : SwaggerOperationProcessorAttribute
#pragma warning restore 618
{
/// <summary>Initializes a new instance of the <see cref="SwaggerOperationProcessorAttribute"/> class.</summary>
/// <param name="type">The operation processor type (must implement IOperationProcessor).</param>
Expand Down Expand Up @@ -44,4 +46,4 @@ public SwaggerOperationProcessorAttribute(Type type, params object[] parameters)
/// <summary>Gets or sets the type of the constructor parameters.</summary>
public object[] Parameters { get; set; }
}
}
}
4 changes: 3 additions & 1 deletion src/NSwag.Annotations/OpenApiTagAttribute.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@ namespace NSwag.Annotations
{
/// <summary>Specifies the tags for an operation.</summary>
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Method, AllowMultiple = true)]
#pragma warning disable 618
public class OpenApiTagAttribute : SwaggerTagAttribute
#pragma warning restore 618
{
/// <summary>Initializes a new instance of the <see cref="SwaggerTagAttribute"/> class.</summary>
public OpenApiTagAttribute(string name) : base(name)
Expand Down Expand Up @@ -46,4 +48,4 @@ public SwaggerTagAttribute(string name)
/// <summary>Gets or sets a value indicating whether the tags should be added to document's 'tags' property (only needed on operation methods, default: false).</summary>
public bool AddToDocument { get; set; }
}
}
}
4 changes: 3 additions & 1 deletion src/NSwag.Annotations/OpenApiTagsAttribute.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@ namespace NSwag.Annotations
{
/// <summary>Specifies the tags for an operation or a document.</summary>
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Method)]
#pragma warning disable 618
public class OpenApiTagsAttribute : SwaggerTagsAttribute
#pragma warning restore 618
{
/// <summary>Initializes a new instance of the <see cref="SwaggerTagsAttribute"/> class.</summary>
/// <param name="tags">The tags.</param>
Expand Down Expand Up @@ -40,4 +42,4 @@ public SwaggerTagsAttribute(params string[] tags)
/// <summary>Gets or sets a value indicating whether the tags should be added to document's 'tags' property (only needed on operation methods, default: false).</summary>
public bool AddToDocument { get; set; }
}
}
}
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.10.8</version>
<version>13.10.9</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.10.8" />
<dependency id="NSwag.MSBuild" version="13.10.9" />
</dependencies>
<references />
</metadata>
Expand Down
4 changes: 2 additions & 2 deletions 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.10.8</Version>
<Version>13.10.9</Version>
<PackageTags>OpenAPI Swagger AspNetCore Documentation CodeGen TypeScript WebApi AspNet</PackageTags>
<Copyright>Copyright © Rico Suter, 2020</Copyright>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
Expand Down Expand Up @@ -49,7 +49,7 @@
<ItemGroup>
<PackageReference Include="Microsoft.Owin" Version="3.0.1" />
<PackageReference Include="Microsoft.Owin.StaticFiles" Version="3.0.1" />
<PackageReference Include="NJsonSchema" Version="10.3.11" />
<PackageReference Include="NJsonSchema" Version="10.4.1" />
<PackageReference Include="Owin" Version="1.0" />
</ItemGroup>
<ItemGroup>
Expand Down
4 changes: 2 additions & 2 deletions 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.10.8</Version>
<Version>13.10.9</Version>
<PackageTags>OpenAPI Swagger AspNetCore Documentation CodeGen TypeScript WebApi AspNet</PackageTags>
<Copyright>Copyright © Rico Suter, 2020</Copyright>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
Expand All @@ -25,7 +25,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.3.11" />
<PackageReference Include="NJsonSchema" Version="10.4.1" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\NSwag.Annotations\NSwag.Annotations.csproj" />
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.10.8</Version>
<Version>13.10.9</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.10.8</Version>
<Version>13.10.9</Version>
<Authors>Rico Suter</Authors>
<Company>Rico Suter</Company>
<Description>NSwag: The OpenAPI/Swagger API toolchain for .NET and TypeScript</Description>
Expand Down
43 changes: 32 additions & 11 deletions src/NSwag.AspNetCore/HttpRequestExtension.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ namespace NSwag.AspNetCore
{
internal static class HttpRequestExtension
{
private const string ForwardedProtoHeader = "X-Forwarded-Proto";
private const string ForwardedPrefixHeader = "X-Forwarded-Prefix";
private const string ForwardedHostHeader = "X-Forwarded-Host";

#if AspNetOwin
private static string GetHttpScheme(this IOwinRequest request)
#else
Expand All @@ -35,9 +39,8 @@ public static string GetServerUrl(this IOwinRequest request)
public static string GetServerUrl(this HttpRequest request)
#endif
{
var baseUrl = request.Headers.ContainsKey("X-Forwarded-Host") ?
new Uri($"{request.GetHttpScheme()}://{request.Headers.TryGetFirstHeader("X-Forwarded-Host")}").ToString().TrimEnd('/') :
new Uri($"{request.GetHttpScheme()}://{request.Host}").ToString().TrimEnd('/');
var host = TryGetFirstHeader(request.Headers, ForwardedHostHeader);
var baseUrl = new Uri($"{request.GetHttpScheme()}://{host ?? request.Host.ToString()}").ToString().TrimEnd('/');

return $"{baseUrl}{request.GetBasePath()}".TrimEnd('/');
}
Expand All @@ -48,29 +51,47 @@ public static string GetBasePath(this IOwinRequest request)
public static string GetBasePath(this HttpRequest request)
#endif
{
if (request.Headers.ContainsKey("X-Forwarded-Prefix"))
var prefix = TryGetFirstHeader(request.Headers, ForwardedPrefixHeader);

if (prefix != null)
{
return "/" + request.Headers.TryGetFirstHeader("X-Forwarded-Prefix").Trim('/');
return "/" + prefix.Trim('/');
}

var basePath = request.Headers.ContainsKey("X-Forwarded-Host") ?
new Uri($"http://{request.Headers.TryGetFirstHeader("X-Forwarded-Host")}").AbsolutePath :
"";
var host = TryGetFirstHeader(request.Headers, ForwardedHostHeader);
string basePath;

if (host != null)
{
var proto = TryGetFirstHeader(request.Headers, ForwardedProtoHeader) ?? "http";
basePath = new Uri($"{proto}://{host}").AbsolutePath.TrimEnd('/');
}
else
{
basePath = "";
}

if (request.PathBase.HasValue)
{
basePath = basePath.TrimEnd('/') + "/" + request.PathBase.Value;
basePath += "/" + request.PathBase.Value;
}

return ("/" + basePath.Trim('/')).TrimEnd('/');
}

private static string TryGetFirstHeader(this IHeaderDictionary headers, string name)
{
name = headers.Keys.FirstOrDefault(n => string.Equals(n, name, StringComparison.OrdinalIgnoreCase));

if (name == null)
{
return null;
}

#if AspNetOwin
return headers[name]?.Split(',').Select(s => s.Trim()).First();
return headers[name].Split(',').Select(s => s.Trim()).First();
#else
return headers[name].FirstOrDefault()?.Split(',').Select(s => s.Trim()).First();
return headers[name].First().Split(',').Select(s => s.Trim()).First();
#endif
}
}
Expand Down
Loading

0 comments on commit 5162566

Please sign in to comment.