<commit_before>﻿using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.DotNet.InternalAbstractions;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using NLog.Extensions.Logging;
using SandTigerShark.GameServer.Exceptions;
using SandTigerShark.GameServer.Services;
using SandTigerShark.GameServer.Services.Configurations;
using SandTigerShark.GameServer.Services.Http;
using SandTigerShark.GameServer.Swagger;
using Swashbuckle.AspNetCore.Swagger;

namespace SandTigerShark.GameServer
{
    public class Startup
    {
        public Startup(IConfiguration configuration)
        {
            Configuration = configuration;
        }

        public IConfiguration Configuration { get; }

        public void ConfigureServices(IServiceCollection services)
        {
            LoggerFactory loggerFactory = ConfigureLogging();

            services.Configure<AzureConfig>(Configuration.GetSection("Azure"))
                    .Configure<HttpClientConfig>(Configuration.GetSection("Http"))
                    .AddSingleton(loggerFactory)
                    .AddMvc(c => c.Filters.Add(new ExceptionMapper(loggerFactory.CreateLogger<ExceptionMapper>())));
            Module.Bootstrap(services);

            services.AddSwaggerGen(c =>
            {
                c.SwaggerDoc("v1", new Info { Title = "SandTigerShark api", Version = "v1" });
                c.IncludeXmlComments($"{ApplicationEnvironment.ApplicationBasePath}\\SandTigerShark.GameServer.xml");
                c.DescribeAllEnumsAsStrings();
                c.OperationFilter<AddTokenHeaderOperationFilter>();
            });
        }

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

            app.UseSwagger();
            app.UseSwaggerUI(c =>
            {
                c.SwaggerEndpoint("/swagger/v1/swagger.json", "SandTigerShark api V1");
            });


            app.UseMvc();
        }

        private LoggerFactory ConfigureLogging()
        {
            var loggerFactory = new LoggerFactory();
            loggerFactory.AddConsole(Configuration.GetSection("Logging"))
                         .AddDebug()
                         .AddNLog();

            return loggerFactory;
        }
    }
}<commit_msg>Check Xml document for Swagger<commit_after>﻿using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.DotNet.InternalAbstractions;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using NLog.Extensions.Logging;
using SandTigerShark.GameServer.Exceptions;
using SandTigerShark.GameServer.Services;
using SandTigerShark.GameServer.Services.Configurations;
using SandTigerShark.GameServer.Services.Http;
using SandTigerShark.GameServer.Swagger;
using Swashbuckle.AspNetCore.Swagger;
using System.IO;

namespace SandTigerShark.GameServer
{
    public class Startup
    {
        public Startup(IConfiguration configuration)
        {
            Configuration = configuration;
        }

        public IConfiguration Configuration { get; }

        public void ConfigureServices(IServiceCollection services)
        {
            LoggerFactory loggerFactory = ConfigureLogging();

            services.Configure<AzureConfig>(Configuration.GetSection("Azure"))
                    .Configure<HttpClientConfig>(Configuration.GetSection("Http"))
                    .AddSingleton(loggerFactory)
                    .AddMvc(c => c.Filters.Add(new ExceptionMapper(loggerFactory.CreateLogger<ExceptionMapper>())));
            Module.Bootstrap(services);

            services.AddSwaggerGen(c =>
            {
                c.SwaggerDoc("v1", new Info { Title = "SandTigerShark api", Version = "v1" });

                var xmlDocument = $"{ApplicationEnvironment.ApplicationBasePath}\\SandTigerShark.GameServer.xml";

                if(File.Exists(xmlDocument))
                {
                    c.IncludeXmlComments(xmlDocument);
                }
                c.DescribeAllEnumsAsStrings();
                c.OperationFilter<AddTokenHeaderOperationFilter>();
            });
        }

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

            app.UseSwagger();
            app.UseSwaggerUI(c =>
            {
                c.SwaggerEndpoint("/swagger/v1/swagger.json", "SandTigerShark api V1");
            });


            app.UseMvc();
        }

        private LoggerFactory ConfigureLogging()
        {
            var loggerFactory = new LoggerFactory();
            loggerFactory.AddConsole(Configuration.GetSection("Logging"))
                         .AddDebug()
                         .AddNLog();

            return loggerFactory;
        }
    }
}
{'fraction_non_alphanumeric': 0.09149686520376175, 'fraction_numerical': 0.001567398119122257, 'mean_word_length': 2.280848329048843, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 17, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 5}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5408793', 'n_tokens_mistral': 1306, 'n_tokens_neox': 1255, 'n_words': 198}