Skip to content

Commit

Permalink
Merge pull request #3500 from RicoSuter/master
Browse files Browse the repository at this point in the history
Release v13.11.3
  • Loading branch information
RicoSuter authored Jun 4, 2021
2 parents c9f1ef9 + 1c836ee commit 1c50bfb
Show file tree
Hide file tree
Showing 54 changed files with 114 additions and 98 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.11.2" />
<PackageReference Include="NSwag.MSBuild" Version="13.11.2">
<PackageReference Include="NSwag.AspNetCore" Version="13.11.3" />
<PackageReference Include="NSwag.MSBuild" Version="13.11.3">
<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.11.2.0, Culture=neutral, PublicKeyToken=c2d88086e098d109, processorArchitecture=MSIL">
<HintPath>..\..\packages\NSwag.AspNet.Owin.13.11.2\lib\net45\NSwag.AspNet.Owin.dll</HintPath>
<Reference Include="NSwag.AspNet.Owin, Version=13.11.3.0, Culture=neutral, PublicKeyToken=c2d88086e098d109, processorArchitecture=MSIL">
<HintPath>..\..\packages\NSwag.AspNet.Owin.13.11.3\lib\net45\NSwag.AspNet.Owin.dll</HintPath>
</Reference>
<Reference Include="NSwag.Core, Version=13.11.2.0, Culture=neutral, PublicKeyToken=c2d88086e098d109, processorArchitecture=MSIL">
<HintPath>..\..\packages\NSwag.Core.13.11.2\lib\net45\NSwag.Core.dll</HintPath>
<Reference Include="NSwag.Core, Version=13.11.3.0, Culture=neutral, PublicKeyToken=c2d88086e098d109, processorArchitecture=MSIL">
<HintPath>..\..\packages\NSwag.Core.13.11.3\lib\net45\NSwag.Core.dll</HintPath>
</Reference>
<Reference Include="NSwag.Generation, Version=13.11.2.0, Culture=neutral, PublicKeyToken=c2d88086e098d109, processorArchitecture=MSIL">
<HintPath>..\..\packages\NSwag.Generation.13.11.2\lib\net45\NSwag.Generation.dll</HintPath>
<Reference Include="NSwag.Generation, Version=13.11.3.0, Culture=neutral, PublicKeyToken=c2d88086e098d109, processorArchitecture=MSIL">
<HintPath>..\..\packages\NSwag.Generation.13.11.3\lib\net45\NSwag.Generation.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="NSwag.Generation.WebApi, Version=13.11.2.0, Culture=neutral, PublicKeyToken=c2d88086e098d109, processorArchitecture=MSIL">
<HintPath>..\..\packages\NSwag.Generation.WebApi.13.11.2\lib\net45\NSwag.Generation.WebApi.dll</HintPath>
<Reference Include="NSwag.Generation.WebApi, Version=13.11.3.0, Culture=neutral, PublicKeyToken=c2d88086e098d109, processorArchitecture=MSIL">
<HintPath>..\..\packages\NSwag.Generation.WebApi.13.11.3\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.11.2.0 (NJsonSchema v10.4.4.0 (Newtonsoft.Json v11.0.0.0))",
"x-generator": "NSwag v13.11.3.0 (NJsonSchema v10.4.4.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.11.2.0 (NJsonSchema v10.4.4.0 (Newtonsoft.Json v11.0.0.0))",
"x-generator": "NSwag v13.11.3.0 (NJsonSchema v10.4.4.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.11.2.0 (NJsonSchema v10.4.4.0 (Newtonsoft.Json v11.0.0.0))",
"x-generator": "NSwag v13.11.3.0 (NJsonSchema v10.4.4.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.11.2</Version>
<Version>13.11.3</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.11.2</version>
<version>13.11.3</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.11.2" />
<dependency id="NSwag.MSBuild" version="13.11.3" />
</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.11.2</Version>
<Version>13.11.3</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.11.2</Version>
<Version>13.11.3</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.11.2</Version>
<Version>13.11.3</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.11.2</Version>
<Version>13.11.3</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</TargetFrameworks>
<Description>NSwag: The OpenAPI/Swagger API toolchain for .NET and TypeScript</Description>
<Version>13.11.2</Version>
<Version>13.11.3</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;net451;netstandard2.0</TargetFrameworks>
<Description>NSwag: The OpenAPI/Swagger API toolchain for .NET and TypeScript</Description>
<Version>13.11.2</Version>
<Version>13.11.3</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.11.2</Version>
<Version>13.11.3</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.11.2</Version>
<Version>13.11.3</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.11.2</Version>
<Version>13.11.3</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.Commands/NSwag.Commands.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<PropertyGroup>
<TargetFrameworks>net461;netcoreapp2.1;netcoreapp3.1;net5.0</TargetFrameworks>
<Description>NSwag: The OpenAPI/Swagger API toolchain for .NET and TypeScript</Description>
<Version>13.11.2</Version>
<Version>13.11.3</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.Console.x86/NSwag.Console.x86.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<PropertyGroup>
<TargetFramework>net461</TargetFramework>
<Description>NSwag: The OpenAPI/Swagger API toolchain for .NET and TypeScript</Description>
<Version>13.11.2</Version>
<Version>13.11.3</Version>
<PackageTags>OpenAPI Swagger AspNetCore Documentation CodeGen TypeScript WebApi AspNet</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.Console/NSwag.Console.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<PropertyGroup>
<TargetFramework>net461</TargetFramework>
<Description>NSwag: The OpenAPI/Swagger API toolchain for .NET and TypeScript</Description>
<Version>13.11.2</Version>
<Version>13.11.3</Version>
<PackageTags>OpenAPI Swagger AspNetCore Documentation CodeGen TypeScript WebApi AspNet</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.ConsoleCore/NSwag.ConsoleCore.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<TargetFrameworks>netcoreapp2.1;netcoreapp3.1;net5.0</TargetFrameworks>
<OutputType>Exe</OutputType>
<Description>NSwag: The OpenAPI/Swagger API toolchain for .NET and TypeScript</Description>
<Version>13.11.2</Version>
<Version>13.11.3</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.Core.Yaml/NSwag.Core.Yaml.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<PropertyGroup>
<TargetFrameworks>netstandard1.3;net45;netstandard2.0</TargetFrameworks>
<Description>NSwag: The OpenAPI/Swagger API toolchain for .NET and TypeScript</Description>
<Version>13.11.2</Version>
<Version>13.11.3</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.Core/NSwag.Core.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.11.2</Version>
<Version>13.11.3</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.Core/OpenApiParameter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ public override string Description
[JsonProperty(PropertyName = "collectionFormat", DefaultValueHandling = DefaultValueHandling.Ignore)]
public OpenApiParameterCollectionFormat CollectionFormat { get; set; }

/// <summary>Gets or sets the headers (OpenAPI only).</summary>
/// <summary>Gets or sets the examples (OpenAPI only).</summary>
[JsonProperty(PropertyName = "examples", DefaultValueHandling = DefaultValueHandling.Ignore)]
public IDictionary<string, OpenApiExample> Examples
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ public ActionResult GetList([FromQuery]GetListCommand getListCommand)

public class GetListCommand
{
/// <example>42</example>
/// <summary>Bar.</summary>
public int? Required01 { get; set; }

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System.Linq;
using System.Threading.Tasks;
using Newtonsoft.Json.Linq;
using NSwag.Generation.AspNetCore.Tests.Web.Controllers.Parameters;
using Xunit;

Expand All @@ -24,7 +25,10 @@ public async Task When_complex_query_parameters_are_nullable_and_set_to_null_the
Assert.True(operation.ActualParameters.Last().IsRequired);

Assert.Equal(2, operation.ActualParameters.Count);

Assert.Equal("Bar.", operation.ActualParameters.First().Description);
Assert.Equal(JToken.Parse("42"), operation.ActualParameters.First().Example);

Assert.Equal("Baz.", operation.ActualParameters.Last().Description);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<PropertyGroup>
<TargetFrameworks>netstandard1.6;net451;netstandard2.0;netcoreapp3.1;net5.0</TargetFrameworks>
<Description>NSwag: The OpenAPI/Swagger API toolchain for .NET and TypeScript</Description>
<Version>13.11.2</Version>
<Version>13.11.3</Version>
<PackageTags>Swagger Documentation AspNetCore</PackageTags>
<Copyright>Copyright © Rico Suter, 2020</Copyright>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -437,20 +437,28 @@ private OpenApiParameter CreatePrimitiveParameter(
OperationProcessorContext context,
ExtendedApiParameterDescription extendedApiParameter)
{
var contextualParameter = extendedApiParameter.ParameterType.ToContextualType(extendedApiParameter.Attributes);
var contextualParameterType = extendedApiParameter.ParameterType
.ToContextualType(extendedApiParameter.Attributes);

var description = extendedApiParameter.GetDocumentation();
var operationParameter = context.DocumentGenerator.CreatePrimitiveParameter(
extendedApiParameter.ApiParameter.Name, description, contextualParameter);
extendedApiParameter.ApiParameter.Name, description, contextualParameterType);

var exampleValue = extendedApiParameter.PropertyInfo != null ?
context.SchemaGenerator.GenerateExample(extendedApiParameter.PropertyInfo.ToContextualMember()) : null;

var hasExampleValue = exampleValue != null;
var hasDefaultValue = extendedApiParameter.ParameterInfo?.HasDefaultValue == true;

if (extendedApiParameter.ParameterInfo?.HasDefaultValue == true)
if (hasExampleValue || hasDefaultValue)
{
var defaultValue = context.SchemaGenerator
.ConvertDefaultValue(contextualParameter, extendedApiParameter.ParameterInfo.DefaultValue);
var defaultValue = hasDefaultValue ? context.SchemaGenerator
.ConvertDefaultValue(contextualParameterType, extendedApiParameter.ParameterInfo.DefaultValue) : null;

if (_settings.SchemaType == SchemaType.Swagger2)
{
operationParameter.Default = defaultValue;
operationParameter.Example = exampleValue;
}
else if (operationParameter.Schema.HasReference)
{
Expand All @@ -459,6 +467,7 @@ private OpenApiParameter CreatePrimitiveParameter(
operationParameter.Schema = new JsonSchema
{
Default = defaultValue,
Example = exampleValue,
Reference = operationParameter.Schema,
};
}
Expand All @@ -467,13 +476,15 @@ private OpenApiParameter CreatePrimitiveParameter(
operationParameter.Schema = new JsonSchema
{
Default = defaultValue,
Example = exampleValue,
OneOf = { operationParameter.Schema },
};
}
}
else
{
operationParameter.Schema.Default = defaultValue;
operationParameter.Schema.Example = exampleValue;
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/NSwag.Generation.WebApi/NSwag.Generation.WebApi.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.11.2</Version>
<Version>13.11.3</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.Generation/NSwag.Generation.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.11.2</Version>
<Version>13.11.3</Version>
<PackageTags>OpenAPI Swagger AspNetCore Documentation CodeGen TypeScript WebApi AspNet</PackageTags>
<Copyright>Copyright © Rico Suter, 2020</Copyright>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
Expand Down
Loading

0 comments on commit 1c50bfb

Please sign in to comment.