Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add multi-file output to NSwagStudio #4472

Open
wants to merge 44 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
5b8b9da
Initial update from .NET 4.6.1 to .NET 4.6.2, as well as removal of r…
geckogeckogecko Oct 30, 2022
c19537d
Continued fixing effects of updating to v4.6.2
geckogeckogecko Oct 30, 2022
31cdeaf
Finished updating to .NET 4.6.2
geckogeckogecko Oct 30, 2022
a1098b1
Started creating GenerateFiles methods
geckogeckogecko Oct 30, 2022
79e2e20
Finished GenerateFiles method.
geckogeckogecko Oct 30, 2022
6fb293c
Made GenerateFiles less complicated by splitting parts of it into int…
geckogeckogecko Oct 30, 2022
ba6279f
Fixes to upgrades
Nov 2, 2022
3294f46
Added functionality to GenerateFiles(), changed output of GenerateCli…
geckogeckogecko Nov 5, 2022
d39931d
Added unit tests for GenerateClientFiles and GenerateDTOFiles methods
geckogeckogecko Nov 5, 2022
9bac675
Added additional unit tests for GenerateClientFiles and GenerateDTOFi…
geckogeckogecko Nov 5, 2022
7fc48c4
Added missing XML comments. Added new enum GenerationStyle to CSharpC…
geckogeckogecko Nov 6, 2022
3cbeae4
Began adding option to generate multiple files to NSwagStudio project
geckogeckogecko Nov 6, 2022
41e7166
Added new dropdown to the SwaggerToCSharpClientGeneratorView
geckogeckogecko Nov 6, 2022
72572db
Added functionality to GenerationStyle dropdown.
geckogeckogecko Nov 6, 2022
bdc2de8
Correction to copy/paste bug in XML comment
Nov 8, 2022
ad3496d
Changed CodeGenerationArtifact to expose more information from the ar…
Nov 8, 2022
8d602e9
Merge branch 'net462update' into newGenerateFilesMethod
geckogeckogecko Nov 12, 2022
79ef7e7
Added abstract method for getting file names from a code artifact, an…
geckogeckogecko Nov 12, 2022
927435f
Began fixing error where multi-file generation does not work.
geckogeckogecko Nov 12, 2022
ce893c3
Continued process of making GenerateFiles work in NSwagStudio
geckogeckogecko Nov 13, 2022
46195a7
Altered the default Output panel's visibility to be hidden when the g…
geckogeckogecko Nov 13, 2022
4863e56
Started attempting to implement a directory picker dialog
geckogeckogecko Nov 13, 2022
f584e59
Fixed usings issues in MainWindowModel, got NSwagStudio running and w…
geckogeckogecko Nov 19, 2022
18a69c1
Finished implementing multi-file generation in NSwagStudio. OneFilePe…
geckogeckogecko Nov 19, 2022
0ec16f8
Added missing call to GetOutputFileName to GenerateDTOTypes, NSwagStu…
geckogeckogecko Nov 19, 2022
0a8c7c1
Interfaces now generate in a seperate sub-folder, and are preceded wi…
geckogeckogecko Nov 20, 2022
e30a1f1
Implemented attempt to sort generated files into subfolders based on …
geckogeckogecko Nov 20, 2022
1a831c3
Added seperation of generated Exception files into their own subfolder.
geckogeckogecko Nov 20, 2022
b9f0edf
Based decision on type using enum for that purpose
TheCakeMonster Nov 23, 2022
adc72ea
Move our multi-file implementation eariler, so that it does not get b…
TheCakeMonster Nov 23, 2022
dd43057
Exception folder is created manually; no need to do this here
TheCakeMonster Nov 23, 2022
1353da7
Fixed interface generation so generated interfaces now actually has t…
Nov 26, 2022
e7ee92a
Fixed incorrect GenerationStyle description
Dec 22, 2022
a1ea0ba
Began implementing folder save dialog
Dec 30, 2022
6547dd7
Folder picker now works
geckogeckogecko Dec 30, 2022
147a9a4
Folder picker only appears when OneFilePerTyper is selected.
geckogeckogecko Dec 30, 2022
3328ab9
Added temporary text box to make sure that folder file path is actual…
geckogeckogecko Dec 30, 2022
a441ccb
Fix build failure caused by whitespace
TheCakeMonster Jan 4, 2023
2f802a0
Fixed bug where folder file path would not update
May 10, 2023
b1796a8
Removed duplicate filepath text box
May 10, 2023
977098c
Changed the UpdateSourceTrigger on all text inputs in CSharp Client v…
May 10, 2023
e7d2d1b
Added folder picker to template directory field
Jun 13, 2023
a5ef70d
Merge in updates from main repo since we created the fork
TheCakeMonster Jul 3, 2023
57a7386
Removed unused namespaces
TheCakeMonster Jul 3, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 4 additions & 30 deletions build/Build.cs
Original file line number Diff line number Diff line change
@@ -1,28 +1,3 @@
using System;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices;
using System.Xml.Linq;
using Microsoft.Build.Evaluation;
using Microsoft.Build.Locator;
using Nuke.Common;
using Nuke.Common.Git;
using Nuke.Common.IO;
using Nuke.Common.ProjectModel;
using Nuke.Common.Tooling;
using Nuke.Common.Tools.DotNet;
using Nuke.Common.Tools.MSBuild;
using Nuke.Common.Tools.Npm;
using Nuke.Common.Tools.VSTest;
using Nuke.Common.Utilities.Collections;

using static Nuke.Common.IO.FileSystemTasks;
using static Nuke.Common.Tooling.ProcessTasks;
using static Nuke.Common.Tools.Chocolatey.ChocolateyTasks;
using static Nuke.Common.Tools.DotNet.DotNetTasks;
using static Nuke.Common.Tools.MSBuild.MSBuildTasks;
using static Nuke.Common.Tools.Npm.NpmTasks;
using static Nuke.Common.Tools.VSTest.VSTestTasks;
using Project = Nuke.Common.ProjectModel.Project;

partial class Build : NukeBuild
Expand Down Expand Up @@ -103,7 +78,7 @@ protected override void OnBuildInitialized()
Serilog.Log.Information("BUILD SETUP");
Serilog.Log.Information("Configuration:\t{Configuration}", Configuration);
Serilog.Log.Information("Version prefix:\t{VersionPrefix}", VersionPrefix);
Serilog.Log.Information("Version suffix:\t{VersionSuffix}",VersionSuffix);
Serilog.Log.Information("Version suffix:\t{VersionSuffix}", VersionSuffix);
Serilog.Log.Information("Tagged build:\t{IsTaggedBuild}", IsTaggedBuild);
}

Expand Down Expand Up @@ -352,9 +327,9 @@ void PublishConsoleProject(Nuke.Common.ProjectModel.Project project, string[] ta
}
}

PublishConsoleProject(consoleX86Project, new[] { "net461" });
PublishConsoleProject(consoleProject, new[] { "net461" });
PublishConsoleProject(consoleCoreProject, new[] { "netcoreapp2.1", "netcoreapp3.1", "net5.0", "net6.0", "net7.0" });
PublishConsoleProject(consoleX86Project, new[] { "net462" });
PublishConsoleProject(consoleProject, new[] { "net462" });
PublishConsoleProject(consoleCoreProject, new[] { "netcoreapp3.1", "net5.0", "net6.0", "net7.0" });

void CopyConsoleBinaries(AbsolutePath target)
{
Expand All @@ -366,7 +341,6 @@ void CopyConsoleBinaries(AbsolutePath target)
CopyDirectoryRecursively(consoleProject.Directory / "bin" / Configuration / "net461" / "publish", target / "Win", DirectoryExistsPolicy.Merge);

var consoleCoreDirectory = consoleCoreProject.Directory / "bin" / Configuration;
CopyDirectoryRecursively(consoleCoreDirectory / "netcoreapp2.1" / "publish", target / "NetCore21");
CopyDirectoryRecursively(consoleCoreDirectory / "netcoreapp3.1" / "publish", target / "NetCore31");
CopyDirectoryRecursively(consoleCoreDirectory / "net5.0" / "publish", target / "Net50");
CopyDirectoryRecursively(consoleCoreDirectory / "net6.0" / "publish", target / "Net60");
Expand Down
4 changes: 2 additions & 2 deletions src/NSwag.Annotations/NSwag.Annotations.csproj
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>netstandard1.0;net45;netstandard2.0</TargetFrameworks>
<TargetFrameworks>netstandard1.0;net462;netstandard2.0</TargetFrameworks>
</PropertyGroup>
<PropertyGroup>
<DocumentationFile>bin\$(Configuration)\$(TargetFramework)\$(AssemblyName).xml</DocumentationFile>
</PropertyGroup>
<ItemGroup Condition="'$(TargetFramework)' == 'net45'">
<ItemGroup Condition="'$(TargetFramework)' == 'net462'">
<Reference Include="Microsoft.CSharp" />
</ItemGroup>
</Project>
10 changes: 5 additions & 5 deletions src/NSwag.AspNet.Owin/NSwag.AspNet.Owin.csproj
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net45</TargetFramework>
<TargetFramework>net462</TargetFramework>
</PropertyGroup>
<PropertyGroup>
<DocumentationFile>bin\$(Configuration)\$(TargetFramework)\$(AssemblyName).xml</DocumentationFile>
Expand All @@ -17,11 +17,11 @@
<EmbeddedResource Include="SwaggerUi3\swagger-ui.css" />
<EmbeddedResource Include="SwaggerUi3\swagger-ui.js" />
</ItemGroup>
<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Debug|net45|AnyCPU'">
<DefineConstants>TRACE;DEBUG;AspNetOwin;NET45</DefineConstants>
<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Debug|net462|AnyCPU'">
<DefineConstants>TRACE;DEBUG;AspNetOwin;NET462</DefineConstants>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Release|net45|AnyCPU'">
<DefineConstants>TRACE;RELEASE;AspNetOwin;NET45</DefineConstants>
<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Release|net462|AnyCPU'">
<DefineConstants>TRACE;RELEASE;AspNetOwin;NET462</DefineConstants>
</PropertyGroup>
<ItemGroup>
<Compile Include="..\NSwag.AspNetCore\HttpRequestExtension.cs" Link="HttpRequestExtension.cs" />
Expand Down
6 changes: 3 additions & 3 deletions src/NSwag.AspNet.WebApi/NSwag.AspNet.WebApi.csproj
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net45</TargetFramework>
<TargetFramework>net462</TargetFramework>
</PropertyGroup>
<PropertyGroup>
<DocumentationFile>bin\$(Configuration)\$(TargetFramework)\$(AssemblyName).xml</DocumentationFile>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Debug|net45|AnyCPU'">
<DefineConstants>TRACE;DEBUG;NET45</DefineConstants>
<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Debug|net462|AnyCPU'">
<DefineConstants>TRACE;DEBUG;NET462</DefineConstants>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.AspNet.WebApi.Core" Version="5.2.3" />
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net461</TargetFramework>
<TargetFramework>net462</TargetFramework>
<PlatformTarget>x86</PlatformTarget>
<OutputType>Exe</OutputType>
<IsPackable>false</IsPackable>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>netcoreapp3.1;net461</TargetFrameworks>
<PlatformTarget Condition="'$(TargetFramework)'=='net461'">x64</PlatformTarget>
<TargetFrameworks>netcoreapp3.1;net462</TargetFrameworks>
<PlatformTarget Condition="'$(TargetFramework)'=='net462'">x64</PlatformTarget>
<OutputType>Exe</OutputType>
<IsPackable>false</IsPackable>
</PropertyGroup>
Expand Down
10 changes: 3 additions & 7 deletions src/NSwag.AspNetCore/NSwag.AspNetCore.csproj
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>net461;netstandard1.6;netstandard2.0;netcoreapp3.1;net5.0;net6.0;net7.0</TargetFrameworks>
<TargetFrameworks>net462;netstandard1.6;netstandard2.0;net6.0;net7.0</TargetFrameworks>
<PackageTags>Swagger Documentation AspNetCore NetCore TypeScript CodeGen</PackageTags>
<NuspecFile>$(MSBuildProjectName).nuspec</NuspecFile>
<SymbolPackageFormat>symbols.nupkg</SymbolPackageFormat>
Expand Down Expand Up @@ -30,7 +30,7 @@
<EmbeddedResource Include="SwaggerUi\**\*" Exclude="bin\**;obj\**;**\*.xproj;packages\**;@(EmbeddedResource)" />
<EmbeddedResource Include="SwaggerUi3\**\*" Exclude="bin\**;obj\**;**\*.xproj;packages\**;@(EmbeddedResource)" />
</ItemGroup>
<ItemGroup Condition=" '$(TargetFramework)' == 'net461' OR '$(TargetFramework)' == 'netstandard1.6' OR '$(TargetFramework)' == 'netstandard2.0' ">
<ItemGroup Condition=" '$(TargetFramework)' == 'net462' OR '$(TargetFramework)' == 'netstandard1.6' OR '$(TargetFramework)' == 'netstandard2.0' ">
<PackageReference Include="Microsoft.Extensions.FileProviders.Embedded" Version="$(MicrosoftExtensionsFileProvidersEmbeddedPackageVersion)" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.Core" Version="$(MicrosoftAspNetCoreMvcCorePackageVersion)" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.Formatters.Json" Version="$(MicrosoftAspNetCoreMvcFormattersJsonPackageVersion)" />
Expand All @@ -40,17 +40,13 @@
<PackageReference Include="System.IO.FileSystem" Version="$(SystemIOFileSystemPackageVersion)" />
<PackageReference Include="System.Xml.XPath.XDocument" Version="$(SystemXmlXPathXDocumentPackageVersion)" />
</ItemGroup>
<ItemGroup Condition=" '$(TargetFramework)' == 'net461' ">
<ItemGroup Condition=" '$(TargetFramework)' == 'net462' ">
<Reference Include="Microsoft.CSharp" />
</ItemGroup>
<ItemGroup Condition=" '$(TargetFramework)' == 'netcoreapp3.1' ">
<FrameworkReference Include="Microsoft.AspNetCore.App" />
<PackageReference Include="Microsoft.Extensions.FileProviders.Embedded" Version="$(MicrosoftExtensionsFileProvidersEmbeddedPackageVersionCore31)" />
</ItemGroup>
<ItemGroup Condition=" '$(TargetFramework)' == 'net5.0' ">
<FrameworkReference Include="Microsoft.AspNetCore.App" />
<PackageReference Include="Microsoft.Extensions.FileProviders.Embedded" Version="$(MicrosoftExtensionsFileProvidersEmbeddedPackageVersionNet5)" />
</ItemGroup>
<ItemGroup Condition=" '$(TargetFramework)' == 'net6.0' ">
<FrameworkReference Include="Microsoft.AspNetCore.App" />
<PackageReference Include="Microsoft.Extensions.FileProviders.Embedded" Version="$(MicrosoftExtensionsFileProvidersEmbeddedPackageVersionNet6)" />
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>netcoreapp2.1;net461</TargetFrameworks>
<TargetFrameworks>net462;net6.0</TargetFrameworks>
<IsPackable>false</IsPackable>
</PropertyGroup>
<ItemGroup>
Expand Down
6 changes: 3 additions & 3 deletions src/NSwag.AssemblyLoader/AppDomainIsolation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ namespace NSwag.AssemblyLoader
public sealed class AppDomainIsolation<T> : IDisposable where T : AssemblyLoader
{
/// <exception cref="ArgumentNullException"><paramref name="assemblyDirectory"/> is <see langword="null" />.</exception>
public AppDomainIsolation(string assemblyDirectory, string assemblyConfiguration, IEnumerable<BindingRedirect> bindingRedirects, IEnumerable<string> preloadedAssemblies)
public AppDomainIsolation(string assemblyDirectory, string assemblyConfiguration, IEnumerable<BindingRedirect> bindingRedirects, IEnumerable<Assembly> preloadedAssemblies)
{
if (string.IsNullOrEmpty(assemblyDirectory))
{
Expand All @@ -40,7 +40,7 @@ public AppDomainIsolation(string assemblyDirectory, string assemblyConfiguration

foreach (var pa in preloadedAssemblies)
{
Domain.Load(new AssemblyName { CodeBase = pa });
Domain.Load(new AssemblyName { CodeBase = pa.EscapedCodeBase });
}

var type = typeof(T);
Expand Down Expand Up @@ -70,7 +70,7 @@ public void Dispose()

#else

public sealed class AppDomainIsolation<T> : IDisposable where T : AssemblyLoader, new()
public sealed class AppDomainIsolation<T> : IDisposable where T : AssemblyLoader, new()
{
/// <exception cref="ArgumentNullException"><paramref name="assemblyDirectory"/> is <see langword="null" />.</exception>
public AppDomainIsolation(string assemblyDirectory, string assemblyConfiguration, IEnumerable<BindingRedirect> bindingRedirects, IEnumerable<Assembly> preloadedAssemblies)
Expand Down
2 changes: 1 addition & 1 deletion src/NSwag.AssemblyLoader/NSwag.AssemblyLoader.csproj
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>netstandard1.6;net461;netstandard2.0</TargetFrameworks>
<TargetFrameworks>netstandard1.6;net462;netstandard2.0</TargetFrameworks>
<!-- Missing XML comments -->
<NoWarn>$(NoWarn),1591</NoWarn>
<DocumentationFile>bin\$(Configuration)\$(TargetFramework)\$(AssemblyName).xml</DocumentationFile>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
#if NETFRAMEWORK
using System.Web.Mvc;
using System.Web.Http;
#else
using Microsoft.AspNetCore.Mvc;
#endif
using NSwag.CodeGeneration.OperationNameGenerators;
using NSwag.Generation.WebApi;
using System.ComponentModel.DataAnnotations;
Expand Down Expand Up @@ -102,13 +107,13 @@ private static async Task<CSharpClientGenerator> GenerateCode(bool allowNullable

public class TestController : Controller
{
[Route("Foo")]
[Microsoft.AspNetCore.Mvc.Route("Foo")]
public string Foo([FromBody][Required] T requiredBody)
{
return string.Empty;
}

[Route("Bar")]
[Microsoft.AspNetCore.Mvc.Route("Bar")]
public void Bar([FromBody] T notRequiredBody)
{
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
using System.Threading.Tasks;
#if NETFRAMEWORK
using System.Web.Mvc;
#else
using Microsoft.AspNetCore.Mvc;
#endif
using System.Threading.Tasks;
using NSwag.Generation.WebApi;
using Xunit;

Expand Down
10 changes: 7 additions & 3 deletions src/NSwag.CodeGeneration.CSharp.Tests/FileDownloadTests.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
using System;
#if NETFRAMEWORK
using System.Web.Mvc;
#else
using Microsoft.AspNetCore.Mvc;
#endif
using System;
using System.Net.Http;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using NSwag.Generation.WebApi;
using Xunit;

Expand All @@ -11,7 +15,7 @@ public class FileDownloadTests
{
public class FileDownloadController : Controller
{
[Route("DownloadFile")]
[Microsoft.AspNetCore.Mvc.Route("DownloadFile")]
public HttpResponseMessage DownloadFile()
{
throw new NotImplementedException();
Expand Down
10 changes: 7 additions & 3 deletions src/NSwag.CodeGeneration.CSharp.Tests/FileTests.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
using System;
#if NETFRAMEWORK
using System.Web.Mvc;
#else
using Microsoft.AspNetCore.Mvc;
#endif
using System;
using System.Net.Http;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using NSwag.Generation.WebApi;
using Xunit;

Expand All @@ -11,7 +15,7 @@ public class FileTests
{
public class FileDownloadController : Controller
{
[Route("DownloadFile")]
[Microsoft.AspNetCore.Mvc.Route("DownloadFile")]
public HttpResponseMessage DownloadFile()
{
throw new NotImplementedException();
Expand Down
7 changes: 6 additions & 1 deletion src/NSwag.CodeGeneration.CSharp.Tests/FormParameterTests.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
using System.Threading.Tasks;
#if NETFRAMEWORK
using System.Web.Mvc;
using System.Web.Http;
#else
using Microsoft.AspNetCore.Mvc;
#endif
using System.Threading.Tasks;
using NJsonSchema;
using NSwag.Generation.WebApi;
using Xunit;
Expand Down
6 changes: 5 additions & 1 deletion src/NSwag.CodeGeneration.CSharp.Tests/HeadRequestTests.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
using System.Threading.Tasks;
#if NETFRAMEWORK
using System.Web.Mvc;
#else
using Microsoft.AspNetCore.Mvc;
#endif
using System.Threading.Tasks;
using NSwag.Generation.WebApi;
using Xunit;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netcoreapp2.1</TargetFramework>
<TargetFrameworks>net462;net6.0</TargetFrameworks>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.App" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.0.0" />
<PackageReference Include="xunit" Version="2.4.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.3" />
<PackageReference Include="System.ComponentModel.Annotations" Version="6.0.0-preview.4.21253.7" />
<PackageReference Include="Microsoft.AspNet.Mvc" Version="5.2.3" />
</ItemGroup>

<ItemGroup>
Expand All @@ -16,4 +17,11 @@
<ProjectReference Include="..\NSwag.Generation.WebApi\NSwag.Generation.WebApi.csproj" />
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)' != 'net462'">
<FrameworkReference Include="Microsoft.AspNetCore.App" />
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'net462'">
<ProjectReference Include="..\NSwag.Generation.WebApi.Tests\NSwag.Generation.WebApi.Tests.csproj" />
</ItemGroup>
</Project>
14 changes: 9 additions & 5 deletions src/NSwag.CodeGeneration.CSharp.Tests/OptionalParameterTests.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
using System;
#if NETFRAMEWORK
using System.Web.Mvc;
#else
using Microsoft.AspNetCore.Mvc;
#endif
using System;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using NSwag.Generation.WebApi;
using Xunit;

Expand All @@ -11,17 +15,17 @@ public class OptionalParameterTests
{
public class TestController : Controller
{
[Route("Test")]
[Microsoft.AspNetCore.Mvc.Route("Test")]
public void Test(string a, string b, string c = null)
{
}

[Route("TestWithClass")]
[Microsoft.AspNetCore.Mvc.Route("TestWithClass")]
public void TestWithClass([FromUri] MyClass objet)
{
}

[Route("TestWithEnum")]
[Microsoft.AspNetCore.Mvc.Route("TestWithEnum")]
public void TestWithEnum([FromUri] MyEnum? myEnum = null)
{
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"profiles": {
"NSwag.CodeGeneration.CSharp.Tests": {
"commandName": "Project",
"launchBrowser": true,
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
},
"applicationUrl": "http://localhost:52040"
}
}
}
Loading