From ae73bb755369c32e2ac5b385e273cbafc95f6df4 Mon Sep 17 00:00:00 2001 From: Jim Schubert Date: Tue, 5 Jul 2016 22:17:14 -0400 Subject: [PATCH] [aspnet5] Update to ASP.NET Core 1.0.0 This migrates the server generator for aspnet5 from 1.0.0-rc1-final to 1.0.0. Changes are fairly significant in how Kestrel hosts the application, as well as how Swagger finds XML comments for documentation. Changes are only related to hosting, docker, and configuration. --- bin/all-petstore.sh | 1 + .../languages/AspNet5ServerCodegen.java | 12 +- .../resources/aspnet5/Dockerfile.mustache | 10 +- .../src/main/resources/aspnet5/NuGet.Config | 9 ++ .../main/resources/aspnet5/Program.mustache | 32 +++++ .../resources/aspnet5/Project.xproj.mustache | 19 +++ .../aspnet5/Properties/launchSettings.json | 22 +++- .../main/resources/aspnet5/README.mustache | 27 ++++ .../main/resources/aspnet5/Solution.mustache | 32 +++++ .../main/resources/aspnet5/Startup.mustache | 115 +++++------------- .../main/resources/aspnet5/appsettings.json | 2 +- .../main/resources/aspnet5/build.bat.mustache | 20 +++ .../src/main/resources/aspnet5/build.mustache | 17 --- .../main/resources/aspnet5/build.sh.mustache | 19 +++ .../resources/aspnet5/controller.mustache | 3 +- .../src/main/resources/aspnet5/global.json | 7 +- .../src/main/resources/aspnet5/model.mustache | 1 + .../resources/aspnet5/partial_header.mustache | 25 ++++ .../resources/aspnet5/project.json.mustache | 88 ++++++++++++++ .../main/resources/aspnet5/project.mustache | 41 ------- .../src/main/resources/aspnet5/web.config | 14 +++ 21 files changed, 358 insertions(+), 158 deletions(-) create mode 100644 modules/swagger-codegen/src/main/resources/aspnet5/NuGet.Config create mode 100644 modules/swagger-codegen/src/main/resources/aspnet5/Program.mustache create mode 100644 modules/swagger-codegen/src/main/resources/aspnet5/Project.xproj.mustache create mode 100644 modules/swagger-codegen/src/main/resources/aspnet5/README.mustache create mode 100644 modules/swagger-codegen/src/main/resources/aspnet5/Solution.mustache create mode 100644 modules/swagger-codegen/src/main/resources/aspnet5/build.bat.mustache delete mode 100644 modules/swagger-codegen/src/main/resources/aspnet5/build.mustache create mode 100644 modules/swagger-codegen/src/main/resources/aspnet5/build.sh.mustache create mode 100644 modules/swagger-codegen/src/main/resources/aspnet5/partial_header.mustache create mode 100644 modules/swagger-codegen/src/main/resources/aspnet5/project.json.mustache delete mode 100644 modules/swagger-codegen/src/main/resources/aspnet5/project.mustache create mode 100644 modules/swagger-codegen/src/main/resources/aspnet5/web.config diff --git a/bin/all-petstore.sh b/bin/all-petstore.sh index 849af6b5d4a..e46d98eb559 100755 --- a/bin/all-petstore.sh +++ b/bin/all-petstore.sh @@ -20,6 +20,7 @@ fi cd $APP_DIR ./bin/akka-scala-petstore.sh ./bin/android-petstore.sh +./bin/aspnet5-petstore-server.sh ./bin/clojure-petstore.sh ./bin/csharp-petstore.sh ./bin/dynamic-html.sh diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/AspNet5ServerCodegen.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/AspNet5ServerCodegen.java index 099d049707b..8b73275984a 100644 --- a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/AspNet5ServerCodegen.java +++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/AspNet5ServerCodegen.java @@ -84,14 +84,22 @@ public class AspNet5ServerCodegen extends AbstractCSharpCodegen { apiPackage = packageName + ".Controllers"; modelPackage = packageName + ".Models"; + supportingFiles.add(new SupportingFile("NuGet.Config", "", "NuGet.Config")); supportingFiles.add(new SupportingFile("global.json", "", "global.json")); - supportingFiles.add(new SupportingFile("build.mustache", "", "build.sh")); + supportingFiles.add(new SupportingFile("build.sh.mustache", "", "build.sh")); + supportingFiles.add(new SupportingFile("build.bat.mustache", "", "build.bat")); + supportingFiles.add(new SupportingFile("README.mustache", "", "README.md")); + supportingFiles.add(new SupportingFile("Solution.mustache", "", this.packageName + ".sln")); supportingFiles.add(new SupportingFile("Dockerfile.mustache", this.sourceFolder, "Dockerfile")); supportingFiles.add(new SupportingFile("gitignore", this.sourceFolder, ".gitignore")); supportingFiles.add(new SupportingFile("appsettings.json", this.sourceFolder, "appsettings.json")); - supportingFiles.add(new SupportingFile("project.mustache", this.sourceFolder, "project.json")); + supportingFiles.add(new SupportingFile("project.json.mustache", this.sourceFolder, "project.json")); supportingFiles.add(new SupportingFile("Startup.mustache", this.sourceFolder, "Startup.cs")); + supportingFiles.add(new SupportingFile("Program.mustache", this.sourceFolder, "Program.cs")); + supportingFiles.add(new SupportingFile("web.config", this.sourceFolder, "web.config")); + + supportingFiles.add(new SupportingFile("Project.xproj.mustache", this.sourceFolder, this.packageName + ".xproj")); supportingFiles.add(new SupportingFile("Properties" + File.separator + "launchSettings.json", this.sourceFolder + File.separator + "Properties", "launchSettings.json")); diff --git a/modules/swagger-codegen/src/main/resources/aspnet5/Dockerfile.mustache b/modules/swagger-codegen/src/main/resources/aspnet5/Dockerfile.mustache index 8ff1b8faeed..0765ead2db2 100644 --- a/modules/swagger-codegen/src/main/resources/aspnet5/Dockerfile.mustache +++ b/modules/swagger-codegen/src/main/resources/aspnet5/Dockerfile.mustache @@ -1,10 +1,12 @@ -FROM microsoft/aspnet:1.0.0-rc1-final +FROM microsoft/dotnet:latest + +ENV DOTNET_CLI_TELEMETRY_OPTOUT 1 RUN mkdir -p /app/{{packageName}} COPY . /app/{{packageName}} WORKDIR /app/{{packageName}} -RUN ["dnu", "restore"] -RUN ["dnu", "pack", "--out", "artifacts"] EXPOSE 5000/tcp -ENTRYPOINT ["dnx", "-p", "project.json", "web"] + +RUN ["dotnet", "restore"] +ENTRYPOINT ["dotnet", "run", "-p", "project.json", "web"] diff --git a/modules/swagger-codegen/src/main/resources/aspnet5/NuGet.Config b/modules/swagger-codegen/src/main/resources/aspnet5/NuGet.Config new file mode 100644 index 00000000000..01f3d1f203f --- /dev/null +++ b/modules/swagger-codegen/src/main/resources/aspnet5/NuGet.Config @@ -0,0 +1,9 @@ + + + + + + + + + diff --git a/modules/swagger-codegen/src/main/resources/aspnet5/Program.mustache b/modules/swagger-codegen/src/main/resources/aspnet5/Program.mustache new file mode 100644 index 00000000000..ab465c42516 --- /dev/null +++ b/modules/swagger-codegen/src/main/resources/aspnet5/Program.mustache @@ -0,0 +1,32 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Threading.Tasks; +using Microsoft.AspNetCore.Hosting; +using Microsoft.AspNetCore.Builder; + +namespace {{packageName}} +{ + public class Program + { + public static void Main(string[] args) + { + var host = new WebHostBuilder() + .UseKestrel(options => + { + // options.ThreadCount = 4; + // options.UseHttps("cert.pfx", "certpassword"); + options.NoDelay = true; + options.UseConnectionLogging(); + }) + .UseUrls("http://+:5000" /*, "https://+:5001" */) + .UseContentRoot(Directory.GetCurrentDirectory()) + .UseIISIntegration() + .UseStartup() + .Build(); + + host.Run(); + } + } +} diff --git a/modules/swagger-codegen/src/main/resources/aspnet5/Project.xproj.mustache b/modules/swagger-codegen/src/main/resources/aspnet5/Project.xproj.mustache new file mode 100644 index 00000000000..22123b97009 --- /dev/null +++ b/modules/swagger-codegen/src/main/resources/aspnet5/Project.xproj.mustache @@ -0,0 +1,19 @@ + + + + 14.0 + $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) + + + + {{projectGuid}} + Sample + .\obj + .\bin\ + v4.6 + + + 2.0 + + + \ No newline at end of file diff --git a/modules/swagger-codegen/src/main/resources/aspnet5/Properties/launchSettings.json b/modules/swagger-codegen/src/main/resources/aspnet5/Properties/launchSettings.json index 7d41a0f84b9..45a5f3319a5 100644 --- a/modules/swagger-codegen/src/main/resources/aspnet5/Properties/launchSettings.json +++ b/modules/swagger-codegen/src/main/resources/aspnet5/Properties/launchSettings.json @@ -1,12 +1,28 @@ { + "iisSettings": { + "windowsAuthentication": false, + "anonymousAuthentication": true, + "iisExpress": { + "applicationUrl": "http://localhost:50352/", + "sslPort": 0 + } + }, "profiles": { "IIS Express": { "commandName": "IISExpress", "launchBrowser": true, - "launchUrl": "swagger/ui", + "launchUrl": "swagger/ui/index.html", "environmentVariables": { - "ASPNET_ENV": "Development" + "ASPNETCORE_ENVIRONMENT": "Development" + } + }, + "web": { + "commandName": "Project", + "launchBrowser": true, + "launchUrl": "http://localhost:5000/swagger/ui/index.html", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" } } } -} +} \ No newline at end of file diff --git a/modules/swagger-codegen/src/main/resources/aspnet5/README.mustache b/modules/swagger-codegen/src/main/resources/aspnet5/README.mustache new file mode 100644 index 00000000000..451508ad676 --- /dev/null +++ b/modules/swagger-codegen/src/main/resources/aspnet5/README.mustache @@ -0,0 +1,27 @@ +# {{packageName}} - ASP.NET Core 1.0 Server + +{{#appDescription}} +{{{appDescription}}} +{{/appDescription}} + +## Run + +Linux/OS X: + +``` +sh build.sh +``` + +Windows: + +``` +build.bat +``` + +## Run in Docker + +``` +cd src/{{packageName}} +docker build -t {{packageName}} . +docker run -p 5000:5000 {{packageName}} +``` diff --git a/modules/swagger-codegen/src/main/resources/aspnet5/Solution.mustache b/modules/swagger-codegen/src/main/resources/aspnet5/Solution.mustache new file mode 100644 index 00000000000..4ea98f8e492 --- /dev/null +++ b/modules/swagger-codegen/src/main/resources/aspnet5/Solution.mustache @@ -0,0 +1,32 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 14 +VisualStudioVersion = 14.0.25420.1 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{815BE834-0656-4C12-84A4-43F2BA4B8BDE}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{AFF6BF88-8A7D-4736-AF81-31BCE86B19BD}" + ProjectSection(SolutionItems) = preProject + global.json = global.json + EndProjectSection +EndProject +Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "{{packageName}}", "src\{{packageName}}\{{packageName}}.xproj", "{{packageGuid}}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {3B5990B3-40F1-4148-89B5-84AC71432557}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {3B5990B3-40F1-4148-89B5-84AC71432557}.Debug|Any CPU.Build.0 = Debug|Any CPU + {3B5990B3-40F1-4148-89B5-84AC71432557}.Release|Any CPU.ActiveCfg = Release|Any CPU + {3B5990B3-40F1-4148-89B5-84AC71432557}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(NestedProjects) = preSolution + {{packageGuid}} = {815BE834-0656-4C12-84A4-43F2BA4B8BDE} + EndGlobalSection +EndGlobal \ No newline at end of file diff --git a/modules/swagger-codegen/src/main/resources/aspnet5/Startup.mustache b/modules/swagger-codegen/src/main/resources/aspnet5/Startup.mustache index c4e9d328cc7..80709bd068f 100644 --- a/modules/swagger-codegen/src/main/resources/aspnet5/Startup.mustache +++ b/modules/swagger-codegen/src/main/resources/aspnet5/Startup.mustache @@ -1,136 +1,81 @@ +{{>partial_header}} using System; +using System.Collections.Generic; using System.IO; using System.Linq; -using Microsoft.AspNet.Builder; -using Microsoft.AspNet.Hosting; +using System.Threading.Tasks; +using System.Xml.XPath; +using Microsoft.AspNetCore.Builder; +using Microsoft.AspNetCore.Hosting; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging; -using Microsoft.Extensions.PlatformAbstractions; using Newtonsoft.Json.Serialization; -using Swashbuckle.SwaggerGen; -using Swashbuckle.SwaggerGen.XmlComments; +using Swashbuckle.Swagger.Model; +using Swashbuckle.SwaggerGen.Annotations; namespace {{packageName}} { public class Startup { private readonly IHostingEnvironment _hostingEnv; - private readonly IApplicationEnvironment _appEnv; - public Startup(IHostingEnvironment env, IApplicationEnvironment appEnv) + public IConfigurationRoot Configuration { get; } + + public Startup(IHostingEnvironment env) { _hostingEnv = env; - _appEnv = appEnv; - // Set up configuration sources. var builder = new ConfigurationBuilder() - .AddJsonFile("appsettings.json") + .SetBasePath(env.ContentRootPath) + .AddJsonFile("appsettings.json", optional: true, reloadOnChange: true) + .AddJsonFile($"appsettings.{env.EnvironmentName}.json", optional: true) .AddEnvironmentVariables(); Configuration = builder.Build(); } - - public IConfigurationRoot Configuration { get; set; } - + + // This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { - string xmlComments = string.Format(@"{0}{4}artifacts{4}{1}{4}{2}{3}{4}{{packageName}}.xml", - GetSolutionBasePath(), - _appEnv.Configuration, - _appEnv.RuntimeFramework.Identifier.ToLower(), - _appEnv.RuntimeFramework.Version.ToString().Replace(".", string.Empty), - Path.DirectorySeparatorChar); - // Add framework services. services.AddMvc() .AddJsonOptions( opts => { opts.SerializerSettings.ContractResolver = new CamelCasePropertyNamesContractResolver(); }); - - // Uncomment the following line to add Web API services which makes it easier to port Web API 2 controllers. - // You will also need to add the Microsoft.AspNet.Mvc.WebApiCompatShim package to the 'dependencies' section of project.json. - // services.AddWebApiConventions(); - + services.AddSwaggerGen(); - services.ConfigureSwaggerDocument(options => + + services.ConfigureSwaggerGen(options => { options.SingleApiVersion(new Info { Version = "v1", Title = "{{packageName}}", - Description = "{{packageName}} (ASP.NET 5 Web API 2.x)" + Description = "{{packageName}} (ASP.NET Core 1.0)" }); - - options.OperationFilter(new ApplyXmlActionCommentsFixed(xmlComments)); - }); - services.ConfigureSwaggerSchema(options => { - options.DescribeAllEnumsAsStrings = true; - options.ModelFilter(new ApplyXmlTypeCommentsFixed(xmlComments)); + options.DescribeAllEnumsAsStrings(); + + var comments = new XPathDocument($"{AppContext.BaseDirectory}{Path.DirectorySeparatorChar}{_hostingEnv.ApplicationName}.xml"); + options.OperationFilter(comments); + options.ModelFilter(comments); }); + } // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory) { - loggerFactory.MinimumLevel = LogLevel.Information; loggerFactory.AddConsole(Configuration.GetSection("Logging")); loggerFactory.AddDebug(); - app.UseIISPlatformHandler(); - + app.UseMvc(); + app.UseDefaultFiles(); app.UseStaticFiles(); - app.UseMvc(); - - app.UseSwaggerGen(); + app.UseSwagger(); app.UseSwaggerUi(); } - - // Taken from https://github.com/domaindrivendev/Ahoy/blob/master/test/WebSites/Basic/Startup.cs - private string GetSolutionBasePath() - { - var dir = Directory.CreateDirectory(_appEnv.ApplicationBasePath); - while (dir.Parent != null) - { - if (dir.GetDirectories("artifacts").Any()) - return dir.FullName; - - dir = dir.Parent; - } - throw new InvalidOperationException("Failed to detect solution base path - artifacts not found. Did you run dnu pack --out artifacts?"); - } - - // Entry point for the application. - public static void Main(string[] args) => WebApplication.Run(args); } - - - // using Swashbuckle.SwaggerGen.XmlComments; - public class ApplyXmlTypeCommentsFixed : ApplyXmlTypeComments - { - public ApplyXmlTypeCommentsFixed() : base("") - { - throw new NotImplementedException(); - } - - public ApplyXmlTypeCommentsFixed(string filePath): base(filePath) - { - - } - } - - public class ApplyXmlActionCommentsFixed : ApplyXmlActionComments - { - public ApplyXmlActionCommentsFixed() : base("") - { - throw new NotImplementedException(); - } - - public ApplyXmlActionCommentsFixed(string filePath): base(filePath) - { - - } - } -} \ No newline at end of file +} diff --git a/modules/swagger-codegen/src/main/resources/aspnet5/appsettings.json b/modules/swagger-codegen/src/main/resources/aspnet5/appsettings.json index e5472e562b7..c6af7d9b069 100644 --- a/modules/swagger-codegen/src/main/resources/aspnet5/appsettings.json +++ b/modules/swagger-codegen/src/main/resources/aspnet5/appsettings.json @@ -2,7 +2,7 @@ "Logging": { "IncludeScopes": false, "LogLevel": { - "Default": "Verbose", + "Default": "Information", "System": "Information", "Microsoft": "Information" } diff --git a/modules/swagger-codegen/src/main/resources/aspnet5/build.bat.mustache b/modules/swagger-codegen/src/main/resources/aspnet5/build.bat.mustache new file mode 100644 index 00000000000..b39b7232a1c --- /dev/null +++ b/modules/swagger-codegen/src/main/resources/aspnet5/build.bat.mustache @@ -0,0 +1,20 @@ +:: Generated by: https://github.com/swagger-api/swagger-codegen.git +:: +:: Licensed under the Apache License, Version 2.0 (the "License"); +:: you may not use this file except in compliance with the License. +:: You may obtain a copy of the License at +:: +:: http://www.apache.org/licenses/LICENSE-2.0 +:: +:: Unless required by applicable law or agreed to in writing, software +:: distributed under the License is distributed on an "AS IS" BASIS, +:: WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +:: See the License for the specific language governing permissions and +:: limitations under the License. + +@echo off + +dotnet restore src\{{packageName}} +dotnet build src\{{packageName}} +echo Now, run the following to start the project: dotnet run -p src\{{packageName}}\project.json web. +echo. diff --git a/modules/swagger-codegen/src/main/resources/aspnet5/build.mustache b/modules/swagger-codegen/src/main/resources/aspnet5/build.mustache deleted file mode 100644 index 0a63bfeaf3d..00000000000 --- a/modules/swagger-codegen/src/main/resources/aspnet5/build.mustache +++ /dev/null @@ -1,17 +0,0 @@ -#!/usr/bin/env bash - -if ! type dnvm > /dev/null 2>&1; then - source /usr/local/lib/dnx/bin/dnvm.sh -fi - -if ! type dnu > /dev/null 2>&1 || [ -z "$SKIP_DNX_INSTALL" ]; then - dnvm install latest -runtime coreclr -alias default - dnvm install default -runtime mono -alias default -else - dnvm use default -runtime mono -fi - -dnu restore src/{{packageName}}/ && \ - dnu build src/{{packageName}}/ && \ - dnu pack src/{{packageName}}/ --out artifacts && \ - echo "Now, run the following to start the project: dnx --project src/{{packageName}}/project.json web" \ No newline at end of file diff --git a/modules/swagger-codegen/src/main/resources/aspnet5/build.sh.mustache b/modules/swagger-codegen/src/main/resources/aspnet5/build.sh.mustache new file mode 100644 index 00000000000..179fe5fb61f --- /dev/null +++ b/modules/swagger-codegen/src/main/resources/aspnet5/build.sh.mustache @@ -0,0 +1,19 @@ +#!/usr/bin/env bash +# +# Generated by: https://github.com/swagger-api/swagger-codegen.git +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +dotnet restore src/{{packageName}}/ && \ + dotnet build src/{{packageName}}/ && \ + echo "Now, run the following to start the project: dotnet run -p src/{{packageName}}/project.json web" \ No newline at end of file diff --git a/modules/swagger-codegen/src/main/resources/aspnet5/controller.mustache b/modules/swagger-codegen/src/main/resources/aspnet5/controller.mustache index 592ef42362b..bfeb2307ff8 100644 --- a/modules/swagger-codegen/src/main/resources/aspnet5/controller.mustache +++ b/modules/swagger-codegen/src/main/resources/aspnet5/controller.mustache @@ -1,3 +1,4 @@ +{{>partial_header}} using System; using System.Collections.Generic; using System.Collections.ObjectModel; @@ -6,7 +7,7 @@ using System.IO; using System.Linq; using System.Net; using System.Threading.Tasks; -using Microsoft.AspNet.Mvc; +using Microsoft.AspNetCore.Mvc; using Newtonsoft.Json; using Swashbuckle.SwaggerGen.Annotations; using {{packageName}}.Models; diff --git a/modules/swagger-codegen/src/main/resources/aspnet5/global.json b/modules/swagger-codegen/src/main/resources/aspnet5/global.json index 4a6d1feac95..e5360d025ec 100644 --- a/modules/swagger-codegen/src/main/resources/aspnet5/global.json +++ b/modules/swagger-codegen/src/main/resources/aspnet5/global.json @@ -1,8 +1,7 @@ { - "projects": [ "src", "." ], + "projects": [ "src", "test" ], "sdk": { - "version": "1.0.0-rc1-final", - "runtime": "coreclr", - "architecture": "x64" + "version": "1.0.0-preview2-003121", + "runtime": "coreclr" } } \ No newline at end of file diff --git a/modules/swagger-codegen/src/main/resources/aspnet5/model.mustache b/modules/swagger-codegen/src/main/resources/aspnet5/model.mustache index 08aaed01f3d..5af9183b1dc 100644 --- a/modules/swagger-codegen/src/main/resources/aspnet5/model.mustache +++ b/modules/swagger-codegen/src/main/resources/aspnet5/model.mustache @@ -1,3 +1,4 @@ +{{>partial_header}} using System; using System.Linq; using System.IO; diff --git a/modules/swagger-codegen/src/main/resources/aspnet5/partial_header.mustache b/modules/swagger-codegen/src/main/resources/aspnet5/partial_header.mustache new file mode 100644 index 00000000000..f7477da5c47 --- /dev/null +++ b/modules/swagger-codegen/src/main/resources/aspnet5/partial_header.mustache @@ -0,0 +1,25 @@ +/* + {{#appName}} + * {{{appName}}} + * + {{/appName}} + {{#appDescription}} + * {{{appDescription}}} + * + {{/appDescription}} + * {{#version}}OpenAPI spec version: {{{version}}}{{/version}} + * {{#infoEmail}}Contact: {{{infoEmail}}}{{/infoEmail}} + * Generated by: https://github.com/swagger-api/swagger-codegen.git + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ diff --git a/modules/swagger-codegen/src/main/resources/aspnet5/project.json.mustache b/modules/swagger-codegen/src/main/resources/aspnet5/project.json.mustache new file mode 100644 index 00000000000..432ba86d5a9 --- /dev/null +++ b/modules/swagger-codegen/src/main/resources/aspnet5/project.json.mustache @@ -0,0 +1,88 @@ +{ + "title": "Swagger UI", + "version": "{{packageVersion}}-*", + "copyright": "{{packageName}}", + "description": "{{packageName}}", + "dependencies": { + "Microsoft.NETCore.App": { + "version": "1.0.0", + "type": "platform" + }, + "Microsoft.AspNetCore.Mvc": "1.0.0", + "Microsoft.AspNetCore.Server.IISIntegration": "1.0.0", + "Microsoft.AspNetCore.Server.Kestrel": "1.0.0", + "Microsoft.AspNetCore.Server.Kestrel.Https": "1.0.0", + "Microsoft.AspNetCore.StaticFiles": "1.0.0", + "Microsoft.Extensions.Configuration.EnvironmentVariables": "1.0.0", + "Microsoft.Extensions.Configuration.FileExtensions": "1.0.0", + "Microsoft.Extensions.Configuration.Json": "1.0.0", + "Microsoft.Extensions.Logging": "1.0.0", + "Microsoft.Extensions.Logging.Console": "1.0.0", + "Microsoft.Extensions.Logging.Debug": "1.0.0", + "Microsoft.Extensions.Options.ConfigurationExtensions": "1.0.0", + "Microsoft.EntityFrameworkCore": "1.0.0", + "Swashbuckle.SwaggerGen": "6.0.0-beta901", + "Swashbuckle.SwaggerUi": "6.0.0-beta901" + }, + + "tools": { + "Microsoft.AspNetCore.Server.IISIntegration.Tools": "1.0.0-preview2-final", + + "Microsoft.Extensions.SecretManager.Tools": { + "imports": [ + "netstandard1.6", + "portable-net45+win8+dnxcore50", + "portable-net45+win8" + ], + "version": "1.0.0-preview2-final" + } + }, + + "frameworks": { + "netcoreapp1.0": { + "imports": [ + "dotnet5.6", + "dnxcore50", + "netstandard1.6", + "portable-net452+win81" + ] + } + }, + + "buildOptions": { + "emitEntryPoint": true, + "preserveCompilationContext": true, + "xmlDoc": true, + "compile": { + "exclude": [ + "wwwroot", + "node_modules", + "bower_components" + ] + } + }, + + "runtimeOptions": { + "configProperties": { + "System.GC.Server": true + } + }, + + "publishOptions": { + "include": [ + "wwwroot", + "Views", + "Areas/**/Views", + "appsettings.json", + "web.config" + ], + "exclude": [ + "**.user", + "**.vspscc" + ] + }, + + "scripts": { + "postpublish": [ "dotnet publish-iis --publish-folder %publish:OutputPath% --framework %publish:FullTargetFramework%" ] + } +} diff --git a/modules/swagger-codegen/src/main/resources/aspnet5/project.mustache b/modules/swagger-codegen/src/main/resources/aspnet5/project.mustache deleted file mode 100644 index 018084bc7e1..00000000000 --- a/modules/swagger-codegen/src/main/resources/aspnet5/project.mustache +++ /dev/null @@ -1,41 +0,0 @@ -{ - "version": "{{packageVersion}}-*", - "compilationOptions": { - "emitEntryPoint": true - }, - "tooling": { - "defaultNamespace": "{{packageName}}" - }, - - "dependencies": { - "Microsoft.AspNet.IISPlatformHandler": "1.0.0-rc1-final", - "Microsoft.AspNet.Mvc": "6.0.0-rc1-final", - "Microsoft.AspNet.Server.Kestrel": "1.0.0-rc1-final", - "Microsoft.AspNet.StaticFiles": "1.0.0-rc1-final", - "Microsoft.Extensions.Configuration.FileProviderExtensions" : "1.0.0-rc1-final", - "Microsoft.Extensions.Logging": "1.0.0-rc1-final", - "Microsoft.Extensions.Logging.Console": "1.0.0-rc1-final", - "Microsoft.Extensions.Logging.Debug" : "1.0.0-rc1-final", - "Swashbuckle.SwaggerGen": "6.0.0-rc1-final", - "Swashbuckle.SwaggerUi": "6.0.0-rc1-final" - }, - - "commands": { - "web": "Microsoft.AspNet.Server.Kestrel --server.urls http://0.0.0.0:5000" - }, - - "frameworks": { - "dnx451": { }, - "dnxcore50": { } - }, - - "exclude": [ - "wwwroot", - "node_modules", - "bower_components" - ], - "publishExclude": [ - "**.user", - "**.vspscc" - ] -} diff --git a/modules/swagger-codegen/src/main/resources/aspnet5/web.config b/modules/swagger-codegen/src/main/resources/aspnet5/web.config new file mode 100644 index 00000000000..a3b9f6add9c --- /dev/null +++ b/modules/swagger-codegen/src/main/resources/aspnet5/web.config @@ -0,0 +1,14 @@ + + + + + + + + + + + +