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

.Net core 3.1 #2567

Merged
merged 3 commits into from Dec 16, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -3,7 +3,7 @@
<PropertyGroup>
<_NSwagCommand>$(NSwagExe)</_NSwagCommand>
<_NSwagCommand
Condition="'$(MSBuildRuntimeType)' == 'Core'">dotnet --roll-forward-on-no-candidate-fx 2 $(NSwagDir_Core21)/dotnet-nswag.dll</_NSwagCommand>
Condition="'$(MSBuildRuntimeType)' == 'Core'">dotnet --roll-forward-on-no-candidate-fx 2 $(NSwagDir_Core31)/dotnet-nswag.dll</_NSwagCommand>
RicoSuter marked this conversation as resolved.
Show resolved Hide resolved
</PropertyGroup>

<!-- OpenApiReference support for C# -->
Expand Down
4 changes: 4 additions & 0 deletions src/NSwag.Commands/NSwagDocument.cs
Expand Up @@ -328,6 +328,10 @@ private string GetArgumentsPrefix()
{
return "\"" + System.IO.Path.Combine(RootBinaryDirectory, "NetCore30/dotnet-nswag.dll") + "\" ";
}
else if (runtime == Runtime.NetCore31)
{
return "\"" + System.IO.Path.Combine(RootBinaryDirectory, "NetCore31/dotnet-nswag.dll") + "\" ";
}
else
#endif
return "";
Expand Down
3 changes: 3 additions & 0 deletions src/NSwag.Commands/Runtime.cs
Expand Up @@ -38,6 +38,9 @@ public enum Runtime
/// <summary>.NET Core 3.0 app.</summary>
NetCore30,

/// <summary>.NET Core 3.1 app.</summary>
NetCore31,

/// <summary>Execute in the same proces.</summary>
Debug
}
Expand Down
6 changes: 5 additions & 1 deletion src/NSwag.Commands/RuntimeUtilities.cs
Expand Up @@ -37,10 +37,14 @@ public static Runtime CurrentRuntime
{
return Runtime.NetCore22;
}
else if (framework.Version.Major >= 3)
else if (framework.Version.Major >= 3 && framework.Version.Minor < 1)
{
return Runtime.NetCore30;
}
else if (framework.Version.Major >= 3 && framework.Version.Minor >= 1)
{
return Runtime.NetCore31;
}
else if (framework.Version.Major == 1 && framework.Version.Minor == 1)
{
return Runtime.NetCore11;
Expand Down
7 changes: 6 additions & 1 deletion src/NSwag.ConsoleCore/NSwag.ConsoleCore.csproj
@@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>netcoreapp1.0;netcoreapp1.1;netcoreapp2.0;netcoreapp2.1;netcoreapp2.2;netcoreapp3.0</TargetFrameworks>
<TargetFrameworks>netcoreapp1.0;netcoreapp1.1;netcoreapp2.0;netcoreapp2.1;netcoreapp2.2;netcoreapp3.0;netcoreapp3.1</TargetFrameworks>
<OutputType>Exe</OutputType>
<Description>NSwag: The OpenAPI/Swagger API toolchain for .NET and TypeScript</Description>
<Version>13.1.6</Version>
Expand Down Expand Up @@ -48,6 +48,11 @@
<PackageReference Include="Microsoft.Extensions.DependencyModel" Version="3.0.0" />
<PackageReference Include="Microsoft.AspNetCore.TestHost" Version="3.0.0" />
</ItemGroup>
<ItemGroup Condition="'$(TargetFramework)' == 'netcoreapp3.1'">
<PackageReference Include="Newtonsoft.Json" Version="12.0.2" />
<PackageReference Include="Microsoft.Extensions.DependencyModel" Version="3.1.0" />
<PackageReference Include="Microsoft.AspNetCore.TestHost" Version="3.0.0" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="NConsole" Version="3.9.6519.30868" />
Expand Down
1 change: 1 addition & 0 deletions src/NSwag.MSBuild/NSwag.MSBuild.nuspec
Expand Up @@ -33,5 +33,6 @@
<file src="..\NSwag.ConsoleCore\bin\release\netcoreapp2.1\Publish\**" target="tools/NetCore21" />
<file src="..\NSwag.ConsoleCore\bin\release\netcoreapp2.2\Publish\**" target="tools/NetCore22" />
<file src="..\NSwag.ConsoleCore\bin\release\netcoreapp3.0\Publish\**" target="tools/NetCore30" />
<file src="..\NSwag.ConsoleCore\bin\release\netcoreapp3.1\Publish\**" target="tools/NetCore31" />
</files>
</package>
5 changes: 4 additions & 1 deletion src/NSwag.MSBuild/NSwag.MSBuild.props
Expand Up @@ -9,12 +9,15 @@
<NSwagExe_Core21>dotnet "$(MSBuildThisFileDirectory)../tools/NetCore21/dotnet-nswag.dll"</NSwagExe_Core21>
<NSwagExe_Core22>dotnet "$(MSBuildThisFileDirectory)../tools/NetCore22/dotnet-nswag.dll"</NSwagExe_Core22>
<NSwagExe_Core30>dotnet "$(MSBuildThisFileDirectory)../tools/NetCore30/dotnet-nswag.dll"</NSwagExe_Core30>
<NSwagExe_Core31>dotnet "$(MSBuildThisFileDirectory)../tools/NetCore31/dotnet-nswag.dll"</NSwagExe_Core31>

<NSwagDir>$(MSBuildThisFileDirectory)../tools/Win/</NSwagDir>
<NSwagDir_Core10>$(MSBuildThisFileDirectory)../tools/NetCore10/</NSwagDir_Core10>
<NSwagDir_Core11>$(MSBuildThisFileDirectory)../tools/NetCore11/</NSwagDir_Core11>
<NSwagDir_Core20>$(MSBuildThisFileDirectory)../tools/NetCore20/</NSwagDir_Core20>
<NSwagDir_Core21>$(MSBuildThisFileDirectory)../tools/NetCore21/</NSwagDir_Core21>
<NSwagDir_Core22>$(MSBuildThisFileDirectory)../tools/NetCore30/</NSwagDir_Core22>
<NSwagDir_Core22>$(MSBuildThisFileDirectory)../tools/NetCore22/</NSwagDir_Core22>
<NSwagDir_Core30>$(MSBuildThisFileDirectory)../tools/NetCore30/</NSwagDir_Core30>
<NSwagDir_Core31>$(MSBuildThisFileDirectory)../tools/NetCore31/</NSwagDir_Core31>
</PropertyGroup>
</Project>
Binary file modified src/NSwag.MSBuild/NuGet.exe
Binary file not shown.
4 changes: 4 additions & 0 deletions src/NSwag.Npm/README.md
Expand Up @@ -61,6 +61,10 @@ or

nswag run version /runtime:NetCore30

or

nswag run version /runtime:NetCore31

## Development

Run the following command to compile and copy the current NSwag console binaries into the NPM module directory `binaries` directory:
Expand Down
3 changes: 2 additions & 1 deletion src/NSwag.Npm/bin/nswag.js
Expand Up @@ -2,7 +2,7 @@
"use strict";

var defaultCoreVersion = "21";
var supportedCoreVersions = ["10", "11", "20", "21", "22", "30"];
var supportedCoreVersions = ["10", "11", "20", "21", "22", "30", "31"];

// Initialize
process.title = 'nswag';
Expand All @@ -18,6 +18,7 @@ args = args.replace("--core 2.0", "/runtime:NetCore20");
args = args.replace("--core 2.1", "/runtime:NetCore21");
args = args.replace("--core 2.2", "/runtime:NetCore22");
args = args.replace("--core 3.0", "/runtime:NetCore30");
args = args.replace("--core 3.1", "/runtime:NetCore31");
args = args.replace("--core", "/runtime:NetCore" + defaultCoreVersion);

// Search for full .NET installation
Expand Down
60 changes: 60 additions & 0 deletions src/NSwag.Sample.NETCore31/Controllers/ValuesController.cs
@@ -0,0 +1,60 @@
using System;
using System.Collections.Generic;
using Microsoft.AspNetCore.Mvc;

namespace NSwag.Sample.NETCore31.Controllers
{
[Route("api/[controller]")]
[ApiController]
public class ValuesController : ControllerBase
{
public class Person
{
public string FirstName { get; set; }

public string? MiddleName { get; set; }

public string LastName { get; set; }

public DateTime DayOfBirth { get; set; }
}

[HttpGet]
public ActionResult<IEnumerable<Person>> Get()
{
return new Person[] { };
}

// GET api/values/5
[HttpGet("{id}")]
public ActionResult<string> Get(int id)
{
return "value";
}

// GET api/values/5
[HttpGet("{id}/foo")]
public ActionResult<string> GetFooBar(int id)
{
return "value";
}

// POST api/values
[HttpPost]
public void Post([FromBody] string value)
{
}

// PUT api/values/5
[HttpPut("{id}")]
public void Put(int id, [FromBody] string value)
{
}

// DELETE api/values/5
[HttpDelete("{id}")]
public void Delete(int id)
{
}
}
}
9 changes: 9 additions & 0 deletions src/NSwag.Sample.NETCore31/NSwag.Sample.NETCore31.csproj
@@ -0,0 +1,9 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\NSwag.AspNetCore\NSwag.AspNetCore.csproj" />
</ItemGroup>
</Project>
20 changes: 20 additions & 0 deletions src/NSwag.Sample.NETCore31/Program.cs
@@ -0,0 +1,20 @@
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Hosting;

namespace NSwag.Sample.NETCore31
{
public class Program
{
public static void Main(string[] args)
{
CreateHostBuilder(args).Build().Run();
}

public static IHostBuilder CreateHostBuilder(string[] args) =>
Host.CreateDefaultBuilder(args)
.ConfigureWebHostDefaults(webBuilder =>
{
webBuilder.UseStartup<Startup>();
});
}
}
30 changes: 30 additions & 0 deletions src/NSwag.Sample.NETCore31/Properties/launchSettings.json
@@ -0,0 +1,30 @@
{
"iisSettings": {
"windowsAuthentication": false,
"anonymousAuthentication": true,
"iisExpress": {
"applicationUrl": "http://localhost:51340",
"sslPort": 44379
}
},
"$schema": "http://json.schemastore.org/launchsettings.json",
"profiles": {
"IIS Express": {
"commandName": "IISExpress",
"launchBrowser": true,
"launchUrl": "swagger",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"NSwag.Sample.NETCore31": {
"commandName": "Project",
"launchBrowser": true,
"launchUrl": "apiverse",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
},
"applicationUrl": "https://localhost:7001;http://localhost:7000"
}
}
}
55 changes: 55 additions & 0 deletions src/NSwag.Sample.NETCore31/Startup.cs
@@ -0,0 +1,55 @@
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using NJsonSchema.Generation;

namespace NSwag.Sample.NETCore31
{
public class Startup
{
public Startup(IConfiguration configuration)
{
Configuration = configuration;
}

public IConfiguration Configuration { get; }

public void ConfigureServices(IServiceCollection services)
{
services.AddMvc();

services.AddOpenApiDocument(document =>
{
document.Description = "Hello world!";
document.DefaultReferenceTypeNullHandling = ReferenceTypeNullHandling.NotNull;
});
}

public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
{
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
}

app.UseHttpsRedirection();
app.UseRouting();
app.UseAuthorization();
app.UseEndpoints(endpoints =>
{
endpoints.MapControllers();
});

app.UseOpenApi();
app.UseSwaggerUi3();
//app.UseApiverse();
app.UseApiverse(settings =>
{
//settings.CompareTo = "a:a:27:25:15:latest";
settings.ApiverseUrl = "https://localhost:5001";
});
}
}
}
9 changes: 9 additions & 0 deletions src/NSwag.Sample.NETCore31/appsettings.Development.json
@@ -0,0 +1,9 @@
{
"Logging": {
"LogLevel": {
"Default": "Debug",
"System": "Information",
"Microsoft": "Information"
}
}
}
9 changes: 9 additions & 0 deletions src/NSwag.Sample.NETCore31/appsettings.json
@@ -0,0 +1,9 @@
{
"Logging": {
"LogLevel": {
"Default": "Warning",
"Microsoft.Hosting.Lifetime": "Information"
}
},
"AllowedHosts": "*"
}
58 changes: 58 additions & 0 deletions src/NSwag.Sample.NETCore31/nswag.json
@@ -0,0 +1,58 @@
{
"runtime": "NetCore31",
"defaultVariables": null,
"documentGenerator": {
"aspNetCoreToOpenApi": {
"project": "NSwag.Sample.NETCore31.csproj",
"msBuildProjectExtensionsPath": null,
"configuration": null,
"runtime": null,
"targetFramework": null,
"noBuild": false,
"verbose": true,
"workingDirectory": null,
"requireParametersWithoutDefault": false,
"apiGroupNames": null,
"defaultPropertyNameHandling": "Default",
"defaultReferenceTypeNullHandling": "Null",
"defaultDictionaryValueReferenceTypeNullHandling": "NotNull",
"defaultResponseReferenceTypeNullHandling": "NotNull",
"defaultEnumHandling": "Integer",
"flattenInheritanceHierarchy": false,
"generateKnownTypes": true,
"generateEnumMappingDescription": false,
"generateXmlObjects": false,
"generateAbstractProperties": false,
"generateAbstractSchemas": true,
"ignoreObsoleteProperties": false,
"allowReferencesWithProperties": false,
"excludedTypeNames": [],
"serviceHost": null,
"serviceBasePath": null,
"serviceSchemes": [],
"infoTitle": "My Title",
"infoDescription": null,
"infoVersion": "1.0.0",
"documentTemplate": null,
"documentProcessorTypes": [],
"operationProcessorTypes": [],
"typeNameGeneratorType": null,
"schemaNameGeneratorType": null,
"contractResolverType": null,
"serializerSettingsType": null,
"useDocumentProvider": true,
"documentName": "v1",
"aspNetCoreEnvironment": null,
"createWebHostBuilderMethod": null,
"startupType": null,
"allowNullableBodyParameters": true,
"output": "openapi.json",
"outputType": "Swagger2",
"assemblyPaths": [],
"assemblyConfig": null,
"referencePaths": [],
"useNuGetCache": false
}
},
"codeGenerators": {}
}