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.Hosting;
using Microsoft.AspNetCore.Mvc.ApiExplorer;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using Microsoft.EntityFrameworkCore;
using Microsoft.AspNetCore.Authentication.JwtBearer;
using Microsoft.IdentityModel.Tokens;
using Microsoft.Extensions.Hosting;
using Microsoft.AspNetCore.Http;
using Microsoft.OpenApi.Models;
using Microsoft.Extensions.Options;
using Swashbuckle.AspNetCore.Swagger;
using Swashbuckle.AspNetCore.SwaggerGen;
using AyaNova.Models;
using AyaNova.Util;
using AyaNova.Generator;
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
{
public class Startup
{
/////////////////////////////////////////////////////////////
//
public Startup(ILogger<Startup> logger, ILoggerFactory logFactory, Microsoft.AspNetCore.Hosting.IWebHostEnvironment hostingEnvironment)
@@ -151,7 +135,6 @@ namespace AyaNova
#endregion
// Add service and create Policy with options
_log.LogDebug("BOOT: init CORS service");
services.AddCors(options =>
@@ -177,12 +160,10 @@ namespace AyaNova
options.ReportApiVersions = true;
});
services.AddVersionedApiExplorer(options => options.GroupNameFormat = "'v'VVV");
services.AddTransient<IConfigureOptions<SwaggerGenOptions>, ConfigureSwaggerOptions>();
services.AddSwaggerGen(
c =>
{
// integrate xml comments
c.IncludeXmlComments(XmlCommentsFilePath);
@@ -212,7 +193,6 @@ namespace AyaNova
#endregion
#region JWT AUTHENTICATION
//get the key if specified
var secretKey = ServerBootConfig.AYANOVA_JWT_SECRET;
@@ -270,7 +250,6 @@ namespace AyaNova
_log.LogDebug("BOOT: init Generator service");
services.AddSingleton<IHostedService, GeneratorService>();
}
@@ -478,9 +457,7 @@ namespace AyaNova
static string XmlCommentsFilePath
{
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 fileName = typeof(Startup).GetTypeInfo().Assembly.GetName().Name + ".xml";
return Path.Combine(basePath, fileName);