This commit is contained in:
2019-10-18 19:58:45 +00:00
parent c1de29aee4
commit 529f979d66

View File

@@ -1,47 +1,31 @@
using Microsoft.AspNetCore.Mvc; using System.IO;
using System.Reflection;
using System.Linq;
using System;
using System.Collections.Generic;
using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Mvc.ApiExplorer; using Microsoft.AspNetCore.Mvc.ApiExplorer;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging;
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
using Microsoft.AspNetCore.Authentication.JwtBearer; using Microsoft.AspNetCore.Authentication.JwtBearer;
using Microsoft.IdentityModel.Tokens; using Microsoft.IdentityModel.Tokens;
using Microsoft.Extensions.Hosting; using Microsoft.Extensions.Hosting;
using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Http;
using Microsoft.OpenApi.Models; using Microsoft.OpenApi.Models;
using Microsoft.Extensions.Options; using Microsoft.Extensions.Options;
using Swashbuckle.AspNetCore.Swagger;
using Swashbuckle.AspNetCore.SwaggerGen; using Swashbuckle.AspNetCore.SwaggerGen;
using AyaNova.Models; using AyaNova.Models;
using AyaNova.Util; using AyaNova.Util;
using AyaNova.Generator; using AyaNova.Generator;
using AyaNova.Biz; using AyaNova.Biz;
using Swashbuckle.AspNetCore.SwaggerUI;
using System.IO;
using System.Reflection;
using System.Linq;
using System;
using System.Collections.Generic;
using Newtonsoft.Json.Serialization;
namespace AyaNova namespace AyaNova
{ {
public class Startup public class Startup
{ {
///////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////
// //
public Startup(ILogger<Startup> logger, ILoggerFactory logFactory, Microsoft.AspNetCore.Hosting.IWebHostEnvironment hostingEnvironment) public Startup(ILogger<Startup> logger, ILoggerFactory logFactory, Microsoft.AspNetCore.Hosting.IWebHostEnvironment hostingEnvironment)
@@ -151,7 +135,6 @@ namespace AyaNova
#endregion #endregion
// Add service and create Policy with options // Add service and create Policy with options
_log.LogDebug("BOOT: init CORS service"); _log.LogDebug("BOOT: init CORS service");
services.AddCors(options => services.AddCors(options =>
@@ -177,12 +160,10 @@ namespace AyaNova
options.ReportApiVersions = true; options.ReportApiVersions = true;
}); });
services.AddVersionedApiExplorer(options => options.GroupNameFormat = "'v'VVV"); services.AddVersionedApiExplorer(options => options.GroupNameFormat = "'v'VVV");
services.AddTransient<IConfigureOptions<SwaggerGenOptions>, ConfigureSwaggerOptions>(); services.AddTransient<IConfigureOptions<SwaggerGenOptions>, ConfigureSwaggerOptions>();
services.AddSwaggerGen( services.AddSwaggerGen(
c => c =>
{ {
// integrate xml comments // integrate xml comments
c.IncludeXmlComments(XmlCommentsFilePath); c.IncludeXmlComments(XmlCommentsFilePath);
@@ -212,7 +193,6 @@ namespace AyaNova
#endregion #endregion
#region JWT AUTHENTICATION #region JWT AUTHENTICATION
//get the key if specified //get the key if specified
var secretKey = ServerBootConfig.AYANOVA_JWT_SECRET; var secretKey = ServerBootConfig.AYANOVA_JWT_SECRET;
@@ -270,7 +250,6 @@ namespace AyaNova
_log.LogDebug("BOOT: init Generator service"); _log.LogDebug("BOOT: init Generator service");
services.AddSingleton<IHostedService, GeneratorService>(); services.AddSingleton<IHostedService, GeneratorService>();
} }
@@ -479,8 +458,6 @@ namespace AyaNova
{ {
get get
{ {
//Obsolete, used new method: https://developers.de/blogs/holger_vetter/archive/2017/06/30/swagger-includexmlcomments-platformservices-obsolete-replacement.aspx
//var basePath = PlatformServices.Default.Application.ApplicationBasePath;
var basePath = AppContext.BaseDirectory; var basePath = AppContext.BaseDirectory;
var fileName = typeof(Startup).GetTypeInfo().Assembly.GetName().Name + ".xml"; var fileName = typeof(Startup).GetTypeInfo().Assembly.GetName().Name + ".xml";
return Path.Combine(basePath, fileName); return Path.Combine(basePath, fileName);